Prevent nested command invocations in command-prompt

For example, running "devel/send-key SELECT" in command-prompt would
blow up the stack by recursively calling submit()
develop
lethosor 2015-12-27 22:35:14 -05:00
parent c23ac50250
commit 2ef24a3daf
1 changed files with 5 additions and 1 deletions

@ -56,7 +56,7 @@ public:
df::building* getSelectedBuilding() { return Gui::getAnyBuilding(parent); }
std::string getFocusString() { return "commandprompt"; }
viewscreen_commandpromptst(std::string entry):is_response(false)
viewscreen_commandpromptst(std::string entry):is_response(false), submitted(false)
{
show_fps=gps->display_frames;
gps->display_frames=0;
@ -127,6 +127,7 @@ protected:
std::list<std::pair<color_value,std::string> > responses;
int cursor_pos;
int history_idx;
bool submitted;
bool is_response;
bool show_fps;
int frame;
@ -194,6 +195,9 @@ void viewscreen_commandpromptst::submit()
Screen::dismiss(this);
return;
}
if(submitted)
return;
submitted = true;
prompt_ostream out(this);
Core::getInstance().runCommand(out, get_entry());
if(out.empty() && responses.empty())