]> git.mxchange.org Git - flightgear.git/blobdiff - src/Objects/matlib.cxx
- adjusted for no-value constructor for FGPanel
[flightgear.git] / src / Objects / matlib.cxx
index 6bac2370b0da27da6ffef3bfe741b313ed7ee940..6c8cf6b7ff9761ea2d10121a72a2aae42a18b0c2 100644 (file)
@@ -130,8 +130,14 @@ bool FGMaterialLib::load( const string& mpath ) {
            in >> token;
 
            if ( token == '{' ) {
+                // Read the data into a temporary but stack allocated
+                // copy of the structure
+                FGNewMat tmp;
+               in >> tmp;
+
+                // create a pointer to a heap allocated copy of the structure
                FGNewMat *m = new FGNewMat;
-               in >> *m;
+                *m = tmp;
 
                // build the ssgSimpleState
                SGPath tex_path( globals->get_fg_root() );
@@ -267,6 +273,13 @@ FGNewMat *FGMaterialLib::find( const string& material ) {
 
 // Destructor
 FGMaterialLib::~FGMaterialLib ( void ) {
+    // Free up all the material entries first
+    for ( material_map_iterator it = begin(); it != end(); it++ ) {
+       FGNewMat *slot = it->second;
+        if ( slot != NULL ) {
+            delete slot;
+        }
+    }
 }