[gnome-software] Disconnect the unmapped signal handler when destroying dialogs



commit 02d5040db3313fa1216c2c6c1e73cbd3be7e3fbd
Author: Sam Spilsbury <sam endlessm com>
Date:   Fri Jul 22 12:54:53 2016 +0100

    Disconnect the unmapped signal handler when destroying dialogs
    
    The unmapped signal handler removes dialogs from the array of dialogs.
    However, this signal handler might get run when we set the array size to zero.
    
    Signed-off-by: Richard Hughes <richard hughsie com>

 src/gs-shell.c |   14 +++++++++++++-
 1 files changed, 13 insertions(+), 1 deletions(-)
---
diff --git a/src/gs-shell.c b/src/gs-shell.c
index cef2ef9..347b4e8 100644
--- a/src/gs-shell.c
+++ b/src/gs-shell.c
@@ -345,8 +345,20 @@ gs_shell_change_mode (GsShell *shell,
        gs_shell_set_header_end_widget (shell, widget);
 
        /* destroy any existing modals */
-       if (priv->modal_dialogs != NULL)
+       if (priv->modal_dialogs != NULL) {
+               gsize i = 0;
+               /* block signal emission of 'unmapped' since that will
+                * call g_ptr_array_remove_index. The unmapped signal may
+                * be emitted whilst running unref handlers for
+                * g_ptr_array_set_size */
+               for (i = 0; i < priv->modal_dialogs->len; ++i) {
+                       GtkWidget *dialog = g_ptr_array_index (priv->modal_dialogs, i);
+                       g_signal_handlers_disconnect_by_func (dialog,
+                                                             modal_dialog_unmapped_cb,
+                                                             shell);
+               }
                g_ptr_array_set_size (priv->modal_dialogs, 0);
+       }
 }
 
 static void


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