Skip to content

Commit

Permalink
Reorder startup sequence to display debug information early
Browse files Browse the repository at this point in the history
  • Loading branch information
droidmonkey committed Apr 4, 2021
1 parent 67d0657 commit f99c44c
Showing 1 changed file with 16 additions and 17 deletions.
33 changes: 16 additions & 17 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,14 @@ int main(int argc, char** argv)
return EXIT_SUCCESS;
}

// Show debug information and then exit
if (parser.isSet(debugInfoOption)) {
QTextStream out(stdout, QIODevice::WriteOnly);
QString debugInfo = Tools::debugInfo().append("\n").append(Crypto::debugInfo());
out << debugInfo << endl;
return EXIT_SUCCESS;
}

// Process config file options early
if (parser.isSet(configOption) || parser.isSet(localConfigOption)) {
Config::createConfigFromFile(parser.value(configOption), parser.value(localConfigOption));
Expand All @@ -111,15 +119,6 @@ int main(int argc, char** argv)
return EXIT_SUCCESS;
}

// Apply the configured theme before creating any GUI elements
app.applyTheme();

#if QT_VERSION >= QT_VERSION_CHECK(5, 7, 0)
QGuiApplication::setDesktopFileName(app.property("KPXC_QUALIFIED_APPNAME").toString() + QStringLiteral(".desktop"));
#endif

Application::bootstrap();

if (!Crypto::init()) {
QString error = QObject::tr("Fatal error while testing the cryptographic functions.");
error.append("\n");
Expand All @@ -128,14 +127,14 @@ int main(int argc, char** argv)
return EXIT_FAILURE;
}

// Displaying the debugging informations must be done after Crypto::init,
// to make sure we know which libgcrypt version is used.
if (parser.isSet(debugInfoOption)) {
QTextStream out(stdout, QIODevice::WriteOnly);
QString debugInfo = Tools::debugInfo().append("\n").append(Crypto::debugInfo());
out << debugInfo << endl;
return EXIT_SUCCESS;
}
// Apply the configured theme before creating any GUI elements
app.applyTheme();

#if QT_VERSION >= QT_VERSION_CHECK(5, 7, 0)
QGuiApplication::setDesktopFileName(app.property("KPXC_QUALIFIED_APPNAME").toString() + QStringLiteral(".desktop"));
#endif

Application::bootstrap();

MainWindow mainWindow;

Expand Down

0 comments on commit f99c44c

Please sign in to comment.