[gnote] Fix race condition in main_context_call



commit 09fc0e92732afaec4f5695906a9327d9b69ef600
Author: Aurimas Äernius <aurisc4 gmail com>
Date:   Mon Jan 21 22:10:09 2013 +0200

    Fix race condition in main_context_call

 src/utils.cpp |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)
---
diff --git a/src/utils.cpp b/src/utils.cpp
index b383b55..3b7a690 100644
--- a/src/utils.cpp
+++ b/src/utils.cpp
@@ -99,10 +99,14 @@ namespace gnote {
         return FALSE;
       }
 
-      void main_context_call_func(const sigc::slot<void> & slot, Glib::Threads::Cond * cond)
+      void main_context_call_func(const sigc::slot<void> & slot,
+                                  Glib::Threads::Cond * cond,
+                                  Glib::Threads::Mutex * mutex)
       {
+        mutex->lock();
         slot();
         cond->signal();
+        mutex->unlock();
       }
     }
 
@@ -269,8 +273,9 @@ namespace gnote {
 
       mutex.lock();
       main_context_invoke(boost::bind(
-        sigc::ptr_fun(main_context_call_func), slot, &cond));
+        sigc::ptr_fun(main_context_call_func), slot, &cond, &mutex));
       cond.wait(mutex);
+      mutex.unlock();
     }
 
 



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