Allow content parts to not be preset in XML.
[dcpomatic.git] / src / lib / signaller.h
index 661a171eccea20e6f98f28782dd56234d1318f1a..c6037deaa085c737bce9e750b2171fba67aecd53 100644 (file)
@@ -22,7 +22,6 @@
 
 #include "signal_manager.h"
 #include <boost/thread/mutex.hpp>
-#include <boost/signals2.hpp>
 
 class WrapperBase
 {
@@ -42,7 +41,17 @@ public:
        }
 
        bool finished () const {
-               boost::mutex::scoped_lock lm (_mutex);
+               boost::mutex::scoped_lock lm (_mutex, boost::try_to_lock);
+               if (!lm) {
+                       /* It's possible that emission of this
+                          wrapper's signal causes another signal to
+                          be emitted, which causes finished() on this
+                          wrapper to be called (by Signaller::emit).
+                          In this case, just say that the wrapper is
+                          not yet finished.
+                       */
+                       return false;
+               }
                return _finished;
        }
 
@@ -103,7 +112,7 @@ public:
                if (signal_manager) {
                        signal_manager->emit (boost::bind (&Wrapper<T>::signal, w));
                }
-               
+
                boost::mutex::scoped_lock lm (_signaller_mutex);
 
                /* Clean up finished Wrappers */