Bug 539897: Add missing socket_window reference due to GtkPlug bug. r=cjones

--HG--
extra : transplant_source : %D0%91%8Eoa%1F%00JDF%7Cj%AB%9A%C8%06%E13%E37
This commit is contained in:
Karl Tomlinson 2010-01-19 15:45:56 -06:00
parent 8b4c05501b
commit a753e3901b
2 changed files with 34 additions and 1 deletions

View File

@ -464,6 +464,17 @@ PluginInstanceChild::AnswerNPP_SetWindow(const NPRemoteWindow& aWindow,
&mWsInfo.visual, &mWsInfo.depth))
return false;
if (aWindow.type == NPWindowTypeWindow) {
if (GdkWindow* socket_window = gdk_window_lookup(aWindow.window)) {
// A GdkWindow for the socket already exists. Need to
// workaround https://bugzilla.gnome.org/show_bug.cgi?id=607061
// See wrap_gtk_plug_embedded in PluginModuleChild.cpp.
g_object_set_data(G_OBJECT(socket_window),
"moz-existed-before-set-window",
GUINT_TO_POINTER(1));
}
}
*rv = mPluginIface->setwindow(&mData, &mWindow);
#elif defined(OS_WIN)

View File

@ -179,8 +179,10 @@ PluginModuleChild::Init(const std::string& aPluginFilename,
#if defined(OS_LINUX)
typedef void (*GObjectDisposeFn)(GObject*);
typedef void (*GtkPlugEmbeddedFn)(GtkPlug*);
static GObjectDisposeFn real_gtk_plug_dispose;
static GtkPlugEmbeddedFn real_gtk_plug_embedded;
static void
undo_bogus_unref(gpointer data, GObject* object, gboolean is_last_ref) {
@ -210,6 +212,22 @@ wrap_gtk_plug_dispose(GObject* object) {
(*real_gtk_plug_dispose)(object);
g_object_remove_toggle_ref(object, undo_bogus_unref, NULL);
}
static void
wrap_gtk_plug_embedded(GtkPlug* plug) {
GdkWindow* socket_window = plug->socket_window;
if (socket_window &&
g_object_get_data(G_OBJECT(socket_window),
"moz-existed-before-set-window")) {
// Add missing reference for
// https://bugzilla.gnome.org/show_bug.cgi?id=607061
g_object_ref(socket_window);
}
if (*real_gtk_plug_embedded) {
(*real_gtk_plug_embedded)(plug);
}
}
#endif
bool
@ -221,16 +239,20 @@ PluginModuleChild::InitGraphics()
// GtkPlug is a static class so will leak anyway but this ref makes sure.
gpointer gtk_plug_class = g_type_class_ref(GTK_TYPE_PLUG);
// The dispose method is a good place to hook into the destruction process
// because the reference count should be 1 the last time dispose is
// called. (Toggle references wouldn't detect if the reference count
// might be higher.)
GObjectDisposeFn* dispose = &G_OBJECT_CLASS(gtk_plug_class)->dispose;
NS_ABORT_IF_FALSE(*dispose != wrap_gtk_plug_dispose,
"InitGraphics called twice");
real_gtk_plug_dispose = *dispose;
*dispose = wrap_gtk_plug_dispose;
GtkPlugEmbeddedFn* embedded = &GTK_PLUG_CLASS(gtk_plug_class)->embedded;
real_gtk_plug_embedded = *embedded;
*embedded = wrap_gtk_plug_embedded;
#else
// may not be necessary on all platforms
#endif