[gnac] Fixed a concurrency bug



commit 65cbe0e6d39bf51ee8c79a4831914dad0162a131
Author: Benoît Dupasquier <bdupasqu src gnome org>
Date:   Wed Jun 9 08:54:15 2010 +0100

    Fixed a concurrency bug

 src/gnac-main.c |   40 +++++++++++++++++++++++++---------------
 1 files changed, 25 insertions(+), 15 deletions(-)
---
diff --git a/src/gnac-main.c b/src/gnac-main.c
index 3c481ea..1a7c447 100644
--- a/src/gnac-main.c
+++ b/src/gnac-main.c
@@ -285,29 +285,39 @@ gnac_files_names_list_foreach(gpointer data,
 static void
 gnac_add_files_thread_entry(gpointer data) 
 {
-  GSList *files;
+  static GSList *files;
   gchar *files_added_text;
-  
+
+  /* If we are already adding files, simply update the list */
+  if (files) {
+    files = g_slist_concat(files, (GSList*)data);
+    return;
+  }
+
   gdk_threads_enter();
-  gnac_file_list_attach_default_model(FALSE);
-  gnac_ui_push_status(_("Importing files..."));
-  gdk_flush();
+    gnac_file_list_attach_default_model(FALSE);
+    gnac_ui_push_status(_("Importing files..."));
   gdk_threads_leave();
+
   files = (GSList*) data;
   nb_files_added = 0;
-  g_slist_foreach(files, (GFunc) gnac_files_names_list_foreach, NULL);
+  while (files) {
+    gnac_files_names_list_foreach(files->data, NULL);
+    files = g_slist_next(files);
+  }
   g_slist_free(files);
+
   if (!quit_app) {
     gdk_threads_enter();
-    gnac_ui_set_progress_text("");
-    gnac_file_list_attach_default_model(TRUE);
-    gnac_change_state(GNAC_AUDIO_READY_STATE);
-    files_added_text = g_strdup_printf(
-      ngettext("%u file imported", "%u files imported", nb_files_added), nb_files_added);
-    gnac_ui_push_status(files_added_text);
-    g_free(files_added_text);
-    file_action_thread = NULL;
-    gdk_flush();
+      gnac_ui_set_progress_text("");
+      gnac_file_list_attach_default_model(TRUE);
+      gnac_change_state(GNAC_AUDIO_READY_STATE);
+      files_added_text = g_strdup_printf(
+          ngettext("%u file imported", "%u files imported", nb_files_added),
+          nb_files_added);
+      gnac_ui_push_status(files_added_text);
+      g_free(files_added_text);
+      file_action_thread = NULL;
     gdk_threads_leave();
   }
 }



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