From e30112a5ca02d2a9bbdfe052c885869c031a66b2 Mon Sep 17 00:00:00 2001 From: ehofman <ehofman> Date: Mon, 5 Apr 2004 11:29:12 +0000 Subject: [PATCH] Frederic Bouvier: this patch is to clear a problem that I sometimes encounter : FG locks when hitting the cancel button of a dialog. In fact, an interator is always invalid when it was used to erase a member of a collection. The braces are here to help my debugger, and I also removed a warning about unused variable. --- src/GUI/new_gui.cxx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/GUI/new_gui.cxx b/src/GUI/new_gui.cxx index 8a3a12f3c..6b233a343 100644 --- a/src/GUI/new_gui.cxx +++ b/src/GUI/new_gui.cxx @@ -95,9 +95,13 @@ NewGUI::closeActiveDialog () // algorithm to do (delete map entries by value, not key)? I hate // the STL :) -Andy map<string,FGDialog *>::iterator iter = _active_dialogs.begin(); - for(/**/; iter != _active_dialogs.end(); iter++) - if(iter->second == _active_dialog) + for(/**/; iter != _active_dialogs.end(); iter++) { + if(iter->second == _active_dialog) { _active_dialogs.erase(iter); + // iter is no longer valid + break; + } + } delete _active_dialog; _active_dialog = 0; @@ -206,7 +210,7 @@ NewGUI::readDir (const char * path) SGPropertyNode * props = new SGPropertyNode; try { readProperties(subpath, props); - } catch (const sg_exception &ex) { + } catch (const sg_exception &) { SG_LOG(SG_INPUT, SG_ALERT, "Error parsing dialog " << subpath); delete props;