reload properly on a reinit.
// Implementation of FGDialog.
////////////////////////////////////////////////////////////////////////
-FGDialog::FGDialog (SGPropertyNode_ptr props)
+FGDialog::FGDialog (SGPropertyNode * props)
: _object(0)
{
display(props);
}
void
-FGDialog::display (SGPropertyNode_ptr props)
+FGDialog::display (SGPropertyNode * props)
{
if (_object != 0) {
SG_LOG(SG_GENERAL, SG_ALERT, "This widget is already active");
*
* @param props A property tree describing the dialog.
*/
- FGDialog (SGPropertyNode_ptr props);
+ FGDialog (SGPropertyNode * props);
/**
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,
}
#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
#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
}
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");
private:
// Make a single menu.
- void make_menu (SGPropertyNode_ptr node);
+ void make_menu (SGPropertyNode * node);
// Make the top-level menubar.
void make_menubar ();
NewGUI::~NewGUI ()
{
- delete _menubar;
+ clear();
}
void
NewGUI::reinit ()
{
unbind();
-
-#if !defined(FG_OLD_MENUBAR)
- delete _menubar;
+ clear();
_menubar = new FGMenuBar;
-#endif
- _dialog_props.clear();
-
init();
bind();
}
_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)
{
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);
}
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;
};