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 298501 e07497654dcc21a2cf4974dcb39d8e06c30c0e9e
parent 298500 07a3f09fbd1c9c8ba8beb1ce660ec4d7afc9a92d
child 298502 659118226cbd8e6f8c23ec239721bdcbd88683cd
push id962
push userjlund@mozilla.com
push dateFri, 04 Dec 2015 23:28:54 +0000
treeherdermozilla-release@23a2d286e80f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc, lizzard
bugs1225970
milestone43.0
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
@@ -5340,16 +5340,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)
 {