[gnome-software/wip/rancell/ubuntu-3-20-1: 72/72] shell: Avoid destroying modal windows in the "response" signal handler



commit 9244aa3e8305263e04f94229f6b839c326a1b6fc
Author: Kalev Lember <klember redhat com>
Date:   Tue Jun 7 15:25:40 2016 +0200

    shell: Avoid destroying modal windows in the "response" signal handler
    
    Other code may legitimately connect to the "response" signal handler as
    well and if we destroy it in the handler, their callbacks are never
    invoked. Instead, do our window tracking in the "unmap" signal handler.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=764437

 src/gs-shell.c |   15 +++++----------
 1 files changed, 5 insertions(+), 10 deletions(-)
---
diff --git a/src/gs-shell.c b/src/gs-shell.c
index e226c0e..110d846 100644
--- a/src/gs-shell.c
+++ b/src/gs-shell.c
@@ -90,17 +90,12 @@ enum {
 
 static guint signals [SIGNAL_LAST] = { 0 };
 
-/**
- * gs_shell_modal_dialog_present:
- **/
 static void
-gs_shell_modal_dialog_response_cb (GtkDialog *dialog,
-                                  gint response_id,
-                                  GsShell *shell)
+modal_dialog_unmapped_cb (GtkWidget *dialog,
+                          GsShell *shell)
 {
        GsShellPrivate *priv = gs_shell_get_instance_private (shell);
-       g_debug ("handling modal dialog response %i for %p",
-                response_id, dialog);
+       g_debug ("modal dialog %p unmapped", dialog);
        g_ptr_array_remove (priv->modal_dialogs, dialog);
 }
 
@@ -126,10 +121,10 @@ gs_shell_modal_dialog_present (GsShell *shell, GtkDialog *dialog)
 
        /* add to stack, transfer ownership to here */
        g_ptr_array_add (priv->modal_dialogs, dialog);
+       g_signal_connect (GTK_WIDGET (dialog), "unmap",
+                         G_CALLBACK (modal_dialog_unmapped_cb), shell);
 
        /* present the new one */
-       g_signal_connect (dialog, "response",
-                         G_CALLBACK (gs_shell_modal_dialog_response_cb), shell);
        gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
        gtk_window_present (GTK_WINDOW (dialog));
 }


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