[gtk/wip/otte/inspector-inspector: 1/3] inspector: Don't use global variable here




commit e54567611bb6936283af21bca2070bfc69925105
Author: Benjamin Otte <otte redhat com>
Date:   Tue Jun 21 02:30:47 2022 +0200

    inspector: Don't use global variable here
    
    When inspecting the inspector, we want to create mutiple displays here.
    
    If we need this to be global, we should store it per-inspected-display.

 gtk/inspector/window.c | 21 ++++++++-------------
 1 file changed, 8 insertions(+), 13 deletions(-)
---
diff --git a/gtk/inspector/window.c b/gtk/inspector/window.c
index 35a90302f0..29d079e4c1 100644
--- a/gtk/inspector/window.c
+++ b/gtk/inspector/window.c
@@ -679,20 +679,16 @@ gtk_inspector_window_class_init (GtkInspectorWindowClass *klass)
 static GdkDisplay *
 get_inspector_display (void)
 {
-  static GdkDisplay *display = NULL;
-
-  if (display == NULL)
-    {
-      const char *name;
+  GdkDisplay *display;
+  const char *name;
 
-      name = g_getenv ("GTK_INSPECTOR_DISPLAY");
-      display = gdk_display_open (name);
+  name = g_getenv ("GTK_INSPECTOR_DISPLAY");
+  display = gdk_display_open (name);
 
-      if (display)
-        g_debug ("Using display %s for GtkInspector", name);
-      else
-        g_message ("Failed to open display %s", name);
-    }
+  if (display)
+    g_debug ("Using display %s for GtkInspector", name);
+  else
+    g_message ("Failed to open display %s", name);
 
   if (!display)
     {
@@ -706,7 +702,6 @@ get_inspector_display (void)
 
   if (display)
     {
-      const char *name;
       GdkDebugFlags flags;
 
       name = g_getenv ("GTK_INSPECTOR_RENDERER");


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