diff transform/TransformFactory.cpp @ 574:2d551c765d51

* thread tidying fix, etc
author Chris Cannam
date Mon, 16 Mar 2009 13:56:11 +0000
parents 1b8c748fd7ea
children 2ba202c5be8d
line wrap: on
line diff
--- a/transform/TransformFactory.cpp	Fri Mar 13 17:53:43 2009 +0000
+++ b/transform/TransformFactory.cpp	Mon Mar 16 13:56:11 2009 +0000
@@ -49,15 +49,30 @@
     return m_instance;
 }
 
+void
+TransformFactory::deleteInstance()
+{
+    std::cerr << "TransformFactory::deleteInstance called" << std::endl;
+    delete m_instance;
+    m_instance = 0;
+}
+
 TransformFactory::TransformFactory() :
     m_transformsPopulated(false),
     m_uninstalledTransformsPopulated(false),
-    m_thread(0)
+    m_thread(0),
+    m_exiting(false)
 {
 }
 
 TransformFactory::~TransformFactory()
 {
+    m_exiting = true;
+    if (m_thread) {
+        std::cerr << "TransformFactory::~TransformFactory: waiting on thread" << std::endl;
+        m_thread->wait();
+        delete m_thread;
+    }
 }
 
 void
@@ -694,6 +709,8 @@
 
             m_uninstalledTransforms[tid] = td;
         }
+
+        if (m_exiting) break;
     }
 
     m_uninstalledTransformsPopulated = true;