Make sure that Value::IsEmpty() returns true for empty strings

fixes #8018
This commit is contained in:
Gunnar Beutner 2014-12-20 09:31:55 +01:00
parent 6fddec0dd3
commit 1ddab493e1
2 changed files with 2 additions and 5 deletions

View File

@ -51,7 +51,6 @@ class I2_BASE_API Value
{ {
public: public:
inline Value(void) inline Value(void)
: m_Value()
{ } { }
inline Value(int value) inline Value(int value)
@ -91,7 +90,6 @@ public:
{ } { }
inline Value(Object *value) inline Value(Object *value)
: m_Value()
{ {
if (!value) if (!value)
return; return;
@ -101,7 +99,6 @@ public:
template<typename T> template<typename T>
inline Value(const intrusive_ptr<T>& value) inline Value(const intrusive_ptr<T>& value)
: m_Value()
{ {
if (!value) if (!value)
return; return;
@ -160,7 +157,7 @@ public:
*/ */
inline bool IsEmpty(void) const inline bool IsEmpty(void) const
{ {
return (GetType() == ValueEmpty); return (GetType() == ValueEmpty || (IsString() && boost::get<String>(m_Value).IsEmpty()));
} }
/** /**

View File

@ -163,7 +163,7 @@ void ConfigType::ValidateObject(const Object::Ptr& object,
Value value = VMOps::GetField(object, require); Value value = VMOps::GetField(object, require);
if (value.IsEmpty() || (value.IsString() && static_cast<String>(value).IsEmpty())) if (value.IsEmpty())
BOOST_THROW_EXCEPTION(ScriptError("Required attribute is missing: " + LocationToString(locations))); BOOST_THROW_EXCEPTION(ScriptError("Required attribute is missing: " + LocationToString(locations)));
locations.pop_back(); locations.pop_back();