diff main/main.cpp @ 283:d27c322b5d6e

* Avoid crash when "hiding" non-visible splash (I don't quite understand this one, but hey)
author Chris Cannam
date Thu, 13 Nov 2008 18:17:33 +0000
parents 64a8ee011004
children 5c5a1ce79ad5
line wrap: on
line diff
--- a/main/main.cpp	Thu Nov 13 14:23:23 2008 +0000
+++ b/main/main.cpp	Thu Nov 13 18:17:33 2008 +0000
@@ -21,7 +21,6 @@
 #include "base/PropertyContainer.h"
 #include "base/Preferences.h"
 #include "widgets/TipDialog.h"
-#include "rdf/SimpleSPARQLQuery.h"
 
 #include <QMetaType>
 #include <QApplication>
@@ -237,14 +236,15 @@
     QApplication::setApplicationName(QApplication::tr("Sonic Visualiser"));
 
     QPixmap pixmap(":/icons/sv-splash.png");
-    QSplashScreen splash(pixmap);
+    QSplashScreen *splash = 0;
 
     QSettings settings;
 
     settings.beginGroup("Preferences");
     if (settings.value("show-splash", true).toBool()) {
-        splash.show();
-        QTimer::singleShot(5000, &splash, SLOT(hide()));
+        splash = new QSplashScreen(pixmap);
+        splash->show();
+        QTimer::singleShot(5000, splash, SLOT(hide()));
         application.processEvents();
     }
     settings.endGroup();
@@ -257,10 +257,6 @@
     }
     settings.endGroup();
 
-    SimpleSPARQLQuery::setImplementationPreference
-        (SimpleSPARQLQuery::UseDatastore);
-//        (SimpleSPARQLQuery::UseDirectParser);
-
     QIcon icon;
     int sizes[] = { 16, 22, 24, 32, 48, 64, 128 };
     for (int i = 0; i < sizeof(sizes)/sizeof(sizes[0]); ++i) {
@@ -303,7 +299,9 @@
 
     MainWindow *gui = new MainWindow(audioOutput, oscSupport);
     application.setMainWindow(gui);
-    QObject::connect(gui, SIGNAL(hideSplash()), &splash, SLOT(hide()));
+    if (splash) {
+        QObject::connect(gui, SIGNAL(hideSplash()), splash, SLOT(hide()));
+    }
 
     QDesktopWidget *desktop = QApplication::desktop();
     QRect available = desktop->availableGeometry();
@@ -371,12 +369,12 @@
             }
         }
         if (status == MainWindow::FileOpenFailed) {
-            splash.hide();
+            if (splash) splash->hide();
 	    QMessageBox::critical
                 (gui, QMessageBox::tr("Failed to open file"),
                  QMessageBox::tr("File or URL \"%1\" could not be opened").arg(path));
         } else if (status == MainWindow::FileOpenWrongMode) {
-            splash.hide();
+            if (splash) splash->hide();
             QMessageBox::critical
                 (gui, QMessageBox::tr("Failed to open file"),
                  QMessageBox::tr("<b>Audio required</b><p>Please load at least one audio file before importing annotation data"));
@@ -398,7 +396,8 @@
     settings.endGroup();
 #endif
 
-    splash.finish(gui);
+    if (splash) splash->finish(gui);
+    delete splash;
 
 /*
     TipDialog tipDialog;