# HG changeset patch # User Chris Cannam # Date 1374495846 -3600 # Node ID 09c8195c371d5993f479d1a2e9781336e901cfd8 # Parent e8881f405b8f7cba9d7f6f4d177ee09d21345b7b Avoid exiting with locked mutex diff -r e8881f405b8f -r 09c8195c371d main/main.cpp --- a/main/main.cpp Fri Jul 19 15:45:40 2013 +0100 +++ b/main/main.cpp Mon Jul 22 13:24:06 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; }