bonobo_control_finalize() unref/destroy plug (was Re: GTK 1.2 - gtk_object_unref() trouble)



Darin Adler <darin eazel com> writes:

> on 9/27/00 11:39 AM, Martin Baulig at martin home-of-linux org wrote:
> 
> >>> Btw. I found this while I was wondering why
> >>> 
> >>>     plug = bonobo_plug_new (<whatever>);
> >>> 
> >>>     gtk_widget_destroy (plug);
> >>> 
> >>> works without problems but
> >>> 
> >>>     plug = bonobo_plug_new (<whatever>);
> >>> 
> >>>     gtk_object_unref (plug);
> >>> 
> >>> yields
> >>> 
> >>>     Gtk-CRITICAL **: file gtkobject.c: line 1179 (gtk_object_unref):
> >>>     assertion `object->ref_count > 0' failed.
> >> 
> >> That's because top level containers like GtkWindow and GtkWindow subclasses
> >> are owned by the top level container list. They unref themselves when they
> >> are destroyed.
> > 
> > So the correct thing to do is to change this gtk_object_unref () to
> > gtk_object_destroy () ?
> 
> Yes.

Hmm, still a bit confused - when they unref themselves when they're destroyed,
is it still necessary to gtk_object_destroy() them or will this also happen
automatically (I mean, if for some strange reason the refcount of the plug
happens to be larger than 1 in bonobo_control_finalize()) ?

Btw. here's the full patch:

====
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/bonobo/ChangeLog,v
retrieving revision 1.539
diff -u -u -r1.539 ChangeLog
--- ChangeLog	2000/09/27 18:46:11	1.539
+++ ChangeLog	2000/09/27 18:59:41
@@ -1,5 +1,13 @@
 2000-09-27  Martin Baulig  <baulig suse de>
 
+	* bonobo/bonobo-control.c (bonobo_control_finalize): Use
+	gtk_object_destroy() to destroy the plug, not gtk_object_unref();
+	top-level containers like GtkWindow and GtkWindow subclasses are
+	owned by the top level container list. They unref themselves when they
+	are destroyed.
+
+2000-09-27  Martin Baulig  <baulig suse de>
+
 	* gshell/*: Ported to the new UI handler.
 	* gshell/io.[ch]: New files.
 	* gshell/io.xml: New file.
Index: bonobo/bonobo-control.c
===================================================================
RCS file: /cvs/gnome/bonobo/bonobo/bonobo-control.c,v
retrieving revision 1.40
diff -u -u -r1.40 bonobo-control.c
--- bonobo/bonobo-control.c	2000/09/21 14:10:42	1.40
+++ bonobo/bonobo-control.c	2000/09/27 18:59:41
@@ -595,7 +595,7 @@
 	 * needed because there is no plug.  
 	 */
 	if (control->priv->plug) {
-		gtk_object_unref (GTK_OBJECT (control->priv->plug));
+		gtk_object_destroy (GTK_OBJECT (control->priv->plug));
 		control->priv->plug = NULL;
 	}
 
====

-- 
Martin Baulig
martin gnome org (private)
baulig suse de (work)





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