[nautilus/gnome-3-14] application-actions: use valid window list



commit 45413c18167cddaefefc092b63ec75d8fadc6f50
Author: Carlos Soriano <csoriano gnome org>
Date:   Tue Oct 6 16:56:59 2015 +0200

    application-actions: use valid window list
    
    We were using the internal list of the application to
    iterate through the windows and closing them.
    Problem is that when closing one window, the list is modified,
    so next time accessing the list we are accessing the "old"
    list, which is invalid and makes nautilus crash.
    
    To fix it make a copy of the list to preserve the consistency.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=755803

 src/nautilus-application-actions.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)
---
diff --git a/src/nautilus-application-actions.c b/src/nautilus-application-actions.c
index e346d61..4246786 100644
--- a/src/nautilus-application-actions.c
+++ b/src/nautilus-application-actions.c
@@ -180,12 +180,19 @@ action_quit (GSimpleAction *action,
 {
        GtkApplication *application = user_data;
        GList *l;
+        GList *windows;
 
        /* nautilus_window_close() doesn't do anything for desktop windows */
-       for (l = gtk_application_get_windows (GTK_APPLICATION (application)); l; l = l->next) {
+        windows = gtk_application_get_windows (GTK_APPLICATION (application));
+        /* make a copy, since the original list will be modified when destroying
+         * a window, making this list invalid */
+        windows = g_list_copy (windows);
+       for (l = windows; l != NULL; l = l->next) {
                if (NAUTILUS_IS_WINDOW (l->data))
                        nautilus_window_close (NAUTILUS_WINDOW (l->data));
        }
+
+        g_list_free (windows);
 }
 
 static void


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