[gtk/wip/exalm/root] widget: Don't assume GtkWindow root in gtk_widget_propagate_state()




commit 8e2f90e342515cefa0c5825715e761a60503e970
Author: Alexander Mikhaylenko <alexm gnome org>
Date:   Thu Feb 18 13:41:41 2021 +0500

    widget: Don't assume GtkWindow root in gtk_widget_propagate_state()
    
    Avoid crashes with GtkDragIcon children.

 gtk/gtkwidget.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
---
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 990d7c27ab..35a695e080 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -7748,16 +7748,22 @@ gtk_widget_propagate_state (GtkWidget          *widget,
 
   if (old_flags != new_flags)
     {
-      GtkWindowGroup *window_group;
       GtkRoot *root;
-      GtkWidget *grab;
+      GtkWidget *grab = NULL;
       gboolean shadowed;
 
       g_object_ref (widget);
 
       root = gtk_widget_get_root (widget);
-      window_group = gtk_window_get_group (GTK_WINDOW (root));
-      grab = gtk_window_group_get_current_grab (window_group);
+
+      if (GTK_IS_WINDOW (root))
+        {
+          GtkWindowGroup *window_group;
+
+          window_group = gtk_window_get_group (GTK_WINDOW (root));
+          grab = gtk_window_group_get_current_grab (window_group);
+        }
+
       shadowed = grab && grab != widget && !gtk_widget_is_ancestor (widget, grab);
 
       if (!gtk_widget_is_sensitive (widget) && gtk_widget_has_grab (widget))


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]