Bug 1225970 - dispatch an event to release the widget after draw. r=roc, a=lizzard
authorKarl Tomlinson <karlt+@karlt.net>
Thu, 19 Nov 2015 16:41:12 +1300
changeset 305605 dc1991dd52f13423e6b8ec6c73b9931284c253c8
parent 305604 79c9f80eeeb878601c2a9d01a805cda47dfede1f
child 305606 3669fc2d3b4fd2c1933ae20b0d2049b8a79bb5cb
push id1001
push userraliiev@mozilla.com
push dateMon, 18 Jan 2016 19:06:03 +0000
treeherdermozilla-release@8b89261f3ac4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc, lizzard
bugs1225970
milestone44.0a2
Bug 1225970 - dispatch an event to release the widget after draw. r=roc, a=lizzard
widget/gtk/nsWindow.cpp
--- a/widget/gtk/nsWindow.cpp
+++ b/widget/gtk/nsWindow.cpp
@@ -5442,16 +5442,28 @@ draw_window_of_widget(GtkWidget *widget,
     g_list_free(children);
 }
 
 /* static */
 gboolean
 expose_event_cb(GtkWidget *widget, cairo_t *cr)
 {
     draw_window_of_widget(widget, gtk_widget_get_window(widget), cr);
+
+    // A strong reference is already held during "draw" signal emission,
+    // but GTK+ 3.4 wants the object to live a little longer than that
+    // (bug 1225970).
+    g_object_ref(widget);
+    g_idle_add(
+        [](gpointer data) -> gboolean {
+            g_object_unref(data);
+            return G_SOURCE_REMOVE;
+        },
+        widget);
+
     return FALSE;
 }
 #endif //MOZ_WIDGET_GTK2
 
 static gboolean
 configure_event_cb(GtkWidget *widget,
                    GdkEventConfigure *event)
 {