[10602] in The GTK GIMP ToolKit mailing list archive
[gtk-list] Re: object unref error
daemon@ATHENA.MIT.EDU (David Given)
Wed Dec 2 12:26:25 1998
To: gtk-list@redhat.com
From: "David Given" <david_given@tao.co.uk>
In-reply-to: Your message of "Wed, 02 Dec 1998 17:19:48 +0100."
<366568A4.FF89F31F@nl.compuware.com>
Date: Wed, 02 Dec 1998 17:04:58 +0000
Resent-From: gtk-list@redhat.com
Reply-To: gtk-list@redhat.com
[...]
>yes, object is not null but what on earth does it mean? why does
>it occur in 1.1.5 and not in 1.0.5? The signal connection to the
>OK button is as follows:
>
> dlg = gtk_dialog_new();
> gtk_signal_connect(GTK_OBJECT(dlg), "destroy",
> GTK_SIGNAL_FUNC(gtk_widget_destroyed), &dlg);
> : some code omitted for clarity
> gtk_signal_connect(GTK_OBJECT(okBtn), "clicked",
> (GtkSignalFunc)popupCB, (gpointer)dlg);
>
>
>I don't know what gtk_widget_destroyed does by the way...
>
>and the callback is:
>
>
> static void popupCB(GtkWidget *widget, gpointer dlg)
> {
> gtk_widget_destroy((GtkWidget *)dlg);
> }
From my limited knowledge, what I'd expect was happening is this: you click
the button, and your callback gets called. When you call gtk_widget_destroy(),
the "destroy" signal fires. AFAIK gtk_widget_destroyed attempts to destroy the
current widget. So you end up destroying it twice.
Try instead of the second gtk_signal_connect() this:
gtk_signal_connect_object(
GTK_OBJECT(okBtn), // Object signal is attached to
"clicked", // Signal name
GTK_SIGNAL_FUNC(gtk_widget_destroyed), // Callback
GTK_OBJECT(dlg), // Object actually passed to callback
NULL); // User data
Of course, I could be entirely wrong. Feel free to correct me.
--
+- David Given ------------McQ-+
| Work: dg@tao.co.uk | Does a Con Neumann machine run a Make
| Play: dgiven@iname.com | Machines Fast scam?
+- http://wiredsoc.ml.org/~dg -+
--
To unsubscribe: mail -s unsubscribe gtk-list-request@redhat.com < /dev/null