From d467604bf5f3c8ad9386d88d8b3daddd598edcf0 Mon Sep 17 00:00:00 2001 From: Dirk Wilden Date: Mon, 6 Apr 2009 13:06:15 +0000 Subject: [PATCH] nogui protection / batch mode git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@5555 383ad7c9-94d9-4d36-a494-682f7c89f535 --- Core/Core.cc | 5 ++++- Core/ParseIni.cc | 10 +++++----- Core/openFunctions.cc | 5 ++++- OpenFlipper.cc | 21 +++++++++------------ common/GlobalOptions.cc | 10 ++++++++++ common/GlobalOptions.hh | 6 ++++++ 6 files changed, 38 insertions(+), 19 deletions(-) diff --git a/Core/Core.cc b/Core/Core.cc index 98ae571a..7827e9be 100644 --- a/Core/Core.cc +++ b/Core/Core.cc @@ -658,6 +658,9 @@ void Core::updateView() { } } + if ( !OpenFlipper::Options::gui() ) + return; + if ( OpenFlipper::Options::restrictFrameRate() ) { int elapsed = redrawTime_->elapsed (); @@ -682,7 +685,7 @@ void Core::updateView() { redrawTime_->restart (); - if ( OpenFlipper::Options::gui() && !OpenFlipper::Options::loadingSettings() && !OpenFlipper::Options::redrawDisabled() ) { + if ( !OpenFlipper::Options::loadingSettings() && !OpenFlipper::Options::redrawDisabled() ) { for ( unsigned int i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i ) coreWidget_->examiner_widgets_[i]->updateGL(); diff --git a/Core/ParseIni.cc b/Core/ParseIni.cc index 32da48f7..ac2e4404 100644 --- a/Core/ParseIni.cc +++ b/Core/ParseIni.cc @@ -588,12 +588,12 @@ void Core::openIniFile( QString _filename, resetScenegraph(); - for ( unsigned int i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i ) { - PluginFunctions::viewerProperties(i).drawMode( OpenFlipper::Options::standardDrawMode() ); - coreWidget_->examiner_widgets_[i]->viewAll(); - } + if ( OpenFlipper::Options::gui() ){ + for ( unsigned int i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i ) { + PluginFunctions::viewerProperties(i).drawMode( OpenFlipper::Options::standardDrawMode() ); + coreWidget_->examiner_widgets_[i]->viewAll(); + } - if ( OpenFlipper::Options::gui() ) { coreWidget_->statusMessage( "Loading ini File " + _filename + " ... Done", 4000); coreWidget_->setStatus(ApplicationStatus::READY ); } diff --git a/Core/openFunctions.cc b/Core/openFunctions.cc index 16f40f88..fc107d1d 100644 --- a/Core/openFunctions.cc +++ b/Core/openFunctions.cc @@ -59,7 +59,8 @@ void Core::resetScenegraph() { } // Update the draw Modes Menu - coreWidget_->slotUpdateGlobalDrawMenu(); + if ( OpenFlipper::Options::gui() ) + coreWidget_->slotUpdateGlobalDrawMenu(); } //======================================================================================== @@ -104,6 +105,8 @@ void Core::slotCommandLineOpen() { emit executeFileScript(commandLineScriptNames_[i]); } + if ( !OpenFlipper::Options::gui() && !OpenFlipper::Options::remoteControl()) + exitApplication(); } /// Load object by guessing DataType depending on the files extension diff --git a/OpenFlipper.cc b/OpenFlipper.cc index 119069aa..231ddb2f 100644 --- a/OpenFlipper.cc +++ b/OpenFlipper.cc @@ -246,7 +246,7 @@ bool parseCommandLineOptions(CSimpleOpt& args){ OpenFlipper::Options::splash(false); break; case OPT_REMOTE: - remoteControl = true; + OpenFlipper::Options::remoteControl(true); break; case OPT_HELP: showHelp(); @@ -280,17 +280,15 @@ int main(int argc, char **argv) OpenFlipper::Options::argc(&argc); OpenFlipper::Options::argv(&argv); - //print arguments - std::fstream filestr ("/Users/moebius/param.log", std::fstream::out); - - for (int i=0; i < argc; i++) - filestr << argv[i] << " "; - filestr << std::endl; - - filestr.close(); - CSimpleOpt args(argc, argv, g_rgOptions); + //check only batchMode before the core is created + while (args.Next()) + if (args.OptionId() == OPT_BATCH ){ + OpenFlipper::Options::nogui(true); + break; + } + // Only Install signal handler if not running in debug version, otherwise gdb will get confused // #ifndef DEBUG // Set a handler for segfaults @@ -349,8 +347,7 @@ int main(int argc, char **argv) for ( int i = 0 ; i < args.FileCount(); ++i ) w->commandLineScript(args.File(i)); - if ( remoteControl ) - return app.exec(); + return app.exec(); } return 0; diff --git a/common/GlobalOptions.cc b/common/GlobalOptions.cc index 16ec108a..aaf9692b 100644 --- a/common/GlobalOptions.cc +++ b/common/GlobalOptions.cc @@ -195,6 +195,8 @@ static int* argc_; static char *** argv_; +static bool remoteControl_ = false; + # if __WORDSIZE == 64 const bool is64 = true; #else @@ -680,6 +682,14 @@ void argv( char*** _argv) { argv_ = _argv; } +bool remoteControl(){ + return remoteControl_; +} + +void remoteControl(bool _remote){ + remoteControl_ = _remote; +} + void doSlotDebugging( bool _debugging ) { doSlotDebugging_ = _debugging; } diff --git a/common/GlobalOptions.hh b/common/GlobalOptions.hh index 955bf8d3..bc0e8a04 100644 --- a/common/GlobalOptions.hh +++ b/common/GlobalOptions.hh @@ -609,7 +609,13 @@ void argc( int* _argc ); DLLEXPORT void argv( char*** _argv); +/// is the core remoteControlled? +DLLEXPORT +bool remoteControl(); +/// is the core remoteControlled? +DLLEXPORT +void remoteControl( bool _remote ); //=========================================================================== /** @name Debugging Options -- GitLab