diff --git a/gtk/inspector/object-tree.c b/gtk/inspector/object-tree.c index 30fc714fc8..4bcdd8dbb4 100644 --- a/gtk/inspector/object-tree.c +++ b/gtk/inspector/object-tree.c @@ -801,6 +801,10 @@ on_hierarchy_changed (GtkWidget *widget, g_object_set_data (G_OBJECT (previous_toplevel), "object-controller", NULL); toplevel = gtk_widget_get_toplevel (widget); + + if (!GTK_IS_WINDOW (toplevel)) + return; + controller = gtk_event_controller_key_new (); g_object_set_data_full (G_OBJECT (toplevel), "object-controller", controller, g_object_unref); g_signal_connect (controller, "key-pressed", G_CALLBACK (key_pressed), widget); diff --git a/gtk/inspector/prop-list.c b/gtk/inspector/prop-list.c index 70cc6521ab..292ed77d8c 100644 --- a/gtk/inspector/prop-list.c +++ b/gtk/inspector/prop-list.c @@ -114,6 +114,10 @@ hierarchy_changed (GtkWidget *widget, g_object_set_data (G_OBJECT (previous_toplevel), "prop-controller", NULL); toplevel = gtk_widget_get_toplevel (widget); + + if (!GTK_IS_WINDOW (toplevel)) + return; + controller = gtk_event_controller_key_new (); g_object_set_data_full (G_OBJECT (toplevel), "prop-controller", controller, g_object_unref); g_signal_connect (controller, "key-pressed", G_CALLBACK (key_pressed), widget); diff --git a/gtk/inspector/resource-list.c b/gtk/inspector/resource-list.c index bc724cdaec..c6f1a1ed64 100644 --- a/gtk/inspector/resource-list.c +++ b/gtk/inspector/resource-list.c @@ -481,6 +481,10 @@ on_hierarchy_changed (GtkWidget *widget, g_object_set_data (G_OBJECT (previous_toplevel), "resource-controller", NULL); toplevel = gtk_widget_get_toplevel (widget); + + if (!GTK_IS_WINDOW (toplevel)) + return; + controller = gtk_event_controller_key_new (); g_object_set_data_full (G_OBJECT (toplevel), "resource-controller", controller, g_object_unref); g_signal_connect (controller, "key-pressed", G_CALLBACK (key_pressed), widget); diff --git a/gtk/inspector/statistics.c b/gtk/inspector/statistics.c index 1e93dc4980..e48b1ac46d 100644 --- a/gtk/inspector/statistics.c +++ b/gtk/inspector/statistics.c @@ -332,6 +332,10 @@ hierarchy_changed (GtkWidget *widget, g_object_set_data (G_OBJECT (previous_toplevel), "statistics-controller", NULL); toplevel = gtk_widget_get_toplevel (widget); + + if (!GTK_IS_WINDOW (toplevel)) + return; + controller = gtk_event_controller_key_new (); g_object_set_data_full (G_OBJECT (toplevel), "statistics-controller", controller, g_object_unref); g_signal_connect (controller, "key-pressed", G_CALLBACK (key_pressed), widget);