Fix PropertyObject bug and interface improvements.
- Fix overwriting of parent node if PropertyObject::node() is called for a non-existing node. - Prevent implicit conversion from const char* and SGPropertyNode*
This commit is contained in:
parent
fd8369142a
commit
21e2a769eb
@ -66,15 +66,17 @@ SGPropertyNode* PropertyObjectBase::node(bool aCreate) const
|
|||||||
return _prop;
|
return _prop;
|
||||||
}
|
}
|
||||||
|
|
||||||
SGPropertyNode* r = _prop ? _prop : static_defaultRoot;
|
SGPropertyNode *r = _prop ? _prop : static_defaultRoot,
|
||||||
_prop = r->getNode(_path, aCreate);
|
*prop = r->getNode(_path, aCreate);
|
||||||
|
|
||||||
if (_prop) {
|
if( prop )
|
||||||
// resolve worked, we will cache from now on, so clear _path
|
{
|
||||||
|
// resolve worked, we will cache from now on, so clear _path and cache prop
|
||||||
_path = NULL;
|
_path = NULL;
|
||||||
|
_prop = prop;
|
||||||
}
|
}
|
||||||
|
|
||||||
return _prop;
|
return prop;
|
||||||
}
|
}
|
||||||
|
|
||||||
SGPropertyNode* PropertyObjectBase::getOrThrow() const
|
SGPropertyNode* PropertyObjectBase::getOrThrow() const
|
||||||
|
@ -59,19 +59,20 @@ template <typename T>
|
|||||||
class PropertyObject : PropertyObjectBase
|
class PropertyObject : PropertyObjectBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PropertyObject();
|
PropertyObject()
|
||||||
|
{}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create from path relative to the default root, and option default value
|
* Create from path relative to the default root, and option default value
|
||||||
*/
|
*/
|
||||||
PropertyObject(const char* aChild) :
|
explicit PropertyObject(const char* aChild) :
|
||||||
PropertyObjectBase(aChild)
|
PropertyObjectBase(aChild)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create from a node, with optional relative path
|
* Create from a node, with optional relative path
|
||||||
*/
|
*/
|
||||||
PropertyObject(SGPropertyNode* aNode, const char* aChild = NULL) :
|
explicit PropertyObject(SGPropertyNode* aNode, const char* aChild = NULL) :
|
||||||
PropertyObjectBase(aNode, aChild)
|
PropertyObjectBase(aNode, aChild)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -115,6 +116,7 @@ public:
|
|||||||
{
|
{
|
||||||
SGPropertyNode* n = PropertyObjectBase::node(true);
|
SGPropertyNode* n = PropertyObjectBase::node(true);
|
||||||
if (!n) {
|
if (!n) {
|
||||||
|
std::cout << "no node" << std::endl;
|
||||||
return aValue;
|
return aValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -157,13 +159,13 @@ template <>
|
|||||||
class PropertyObject<std::string> : PropertyObjectBase
|
class PropertyObject<std::string> : PropertyObjectBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PropertyObject(const char* aChild) :
|
explicit PropertyObject(const char* aChild) :
|
||||||
PropertyObjectBase(aChild)
|
PropertyObjectBase(aChild)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
PropertyObject(SGPropertyNode* aNode, const char* aChild = NULL) :
|
explicit PropertyObject(SGPropertyNode* aNode, const char* aChild = NULL) :
|
||||||
PropertyObjectBase(aNode, aChild)
|
PropertyObjectBase(aNode, aChild)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user