]> git.mxchange.org Git - simgear.git/commitdiff
Try to avoid some memory leaks.
authordavid <david>
Wed, 5 Jun 2002 15:43:04 +0000 (15:43 +0000)
committerdavid <david>
Wed, 5 Jun 2002 15:43:04 +0000 (15:43 +0000)
simgear/sky/cloud.cxx

index 4c37a17a96994351852dfa6617e388390960f694..cae48fdbbd49bcf088611da7741b9b1d5f69a504 100644 (file)
@@ -46,11 +46,13 @@ SGCloudLayer::SGCloudLayer( const string &tex_path )
     layer_transition(0),
     layer_type(SG_CLOUD_CLEAR)
 {
-  rebuild();
+    rebuild();
 }
 
 // Destructor
-SGCloudLayer::~SGCloudLayer( void ) {
+SGCloudLayer::~SGCloudLayer()
+{
+    delete layer_root;
 }
 
 float
@@ -62,7 +64,10 @@ SGCloudLayer::getSpan_m () const
 void
 SGCloudLayer::setSpan_m (float span_m)
 {
-    layer_span = span_m;
+    if (span_m != layer_span) {
+       layer_span = span_m;
+       rebuild();
+    }
 }
 
 float
@@ -110,8 +115,10 @@ SGCloudLayer::getType () const
 void
 SGCloudLayer::setType (Type type)
 {
-    layer_type = type;
-    rebuild();
+    if (type != layer_type) {
+       layer_type = type;
+       rebuild();
+    }
 }
 
 
@@ -143,7 +150,11 @@ SGCloudLayer::rebuild()
       layer_states[SG_CLOUD_CLEAR] = 0;
     }
 
+                               // This should automatically delete
+                               // layer_transform as well.
     delete layer_root;
+    layer_root = 0;
+    layer_transform = 0;
 
     scale = 4000.0;