]> git.mxchange.org Git - flightgear.git/blobdiff - src/GUI/new_gui.cxx
don't destroy iterated map entries; delete _menubar; restore closed
[flightgear.git] / src / GUI / new_gui.cxx
index a93a0ce1e7b2043a528c3a64e9d34a19d17a93d8..339cc92a9016ae1bfa7307c833514206d1d76800 100644 (file)
@@ -55,21 +55,24 @@ NewGUI::reinit ()
     map<string,FGDialog *>::iterator iter;
     vector<string> dlg;
     // close all open dialogs and remember them ...
-    for (iter = _active_dialogs.begin(); iter != _active_dialogs.end(); iter++) {
+    for (iter = _active_dialogs.begin(); iter != _active_dialogs.end(); ++iter)
         dlg.push_back(iter->first);
-        closeDialog(iter->first);
-    }
+
+    unsigned int i;
+    for (i = 0; i < dlg.size(); i++)
+        closeDialog(dlg[i]);
 
     unbind();
     clear();
     setStyle();
+    delete _menubar;
     _menubar = new FGMenuBar;
     init();
     bind();
 
     // open remembered dialogs again (no nasal generated ones, unfortunately)
-//    for (unsigned int i = 0; i < dlg.size(); i++)
-//        showDialog(dlg[i]);
+    for (i = 0; i < dlg.size(); i++)
+        showDialog(dlg[i]);
 }
 
 void
@@ -142,6 +145,16 @@ NewGUI::closeDialog (const string& name)
     return false; // dialog wasn't open...
 }
 
+SGPropertyNode_ptr
+NewGUI::getDialog (const string &name)
+{
+    if(_dialog_props.find(name) != _dialog_props.end())
+        return _dialog_props[name];
+
+    SG_LOG(SG_GENERAL, SG_ALERT, "dialog '" << name << "' missing");
+    return 0;
+}
+
 void
 NewGUI::setActiveDialog (FGDialog * dialog)
 {
@@ -181,6 +194,9 @@ NewGUI::clear ()
     delete _menubar;
     _menubar = 0;
     _dialog_props.clear();
+    _itt_t it;
+    for (it = _colors.begin(); it != _colors.end(); ++it)
+      delete it->second;
     _colors.clear();
 }
 
@@ -206,7 +222,7 @@ NewGUI::newDialog (SGPropertyNode* props)
         return;
     }
     string name = cname;
-    if(!_active_dialogs[name])
+    if(_active_dialogs.find(name) == _active_dialogs.end())
         _dialog_props[name] = props;
 }
 
@@ -265,6 +281,9 @@ NewGUI::readDir (const char * path)
 void
 NewGUI::setStyle (void)
 {
+    _itt_t it;
+    for (it = _colors.begin(); it != _colors.end(); ++it)
+      delete it->second;
     _colors.clear();
 
     // set up the traditional colors as default