Skip to content
Snippets Groups Projects
Commit 4394860a authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

fix local string in menu + disable gear menu during computations

parent 16edce7d
No related branches found
No related tags found
No related merge requests found
...@@ -157,7 +157,7 @@ bool onelab::localNetworkClient::run() ...@@ -157,7 +157,7 @@ bool onelab::localNetworkClient::run()
if(_pid < 0 || (command.empty() && !CTX::instance()->solver.listen)) if(_pid < 0 || (command.empty() && !CTX::instance()->solver.listen))
break; break;
int stop = server->NonBlockingWait(sock, 0.1, 0.); int stop = server->NonBlockingWait(sock, 0.001, 0.);
if(stop || _pid < 0 || (command.empty() && !CTX::instance()->solver.listen)) if(stop || _pid < 0 || (command.empty() && !CTX::instance()->solver.listen))
break; break;
...@@ -878,6 +878,9 @@ void onelabWindow::rebuildTree() ...@@ -878,6 +878,9 @@ void onelabWindow::rebuildTree()
for(unsigned int i = 0; i < _treeWidgets.size(); i++) for(unsigned int i = 0; i < _treeWidgets.size(); i++)
Fl::delete_widget(_treeWidgets[i]); Fl::delete_widget(_treeWidgets[i]);
_treeWidgets.clear(); _treeWidgets.clear();
for(unsigned int i = 0; i < _treeStrings.size(); i++)
delete _treeStrings[i];
_treeStrings.clear();
std::vector<onelab::number> numbers; std::vector<onelab::number> numbers;
onelab::server::instance()->get(numbers); onelab::server::instance()->get(numbers);
...@@ -929,10 +932,12 @@ void onelabWindow::rebuildTree() ...@@ -929,10 +932,12 @@ void onelabWindow::rebuildTree()
but->copy_label(label.c_str()); but->copy_label(label.c_str());
std::vector<Fl_Menu_Item> menu; std::vector<Fl_Menu_Item> menu;
for(unsigned int j = 0; j < strings[i].getChoices().size(); j++){ for(unsigned int j = 0; j < strings[i].getChoices().size(); j++){
// FIXME memory leak : change the way we construct the menu // need to manually manage the label strings
Fl_Menu_Item it = {strdup(strings[i].getChoices()[j].c_str()), 0, 0, 0, char *str = strdup(strings[i].getChoices()[j].c_str());
(strings[i].getKind() == "file" && _treeStrings.push_back(str);
j == strings[i].getChoices().size() - 1) ? FL_MENU_DIVIDER : 0}; bool divider = (strings[i].getKind() == "file" &&
j == strings[i].getChoices().size() - 1);
Fl_Menu_Item it = {str, 0, 0, 0, divider ? FL_MENU_DIVIDER : 0};
menu.push_back(it); menu.push_back(it);
} }
if(strings[i].getKind() == "file"){ if(strings[i].getKind() == "file"){
...@@ -1003,19 +1008,23 @@ void onelabWindow::setButtonMode(const std::string &butt0, const std::string &bu ...@@ -1003,19 +1008,23 @@ void onelabWindow::setButtonMode(const std::string &butt0, const std::string &bu
_butt[1]->activate(); _butt[1]->activate();
_butt[1]->label("Compute"); _butt[1]->label("Compute");
_butt[1]->callback(onelab_cb, (void*)"compute"); _butt[1]->callback(onelab_cb, (void*)"compute");
_gear->activate();
} }
else if(butt1 == "stop"){ else if(butt1 == "stop"){
_butt[1]->activate(); _butt[1]->activate();
_butt[1]->label("Stop"); _butt[1]->label("Stop");
_butt[1]->callback(onelab_cb, (void*)"stop"); _butt[1]->callback(onelab_cb, (void*)"stop");
_gear->deactivate();
} }
else if(butt1 == "kill"){ else if(butt1 == "kill"){
_butt[1]->activate(); _butt[1]->activate();
_butt[1]->label("Kill"); _butt[1]->label("Kill");
_butt[1]->callback(onelab_cb, (void*)"kill"); _butt[1]->callback(onelab_cb, (void*)"kill");
_gear->deactivate();
} }
else{ else{
_butt[1]->deactivate(); _butt[1]->deactivate();
_gear->deactivate();
} }
} }
......
...@@ -25,6 +25,7 @@ class onelabWindow{ ...@@ -25,6 +25,7 @@ class onelabWindow{
Fl_Menu_Button *_gear; Fl_Menu_Button *_gear;
int _gearFrozenMenuSize; int _gearFrozenMenuSize;
std::vector<Fl_Widget*> _treeWidgets; std::vector<Fl_Widget*> _treeWidgets;
std::vector<char*> _treeStrings;
std::string _title; std::string _title;
int _deltaFontSize; int _deltaFontSize;
bool _stop; bool _stop;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment