From: ThorstenB Date: Mon, 7 Mar 2011 18:37:04 +0000 (+0100) Subject: Untie all TiedPropertyLists before destruction. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=f6fde388a2037341c7ce2a00e8ac199dff3c59a1;p=flightgear.git Untie all TiedPropertyLists before destruction. Untieing needs to be done prior to the destruction of the object which aggregated the TiedPropertyList. So the TiedPropertyLists destructor can't untie the properties automatically (and it doesn't). So, do some manual clean-up. --- diff --git a/src/Environment/realwx_ctrl.cxx b/src/Environment/realwx_ctrl.cxx index 087040486..03db5a87a 100644 --- a/src/Environment/realwx_ctrl.cxx +++ b/src/Environment/realwx_ctrl.cxx @@ -69,6 +69,7 @@ LiveMetarProperties::LiveMetarProperties( SGPropertyNode_ptr rootNode ) : LiveMetarProperties::~LiveMetarProperties() { + _tiedProperties.Untie(); } void LiveMetarProperties::update( double dt ) @@ -106,7 +107,7 @@ protected: bool _enabled; bool __enabled; simgear::TiedPropertyList _tiedProperties; - ; typedef std::vector MetarPropertiesList; + typedef std::vector MetarPropertiesList; MetarPropertiesList _metarProperties; }; diff --git a/src/FDM/TankProperties.cxx b/src/FDM/TankProperties.cxx index d42871a61..64d47882e 100644 --- a/src/FDM/TankProperties.cxx +++ b/src/FDM/TankProperties.cxx @@ -68,6 +68,11 @@ TankProperties::~TankProperties() { } +void TankProperties::unbind() +{ + _tiedProperties.Untie(); +} + double TankProperties::getContent_kg() const { return _content_kg; @@ -286,4 +291,10 @@ double TankPropertiesList::getTotalContent_norm() const return capacity > SGLimitsd::min() ? content / capacity : 0.0; } - +void TankPropertiesList::unbind() +{ + for( const_iterator it = begin(); it != end(); ++it ) { + (*it)->unbind(); + } + _tiedProperties.Untie(); +} diff --git a/src/FDM/TankProperties.hxx b/src/FDM/TankProperties.hxx index f1ec8b4aa..4a61d2d99 100644 --- a/src/FDM/TankProperties.hxx +++ b/src/FDM/TankProperties.hxx @@ -34,6 +34,8 @@ public: TankProperties( const TankProperties & ); const TankProperties & operator = ( const TankProperties & ); + void unbind(); + double getContent_kg() const; void setContent_kg( double value ); @@ -98,6 +100,8 @@ public: double getTotalContent_m3() const; double getTotalContent_norm() const; + void unbind(); + private: simgear::TiedPropertyList _tiedProperties; }; diff --git a/src/FDM/fdm_shell.cxx b/src/FDM/fdm_shell.cxx index dff0d40fe..e630c7bef 100644 --- a/src/FDM/fdm_shell.cxx +++ b/src/FDM/fdm_shell.cxx @@ -102,6 +102,7 @@ void FDMShell::bind() void FDMShell::unbind() { if( _impl ) _impl->unbind(); + _tankProperties.unbind(); } void FDMShell::update(double dt) diff --git a/src/Main/globals.cxx b/src/Main/globals.cxx index 2c1156c1a..af4e69345 100644 --- a/src/Main/globals.cxx +++ b/src/Main/globals.cxx @@ -182,6 +182,7 @@ FGGlobals::~FGGlobals() delete current_panel; delete ATC_mgr; + controls->unbind(); delete controls; delete channel_options_list;