Commit bb4e1fc4 authored by schultz's avatar schultz

use QCoreApplication for commandline parsing and use QApplication

afterwards to prevent setting the default SurfaceFormat multiple times
parent b31da1d8
......@@ -463,11 +463,30 @@ int main(int argc, char **argv)
QApplication::setAttribute(Qt::AA_ShareOpenGLContexts);
#endif
QApplication::setColorSpec( QApplication::CustomColor );
QApplication app(argc,argv);
// 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
QSurfaceFormat format = QSurfaceFormat::defaultFormat();
QSurfaceFormat format;
format.setVersion(4, 4);
......@@ -481,6 +500,11 @@ int main(int argc, char **argv)
QSurfaceFormat::setDefaultFormat(format);
// only one application is allowed so delete the core application
// once cmdline parsing is done
delete coreApp;
QApplication app(argc, argv);
QScreen *screen = app.primaryScreen();
......@@ -511,25 +535,6 @@ int main(int argc, char **argv)
// create core ( this also reads the ini files )
Core * w = new Core( );
switch (parseCommandLine(parser, &errorMessage)) {
case CommandLineOk:
break;
case CommandLineError:
fputs(qPrintable(errorMessage), stderr);
fputs("\n\n", stderr);
fputs(qPrintable(parser.helpText()), stderr);
delete w;
return 1;
case CommandLineVersionRequested:
printf("%s %s\n", qPrintable(QCoreApplication::applicationName()),
qPrintable(QCoreApplication::applicationVersion()));
return 0;
case CommandLineHelpRequested:
parser.showHelp();
Q_UNREACHABLE();
}
QString tLang = OpenFlipperSettings().value("Core/Language/Translation","en_US").toString();
if (tLang == "locale")
......
......@@ -223,7 +223,6 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
format.setStencil(true);
format.setSampleBuffers(true);
#endif
OFGLFormat::setDefaultFormat(format);
// Construct GL context & widget
baseLayout_ = new QtMultiViewLayout;
......@@ -244,7 +243,6 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
if ( ! test->format().stereo() ) {
// std::cerr << "No stereo ... disabling stereo for real context!" << std::endl;
format.setStereo(false);
OFGLFormat::setDefaultFormat(format);
}/* else {
std::cerr << "Stereo found ok" << std::endl;
}*/
......
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