Accommodate newly introduced source(s) in our MSVC project (libpbd)
[ardour.git] / libs / pbd / pbd / signals.h
index cc70d07ca5ecdc5920d3e6641afbe5ddf874bb2e..df4c9cef29331c5d3b0477143d932e0c7fc4df8e 100644 (file)
@@ -20,6 +20,8 @@
 #ifndef __pbd_signals_h__
 #define __pbd_signals_h__
 
+#include <csignal>
+
 #include <list>
 #include <map>
 
@@ -67,7 +69,7 @@ public:
 #endif
 
 protected:
-        Glib::Threads::Mutex _mutex;
+       mutable Glib::Threads::Mutex _mutex;
 #ifdef DEBUG_PBD_SIGNAL_CONNECTIONS
        bool _debug_connection;
 #endif
@@ -76,7 +78,12 @@ protected:
 class LIBPBD_API Connection : public boost::enable_shared_from_this<Connection>
 {
 public:
-       Connection (SignalBase* b) : _signal (b) {}
+       Connection (SignalBase* b, PBD::EventLoop::InvalidationRecord* ir) : _signal (b), _invalidation_record (ir)
+       {
+               if (_invalidation_record) {
+                       _invalidation_record->ref ();
+               }
+       }
 
        void disconnect ()
        {
@@ -87,15 +94,26 @@ public:
                }
        }
 
+       void disconnected ()
+       {
+               if (_invalidation_record) {
+                       _invalidation_record->unref ();
+               }
+       }
+
        void signal_going_away ()
        {
                Glib::Threads::Mutex::Lock lm (_mutex);
+               if (_invalidation_record) {
+                       _invalidation_record->unref ();
+               }
                _signal = 0;
        }
 
 private:
         Glib::Threads::Mutex _mutex;
        SignalBase* _signal;
+       PBD::EventLoop::InvalidationRecord* _invalidation_record;
 };
 
 template<typename R>
@@ -115,9 +133,9 @@ public:
                return r;
        }
 };
-       
+
 typedef boost::shared_ptr<Connection> UnscopedConnection;
-       
+
 class LIBPBD_API ScopedConnection
 {
 public:
@@ -139,7 +157,7 @@ public:
                if (_c == o) {
                        return *this;
                }
-               
+
                disconnect ();
                _c = o;
                return *this;
@@ -148,13 +166,13 @@ public:
 private:
        UnscopedConnection _c;
 };
-       
+
 class LIBPBD_API ScopedConnectionList  : public boost::noncopyable
 {
   public:
        ScopedConnectionList();
        virtual ~ScopedConnectionList ();
-       
+
        void add_connection (const UnscopedConnection& c);
        void drop_connections ();
 
@@ -168,7 +186,7 @@ class LIBPBD_API ScopedConnectionList  : public boost::noncopyable
           (1) (unlikely) we make a connection involving a callback on the
               same object from 2 threads. (wouldn't that just be appalling
               programming style?)
-       
+
           (2) where we are dropping connections in one thread and adding
               one from another.
         */
@@ -179,8 +197,8 @@ class LIBPBD_API ScopedConnectionList  : public boost::noncopyable
        ConnectionList _list;
 };
 
-#include "pbd/signals_generated.h"     
-       
+#include "pbd/signals_generated.h"
+
 } /* namespace */
 
 #endif /* __pbd_signals_h__ */