add the potential for a bit more debugging of signal connects
authorPaul Davis <paul@linuxaudiosystems.com>
Fri, 1 Jul 2016 20:35:46 +0000 (16:35 -0400)
committerPaul Davis <paul@linuxaudiosystems.com>
Fri, 1 Jul 2016 21:47:05 +0000 (17:47 -0400)
libs/pbd/pbd/signals.py

index 9495b70f89365bca18bad35b42fb09744e66a090..fbcf1d4016406620ba8bb2750dc8aa6dd9500f25 100644 (file)
@@ -268,11 +268,17 @@ def signal(f, n, v):
     print("\t}", file=f)
 
     print("""
-       bool empty () {
+       bool empty () const {
                Glib::Threads::Mutex::Lock lm (_mutex);
                return _slots.empty ();
        }
 """, file=f)
+    print("""
+       bool size () const {
+               Glib::Threads::Mutex::Lock lm (_mutex);
+               return _slots.size ();
+       }
+""", file=f)
 
     if v:
         tp = comma_separated(["void"] + An)
@@ -286,14 +292,15 @@ def signal(f, n, v):
     print("""
        boost::shared_ptr<Connection> _connect (slot_function_type f)
        {
+               boost::shared_ptr<Connection> c (new Connection (this));
+               Glib::Threads::Mutex::Lock lm (_mutex);
+               _slots[c] = f;
 #ifdef DEBUG_PBD_SIGNAL_CONNECTIONS
                 if (_debug_connection) {
+                        std::cerr << "+++++++ CONNECT " << this << " size now " << _slots.size() << std::endl;
                         PBD::stacktrace (std::cerr, 10);
                 }
 #endif
-               boost::shared_ptr<Connection> c (new Connection (this));
-               Glib::Threads::Mutex::Lock lm (_mutex);
-               _slots[c] = f;
                return c;
        }""", file=f)
 
@@ -302,6 +309,12 @@ def signal(f, n, v):
        {
                Glib::Threads::Mutex::Lock lm (_mutex);
                _slots.erase (c);
+#ifdef DEBUG_PBD_SIGNAL_CONNECTIONS
+                if (_debug_connection) {
+                        std::cerr << "------- DISCCONNECT " << this << " size now " << _slots.size() << std::endl;
+                        PBD::stacktrace (std::cerr, 10);
+                }
+#endif
        }
 };    
 """, file=f)