diff --git a/Fltk/onelabWindow.cpp b/Fltk/onelabWindow.cpp index 5255611d344376450285c7320211d82a5b9cbbe1..20acdb9ea9c03d044a4b219e3e3ed5ef94bafabc 100644 --- a/Fltk/onelabWindow.cpp +++ b/Fltk/onelabWindow.cpp @@ -410,19 +410,6 @@ static bool incrementLoop() return ret; } -static bool stopOnError(const std::string &client) -{ - if(Msg::GetErrorCount() > 0 && !CTX::instance()->expertMode){ - Msg::ResetErrorCounter(); - std::string msg - (client + " reported an error: do you really want to continue?\n\n" - "(To disable this warning in the future, select `Enable expert mode'\n" - "in the option dialog.)"); - if(Msg::GetAnswer(msg.c_str(), 1, "Stop", "Continue") == 0) return true; - } - return false; -} - static std::vector<double> getRange(onelab::number &p) { std::vector<double> v; @@ -505,6 +492,11 @@ void onelab_cb(Fl_Widget *w, void *data) if(!data) return; std::string action((const char*)data); + if(action == "stop"){ + FlGui::instance()->onelab->deactivate("kill"); + return; + } + if(action == "reset"){ // clear everything except model names std::vector<onelab::string> modelNames; @@ -524,12 +516,10 @@ void onelab_cb(Fl_Widget *w, void *data) action = "check"; } - FlGui::instance()->onelab->deactivate(); + FlGui::instance()->onelab->deactivate("stop"); if(action == "compute") initializeLoop(); - bool stop = false; - do{ // enter computation loop // the Gmsh client is special: it always gets executed first. (The @@ -579,8 +569,9 @@ void onelab_cb(Fl_Widget *w, void *data) onelab::server::instance()->setChanged(false, "Gmsh"); } } - stop = stopOnError("Gmsh"); - if(stop) break; + + FlGui::instance()->onelab->checkForErrors("Gmsh"); + if(FlGui::instance()->onelab->stop()) break; // Iterate over all other clients for(onelab::server::citer it = onelab::server::instance()->firstClient(); @@ -605,14 +596,15 @@ void onelab_cb(Fl_Widget *w, void *data) c->kill(); } - stop = stopOnError(c->getName()); - if(stop) break; + FlGui::instance()->onelab->checkForErrors(c->getName()); + if(FlGui::instance()->onelab->stop()) break; } updateOnelabGraphs(); FlGui::instance()->onelab->rebuildTree(); - } while(action == "compute" && incrementLoop() && !stop); + } while(!FlGui::instance()->onelab->stop() && action == "compute" && + incrementLoop()); FlGui::instance()->onelab->activate(); FlGui::instance()->onelab->show(); @@ -708,7 +700,7 @@ static void onelab_dump_cb(Fl_Widget *w, void *data) printf("ONELAB dump:\n%s\n", onelab::server::instance()->toChar().c_str()); } -onelabWindow::onelabWindow(int deltaFontSize) +onelabWindow::onelabWindow(int deltaFontSize) : _stop(false) { FL_NORMAL_SIZE -= deltaFontSize; @@ -869,17 +861,32 @@ void onelabWindow::rebuildSolverList() _win->label(_title.c_str()); } +void onelabWindow::checkForErrors(const std::string &client) +{ + if(Msg::GetErrorCount() > 0 && !CTX::instance()->expertMode){ + Msg::ResetErrorCounter(); + std::string msg + (client + " reported an error: do you really want to continue?\n\n" + "(To disable this warning in the future, select `Enable expert mode'\n" + "in the option dialog.)"); + if(Msg::GetAnswer(msg.c_str(), 1, "Stop", "Continue") == 0) + _stop = true; + } +} + void onelabWindow::activate() { + _stop = false; _butt[0]->label("Compute"); _butt[0]->callback(onelab_cb, (void*)"compute"); _butt[1]->activate(); } -void onelabWindow::deactivate() +void onelabWindow::deactivate(const std::string &how) { - _butt[0]->label("Kill"); - _butt[0]->callback(onelab_cb, (void*)"kill"); + _stop = (how == "stop") ? false : true; + _butt[0]->label((how == "stop") ? "Stop" : "Kill"); + _butt[0]->callback(onelab_cb, (how == "stop") ? (void*)"stop" : (void*)"kill"); _butt[1]->deactivate(); } diff --git a/Fltk/onelabWindow.h b/Fltk/onelabWindow.h index 8e4ea8b2aac5cf299be05a23bbc48db3f5668fca..34b974f03fc1e628eea3db428f97fec7307d05e2 100644 --- a/Fltk/onelabWindow.h +++ b/Fltk/onelabWindow.h @@ -26,6 +26,7 @@ class onelabWindow{ std::vector<Fl_Widget*> _treeWidgets; std::string _title; std::string _modelExtension; + bool _stop; public: onelabWindow(int deltaFontSize=0); int x(){ return _win->x(); } @@ -34,7 +35,7 @@ class onelabWindow{ void rebuildTree(); void redrawTree(){ _tree->redraw(); } void activate(); - void deactivate(); + void deactivate(const std::string &how); void show(){ _win->show(); } int shown(){ return _win->shown(); } std::string getModelExtension(){ return _modelExtension; } @@ -49,6 +50,8 @@ class onelabWindow{ void addSolver(const std::string &name, const std::string &commandLine, int index); void removeSolver(const std::string &name); + void checkForErrors(const std::string &client); + bool stop(){ return _stop; } }; void onelab_cb(Fl_Widget *w, void *data);