Re: [Fwd: gtkplug commit]




Dietmar Maurer <dm@vlsivie.tuwien.ac.at> writes:

> I´ve observed the following problem with gtk_plug/sockets:
> 
> void
> gtk_plug_construct (GtkPlug *plug, guint32 socket_id)
> {
>   plug->socket_window = gdk_window_lookup (socket_id);
>   plug->same_app = TRUE;
> 
>   if (plug->socket_window == NULL)
>     {
>       plug->socket_window = gdk_window_foreign_new (socket_id);
>       plug->same_app = FALSE;
>     }
> }
> 
> if gdk_window_lookup return something != NULL we use the existing window
> 
> (without increasing the reference count!). But gtk_plug_unrealize
> always  unrefs the window wich causes the window to be destroyed.
> 
> This is why bobobo doesn´t work.

This looks like a real bug to me ... but it doesn't make
any sense to me that it would ever be triggered in
actual code unless the plug and socket were in the
same application, since a socket can only be used
once, so the gdk_window_lookup() is not going to return
non-null unless someone else did a gdk_window_lookup()
on that window for some reason. 
 
> A quick fix would be to "gdk_window_ref" the window:
> 
> gtk_plug_construct (GtkPlug *plug, guint32 socket_id)
> {
>   plug->socket_window = gdk_window_lookup (socket_id);
>   plug->same_app = TRUE;
> 
>   if (plug->socket_window == NULL)
>     {
>       plug->socket_window = gdk_window_foreign_new (socket_id);
>       plug->same_app = FALSE;
>     }
>   else gdk_window_ref (plug->socket_window);   /* reference the window
> */
> }

This is what I meant about GTK+ coding style:

 else
  gdk_window_ref (plug->socket_window);

> I´m sure this change will not break any code.

I'll look into this a bit more and probably apply the
patch once I commit the (very large) merge I'm currently
working on from the 1.2 branch to HEAD.

Regards,
                                        Owen



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