GNOME Bugzilla – Bug 607061
GtkPlug socket window is sometimes incorrectly unref'd (leading to crashes)
Last modified: 2010-02-09 01:31:39 UTC
GtkPlug socket window is sometimes incorrectly unref'd (leading to crashes) GtkPlug::socket_window is sometimes initialized from gdk_window_lookup_for_display (display, socket_id), and sometimes from gdk_window_foreign_new_for_display (display, socket_id). http://git.gnome.org/browse/gtk+/tree/gtk/gtkplug.c#n469 For gdk_window_foreign_new_for_display the reference should be released, and is done so in gtk_plug_unrealize. However, for gdk_window_lookup_for_display (display, socket_id) it looks like the reference count should be incremented while held by the GtkPlug. If that is done even for in-process embedding, then _gtk_plug_remove_from_socket should also decrement the reference count. An adjustment would also be necessary for the call from _gtk_socket_add_window to _gtk_plug_add_to_socket. Client bug report is https://bugzilla.mozilla.org/show_bug.cgi?id=539897
Created attachment 151651 [details] [review] possible patch Does this patch look right to you ? And more importantly, does it fix your problem ?
Review of attachment 151651 [details] [review]: Most of this makes sense to me, thanks Matthias. However, I don't think the extra reference should be added in the gdk_window_foreign_new_for_display case - that case seems to be working fine already.
Created attachment 151822 [details] [review] only add a reference to windows from gdk_window_lookup_for_display (Includes some of Matthias's patch.)
An even easier fix might be to just always call gdk_window_foreign_new, since it returns a new reference regardless of whether the window already existed or not.
Thanks for the commit, Matthias. Sorry I got distracted and didn't get to looking at removing gdk_window_lookup_for_display. It would have meant a g_object_unref(socket_window) in the "if (user_data)" case (or something similar), and I wondered whether the gdk_window_lookup_for_display made for easier-to-understand code anyway.