mirror of https://github.com/axmolengine/axmol.git
Merge pull request #4927 from dumganhar/value-fix
Fixing ‘ActionTest->AnimationTest’ crashes. It should return empty ValueMap/ValueVector when Value::asValueVector/Map is invoked in empty Value.
This commit is contained in:
commit
1ad6064c30
|
@ -594,6 +594,51 @@ std::string Value::asString() const
|
|||
return ret.str();
|
||||
}
|
||||
|
||||
ValueVector& Value::asValueVector()
|
||||
{
|
||||
if (nullptr == _vectorData)
|
||||
_vectorData = new ValueVector();
|
||||
return *_vectorData;
|
||||
}
|
||||
|
||||
const ValueVector& Value::asValueVector() const
|
||||
{
|
||||
static const ValueVector EMPTY_VALUEVECTOR;
|
||||
if (nullptr == _vectorData)
|
||||
return EMPTY_VALUEVECTOR;
|
||||
return *_vectorData;
|
||||
}
|
||||
|
||||
ValueMap& Value::asValueMap()
|
||||
{
|
||||
if (nullptr == _mapData)
|
||||
_mapData = new ValueMap();
|
||||
return *_mapData;
|
||||
}
|
||||
|
||||
const ValueMap& Value::asValueMap() const
|
||||
{
|
||||
static const ValueMap EMPTY_VALUEMAP;
|
||||
if (nullptr == _mapData)
|
||||
return EMPTY_VALUEMAP;
|
||||
return *_mapData;
|
||||
}
|
||||
|
||||
ValueMapIntKey& Value::asIntKeyMap()
|
||||
{
|
||||
if (nullptr == _intKeyMapData)
|
||||
_intKeyMapData = new ValueMapIntKey();
|
||||
return *_intKeyMapData;
|
||||
}
|
||||
|
||||
const ValueMapIntKey& Value::asIntKeyMap() const
|
||||
{
|
||||
static const ValueMapIntKey EMPTY_VALUEMAP_INT_KEY;
|
||||
if (nullptr == _intKeyMapData)
|
||||
return EMPTY_VALUEMAP_INT_KEY;
|
||||
return *_intKeyMapData;
|
||||
}
|
||||
|
||||
static std::string getTabs(int depth)
|
||||
{
|
||||
std::string tabWidth;
|
||||
|
|
|
@ -94,14 +94,14 @@ public:
|
|||
bool asBool() const;
|
||||
std::string asString() const;
|
||||
|
||||
inline ValueVector& asValueVector() { return *_vectorData; }
|
||||
inline const ValueVector& asValueVector() const { return *_vectorData; }
|
||||
ValueVector& asValueVector();
|
||||
const ValueVector& asValueVector() const;
|
||||
|
||||
inline ValueMap& asValueMap() { return *_mapData; }
|
||||
inline const ValueMap& asValueMap() const { return *_mapData; }
|
||||
ValueMap& asValueMap();
|
||||
const ValueMap& asValueMap() const;
|
||||
|
||||
inline ValueMapIntKey& asIntKeyMap() { return *_intKeyMapData; }
|
||||
inline const ValueMapIntKey& asIntKeyMap() const { return *_intKeyMapData; }
|
||||
ValueMapIntKey& asIntKeyMap();
|
||||
const ValueMapIntKey& asIntKeyMap() const;
|
||||
|
||||
inline bool isNull() const { return _type == Type::NONE; }
|
||||
|
||||
|
|
Loading…
Reference in New Issue