aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4value.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/qml/jsruntime/qv4value.cpp')
-rw-r--r--src/qml/jsruntime/qv4value.cpp17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/qml/jsruntime/qv4value.cpp b/src/qml/jsruntime/qv4value.cpp
index 4fd5597475..8292a48e45 100644
--- a/src/qml/jsruntime/qv4value.cpp
+++ b/src/qml/jsruntime/qv4value.cpp
@@ -77,24 +77,25 @@ int Value::toUInt16() const
bool Value::toBoolean() const
{
- if (isInteger() || isBoolean())
+ if (integerCompatible())
return static_cast<bool>(int_32());
- if (isUndefined() || isNull())
- return false;
-
- if (isManaged()) {
+ if (isManagedOrUndefined()) {
+ Heap::Base *b = m();
+ if (!b)
+ return false;
#ifdef V4_BOOTSTRAP
Q_UNIMPLEMENTED();
#else
- if (String *s = stringValue())
- return s->toQString().length() > 0;
+ if (b->vtable()->isString)
+ return static_cast<Heap::String *>(b)->length() > 0;
#endif
return true;
}
// double
- return doubleValue() && !std::isnan(doubleValue());
+ double d = doubleValue();
+ return d && !std::isnan(d);
}
double Value::toInteger() const