Re: Problem with signals..




Michael Oswell <oswell@envy.jealousy.com> writes:

> The problem is that for some reason, clicking on any button causes a
> sigsegv.  I know there is something wrong with the code that is causing
> it, but for the life of me can't figure out what it is.  I am fairly new
> to gtk (Installed it this morning for the first time. :P ), so it may very
> well be something very simple.
> 
> Any help would be greatly appreciated.  Oh.. And I have joined the list,
> or at least sent a request to it, but have had no responce back from the
>  daemon yet, so please respond to oswell@mail.ocis.net.
> 
> int login (void)
      ^^^^^
> {
>     g_print("You pushed login.\n");
> }

[...]

> int dologin(void)
> {
>     GtkWidget *window, *table;
>     GtkWidget *login, *cancel;
                 ^^^^^
[...]
>     /* Create the login button */
>     login = gtk_button_new_with_label ("Login");
>     gtk_signal_connect(GTK_OBJECT(login), "clicked", GTK_SIGNAL_FUNC(login), NULL);
>     gtk_table_attach_defaults(GTK_TABLE(table), login, 1,2,3,4);
>     gtk_widget_show(login);

Does that help? Functions and variables occupy the same namespace in
C, so you are passing a the widget where you wanted to be passing
the function. (Same thing with new_alias)

That's the unfortunate aspect about the GTK_SIGNAL_FUNC() cast -
it hides the problem from the compiler.

Regards,
                                        Owen



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]