Blob Blame History Raw
From a20229f185b494a107634c4b99b2be1ce962a277 Mon Sep 17 00:00:00 2001
From: Ondrej Holy <oholy@redhat.com>
Date: Thu, 26 Sep 2019 11:06:45 +0200
Subject: [PATCH] properties-window: Fix crashes when cancelled

Nautilus crashes on the "timed_wait_free: assertion failed:
(g_hash_table_lookup (timed_wait_hash_table, wait) != NULL)" assertion
when the creating of the properties window is cancelled. This is because
the timed wait has been already removed. Let's don't remove the wait
when cancelled in order to prevent the crashes.
---
 src/nautilus-properties-window.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/src/nautilus-properties-window.c b/src/nautilus-properties-window.c
index 969e3ffea..0112aeb3c 100644
--- a/src/nautilus-properties-window.c
+++ b/src/nautilus-properties-window.c
@@ -148,6 +148,7 @@ typedef struct
     NautilusPropertiesWindowCallback callback;
     gpointer callback_data;
     NautilusPropertiesWindow *window;
+    gboolean cancelled;
 } StartupData;
 
 /* drag and drop definitions */
@@ -5229,6 +5230,8 @@ get_existing_window (GList *file_list)
 static void
 properties_window_finish (StartupData *data)
 {
+    gboolean cancel_timed_wait;
+
     if (data->parent_widget != NULL)
     {
         g_signal_handlers_disconnect_by_data (data->parent_widget,
@@ -5240,14 +5243,21 @@ properties_window_finish (StartupData *data)
                                               data);
     }
 
-    remove_pending (data, TRUE, (data->window == NULL), FALSE);
+    cancel_timed_wait = (data->window == NULL && !data->cancelled);
+    remove_pending (data, TRUE, cancel_timed_wait, FALSE);
+
     startup_data_free (data);
 }
 
 static void
 cancel_create_properties_window_callback (gpointer callback_data)
 {
-    properties_window_finish ((StartupData *) callback_data);
+    StartupData *data;
+
+    data = callback_data;
+    data->cancelled = TRUE;
+
+    properties_window_finish (data);
 }
 
 static void
-- 
2.23.0