diff main/main.cpp @ 591:c06a9e8e2748 with-dependencies

Merge from default branch
author Chris Cannam
date Tue, 23 Jul 2013 16:12:50 +0100
parents 7a6fd7150f2d 09c8195c371d
children c43b3c09da63
line wrap: on
line diff
--- a/main/main.cpp	Tue Jul 23 16:12:08 2013 +0100
+++ b/main/main.cpp	Tue Jul 23 16:12:50 2013 +0100
@@ -172,16 +172,21 @@
 */
 
 static QMutex cleanupMutex;
+static bool cleanedUp = false;
 
 static void
 signalHandler(int /* signal */)
 {
     // Avoid this happening more than once across threads
 
+    std::cerr << "signalHandler: cleaning up and exiting" << std::endl;
     cleanupMutex.lock();
-    std::cerr << "signalHandler: cleaning up and exiting" << std::endl;
-    TempDirectory::getInstance()->cleanup();
-    exit(0); // without releasing mutex
+    if (!cleanedUp) {
+        TempDirectory::getInstance()->cleanup();
+        cleanedUp = true;
+    }
+    cleanupMutex.unlock();
+    exit(0);
 }
 
 class SVApplication : public QApplication
@@ -422,8 +427,12 @@
 
     cleanupMutex.lock();
 
-    TransformFactory::deleteInstance();
-    TempDirectory::getInstance()->cleanup();
+    if (!cleanedUp) {
+        TransformFactory::deleteInstance();
+        TempDirectory::getInstance()->cleanup();
+        cleanedUp = true;
+    }
+
     application.releaseMainWindow();
 
 #ifdef HAVE_FFTW3F
@@ -447,6 +456,8 @@
 
     cleanupMutex.unlock();
 
+    cleanupMutex.unlock();
+
     return rv;
 }