Fix crash on loading invalid cards.xml

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
This commit is contained in:
Fabio Bas 2015-09-22 21:56:02 +02:00
parent 1409b97490
commit 7a4bf9a313

View file

@ -147,6 +147,7 @@ int main(int argc, char *argv[])
rng = new RNG_SFMT; rng = new RNG_SFMT;
settingsCache = new SettingsCache; settingsCache = new SettingsCache;
themeManager = new ThemeManager; themeManager = new ThemeManager;
soundEngine = new SoundEngine;
db = new CardDatabase; db = new CardDatabase;
qtTranslator = new QTranslator; qtTranslator = new QTranslator;
@ -182,13 +183,6 @@ int main(int argc, char *argv[])
} }
if (!QDir().mkpath(settingsCache->getPicsPath() + "/CUSTOM")) if (!QDir().mkpath(settingsCache->getPicsPath() + "/CUSTOM"))
qDebug() << "Could not create " + settingsCache->getPicsPath().toUtf8() + "/CUSTOM. Will fall back on default card images."; 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) { if (!settingsValid() || db->getLoadStatus() != Ok) {
qDebug("main(): invalid settings or load status"); qDebug("main(): invalid settings or load status");
@ -197,12 +191,18 @@ int main(int argc, char *argv[])
app.exec(); 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()) { if (settingsValid()) {
qDebug("main(): starting main program"); qDebug("main(): starting main program");
soundEngine = new SoundEngine;
qDebug("main(): SoundEngine constructor finished");
MainWindow ui; MainWindow ui;
qDebug("main(): MainWindow constructor finished"); qDebug("main(): MainWindow constructor finished");