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 :)
This commit is contained in:
@@ -21,6 +21,7 @@
|
|||||||
#ifndef __TIEDPROPERTYLIST_HXX
|
#ifndef __TIEDPROPERTYLIST_HXX
|
||||||
#define __TIEDPROPERTYLIST_HXX
|
#define __TIEDPROPERTYLIST_HXX
|
||||||
#include <simgear/props/props.hxx>
|
#include <simgear/props/props.hxx>
|
||||||
|
#include <assert.h>
|
||||||
using simgear::PropertyList;
|
using simgear::PropertyList;
|
||||||
|
|
||||||
namespace simgear {
|
namespace simgear {
|
||||||
@@ -34,6 +35,16 @@ class TiedPropertyList : PropertyList {
|
|||||||
public:
|
public:
|
||||||
TiedPropertyList() {}
|
TiedPropertyList() {}
|
||||||
TiedPropertyList( SGPropertyNode_ptr root ) : _root(root) {}
|
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; }
|
void setRoot( SGPropertyNode_ptr root ) { _root = root; }
|
||||||
SGPropertyNode_ptr getRoot() const { return _root; }
|
SGPropertyNode_ptr getRoot() const { return _root; }
|
||||||
|
|||||||
Reference in New Issue
Block a user