From: david Date: Wed, 5 Jun 2002 15:43:04 +0000 (+0000) Subject: Try to avoid some memory leaks. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=1341b5b9f862519e5d423fb786d4de31bf7cdfa2;p=simgear.git Try to avoid some memory leaks. --- diff --git a/simgear/sky/cloud.cxx b/simgear/sky/cloud.cxx index 4c37a17a..cae48fdb 100644 --- a/simgear/sky/cloud.cxx +++ b/simgear/sky/cloud.cxx @@ -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;