Bug 1613130 - [Linux] Use GtkInvisible as a fallback widget to avoid crashes. r=jhorak, a=RyanVM
authorMartin Stransky <stransky@redhat.com>
Thu, 13 Feb 2020 10:04:44 +0000
changeset 574975 ae8d2f148d7d2d30ddbc42ea8404ed4c5613fb2b
parent 574974 5c213138b8bc9ac506f79abe88a00fd1bac8d8c1
child 574976 e98dfef46f45e6e338f0db9c002e864cb2909837
push id2265
push userryanvm@gmail.com
push dateThu, 13 Feb 2020 19:21:01 +0000
treeherdermozilla-release@ae8d2f148d7d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjhorak, RyanVM
bugs1613130
milestone73.0.1
Bug 1613130 - [Linux] Use GtkInvisible as a fallback widget to avoid crashes. r=jhorak, a=RyanVM Differential Revision: https://phabricator.services.mozilla.com/D62715
widget/gtk/WidgetStyleCache.cpp
--- a/widget/gtk/WidgetStyleCache.cpp
+++ b/widget/gtk/WidgetStyleCache.cpp
@@ -752,18 +752,22 @@ static GtkWidget* CreateWidget(WidgetNod
   }
 }
 
 GtkWidget* GetWidget(WidgetNodeType aAppearance) {
   GtkWidget* widget = sWidgetStorage[aAppearance];
   if (!widget) {
     widget = CreateWidget(aAppearance);
     // Some widgets (MOZ_GTK_COMBOBOX_SEPARATOR for instance) may not be
-    // available or implemented.
-    if (!widget) return nullptr;
+    // available or implemented. Use GtkInvisible as a fallback to avoid
+    // potential crashes.
+    if (!widget) {
+      NS_WARNING(nsPrintfCString("Missing GtkWidget %d\n", aAppearance).get());
+      widget = gtk_invisible_new();
+    }
     // In GTK versions prior to 3.18, automatic invalidation of style contexts
     // for widgets was delayed until the next resize event.  Gecko however,
     // typically uses the style context before the resize event runs and so an
     // explicit invalidation may be required.  This is necessary if a style
     // property was retrieved before all changes were made to the style
     // context.  One such situation is where gtk_button_construct_child()
     // retrieves the style property "image-spacing" during construction of the
     // GtkButton, before its parent is set to provide inheritance of ancestor