[Goodies-commits] r1762 - in verve-plugin/trunk: . panel-plugin

Jannis Pohlmann jannis at xfce.org
Thu Jul 13 12:30:37 CEST 2006


Author: jannis
Date: 2006-07-13 10:30:36 +0000 (Thu, 13 Jul 2006)
New Revision: 1762

Modified:
   verve-plugin/trunk/ChangeLog
   verve-plugin/trunk/panel-plugin/verve-env.c
   verve-plugin/trunk/panel-plugin/verve-plugin.c
Log:
	* panel-plugin/verve-plugin.c: Lock command completion using
	  G_LOCK_DEFINE_STATIC. This replaces the global GDK locks and should
	  avoid random crashes when the worker thread (which loads contents of 
	  $PATH) and the panel plugin try to access the completion at the same
	  time.

Modified: verve-plugin/trunk/ChangeLog
===================================================================
--- verve-plugin/trunk/ChangeLog	2006-07-13 08:50:25 UTC (rev 1761)
+++ verve-plugin/trunk/ChangeLog	2006-07-13 10:30:36 UTC (rev 1762)
@@ -1,3 +1,11 @@
+2006-07-13	Jannis Pohlmann <jannis at xfce.org>
+
+	* panel-plugin/verve-plugin.c: Lock command completion using
+	  G_LOCK_DEFINE_STATIC. This replaces the global GDK locks and should
+	  avoid random crashes when the worker thread (which loads contents of 
+	  $PATH) and the panel plugin try to access the completion at the same
+	  time.
+
 2006-07-11	Jannis Pohlmann <jannis at xfce.org>
 
 	* panel-plugin/verve-plugin.c: Use gdk_threads_enter/leave to lock

Modified: verve-plugin/trunk/panel-plugin/verve-env.c
===================================================================
--- verve-plugin/trunk/panel-plugin/verve-env.c	2006-07-13 08:50:25 UTC (rev 1761)
+++ verve-plugin/trunk/panel-plugin/verve-env.c	2006-07-13 10:30:36 UTC (rev 1762)
@@ -172,7 +172,7 @@
 {
   VerveEnv *env = VERVE_ENV (object);
 
-  /* Join the load thread */
+  /* Cancel and join the loading thread */
   env->load_thread_cancelled = TRUE;
   g_thread_join (env->load_thread);
 

Modified: verve-plugin/trunk/panel-plugin/verve-plugin.c
===================================================================
--- verve-plugin/trunk/panel-plugin/verve-plugin.c	2006-07-13 08:50:25 UTC (rev 1761)
+++ verve-plugin/trunk/panel-plugin/verve-plugin.c	2006-07-13 10:30:36 UTC (rev 1762)
@@ -75,16 +75,17 @@
 } VervePlugin;
 
 
+/* Mutex lock used to avoid thread collisions when accessing the command
+ * completion 
+ */
+G_LOCK_DEFINE_STATIC (plugin_completion_mutex);
 
+
 void
 verve_plugin_load_completion (VerveEnv* env, gpointer user_data)
 {
-  gdk_threads_enter ();
-
   VervePlugin *verve = (VervePlugin*) user_data;
 
-  verve->completion = g_completion_new (NULL);
-
   /* Load command history */
   GList *history = verve_history_begin ();
 
@@ -93,6 +94,10 @@
 
   g_debug ("Receiving load-binaries signal\n");
 
+  G_LOCK (plugin_completion_mutex);
+
+  verve->completion = g_completion_new (NULL);
+
   /* Add command history to completion */
   if (G_LIKELY (history != NULL)) 
     g_completion_add_items (verve->completion, history);
@@ -101,7 +106,7 @@
   if (G_LIKELY (binaries != NULL))
     g_completion_add_items (verve->completion, binaries);
 
-  gdk_threads_leave ();
+  G_UNLOCK (plugin_completion_mutex);
 }
 
 




More information about the Goodies-commits mailing list