Hi All,
I've been having a little trouble with signals. I'm using gladeXML to change
views inside of my application. In the .glade file that I'm opening, there are
some custom widgets. When I create a custom widget, I keep a pointer to it for
some internal purposes. But I want the pointer to be set to null when the
widget is destroyed (or a new .glade file is loaded). So I'm using signals, but
I end up with some strange behavior...
// globals
GtkWidget *pointerToCustomWidget=NULL;
guint signalHandlerId=0;
// this function called when gladeXML creates the widget GtkWidget
*createCustomWidget(gchar *widget_name, gchar *string1, gchar *string2, gint
int1, gint int2)
{
GtkWidget *myCustomWidget=createMyCustomWidget(); // my code to create the
widget
pointerToCustomWidget=myCustomWidget;
signalHandlerId=g_signal_connect(gpointer(myCustomWidget), "destroy",
G_CALLBACK(gtk_widget_destroyed), &pointerToCustomWidget);
// also tried this
signalHandlerId=gtk_signal_connect(GTK_OBJECT(myCustomWidget), "destroy",
GTK_SIGNAL_FUNC(gtk_widget_destroyed), &pointerToCustomWidget);
}
// At some pointer user clicks a button and I do the following
if (pointerToCustomWidget!=NULL && signalHandlerId>0)
{
GtkWidget *tempWidgetPointer=pointerToCustomWidget;
guint tempSignalHandlerId;
tempSignalHandlerId=g_signal_connect(gpointer(tempWidgetPointer),
"destroy", G_CALLBACK(gtk_widget_destroyed), &tempWidgetPointer);
// do some other stuff
g_signal_handler_disconnect(gpointer(tempWidgetPointer),
tempSignalHandlerId);
tempWidgetPointer=NULL;
}
I get some errors like this..
Gtk-CRITICAL **: gtk_signal_compat_matched: assertion 'GTK_IS_OBJECT(object)'
failed
My actual code has a more assignments like the above, so sometimes I end up
having 3 or 4 pointers and handlers using the same techniques.
If I remove the following line of code...
assignment tempWidgetPointer=NULL;
I get errors like this...
Gtk-WARNING **: unable to find signal handler for
object(CustomWidget:0x8b5e4b0) with func(0x81a1618) and data (0xbffeca30)
I thought I understood how signals work, but I now I know that I don't have a
clue.
Thanks for any help,
Mark
---------------------------------
No need to miss a message. Get email on-the-go
with Yahoo! Mail for Mobile. Get started.
_______________________________________________
gtk-devel-list mailing list
gtk-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-devel-list