bonobo-wrapper patch.



hi all, 


Thanks to those who answered my questions on IRC during this WE.

My long bonobo hacking WE is getting to an end: you won't have to read my mails
much longer :)


Okay, some people have experienced a bug hanging around in the BonoboWrapper code.
You saw it when using sample-container : everytime you embedded a component,
there was an ugly Square left after the component destruction.

This was due to the ((GtkWidget *)BonoboWrapper)->window GdkWindow not beeing 
destroyed properly. Basically, what happens is that when you unrealize the widget,
the widget's unrealize handler is called. It destroys the cover GdkWindow. Then,
it chains to the parent's unrealize handler in the class hierarchy which is here
the GtkWidget's one. The GtkWidget unrealize handler first calls gtk_widget_unrealize
on all the children of the BonoboWrapper then, if BonoboWrapper has a GdkWindow,
it destroys it. (This is because you have to destroy the GdkWindows from childs to
parents. Thanks to X's XDestroyWindow.)

Now, what happened is that the check to see if a GtkWidget has a GdkWindow is
!GTK_WIDGET_NO_WINDOW (widget) which ends to be: 
#define GTK_WIDGET_NO_WINDOW(wid)         ((GTK_WIDGET_FLAGS (wid) & GTK_NO_WINDOW) != 0)

The problem is that as BonoboWrapper inherits GtkBin, it has not GdkWindow by default
(which is why we create it by hand actually) and the gtk_bin_init function does: 

gtk_bin_init (GtkBin *bin)
{
  GTK_WIDGET_SET_FLAGS (bin, GTK_NO_WINDOW);

  bin->child = NULL;
}


haha !!! bug found !!!

the correction is obvious: 

/* Standard object initialization function */
static void
bonobo_wrapper_init (BonoboWrapper *wrapper)
{
	GTK_WIDGET_UNSET_FLAGS (GTK_WIDGET(wrapper), GTK_NO_WINDOW);

	wrapper->priv = g_new0 (BonoboWrapperPrivate, 1);

	wrapper->priv->covered = TRUE;
	wrapper->priv->visible = TRUE;
}


The patch folows.

regards,
Mathieu

-- 
Mathieu Lacage, mathieu@gnu.org
http://www.advogato.org/person/mathieu
ch 224, 212 Rue de Tolbiac, 75013 Paris, France



Index: bonobo-wrapper.c
===================================================================
RCS file: /cvs/gnome/bonobo/bonobo/bonobo-wrapper.c,v
retrieving revision 1.13
diff -u -r1.13 bonobo-wrapper.c
--- bonobo-wrapper.c	2000/03/07 11:57:03	1.13
+++ bonobo-wrapper.c	2000/04/24 17:37:55
@@ -131,6 +131,8 @@
 static void
 bonobo_wrapper_init (BonoboWrapper *wrapper)
 {
+	GTK_WIDGET_UNSET_FLAGS (GTK_WIDGET(wrapper), GTK_NO_WINDOW);
+
	wrapper->priv = g_new0 (BonoboWrapperPrivate, 1);
 
	wrapper->priv->covered = TRUE;








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