From 7a4bf9a313b40b4f4a2810f0adb53312fe0ddc71 Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Tue, 22 Sep 2015 21:56:02 +0200 Subject: [PATCH] Fix crash on loading invalid cards.xml MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Additionally, move the custom database load after the LoadStatus check, so that they don't bring up the “fix your card database path” settings dialog --- cockatrice/src/main.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/cockatrice/src/main.cpp b/cockatrice/src/main.cpp index c48787a6..058eea63 100644 --- a/cockatrice/src/main.cpp +++ b/cockatrice/src/main.cpp @@ -147,6 +147,7 @@ int main(int argc, char *argv[]) rng = new RNG_SFMT; settingsCache = new SettingsCache; themeManager = new ThemeManager; + soundEngine = new SoundEngine; db = new CardDatabase; qtTranslator = new QTranslator; @@ -182,13 +183,6 @@ int main(int argc, char *argv[]) } if (!QDir().mkpath(settingsCache->getPicsPath() + "/CUSTOM")) qDebug() << "Could not create " + settingsCache->getPicsPath().toUtf8() + "/CUSTOM. Will fall back on default card images."; - if (QDir().mkpath(dataDir + "/customsets")) - { - // if the dir exists (or has just been created) - db->loadCustomCardDatabases(dataDir + "/customsets"); - } else { - qDebug() << "Could not create " + dataDir + "/customsets folder."; - } if (!settingsValid() || db->getLoadStatus() != Ok) { qDebug("main(): invalid settings or load status"); @@ -197,12 +191,18 @@ int main(int argc, char *argv[]) app.exec(); } + // load custom databased after LoadStatus check, so that they don't bring up the settings dialog + if (QDir().mkpath(dataDir + "/customsets")) + { + // if the dir exists (or has just been created) + db->loadCustomCardDatabases(dataDir + "/customsets"); + } else { + qDebug() << "Could not create " + dataDir + "/customsets folder."; + } + if (settingsValid()) { qDebug("main(): starting main program"); - soundEngine = new SoundEngine; - qDebug("main(): SoundEngine constructor finished"); - MainWindow ui; qDebug("main(): MainWindow constructor finished");