void
NewGUI::shutdown()
{
+ DialogDict::iterator it = _active_dialogs.begin();
+ for (; it != _active_dialogs.end(); ++it) {
+ delete it->second;
+ }
+ _active_dialogs.clear();
+
fgUntie("/sim/menubar/visibility");
_menubar.reset();
_dialog_props.clear();
void
NewGUI::reset (bool reload)
{
- map<string,FGDialog *>::iterator iter;
+ DialogDict::iterator iter;
string_list openDialogs;
// close all open dialogs and remember them ...
for (iter = _active_dialogs.begin(); iter != _active_dialogs.end(); ++iter)
std::auto_ptr<FGMenuBar> _menubar;
FGDialog * _active_dialog;
- std::map<std::string,FGDialog *> _active_dialogs;
+ typedef std::map<std::string,FGDialog *> DialogDict;
+ DialogDict _active_dialogs;
typedef std::map<std::string, SGPath> NamePathDict;
// mapping from dialog names to the corresponding XML property list
return buf;
}
-FGNasalSys::FGNasalSys()
+FGNasalSys::FGNasalSys() :
+ _inited(false)
{
nasalSys = this;
_context = 0;
FGNasalSys::~FGNasalSys()
{
+ if (_inited) {
+ SG_LOG(SG_GENERAL, SG_ALERT, "Nasal was not shutdown");
+ }
nasalSys = 0;
}
void FGNasalSys::init()
{
+ if (_inited) {
+ SG_LOG(SG_GENERAL, SG_ALERT, "duplicate init of Nasal");
+ }
int i;
_context = naNewContext();
// now Nasal modules are loaded, we can do some delayed work
postinitNasalPositioned(_globals, _context);
postinitNasalGUI(_globals, _context);
+
+ _inited = true;
}
void FGNasalSys::shutdown()
{
+ if (!_inited) {
+ return;
+ }
+
shutdownNasalPositioned();
map<int, FGNasalListener *>::iterator it, end = _listener.end();
_globals = naNil();
naGC();
-
+ _inited = false;
}
naRef FGNasalSys::wrappedPropsNode(SGPropertyNode* aProps)
void FGNasalSys::deleteModule(const char* moduleName)
{
+ if (!_inited) {
+ // can occur on shutdown due to us being shutdown first, but other
+ // subsystems having Nasal objects.
+ return;
+ }
+
naContext ctx = naNewContext();
naRef modname = naNewString(ctx);
naStr_fromdata(modname, (char*)moduleName, strlen(moduleName));