On Wed, 2005-04-06 at 20:44 -0700, Vasili Sviridov wrote:
> This is my first attempt to write something with GTK+ and LibGlade.
>
> When I pass a struct with my data to the function using
> g_signal_connect, even if i'm not doing anything with that data in the
> function itself (like f(){};) when I close the application I get
> Segmentation Fault Error.
>
> typedef struct myStruct
> {
> GtkWidget * Widget;
> gint i;
> }myStruct;
>
> struct myStruct *p;
> p->Widget = {some widget};
> p->i = {some number};
>
> g_signal_connect(G_OBJECT(BtnConnect),"clicked",G_CALLBACK(f),(gpointer)p);
>
> How would I fix that?
>
> Regards,
>
> Vasili Sviridov.
You're never allocating "p" in memory, you're just create a pointer to
it. To fix this, add:
p = g_new0 (MyStruct, 1);
before you start using p.
--
Peace,
James M. Cape
http://ignore-your.tv/
"`The culture of life,' it seems, is a culture of promoting
life when it does not actually exist, and abandoning it
when it does."
-- M. Junaid Alam, Left Hook"
Attachment:
signature.asc
Description: This is a digitally signed message part