comparison main/main.cpp @ 637:f45af8d8091e imaf_enc

Merge from default branch
author Chris Cannam
date Mon, 04 Nov 2013 17:47:53 +0000
parents c0a20cd1a9ff
children 763b1fbeb31c 6d8a76bd91a7
comparison
equal deleted inserted replaced
636:767789a78984 637:f45af8d8091e
170 of the window. 170 of the window.
171 171
172 */ 172 */
173 173
174 static QMutex cleanupMutex; 174 static QMutex cleanupMutex;
175 static bool cleanedUp = false;
175 176
176 static void 177 static void
177 signalHandler(int /* signal */) 178 signalHandler(int /* signal */)
178 { 179 {
179 // Avoid this happening more than once across threads 180 // Avoid this happening more than once across threads
180 181
182 std::cerr << "signalHandler: cleaning up and exiting" << std::endl;
181 cleanupMutex.lock(); 183 cleanupMutex.lock();
182 std::cerr << "signalHandler: cleaning up and exiting" << std::endl; 184 if (!cleanedUp) {
183 TempDirectory::getInstance()->cleanup(); 185 TempDirectory::getInstance()->cleanup();
184 exit(0); // without releasing mutex 186 cleanedUp = true;
187 }
188 cleanupMutex.unlock();
189 exit(0);
185 } 190 }
186 191
187 class SVApplication : public QApplication 192 class SVApplication : public QApplication
188 { 193 {
189 public: 194 public:
356 int height = available.height() / 2; 361 int height = available.height() / 2;
357 if (height < 450) height = (available.height() * 2) / 3; 362 if (height < 450) height = (available.height() * 2) / 3;
358 if (width > height * 2) width = height * 2; 363 if (width > height * 2) width = height * 2;
359 364
360 settings.beginGroup("MainWindow"); 365 settings.beginGroup("MainWindow");
366
361 QSize size = settings.value("size", QSize(width, height)).toSize(); 367 QSize size = settings.value("size", QSize(width, height)).toSize();
362 gui->resizeConstrained(size); 368 gui->resizeConstrained(size);
369
363 if (settings.contains("position")) { 370 if (settings.contains("position")) {
364 QRect prevrect(settings.value("position").toPoint(), size); 371 QRect prevrect(settings.value("position").toPoint(), size);
365 if (!(available & prevrect).isEmpty()) { 372 if (!(available & prevrect).isEmpty()) {
366 gui->move(prevrect.topLeft()); 373 gui->move(prevrect.topLeft());
367 } 374 }
368 } 375 }
376
377 if (settings.value("maximised", false).toBool()) {
378 gui->setWindowState(Qt::WindowMaximized);
379 }
380
369 settings.endGroup(); 381 settings.endGroup();
370 382
371 gui->show(); 383 gui->show();
372 384
373 // The MainWindow class seems to have trouble dealing with this if 385 // The MainWindow class seems to have trouble dealing with this if
420 432
421 gui->hide(); 433 gui->hide();
422 434
423 cleanupMutex.lock(); 435 cleanupMutex.lock();
424 436
425 TransformFactory::deleteInstance(); 437 if (!cleanedUp) {
426 TempDirectory::getInstance()->cleanup(); 438 TransformFactory::deleteInstance();
439 TempDirectory::getInstance()->cleanup();
440 cleanedUp = true;
441 }
442
427 application.releaseMainWindow(); 443 application.releaseMainWindow();
428 444
429 #ifdef HAVE_FFTW3F 445 #ifdef HAVE_FFTW3F
430 settings.beginGroup("FFTWisdom"); 446 settings.beginGroup("FFTWisdom");
431 char *cwisdom = fftwf_export_wisdom_to_string(); 447 char *cwisdom = fftwf_export_wisdom_to_string();
470 static bool haveSession = false; 486 static bool haveSession = false;
471 static bool haveMainModel = false; 487 static bool haveMainModel = false;
472 static bool havePriorCommandLineModel = false; 488 static bool havePriorCommandLineModel = false;
473 489
474 MainWindow::FileOpenStatus status = MainWindow::FileOpenFailed; 490 MainWindow::FileOpenStatus status = MainWindow::FileOpenFailed;
491
492 #ifdef Q_OS_WIN32
493 path.replace("\\", "/");
494 #endif
475 495
476 if (path.endsWith("sv")) { 496 if (path.endsWith("sv")) {
477 if (!haveSession) { 497 if (!haveSession) {
478 status = m_mainWindow->openSessionFile(path); 498 status = m_mainWindow->openSessionFile(path);
479 if (status == MainWindow::FileOpenSucceeded) { 499 if (status == MainWindow::FileOpenSucceeded) {