]> git.mxchange.org Git - flightgear.git/commitdiff
Remove another deprecated command, and fix things up so that dialogs
authordavid <david>
Tue, 21 Jan 2003 15:44:21 +0000 (15:44 +0000)
committerdavid <david>
Tue, 21 Jan 2003 15:44:21 +0000 (15:44 +0000)
reload properly on a reinit.

src/GUI/dialog.cxx
src/GUI/dialog.hxx
src/GUI/menubar.cxx
src/GUI/menubar.hxx
src/GUI/new_gui.cxx
src/GUI/new_gui.hxx

index 3ad41ca97f6480e924c379ae34dff249c60bd1df..de22f948fe0c4bede213b56167868b0ce19c565f 100644 (file)
@@ -115,7 +115,7 @@ GUIInfo::~GUIInfo ()
 // Implementation of FGDialog.
 ////////////////////////////////////////////////////////////////////////
 
-FGDialog::FGDialog (SGPropertyNode_ptr props)
+FGDialog::FGDialog (SGPropertyNode * props)
     : _object(0)
 {
     display(props);
@@ -189,7 +189,7 @@ FGDialog::applyValues ()
 }
 
 void
-FGDialog::display (SGPropertyNode_ptr props)
+FGDialog::display (SGPropertyNode * props)
 {
     if (_object != 0) {
         SG_LOG(SG_GENERAL, SG_ALERT, "This widget is already active");
index 4b4752d16913d2d700424dfec7a0e2178ae057fa..cf0c199f89fd4040d178c37ba51d50b19d10cf6e 100644 (file)
@@ -40,7 +40,7 @@ public:
      *
      * @param props A property tree describing the dialog.
      */
-    FGDialog (SGPropertyNode_ptr props);
+    FGDialog (SGPropertyNode * props);
 
 
     /**
@@ -97,7 +97,7 @@ private:
     FGDialog (const FGDialog &);
 
     // Show the dialog.
-    void display (SGPropertyNode_ptr props);
+    void display (SGPropertyNode * props);
 
     // Build the dialog or a subobject of it.
     puObject * makeObject (SGPropertyNode * props,
index 0fa6d496dce163cc0f7dd7ee3e86ac88274654fd..43e30fd8126bd9ab7183235c2a277f2ef4d7c624 100644 (file)
@@ -58,15 +58,6 @@ do_hires_snapshot_dialog (const SGPropertyNode * arg)
 }
 #endif // TR_HIRES_SNAP
 
-extern void dumpSnapShot (puObject *);
-static bool
-do_snapshot_dialog (const SGPropertyNode * arg)
-{
-    dumpSnapShot(0);
-    return true;
-}
-
-
 #if defined( WIN32 ) && !defined( __CYGWIN__) && !defined(__MINGW32__)
 extern void printScreen (puObject *);
 static bool
@@ -215,7 +206,6 @@ static struct {
 #if defined(TR_HIRES_SNAP)
     { "old-hires-snapshot-dialog", do_hires_snapshot_dialog },
 #endif
-    { "old-snapshot-dialog", do_snapshot_dialog },
 #if defined( WIN32 ) && !defined( __CYGWIN__) && !defined(__MINGW32__)
     { "old-print-dialog", do_print_dialog },
 #endif
@@ -359,7 +349,7 @@ FGMenuBar::fireItem (puObject * item)
 }
 
 void
-FGMenuBar::make_menu (SGPropertyNode_ptr node)
+FGMenuBar::make_menu (SGPropertyNode * node)
 {
     const char * name = strdup(node->getStringValue("label"));
     vector<SGPropertyNode_ptr> item_nodes = node->getChildren("item");
index 52e82ac0488470a8c850ca83b961356dc65851db..10aeaf7a6f2fef199dddb5f1f5d4383f33b6385f 100644 (file)
@@ -88,7 +88,7 @@ public:
 private:
 
     // Make a single menu.
-    void make_menu (SGPropertyNode_ptr node);
+    void make_menu (SGPropertyNode * node);
 
     // Make the top-level menubar.
     void make_menubar ();
index a0e17a65ed72ee70d435c123d13f2ab93435eb03..4e06c320c417001b6dee772c855646fa9c3edef9 100644 (file)
@@ -26,7 +26,7 @@ NewGUI::NewGUI ()
 
 NewGUI::~NewGUI ()
 {
-    delete _menubar;
+    clear();
 }
 
 void
@@ -46,13 +46,8 @@ void
 NewGUI::reinit ()
 {
     unbind();
-
-#if !defined(FG_OLD_MENUBAR)
-    delete _menubar;
+    clear();
     _menubar = new FGMenuBar;
-#endif
-    _dialog_props.clear();
-
     init();
     bind();
 }
@@ -133,6 +128,18 @@ NewGUI::setMenuBarVisible (bool visible)
         _menubar->hide();
 }
 
+void
+NewGUI::clear ()
+{
+    delete _menubar;
+    _menubar = 0;
+
+    map<string,SGPropertyNode *>::iterator it;
+    for (it = _dialog_props.begin(); it != _dialog_props.end(); it++)
+        delete it->second;
+    _dialog_props.clear();
+}
+
 void
 NewGUI::readDir (const char * path)
 {
@@ -144,32 +151,39 @@ NewGUI::readDir (const char * path)
         return;
     }
 
-    ulDirEnt * dirEnt = ulReadDir(dir);
-    while (dirEnt != 0) {
+    for (ulDirEnt * dirEnt = ulReadDir(dir);
+         dirEnt != 0;
+         dirEnt = ulReadDir(dir)) {
+
         char subpath[1024];
 
         ulMakePath(subpath, path, dirEnt->d_name);
 
-        if (dirEnt->d_isdir && dirEnt->d_name[0] != '.') {
-            readDir(subpath);
+        if (dirEnt->d_isdir) {
+            if (dirEnt->d_name[0] != '.')
+                readDir(subpath);
         } else {
-            SGPropertyNode_ptr props = new SGPropertyNode;
+            SGPropertyNode * props = new SGPropertyNode;
             try {
                 readProperties(subpath, props);
             } catch (const sg_exception &ex) {
-                SG_LOG(SG_INPUT, SG_ALERT, "Error parsing GUI file "
+                SG_LOG(SG_INPUT, SG_ALERT, "Error parsing dialog "
                        << subpath);
+                delete props;
+                continue;
             }
             if (!props->hasValue("name")) {
-                SG_LOG(SG_INPUT, SG_WARN, "GUI file " << subpath
+                SG_LOG(SG_INPUT, SG_WARN, "dialog " << subpath
                    << " has no name; skipping.");
-            } else {
-                string name = props->getStringValue("name");
-                SG_LOG(SG_INPUT, SG_BULK, "Saving GUI node " << name);
-                _dialog_props[name] = props;
+                delete props;
+                continue;
             }
+            string name = props->getStringValue("name");
+            SG_LOG(SG_INPUT, SG_BULK, "Saving dialog " << name);
+            if (_dialog_props[name] != 0)
+                delete _dialog_props[name];
+            _dialog_props[name] = props;
         }
-        dirEnt = ulReadDir(dir);
     }
     ulCloseDir(dir);
 }
index 2fd8909f4f4b2abeb4ebe080ff47a959f4c5d92b..6d3c553690d3ed810718e29978ecc7c9f51230f0 100644 (file)
@@ -142,12 +142,15 @@ protected:
 
 private:
 
+    // Free all allocated memory.
+    void clear ();
+
     // Read all the configuration files in a directory.
     void readDir (const char * path);
 
     FGMenuBar * _menubar;
     FGDialog * _active_dialog;
-    map<string,SGPropertyNode_ptr> _dialog_props;
+    map<string,SGPropertyNode *> _dialog_props;
 
 };