[gtk+] inspector: Avoid crash when canceling at startup



commit 75b3eec7a6549f0c2cf56d5b831c83aa939de3c7
Author: Daiki Ueno <dueno src gnome org>
Date:   Tue Dec 22 11:21:56 2015 +0900

    inspector: Avoid crash when canceling at startup
    
    When clicking "Cancel" on the "Do you want to use GTK+ Inspector?"
    dialog, unregister the update_debugging idle handler.  Also, steal
    reference to 'inspector_window' while gtk_destroy_widget(), to make
    further gtk_window_update_debugging() calls as a no-op.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=759764

 gtk/gtkwindow.c |   17 ++++++++++++++---
 1 files changed, 14 insertions(+), 3 deletions(-)
---
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index a513e6c..d371ba3 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -12143,6 +12143,8 @@ _gtk_window_raise_popover (GtkWindow *window,
 
 static GtkWidget *inspector_window = NULL;
 
+static guint gtk_window_update_debugging_id;
+
 static void set_warn_again (gboolean warn);
 
 static void
@@ -12159,8 +12161,19 @@ warn_response (GtkDialog *dialog,
   g_object_set_data (G_OBJECT (inspector_window), "warning_dialog", NULL);
   if (response == GTK_RESPONSE_NO)
     {
-      gtk_widget_destroy (inspector_window);
+      GtkWidget *window;
+
+      if (gtk_window_update_debugging_id)
+        {
+          g_source_remove (gtk_window_update_debugging_id);
+          gtk_window_update_debugging_id = 0;
+        }
+
+      /* Steal reference into temp variable, so not to mess up with
+         inspector_window during gtk_widget_destroy().  */
+      window = inspector_window;
       inspector_window = NULL;
+      gtk_widget_destroy (window);
     }
   else
     {
@@ -12168,8 +12181,6 @@ warn_response (GtkDialog *dialog,
     }
 }
 
-static guint gtk_window_update_debugging_id;
-
 static gboolean
 update_debugging (gpointer data)
 {


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