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) ...@@ -463,11 +463,30 @@ 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 );
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 #if QT_VERSION >= 0x050500
QSurfaceFormat format = QSurfaceFormat::defaultFormat(); QSurfaceFormat format;
format.setVersion(4, 4); format.setVersion(4, 4);
...@@ -481,6 +500,11 @@ int main(int argc, char **argv) ...@@ -481,6 +500,11 @@ 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);
QScreen *screen = app.primaryScreen(); QScreen *screen = app.primaryScreen();
...@@ -511,25 +535,6 @@ int main(int argc, char **argv) ...@@ -511,25 +535,6 @@ int main(int argc, char **argv)
// create core ( this also reads the ini files ) // create core ( this also reads the ini files )
Core * w = new Core( ); 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(); QString tLang = OpenFlipperSettings().value("Core/Language/Translation","en_US").toString();
if (tLang == "locale") if (tLang == "locale")
......
...@@ -223,7 +223,6 @@ CoreWidget( QVector<ViewMode*>& _viewModes, ...@@ -223,7 +223,6 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
format.setStencil(true); format.setStencil(true);
format.setSampleBuffers(true); format.setSampleBuffers(true);
#endif #endif
OFGLFormat::setDefaultFormat(format);
// Construct GL context & widget // Construct GL context & widget
baseLayout_ = new QtMultiViewLayout; baseLayout_ = new QtMultiViewLayout;
...@@ -244,7 +243,6 @@ CoreWidget( QVector<ViewMode*>& _viewModes, ...@@ -244,7 +243,6 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
if ( ! test->format().stereo() ) { if ( ! test->format().stereo() ) {
// std::cerr << "No stereo ... disabling stereo for real context!" << std::endl; // std::cerr << "No stereo ... disabling stereo for real context!" << std::endl;
format.setStereo(false); format.setStereo(false);
OFGLFormat::setDefaultFormat(format);
}/* else { }/* else {
std::cerr << "Stereo found ok" << std::endl; 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