summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Soriano <csoriano@gnome.org>2016-09-20 16:37:01 +0200
committerCarlos Soriano <csoriano@gnome.org>2016-09-20 16:44:35 +0200
commit32fc66d5bfed95882e1a9746bcc404457d3d1706 (patch)
tree0cd2e92ee1503ba887aaad45c9d4f0861aff5ef4
parent6053de7d94c961c9e945a2fcd81f915d9f94bcdc (diff)
downloadnautilus-32fc66d5bfed95882e1a9746bcc404457d3d1706.tar.gz
batch-rename-dialog: don't multi-thread NautilusDirectory calls
Even if late... I just realized neither NautilusDirectory or NautilusFile are thread safe. We were using them from two different threads for checking conflicts, and that was crashing when the internal hash table was modified and accessed from the different threads. The ideal fix would be to make NautilusDirectory and NautilusFile thread safe, but that's a big work. So for now, call the main thread for using them. https://bugzilla.gnome.org/show_bug.cgi?id=771129
-rw-r--r--src/nautilus-batch-rename-dialog.c25
1 files changed, 20 insertions, 5 deletions
diff --git a/src/nautilus-batch-rename-dialog.c b/src/nautilus-batch-rename-dialog.c
index a545d2fb5..ad71bd36f 100644
--- a/src/nautilus-batch-rename-dialog.c
+++ b/src/nautilus-batch-rename-dialog.c
@@ -1226,6 +1226,7 @@ on_file_names_list_has_duplicates (GObject *object,
typedef struct
{
GList *directories;
+ NautilusDirectory *current_directory;
GMutex wait_ready_mutex;
GCond wait_ready_condition;
gboolean directory_conflicts_ready;
@@ -1256,6 +1257,20 @@ on_directory_conflicts_ready (NautilusDirectory *conflict_directory,
g_mutex_unlock (&task_data->wait_ready_mutex);
}
+static gboolean
+check_conflicts_on_main_thread (gpointer user_data)
+{
+ GTask *task = (GTask *) user_data;
+ CheckConflictsData *task_data = g_task_get_task_data (task);
+
+ nautilus_directory_call_when_ready (task_data->current_directory,
+ NAUTILUS_FILE_ATTRIBUTE_INFO,
+ TRUE,
+ on_directory_conflicts_ready,
+ task);
+ return FALSE;
+}
+
static void
file_names_list_has_duplicates_async_thread (GTask *task,
gpointer object,
@@ -1290,11 +1305,11 @@ file_names_list_has_duplicates_async_thread (GTask *task,
task_data->directory_conflicts_ready = FALSE;
- nautilus_directory_call_when_ready (l->data,
- NAUTILUS_FILE_ATTRIBUTE_INFO,
- TRUE,
- on_directory_conflicts_ready,
- task);
+ task_data->current_directory = l->data;
+ /* NautilusDirectory and NautilusFile are not thread safe, we need to call
+ * them on the main thread.
+ */
+ g_main_context_invoke (NULL, check_conflicts_on_main_thread, task);
/* We need to block this thread until the call_when_ready call is done,
* if not the GTask would finalize. */