Commit a9e8af33 authored by schultz's avatar schultz

moved the commandline parsing further up in main function.

initialize settings before parsing command line options.
prevent double initialization.
parent bb4e1fc4
...@@ -441,9 +441,43 @@ int main(int argc, char **argv) ...@@ -441,9 +441,43 @@ int main(int argc, char **argv)
} }
// Set organization and application names
QCoreApplication::setOrganizationName("rwth-aachen.de");
QCoreApplication::setApplicationName(TOSTRING(PRODUCT_STRING));
QCoreApplication::setApplicationVersion(OpenFlipper::Options::coreVersion());
// initialize a core application to check for commandline parameters
QCoreApplication* coreApp = new QCoreApplication(argc, argv);
OpenFlipper::Options::initializeSettings();
QCommandLineParser parser; QCommandLineParser parser;
QString errorMessage; QString errorMessage;
// parse command line options
switch (parseCommandLine(parser, &errorMessage)) {
case CommandLineOk:
break;
case CommandLineError:
fputs(qPrintable(errorMessage), stderr);
fputs("\n\n", stderr);
fputs(qPrintable(parser.helpText()), stderr);
return 1;
case CommandLineVersionRequested:
printf("%s %s\n", qPrintable(QCoreApplication::applicationName()),
qPrintable(QCoreApplication::applicationVersion()));
return 0;
case CommandLineHelpRequested:
parser.showHelp();
Q_UNREACHABLE();
}
// only one application is allowed so delete the core application
// once cmdline parsing is done
delete coreApp;
#ifdef WIN32 #ifdef WIN32
//attach a console if necessary //attach a console if necessary
attachConsole(); attachConsole();
...@@ -463,26 +497,6 @@ int main(int argc, char **argv) ...@@ -463,26 +497,6 @@ int main(int argc, char **argv)
QApplication::setAttribute(Qt::AA_ShareOpenGLContexts); QApplication::setAttribute(Qt::AA_ShareOpenGLContexts);
#endif #endif
QApplication::setColorSpec( QApplication::CustomColor ); QApplication::setColorSpec( QApplication::CustomColor );
// initialize a core application to check for commandline parameters
QCoreApplication* coreApp = new QCoreApplication(argc,argv);
// parse command line options
switch (parseCommandLine(parser, &errorMessage)) {
case CommandLineOk:
break;
case CommandLineError:
fputs(qPrintable(errorMessage), stderr);
fputs("\n\n", stderr);
fputs(qPrintable(parser.helpText()), stderr);
return 1;
case CommandLineVersionRequested:
printf("%s %s\n", qPrintable(QCoreApplication::applicationName()),
qPrintable(QCoreApplication::applicationVersion()));
return 0;
case CommandLineHelpRequested:
parser.showHelp();
Q_UNREACHABLE();
}
#if QT_VERSION >= 0x050500 #if QT_VERSION >= 0x050500
...@@ -500,12 +514,8 @@ int main(int argc, char **argv) ...@@ -500,12 +514,8 @@ int main(int argc, char **argv)
QSurfaceFormat::setDefaultFormat(format); QSurfaceFormat::setDefaultFormat(format);
// only one application is allowed so delete the core application
// once cmdline parsing is done
delete coreApp;
QApplication app(argc, argv);
QApplication app(argc, argv);
QScreen *screen = app.primaryScreen(); QScreen *screen = app.primaryScreen();
QOffscreenSurface *surface = new QOffscreenSurface(); QOffscreenSurface *surface = new QOffscreenSurface();
...@@ -518,11 +528,6 @@ int main(int argc, char **argv) ...@@ -518,11 +528,6 @@ int main(int argc, char **argv)
#endif #endif
// Set organization and application names
QCoreApplication::setOrganizationName("rwth-aachen.de");
QCoreApplication::setApplicationName(TOSTRING(PRODUCT_STRING));
QCoreApplication::setApplicationVersion(OpenFlipper::Options::coreVersion());
if ( !QGLFormat::hasOpenGL() ) { if ( !QGLFormat::hasOpenGL() ) {
std::cerr << "This system has no OpenGL support.\n"; std::cerr << "This system has no OpenGL support.\n";
return -1; return -1;
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment