inspector: Make really sure we don't inspect ourselves
authorBenjamin Otte <otte@redhat.com>
Sun, 5 Mar 2023 23:13:53 +0000 (00:13 +0100)
committerBenjamin Otte <otte@redhat.com>
Sun, 5 Mar 2023 23:13:53 +0000 (00:13 +0100)
The problem here is that new windows appear in the list before the
window's dispay gets set and we don't update the filter when the
display changes (would need watches support for the filtermodel).

So add this somewhat hacky method.

gtk/inspector/object-tree.c

index a7920b9875db6206c636a1a4e818ac708f5058cd..0c0c9e28ab849c6c5e4f2f6c0db8e190062adc3e 100644 (file)
@@ -1131,11 +1131,19 @@ toplevel_filter_func (gpointer item,
                       gpointer data)
 {
   GdkDisplay *display = data;
+  gpointer iw;
 
   if (!GTK_IS_WINDOW (item))
     return FALSE;
 
-  return gtk_widget_get_display (item) == display;
+  if (gtk_widget_get_display (item) != display)
+    return FALSE;
+
+  iw = g_object_get_data (G_OBJECT (display), "-gtk-inspector");
+  if (iw == item)
+    return FALSE;
+
+  return TRUE;
 }
 
 static GListModel *