Re: Using g_signal_connect in an event handler
- From: "Brian J. Tarricone" <bjt23 cornell edu>
- To: gtk-app-devel-list gnome org
- Subject: Re: Using g_signal_connect in an event handler
- Date: Tue, 17 Oct 2006 11:02:32 -0700
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 10/17/2006 5:17 AM, David Ne?as (Yeti) wrote:
On Tue, Oct 17, 2006 at 01:51:47PM +0200, Lorenzo Marcon wrote:
int main(int argc, char *argv[]) {
...
gpointer data[5];
...
data[0] = (gpointer) gtk_entry_get_text (GTK_ENTRY (entry));
data[1] = (gpointer) notebook;
data[2] = (gpointer) progress_bar;
data[3] = (gpointer) &stop;
data[4] = (gpointer) window;
This is quite cumbersome. Why don't you at least create
a struct and pass a pointer to that? You can pass any
pointer as the callback data.
Not to mention the fact that 'data' is allocated on the stack and ceases
to exist after this function exits, so the pointer you pass to
g_signal_connect() will be garbage later. Not only should you use a
struct for convenience as David suggests, but you need to allocate the
struct on the heap (via g_malloc() or g_new(), etc.).
-brian
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (MingW32)
iD8DBQFFNRq36XyW6VEeAnsRAm1wAKC1zkBA7NeFbLT8En9Ur/4S2YPFlwCg3C0E
MVoNTChGloKk93C+STNVE+M=
=Dk2B
-----END PGP SIGNATURE-----
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]