[glibmm] Make SignalTimeout, SignalIdle::connect_once() more thread safe.



commit ac40deaa6e02797fb228e960dfff8c466f967c32
Author: Kjell Ahlstedt <kjell ahlstedt bredband net>
Date:   Wed Apr 4 13:38:06 2012 +0200

    Make SignalTimeout,SignalIdle::connect_once() more thread safe.
    
    * glib/glibmm/main.cc: Call SourceConnectionNode::install() before
    g_source_attach(). Suggested by Chris Vine. Bug #396963 comments 15-18.

 ChangeLog           |    7 +++++++
 glib/glibmm/main.cc |    8 +-------
 2 files changed, 8 insertions(+), 7 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index d163996..fb37558 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2012-04-04  Kjell Ahlstedt  <kjell ahlstedt bredband net>
+
+	Make SignalTimeout,SignalIdle::connect_once() more thread safe.
+
+	* glib/glibmm/main.cc: Call SourceConnectionNode::install() before
+	g_source_attach(). Suggested by Chris Vine. Bug #396963 comments 15-18.
+
 2012-04-03  Murray Cumming  <murrayc murrayc com>
 
 	Some improvements to the documentation in the previous commit.
diff --git a/glib/glibmm/main.cc b/glib/glibmm/main.cc
index cf1b7c6..47f2638 100644
--- a/glib/glibmm/main.cc
+++ b/glib/glibmm/main.cc
@@ -283,14 +283,8 @@ static void glibmm_signal_connect_once(const sigc::slot<void>& slot, int priorit
     source, &glibmm_source_callback_once, conn_node,
     &SourceConnectionNode::destroy_notify_callback);
 
-  g_source_attach(source, context);
-  // GMainContext holds a reference to source until the source is dispatched and
-  // glibmm_source_callback_once() returns 0. Even if that has happened now
-  // (in another thread), conn_node and source still exist.
-  // SourceConnectionNode::destroy_notify_callback() has not been called,
-  // because the initial reference to source remains until the following call
-  // to g_source_unref().
   conn_node->install(source);
+  g_source_attach(source, context);
   g_source_unref(source);
 }
 



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