From 10bbd435b7c82d15b040c44c81b6dcda5ecbc706 Mon Sep 17 00:00:00 2001 From: ThorstenB Date: Mon, 7 Mar 2011 19:32:20 +0100 Subject: [PATCH] Catch dangling property ties. It's bad when tied properties are not untied before removing the tied property list. We could try to "untie" the properties in the destructor - but that usually caused weird mem access errors, since the tied properties will access a no longer existing object (the very object whose destruction called the TiedPropertyList destructor...). => so just add a warning and a nagging trap :) --- simgear/props/tiedpropertylist.hxx | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/simgear/props/tiedpropertylist.hxx b/simgear/props/tiedpropertylist.hxx index 28cdb518..c825d105 100644 --- a/simgear/props/tiedpropertylist.hxx +++ b/simgear/props/tiedpropertylist.hxx @@ -21,6 +21,7 @@ #ifndef __TIEDPROPERTYLIST_HXX #define __TIEDPROPERTYLIST_HXX #include +#include using simgear::PropertyList; namespace simgear { @@ -34,6 +35,16 @@ class TiedPropertyList : PropertyList { public: TiedPropertyList() {} TiedPropertyList( SGPropertyNode_ptr root ) : _root(root) {} + virtual ~TiedPropertyList() + { + _root = 0; + if (size()>0) + { + SG_LOG(SG_GENERAL, SG_ALERT, "Detected properties with dangling ties. Use 'Untie' before removing a TiedPropertyList."); + // running debug mode: go, fix it! + assert(size() == 0); + } + } void setRoot( SGPropertyNode_ptr root ) { _root = root; } SGPropertyNode_ptr getRoot() const { return _root; } -- 2.39.5