diff src/main.cpp @ 70:5310637392f6

Revert to using three separate tool modes (more like SV). This is less like the proposed design for Tony but better than the previous situation with two incomprehensible toggle buttons.
author Chris Cannam
date Tue, 26 Nov 2013 16:59:31 +0000
parents ab10f175b4cb
children b405349d323f
line wrap: on
line diff
--- a/src/main.cpp	Tue Nov 26 14:54:22 2013 +0000
+++ b/src/main.cpp	Tue Nov 26 16:59:31 2013 +0000
@@ -21,6 +21,7 @@
 #include "base/PropertyContainer.h"
 #include "base/Preferences.h"
 #include "widgets/TipDialog.h"
+#include "transform/TransformFactory.h"
 
 #include <QMetaType>
 #include <QApplication>
@@ -39,16 +40,21 @@
 #include <signal.h>
 
 static QMutex cleanupMutex;
+static bool cleanedUp = false;
 
 static void
 signalHandler(int /* signal */)
 {
     // Avoid this happening more than once across threads
 
+    cerr << "signalHandler: cleaning up and exiting" << 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 TonyApplication : public QApplication
@@ -241,11 +247,19 @@
     gui->hide();
 
     cleanupMutex.lock();
-    TempDirectory::getInstance()->cleanup();
+
+    if (!cleanedUp) {
+        TransformFactory::deleteInstance();
+        TempDirectory::getInstance()->cleanup();
+        cleanedUp = true;
+    }
+
     application.releaseMainWindow();
 
     delete gui;
 
+    cleanupMutex.unlock();
+
     return rv;
 }