]> git.mxchange.org Git - flightgear.git/blobdiff - src/GUI/new_gui.cxx
Miscellaneous tweaks and Bugfixes. Mostly memory leaks ported from the plib
[flightgear.git] / src / GUI / new_gui.cxx
index 4f4b65b982bcd47b75820e6a54a0ae3226858477..667f257644a2a1464e9920c27d25d0c030f0a470 100644 (file)
@@ -35,6 +35,8 @@ NewGUI::~NewGUI ()
 {
     delete _menubar;
     _dialog_props.clear();
+    for (_itt_t it = _colors.begin(); it != _colors.end(); ++it)
+        delete it->second;
 }
 
 void
@@ -53,6 +55,7 @@ void
 NewGUI::reinit ()
 {
     reset(true);
+    fgSetBool("/sim/signals/reinit-gui", true);
 }
 
 void
@@ -414,32 +417,19 @@ FGFontCache::FGFontCache() :
 
 FGFontCache::~FGFontCache()
 {
-   _fonts.clear();
+   map<const string, fnt *>::iterator it, end = _fonts.end();
+   for (it = _fonts.begin(); it != end; ++it)
+       delete it->second;
 }
 
 struct FGFontCache::fnt *
 FGFontCache::getfnt(const char *name, float size, float slant)
 {
-    if (!_initialized) {
-        char *envp = ::getenv("FG_FONTS");
-        if (envp != NULL) {
-            _path.set(envp);
-        } else {
-            _path.set(globals->get_fg_root());
-            _path.append("Fonts");
-        }
-        _initialized = true;
-    }
-
-    for (int i=0; guifonts[i].name; i++)
-        _fonts[guifonts[i].name] = new fnt(guifonts[i].font);
-
     _itt_t it;
     if ((it = _fonts.find(name)) != _fonts.end())
         return it->second;
 
-    SGPath path(_path);
-    path.append(name);
+    SGPath path = getfntpath(name);
 
     fnt *f = new fnt();
     f->texfont = new fntTexFont;
@@ -479,4 +469,35 @@ FGFontCache::get(SGPropertyNode *node)
     return get(name, size, slant);
 }
 
+SGPath
+FGFontCache::getfntpath(const char *name)
+{
+    if (!_initialized) {
+        char *envp = ::getenv("FG_FONTS");
+        if (envp != NULL) {
+            _path.set(envp);
+        } else {
+            _path.set(globals->get_fg_root());
+            _path.append("Fonts");
+        }
+
+        for (int i = 0; guifonts[i].name; i++)
+            _fonts[guifonts[i].name] = new fnt(guifonts[i].font);
+
+        _initialized = true;
+    }
+
+    SGPath path(_path);
+    if (name && std::string(name) != "") {
+        path.append(name);
+        if (path.exists())
+            return path;
+    }
+
+    path = SGPath(_path);
+    path.append("Helvetica.txf");
+    
+    return path;
+}
+
 // end of new_gui.cxx