Further cleanups
authorLars Knoll <lars.knoll@theqtcompany.com>
Fri, 13 Feb 2015 09:42:01 +0000 (10:42 +0100)
committerSimon Hausmann <simon.hausmann@theqtcompany.com>
Thu, 16 Apr 2015 17:44:24 +0000 (17:44 +0000)
The get and getIndexed vtable methods should take a const Managed
pointer. Start cleaning up the asFoo() methods in Value and Managed
by removing asArrayObject() and asErrorObject().

Change-Id: Ibd49bf20773ef84c15785b7ac37a7bc9fd4745d5
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
37 files changed:
src/imports/localstorage/plugin.cpp
src/qml/jsapi/qjsvalue.cpp
src/qml/jsruntime/qv4argumentsobject.cpp
src/qml/jsruntime/qv4argumentsobject_p.h
src/qml/jsruntime/qv4arrayobject.cpp
src/qml/jsruntime/qv4engine.cpp
src/qml/jsruntime/qv4errorobject_p.h
src/qml/jsruntime/qv4jsonobject.cpp
src/qml/jsruntime/qv4lookup.cpp
src/qml/jsruntime/qv4managed_p.h
src/qml/jsruntime/qv4object.cpp
src/qml/jsruntime/qv4object_p.h
src/qml/jsruntime/qv4qobjectwrapper.cpp
src/qml/jsruntime/qv4qobjectwrapper_p.h
src/qml/jsruntime/qv4sequenceobject.cpp
src/qml/jsruntime/qv4serialize.cpp
src/qml/jsruntime/qv4typedarray.cpp
src/qml/jsruntime/qv4typedarray_p.h
src/qml/jsruntime/qv4value_inl_p.h
src/qml/jsruntime/qv4value_p.h
src/qml/qml/qqmlcomponent.cpp
src/qml/qml/qqmlcontextwrapper.cpp
src/qml/qml/qqmlcontextwrapper_p.h
src/qml/qml/qqmllistwrapper.cpp
src/qml/qml/qqmllistwrapper_p.h
src/qml/qml/qqmltypewrapper.cpp
src/qml/qml/qqmltypewrapper_p.h
src/qml/qml/qqmlvaluetypewrapper.cpp
src/qml/qml/qqmlvaluetypewrapper_p.h
src/qml/qml/qqmlxmlhttprequest.cpp
src/qml/qml/v8/qqmlbuiltinfunctions.cpp
src/qml/types/qqmldelegatemodel.cpp
src/qml/types/qqmllistmodel.cpp
src/qmltest/quicktestresult.cpp
src/quick/items/context2d/qquickcontext2d.cpp
src/quick/items/qquickloader.cpp
tools/qmljs/qmljs.cpp

index ef0add2..22f1b0d 100644 (file)
@@ -126,7 +126,7 @@ public:
     ~QQmlSqlDatabaseWrapper() {
     }
 
-    static ReturnedValue getIndexed(Managed *m, uint index, bool *hasProperty);
+    static ReturnedValue getIndexed(const Managed *m, uint index, bool *hasProperty);
 };
 
 }
@@ -214,7 +214,7 @@ static QString qmlsqldatabase_databaseFile(const QString& connectionName, QV4::E
     return qmlsqldatabase_databasesPath(engine) + QDir::separator() + connectionName;
 }
 
-static ReturnedValue qmlsqldatabase_rows_index(QQmlSqlDatabaseWrapper *r, ExecutionEngine *v4, quint32 index, bool *hasProperty = 0)
+static ReturnedValue qmlsqldatabase_rows_index(const QQmlSqlDatabaseWrapper *r, ExecutionEngine *v4, quint32 index, bool *hasProperty = 0)
 {
     Scope scope(v4);
 
@@ -238,15 +238,14 @@ static ReturnedValue qmlsqldatabase_rows_index(QQmlSqlDatabaseWrapper *r, Execut
     }
 }
 
-ReturnedValue QQmlSqlDatabaseWrapper::getIndexed(Managed *m, uint index, bool *hasProperty)
+ReturnedValue QQmlSqlDatabaseWrapper::getIndexed(const Managed *m, uint index, bool *hasProperty)
 {
-    QV4::Scope scope(static_cast<QQmlSqlDatabaseWrapper *>(m)->engine());
     Q_ASSERT(m->as<QQmlSqlDatabaseWrapper>());
-    QV4::Scoped<QQmlSqlDatabaseWrapper> r(scope, static_cast<QQmlSqlDatabaseWrapper *>(m));
+    const QQmlSqlDatabaseWrapper *r = static_cast<const QQmlSqlDatabaseWrapper *>(m);
     if (!r || r->d()->type != Heap::QQmlSqlDatabaseWrapper::Rows)
         return Object::getIndexed(m, index, hasProperty);
 
-    return qmlsqldatabase_rows_index(r, scope.engine, index, hasProperty);
+    return qmlsqldatabase_rows_index(r, r->engine(), index, hasProperty);
 }
 
 static ReturnedValue qmlsqldatabase_rows_item(CallContext *ctx)
@@ -285,7 +284,7 @@ static ReturnedValue qmlsqldatabase_executeSql(CallContext *ctx)
     if (query.prepare(sql)) {
         if (ctx->argc() > 1) {
             ScopedValue values(scope, ctx->args()[1]);
-            if (values->asArrayObject()) {
+            if (values->as<ArrayObject>()) {
                 ScopedArrayObject array(scope, values);
                 quint32 size = array->getLength();
                 QV4::ScopedValue v(scope);
index f4d8f7d..8a419c2 100644 (file)
@@ -44,6 +44,7 @@
 #include "qv4runtime_p.h"
 #include "qv4variantobject_p.h"
 #include "qv4regexpobject_p.h"
+#include "qv4errorobject_p.h"
 #include "private/qv8engine_p.h"
 #include <private/qv4mm_p.h>
 #include <private/qv4scopedvalue_p.h>
@@ -315,8 +316,7 @@ bool QJSValue::isError() const
     QV4::Value *val = QJSValuePrivate::getValue(this);
     if (!val)
         return false;
-    Object *o = val->asObject();
-    return o && o->asErrorObject();
+    return val->as<ErrorObject>();
 }
 
 /*!
@@ -330,7 +330,7 @@ bool QJSValue::isArray() const
     QV4::Value *val = QJSValuePrivate::getValue(this);
     if (!val)
         return false;
-    return val->asArrayObject();
+    return val->as<ArrayObject>();
 }
 
 /*!
index 92c7757..214f0dc 100644 (file)
@@ -144,9 +144,9 @@ bool ArgumentsObject::defineOwnProperty(ExecutionEngine *engine, uint index, con
     return result;
 }
 
-ReturnedValue ArgumentsObject::getIndexed(Managed *m, uint index, bool *hasProperty)
+ReturnedValue ArgumentsObject::getIndexed(const Managed *m, uint index, bool *hasProperty)
 {
-    ArgumentsObject *args = static_cast<ArgumentsObject *>(m);
+    const ArgumentsObject *args = static_cast<const ArgumentsObject *>(m);
     if (args->fullyCreated())
         return Object::getIndexed(m, index, hasProperty);
 
index 43cd6d1..a7297d9 100644 (file)
@@ -111,7 +111,7 @@ struct ArgumentsObject: Object {
     }
 
     bool defineOwnProperty(ExecutionEngine *engine, uint index, const Property *desc, PropertyAttributes attrs);
-    static ReturnedValue getIndexed(Managed *m, uint index, bool *hasProperty);
+    static ReturnedValue getIndexed(const Managed *m, uint index, bool *hasProperty);
     static void putIndexed(Managed *m, uint index, const Value &value);
     static bool deleteIndexedProperty(Managed *m, uint index);
     static PropertyAttributes queryIndexed(const Managed *m, uint index);
index 2c47981..d05504e 100644 (file)
@@ -110,7 +110,7 @@ void ArrayPrototype::init(ExecutionEngine *engine, Object *ctor)
 
 ReturnedValue ArrayPrototype::method_isArray(CallContext *ctx)
 {
-    bool isArray = ctx->argc() && ctx->args()[0].asArrayObject();
+    bool isArray = ctx->argc() && ctx->args()[0].as<ArrayObject>();
     return Encode(isArray);
 }
 
@@ -194,7 +194,7 @@ ReturnedValue ArrayPrototype::method_join(CallContext *ctx)
     QString R;
 
     // ### FIXME
-    if (ArrayObject *a = self->asArrayObject()) {
+    if (ArrayObject *a = self->as<ArrayObject>()) {
         ScopedValue e(scope);
         for (uint i = 0; i < a->getLength(); ++i) {
             if (i)
index a428382..f33eff2 100644 (file)
@@ -1199,7 +1199,7 @@ static QVariant toVariant(QV4::ExecutionEngine *e, const QV4::Value &value, int
     if (value.asObject()) {
         QV4::ScopedObject object(scope, value);
         if (typeHint == QMetaType::QJsonObject
-                   && !value.asArrayObject() && !value.asFunctionObject()) {
+                   && !value.as<ArrayObject>() && !value.asFunctionObject()) {
             return QVariant::fromValue(QV4::JsonObject::toJsonObject(object));
         } else if (QV4::QObjectWrapper *wrapper = object->as<QV4::QObjectWrapper>()) {
             return qVariantFromValue<QObject *>(wrapper->object());
@@ -1215,7 +1215,7 @@ static QVariant toVariant(QV4::ExecutionEngine *e, const QV4::Value &value, int
             return QV4::SequencePrototype::toVariant(object);
     }
 
-    if (value.asArrayObject()) {
+    if (value.as<ArrayObject>()) {
         QV4::ScopedArrayObject a(scope, value);
         if (typeHint == qMetaTypeId<QList<QObject *> >()) {
             QList<QObject *> list;
@@ -1282,7 +1282,7 @@ static QVariant objectToVariant(QV4::ExecutionEngine *e, QV4::Object *o, V4Objec
         // Avoid recursion.
         // For compatibility with QVariant{List,Map} conversion, we return an
         // empty object (and no error is thrown).
-        if (o->asArrayObject())
+        if (o->as<ArrayObject>())
             return QVariantList();
         return QVariantMap();
     }
@@ -1290,7 +1290,7 @@ static QVariant objectToVariant(QV4::ExecutionEngine *e, QV4::Object *o, V4Objec
 
     QVariant result;
 
-    if (o->asArrayObject()) {
+    if (o->as<ArrayObject>()) {
         QV4::Scope scope(e);
         QV4::ScopedArrayObject a(scope, o->asReturnedValue());
         QV4::ScopedValue v(scope);
index f8278a2..0004ba0 100644 (file)
@@ -142,7 +142,7 @@ struct ErrorObject: Object {
 
 template<>
 inline const ErrorObject *Value::as() const {
-    return asErrorObject();
+    return isManaged() && m->vtable->isErrorObject ? reinterpret_cast<const ErrorObject *>(this) : 0;
 }
 
 struct EvalErrorObject: ErrorObject {
index e790597..4580ff1 100644 (file)
@@ -751,7 +751,7 @@ QString Stringify::Str(const QString &key, const Value &v)
     o = value->asReturnedValue();
     if (o) {
         if (!o->asFunctionObject()) {
-            if (o->asArrayObject()) {
+            if (o->as<ArrayObject>()) {
                 return JA(static_cast<ArrayObject *>(o.getPointer()));
             } else {
                 return JO(o);
index d1d0601..274cb90 100644 (file)
@@ -569,7 +569,7 @@ ReturnedValue Lookup::stringLengthGetter(Lookup *l, ExecutionEngine *engine, con
 
 ReturnedValue Lookup::arrayLengthGetter(Lookup *l, ExecutionEngine *engine, const Value &object)
 {
-    if (ArrayObject *a = object.asArrayObject())
+    if (const ArrayObject *a = object.as<ArrayObject>())
         return a->memberData()->data[Heap::ArrayObject::LengthPropertyIndex].asReturnedValue();
 
     l->getter = getterGeneric;
index 79b6de4..c5148ad 100644 (file)
@@ -152,13 +152,11 @@ public:
 
     String *asString() { return d()->vtable->isString ? reinterpret_cast<String *>(this) : 0; }
     Object *asObject() { return d()->vtable->isObject ? reinterpret_cast<Object *>(this) : 0; }
-    ArrayObject *asArrayObject() { return d()->vtable->type == Type_ArrayObject ? reinterpret_cast<ArrayObject *>(this) : 0; }
     FunctionObject *asFunctionObject() { return d()->vtable->isFunctionObject ? reinterpret_cast<FunctionObject *>(this) : 0; }
     BooleanObject *asBooleanObject() { return d()->vtable->type == Type_BooleanObject ? reinterpret_cast<BooleanObject *>(this) : 0; }
     NumberObject *asNumberObject() { return d()->vtable->type == Type_NumberObject ? reinterpret_cast<NumberObject *>(this) : 0; }
     StringObject *asStringObject() { return d()->vtable->type == Type_StringObject ? reinterpret_cast<StringObject *>(this) : 0; }
     DateObject *asDateObject() { return d()->vtable->type == Type_DateObject ? reinterpret_cast<DateObject *>(this) : 0; }
-    ErrorObject *asErrorObject() { return d()->vtable->isErrorObject ? reinterpret_cast<ErrorObject *>(this) : 0; }
     ArgumentsObject *asArgumentsObject() { return d()->vtable->type == Type_ArgumentsObject ? reinterpret_cast<ArgumentsObject *>(this) : 0; }
 
     bool isListType() const { return d()->vtable->type == Type_QmlSequence; }
index 15dec83..37f1360 100644 (file)
@@ -375,14 +375,14 @@ ReturnedValue Object::call(Managed *m, CallData *)
     return static_cast<Object *>(m)->engine()->throwTypeError();
 }
 
-ReturnedValue Object::get(Managed *m, String *name, bool *hasProperty)
+ReturnedValue Object::get(const Managed *m, String *name, bool *hasProperty)
 {
-    return static_cast<Object *>(m)->internalGet(name, hasProperty);
+    return static_cast<const Object *>(m)->internalGet(name, hasProperty);
 }
 
-ReturnedValue Object::getIndexed(Managed *m, uint index, bool *hasProperty)
+ReturnedValue Object::getIndexed(const Managed *m, uint index, bool *hasProperty)
 {
-    return static_cast<Object *>(m)->internalGetIndexed(index, hasProperty);
+    return static_cast<const Object *>(m)->internalGetIndexed(index, hasProperty);
 }
 
 void Object::put(Managed *m, String *name, const Value &value)
@@ -585,7 +585,7 @@ void Object::advanceIterator(Managed *m, ObjectIterator *it, Heap::String **name
 }
 
 // Section 8.12.3
-ReturnedValue Object::internalGet(String *name, bool *hasProperty)
+ReturnedValue Object::internalGet(String *name, bool *hasProperty) const
 {
     uint idx = name->asArrayIndex();
     if (idx != UINT_MAX)
@@ -611,7 +611,7 @@ ReturnedValue Object::internalGet(String *name, bool *hasProperty)
     return Encode::undefined();
 }
 
-ReturnedValue Object::internalGetIndexed(uint index, bool *hasProperty)
+ReturnedValue Object::internalGetIndexed(uint index, bool *hasProperty) const
 {
     Property *pd = 0;
     PropertyAttributes attrs;
index 7758630..9d40bee 100644 (file)
@@ -89,8 +89,8 @@ struct ObjectVTable
     VTable vTable;
     ReturnedValue (*call)(Managed *, CallData *data);
     ReturnedValue (*construct)(Managed *, CallData *data);
-    ReturnedValue (*get)(Managed *, String *name, bool *hasProperty);
-    ReturnedValue (*getIndexed)(Managed *, uint index, bool *hasProperty);
+    ReturnedValue (*get)(const Managed *, String *name, bool *hasProperty);
+    ReturnedValue (*getIndexed)(const Managed *, uint index, bool *hasProperty);
     void (*put)(Managed *, String *name, const Value &value);
     void (*putIndexed)(Managed *, uint index, const Value &value);
     PropertyAttributes (*query)(const Managed *, String *name);
@@ -275,9 +275,9 @@ public:
     }
     void ensureMemberIndex(uint idx);
 
-    inline ReturnedValue get(String *name, bool *hasProperty = 0)
+    inline ReturnedValue get(String *name, bool *hasProperty = 0) const
     { return vtable()->get(this, name, hasProperty); }
-    inline ReturnedValue getIndexed(uint idx, bool *hasProperty = 0)
+    inline ReturnedValue getIndexed(uint idx, bool *hasProperty = 0) const
     { return vtable()->getIndexed(this, idx, hasProperty); }
     inline void put(String *name, const Value &v)
     { vtable()->put(this, name, v); }
@@ -307,8 +307,8 @@ protected:
     static void markObjects(Heap::Base *that, ExecutionEngine *e);
     static ReturnedValue construct(Managed *m, CallData *);
     static ReturnedValue call(Managed *m, CallData *);
-    static ReturnedValue get(Managed *m, String *name, bool *hasProperty);
-    static ReturnedValue getIndexed(Managed *m, uint index, bool *hasProperty);
+    static ReturnedValue get(const Managed *m, String *name, bool *hasProperty);
+    static ReturnedValue getIndexed(const Managed *m, uint index, bool *hasProperty);
     static void put(Managed *m, String *name, const Value &value);
     static void putIndexed(Managed *m, uint index, const Value &value);
     static PropertyAttributes query(const Managed *m, String *name);
@@ -321,8 +321,8 @@ protected:
     static uint getLength(const Managed *m);
 
 private:
-    ReturnedValue internalGet(String *name, bool *hasProperty);
-    ReturnedValue internalGetIndexed(uint index, bool *hasProperty);
+    ReturnedValue internalGet(String *name, bool *hasProperty) const;
+    ReturnedValue internalGetIndexed(uint index, bool *hasProperty) const;
     void internalPut(String *name, const Value &value);
     void internalPutIndexed(uint index, const Value &value);
     bool internalDeleteProperty(String *name);
@@ -464,7 +464,7 @@ inline const Object *Value::as() const {
 
 template<>
 inline const ArrayObject *Value::as() const {
-    return asArrayObject();
+    return isManaged() && m->vtable->type == Managed::Type_ArrayObject ? static_cast<const ArrayObject *>(this) : 0;
 }
 
 #ifndef V4_BOOTSTRAP
index 5bb7bac..a79b028 100644 (file)
@@ -260,7 +260,7 @@ QQmlPropertyData *QObjectWrapper::findProperty(ExecutionEngine *engine, QQmlCont
 }
 
 ReturnedValue QObjectWrapper::getQmlProperty(QQmlContextData *qmlContext, String *n, QObjectWrapper::RevisionMode revisionMode,
-                                             bool *hasProperty, bool includeImports)
+                                             bool *hasProperty, bool includeImports) const
 {
     if (QQmlData::wasDeleted(d()->object)) {
         if (hasProperty)
@@ -674,9 +674,9 @@ ReturnedValue QObjectWrapper::create(ExecutionEngine *engine, QObject *object)
     return (engine->memoryManager->alloc<QV4::QObjectWrapper>(engine, object))->asReturnedValue();
 }
 
-QV4::ReturnedValue QObjectWrapper::get(Managed *m, String *name, bool *hasProperty)
+QV4::ReturnedValue QObjectWrapper::get(const Managed *m, String *name, bool *hasProperty)
 {
-    QObjectWrapper *that = static_cast<QObjectWrapper*>(m);
+    const QObjectWrapper *that = static_cast<const QObjectWrapper*>(m);
     QQmlContextData *qmlContext = QV4::QmlContextWrapper::callingContext(that->engine());
     return that->getQmlProperty(qmlContext, name, IgnoreRevision, hasProperty, /*includeImports*/ true);
 }
@@ -1239,7 +1239,7 @@ static int MatchScore(const QV4::Value &actual, int conversionType)
         default:
             return 10;
         }
-    } else if (actual.asArrayObject()) {
+    } else if (actual.as<ArrayObject>()) {
         switch (conversionType) {
         case QMetaType::QJsonArray:
             return 3;
@@ -1746,14 +1746,14 @@ ReturnedValue QObjectMethod::create(ExecutionContext *scope, QObject *object, in
     return method.asReturnedValue();
 }
 
-ReturnedValue QObjectMethod::create(ExecutionContext *scope, QQmlValueTypeWrapper *valueType, int index, const Value &qmlGlobal)
+ReturnedValue QObjectMethod::create(ExecutionContext *scope, const QQmlValueTypeWrapper *valueType, int index, const Value &qmlGlobal)
 {
     Scope valueScope(scope);
     Scoped<QObjectMethod> method(valueScope, scope->d()->engine->memoryManager->alloc<QObjectMethod>(scope));
     method->d()->propertyCache = valueType->d()->propertyCache;
     method->d()->index = index;
     method->d()->qmlGlobal = qmlGlobal;
-    method->d()->valueTypeWrapper = valueType;
+    method->d()->valueTypeWrapper = *valueType;
     return method.asReturnedValue();
 }
 
index 1b41ca6..e88507e 100644 (file)
@@ -104,7 +104,7 @@ struct Q_QML_EXPORT QObjectWrapper : public Object
 
     QObject *object() const { return d()->object.data(); }
 
-    ReturnedValue getQmlProperty(QQmlContextData *qmlContext, String *name, RevisionMode revisionMode, bool *hasProperty = 0, bool includeImports = false);
+    ReturnedValue getQmlProperty(QQmlContextData *qmlContext, String *name, RevisionMode revisionMode, bool *hasProperty = 0, bool includeImports = false) const;
     static ReturnedValue getQmlProperty(ExecutionEngine *engine, QQmlContextData *qmlContext, QObject *object, String *name, RevisionMode revisionMode, bool *hasProperty = 0);
 
     static bool setQmlProperty(ExecutionEngine *engine, QQmlContextData *qmlContext, QObject *object, String *name, RevisionMode revisionMode, const Value &value);
@@ -127,7 +127,7 @@ private:
 
     QQmlPropertyData *findProperty(ExecutionEngine *engine, QQmlContextData *qmlContext, String *name, RevisionMode revisionMode, QQmlPropertyData *local) const;
 
-    static ReturnedValue get(Managed *m, String *name, bool *hasProperty);
+    static ReturnedValue get(const Managed *m, String *name, bool *hasProperty);
     static void put(Managed *m, String *name, const Value &value);
     static PropertyAttributes query(const Managed *, String *name);
     static void advanceIterator(Managed *m, ObjectIterator *it, Heap::String **name, uint *index, Property *p, PropertyAttributes *attributes);
@@ -148,7 +148,7 @@ struct Q_QML_EXPORT QObjectMethod : public QV4::FunctionObject
     enum { DestroyMethod = -1, ToStringMethod = -2 };
 
     static ReturnedValue create(QV4::ExecutionContext *scope, QObject *object, int index, const Value &qmlGlobal = Primitive::undefinedValue());
-    static ReturnedValue create(QV4::ExecutionContext *scope, QQmlValueTypeWrapper *valueType, int index, const Value &qmlGlobal = Primitive::undefinedValue());
+    static ReturnedValue create(QV4::ExecutionContext *scope, const QQmlValueTypeWrapper *valueType, int index, const Value &qmlGlobal = Primitive::undefinedValue());
 
     int methodIndex() const { return d()->index; }
     QObject *object() const { return d()->object.data(); }
index f2cd5da..c948cbd 100644 (file)
@@ -231,7 +231,7 @@ public:
         defineAccessorProperty(QStringLiteral("length"), method_get_length, method_set_length);
     }
 
-    QV4::ReturnedValue containerGetIndexed(uint index, bool *hasProperty)
+    QV4::ReturnedValue containerGetIndexed(uint index, bool *hasProperty) const
     {
         /* Qt containers have int (rather than uint) allowable indexes. */
         if (index > INT_MAX) {
@@ -526,8 +526,8 @@ public:
         QMetaObject::metacall(d()->object, QMetaObject::WriteProperty, d()->propertyIndex, a);
     }
 
-    static QV4::ReturnedValue getIndexed(QV4::Managed *that, uint index, bool *hasProperty)
-    { return static_cast<QQmlSequence<Container> *>(that)->containerGetIndexed(index, hasProperty); }
+    static QV4::ReturnedValue getIndexed(const QV4::Managed *that, uint index, bool *hasProperty)
+    { return static_cast<const QQmlSequence<Container> *>(that)->containerGetIndexed(index, hasProperty); }
     static void putIndexed(Managed *that, uint index, const QV4::Value &value)
     { static_cast<QQmlSequence<Container> *>(that)->containerPutIndexed(index, value); }
     static QV4::PropertyAttributes queryIndexed(const QV4::Managed *that, uint index)
@@ -700,7 +700,7 @@ QVariant SequencePrototype::toVariant(const QV4::Value &array, int typeHint, boo
 {
     *succeeded = true;
 
-    if (!array.asArrayObject()) {
+    if (!array.as<ArrayObject>()) {
         *succeeded = false;
         return QVariant();
     }
index 43fe9dd..8ccc6a0 100644 (file)
@@ -172,7 +172,7 @@ void Serialize::serialize(QByteArray &data, const QV4::Value &v, ExecutionEngine
         // XXX TODO: Implement passing function objects between the main and
         // worker scripts
         push(data, valueheader(WorkerUndefined));
-    } else if (QV4::ArrayObject *array = v.asArrayObject()) {
+    } else if (const QV4::ArrayObject *array = v.as<ArrayObject>()) {
         uint length = array->getLength();
         if (length > 0xFFFFFF) {
             push(data, valueheader(WorkerUndefined));
index 429ec96..65784cb 100644 (file)
@@ -347,10 +347,10 @@ void TypedArray::markObjects(Heap::Base *that, ExecutionEngine *e)
     Object::markObjects(that, e);
 }
 
-ReturnedValue TypedArray::getIndexed(Managed *m, uint index, bool *hasProperty)
+ReturnedValue TypedArray::getIndexed(const Managed *m, uint index, bool *hasProperty)
 {
-    Scope scope(static_cast<Object *>(m)->engine());
-    Scoped<TypedArray> a(scope, static_cast<TypedArray *>(m));
+    Scope scope(static_cast<const Object *>(m)->engine());
+    Scoped<TypedArray> a(scope, static_cast<const TypedArray *>(m));
 
     uint bytesPerElement = a->d()->type->bytesPerElement;
     uint byteOffset = a->d()->byteOffset + index * bytesPerElement;
index afd1bb9..5bfcc50 100644 (file)
@@ -113,7 +113,7 @@ struct Q_QML_PRIVATE_EXPORT TypedArray : Object
     }
 
     static void markObjects(Heap::Base *that, ExecutionEngine *e);
-    static ReturnedValue getIndexed(Managed *m, uint index, bool *hasProperty);
+    static ReturnedValue getIndexed(const Managed *m, uint index, bool *hasProperty);
     static void putIndexed(Managed *m, uint index, const Value &value);
 };
 
index 1cb93f9..e8973bc 100644 (file)
@@ -263,16 +263,6 @@ inline DateObject *Value::asDateObject() const
     return isObject() ? managed()->asDateObject() : 0;
 }
 
-inline ArrayObject *Value::asArrayObject() const
-{
-    return isObject() ? managed()->asArrayObject() : 0;
-}
-
-inline ErrorObject *Value::asErrorObject() const
-{
-    return isObject() ? managed()->asErrorObject() : 0;
-}
-
 template<>
 inline const String *Value::as() const {
     return asString();
index 20d7404..ece0e52 100644 (file)
@@ -311,8 +311,6 @@ struct Q_QML_PRIVATE_EXPORT Value
     inline NumberObject *asNumberObject() const;
     inline StringObject *asStringObject() const;
     inline DateObject *asDateObject() const;
-    inline ArrayObject *asArrayObject() const;
-    inline ErrorObject *asErrorObject() const;
 
     template <typename T>
     const T *as() const {
index a36b742..3253d48 100644 (file)
@@ -1216,7 +1216,7 @@ void QQmlComponent::createObject(QQmlV4Function *args)
 
     if (args->length() >= 2) {
         QV4::ScopedValue v(scope, (*args)[1]);
-        if (!v->asObject() || v->asArrayObject()) {
+        if (!v->asObject() || v->as<QV4::ArrayObject>()) {
             qmlInfo(this) << tr("createObject: value is not an object");
             args->setReturnValue(QV4::Encode::null());
             return;
@@ -1342,7 +1342,7 @@ void QQmlComponent::incubateObject(QQmlV4Function *args)
     if (args->length() >= 2) {
         QV4::ScopedValue v(scope, (*args)[1]);
         if (v->isNull()) {
-        } else if (!v->asObject() || v->asArrayObject()) {
+        } else if (!v->asObject() || v->as<QV4::ArrayObject>()) {
             qmlInfo(this) << tr("createObject: value is not an object");
             args->setReturnValue(QV4::Encode::null());
             return;
index 2498e5a..7bce556 100644 (file)
@@ -123,10 +123,10 @@ void QmlContextWrapper::takeContextOwnership(const Value &qmlglobal)
 }
 
 
-ReturnedValue QmlContextWrapper::get(Managed *m, String *name, bool *hasProperty)
+ReturnedValue QmlContextWrapper::get(const Managed *m, String *name, bool *hasProperty)
 {
     Q_ASSERT(m->as<QmlContextWrapper>());
-    QmlContextWrapper *resource = static_cast<QmlContextWrapper *>(m);
+    const QmlContextWrapper *resource = static_cast<const QmlContextWrapper *>(m);
     QV4::ExecutionEngine *v4 = resource->engine();
     QV4::Scope scope(v4);
 
@@ -427,10 +427,10 @@ Heap::QQmlIdObjectsArray::QQmlIdObjectsArray(ExecutionEngine *engine, QV4::QmlCo
 {
 }
 
-ReturnedValue QQmlIdObjectsArray::getIndexed(Managed *m, uint index, bool *hasProperty)
+ReturnedValue QQmlIdObjectsArray::getIndexed(const Managed *m, uint index, bool *hasProperty)
 {
-    Scope scope(static_cast<QV4::QQmlIdObjectsArray*>(m)->engine());
-    Scoped<QQmlIdObjectsArray> This(scope, static_cast<QV4::QQmlIdObjectsArray*>(m));
+    Scope scope(static_cast<const QV4::QQmlIdObjectsArray*>(m)->engine());
+    Scoped<QQmlIdObjectsArray> This(scope, static_cast<const QV4::QQmlIdObjectsArray*>(m));
     Scoped<QmlContextWrapper> contextWrapper(scope, This->d()->contextWrapper);
     QQmlContextData *context = contextWrapper->getContext();
     if (!context) {
index 52d8677..7aad092 100644 (file)
@@ -103,7 +103,7 @@ struct Q_QML_EXPORT QmlContextWrapper : Object
 
     void setReadOnly(bool b) { d()->readOnly = b; }
 
-    static ReturnedValue get(Managed *m, String *name, bool *hasProperty);
+    static ReturnedValue get(const Managed *m, String *name, bool *hasProperty);
     static void put(Managed *m, String *name, const Value &value);
     static void markObjects(Heap::Base *m, ExecutionEngine *engine);
 
@@ -118,7 +118,7 @@ struct QQmlIdObjectsArray : public Object
 {
     V4_OBJECT2(QQmlIdObjectsArray, Object)
 
-    static ReturnedValue getIndexed(Managed *m, uint index, bool *hasProperty);
+    static ReturnedValue getIndexed(const Managed *m, uint index, bool *hasProperty);
     static void markObjects(Heap::Base *that, ExecutionEngine *engine);
 
 };
index bcb1e72..32a5b36 100644 (file)
@@ -92,10 +92,10 @@ QVariant QmlListWrapper::toVariant() const
 }
 
 
-ReturnedValue QmlListWrapper::get(Managed *m, String *name, bool *hasProperty)
+ReturnedValue QmlListWrapper::get(const Managed *m, String *name, bool *hasProperty)
 {
     Q_ASSERT(m->as<QmlListWrapper>());
-    QmlListWrapper *w = static_cast<QmlListWrapper *>(m);
+    const QmlListWrapper *w = static_cast<const QmlListWrapper *>(m);
     QV4::ExecutionEngine *v4 = w->engine();
 
     if (name->equals(v4->id_length) && !w->d()->object.isNull()) {
@@ -110,12 +110,12 @@ ReturnedValue QmlListWrapper::get(Managed *m, String *name, bool *hasProperty)
     return Object::get(m, name, hasProperty);
 }
 
-ReturnedValue QmlListWrapper::getIndexed(Managed *m, uint index, bool *hasProperty)
+ReturnedValue QmlListWrapper::getIndexed(const Managed *m, uint index, bool *hasProperty)
 {
     Q_UNUSED(hasProperty);
 
     Q_ASSERT(m->as<QmlListWrapper>());
-    QmlListWrapper *w = static_cast<QmlListWrapper *>(m);
+    const QmlListWrapper *w = static_cast<const QmlListWrapper *>(m);
     QV4::ExecutionEngine *v4 = w->engine();
 
     quint32 count = w->d()->property.count ? w->d()->property.count(&w->d()->property) : 0;
index 3590bcb..b2f7ec1 100644 (file)
@@ -81,8 +81,8 @@ struct Q_QML_EXPORT QmlListWrapper : Object
 
     QVariant toVariant() const;
 
-    static ReturnedValue get(Managed *m, String *name, bool *hasProperty);
-    static ReturnedValue getIndexed(Managed *m, uint index, bool *hasProperty);
+    static ReturnedValue get(const Managed *m, String *name, bool *hasProperty);
+    static ReturnedValue getIndexed(const Managed *m, uint index, bool *hasProperty);
     static void put(Managed *m, String *name, const Value &value);
     static void advanceIterator(Managed *m, ObjectIterator *it, Heap::String **name, uint *index, Property *p, PropertyAttributes *attributes);
 };
index 1326613..3b8a179 100644 (file)
@@ -121,14 +121,14 @@ ReturnedValue QmlTypeWrapper::create(QV4::ExecutionEngine *engine, QObject *o, Q
 }
 
 
-ReturnedValue QmlTypeWrapper::get(Managed *m, String *name, bool *hasProperty)
+ReturnedValue QmlTypeWrapper::get(const Managed *m, String *name, bool *hasProperty)
 {
     Q_ASSERT(m->as<QmlTypeWrapper>());
 
-    QV4::ExecutionEngine *v4 = static_cast<QmlTypeWrapper *>(m)->engine();
+    QV4::ExecutionEngine *v4 = static_cast<const QmlTypeWrapper *>(m)->engine();
     QV4::Scope scope(v4);
 
-    Scoped<QmlTypeWrapper> w(scope, static_cast<QmlTypeWrapper *>(m));
+    Scoped<QmlTypeWrapper> w(scope, static_cast<const QmlTypeWrapper *>(m));
 
     if (hasProperty)
         *hasProperty = true;
index 660d283..fb9906a 100644 (file)
@@ -94,7 +94,7 @@ struct Q_QML_EXPORT QmlTypeWrapper : Object
                                 Heap::QmlTypeWrapper::TypeNameMode = Heap::QmlTypeWrapper::IncludeEnums);
 
 
-    static ReturnedValue get(Managed *m, String *name, bool *hasProperty);
+    static ReturnedValue get(const Managed *m, String *name, bool *hasProperty);
     static void put(Managed *m, String *name, const Value &value);
     static PropertyAttributes query(const Managed *, String *name);
     static bool isEqualTo(Managed *that, Managed *o);
index d3a80f0..92401f2 100644 (file)
@@ -283,14 +283,14 @@ ReturnedValue QQmlValueTypeWrapper::method_toString(CallContext *ctx)
     return Encode(ctx->engine()->newString(result));
 }
 
-ReturnedValue QQmlValueTypeWrapper::get(Managed *m, String *name, bool *hasProperty)
+ReturnedValue QQmlValueTypeWrapper::get(const Managed *m, String *name, bool *hasProperty)
 {
     Q_ASSERT(m->as<QQmlValueTypeWrapper>());
-    QQmlValueTypeWrapper *r = static_cast<QQmlValueTypeWrapper *>(m);
+    const QQmlValueTypeWrapper *r = static_cast<const QQmlValueTypeWrapper *>(m);
     QV4::ExecutionEngine *v4 = r->engine();
 
     // Note: readReferenceValue() can change the reference->type.
-    if (QQmlValueTypeReference *reference = r->as<QQmlValueTypeReference>()) {
+    if (const QQmlValueTypeReference *reference = r->as<QQmlValueTypeReference>()) {
         if (!reference->readReferenceValue())
             return Primitive::undefinedValue().asReturnedValue();
     }
index 0b8c30d..08b3ec7 100644 (file)
@@ -87,7 +87,7 @@ public:
     void toGadget(void *data) const;
     bool isEqual(const QVariant& value);
 
-    static ReturnedValue get(Managed *m, String *name, bool *hasProperty);
+    static ReturnedValue get(const Managed *m, String *name, bool *hasProperty);
     static void put(Managed *m, String *name, const Value &value);
     static bool isEqualTo(Managed *m, Managed *other);
     static PropertyAttributes query(const Managed *, String *name);
index a2c5f09..74577ad 100644 (file)
@@ -222,8 +222,8 @@ public:
     static ReturnedValue create(ExecutionEngine *, NodeImpl *, const QList<NodeImpl *> &);
 
     // JS API
-    static ReturnedValue get(Managed *m, String *name, bool *hasProperty);
-    static ReturnedValue getIndexed(Managed *m, uint index, bool *hasProperty);
+    static ReturnedValue get(const Managed *m, String *name, bool *hasProperty);
+    static ReturnedValue getIndexed(const Managed *m, uint index, bool *hasProperty);
 };
 
 Heap::NamedNodeMap::NamedNodeMap(ExecutionEngine *engine, NodeImpl *data, const QList<NodeImpl *> &list)
@@ -244,8 +244,8 @@ public:
     V4_NEEDS_DESTROY
 
     // JS API
-    static ReturnedValue get(Managed *m, String *name, bool *hasProperty);
-    static ReturnedValue getIndexed(Managed *m, uint index, bool *hasProperty);
+    static ReturnedValue get(const Managed *m, String *name, bool *hasProperty);
+    static ReturnedValue getIndexed(const Managed *m, uint index, bool *hasProperty);
 
     // C++ API
     static ReturnedValue create(ExecutionEngine *, NodeImpl *);
@@ -871,10 +871,10 @@ bool Node::isNull() const
     return d()->d == 0;
 }
 
-ReturnedValue NamedNodeMap::getIndexed(Managed *m, uint index, bool *hasProperty)
+ReturnedValue NamedNodeMap::getIndexed(const Managed *m, uint index, bool *hasProperty)
 {
     Q_ASSERT(m->as<NamedNodeMap>());
-    NamedNodeMap *r = static_cast<NamedNodeMap *>(m);
+    const NamedNodeMap *r = static_cast<const NamedNodeMap *>(m);
     QV4::ExecutionEngine *v4 = r->engine();
 
     if ((int)index < r->d()->list.count()) {
@@ -887,10 +887,10 @@ ReturnedValue NamedNodeMap::getIndexed(Managed *m, uint index, bool *hasProperty
     return Encode::undefined();
 }
 
-ReturnedValue NamedNodeMap::get(Managed *m, String *name, bool *hasProperty)
+ReturnedValue NamedNodeMap::get(const Managed *m, String *name, bool *hasProperty)
 {
     Q_ASSERT(m->as<NamedNodeMap>());
-    NamedNodeMap *r = static_cast<NamedNodeMap *>(m);
+    const NamedNodeMap *r = static_cast<const NamedNodeMap *>(m);
     QV4::ExecutionEngine *v4 = r->engine();
 
     name->makeIdentifier(v4);
@@ -916,10 +916,10 @@ ReturnedValue NamedNodeMap::create(ExecutionEngine *v4, NodeImpl *data, const QL
     return (v4->memoryManager->alloc<NamedNodeMap>(v4, data, list))->asReturnedValue();
 }
 
-ReturnedValue NodeList::getIndexed(Managed *m, uint index, bool *hasProperty)
+ReturnedValue NodeList::getIndexed(const Managed *m, uint index, bool *hasProperty)
 {
     Q_ASSERT(m->as<NodeList>());
-    NodeList *r = static_cast<NodeList *>(m);
+    const NodeList *r = static_cast<const NodeList *>(m);
     QV4::ExecutionEngine *v4 = r->engine();
 
     if ((int)index < r->d()->d->children.count()) {
@@ -932,10 +932,10 @@ ReturnedValue NodeList::getIndexed(Managed *m, uint index, bool *hasProperty)
     return Encode::undefined();
 }
 
-ReturnedValue NodeList::get(Managed *m, String *name, bool *hasProperty)
+ReturnedValue NodeList::get(const Managed *m, String *name, bool *hasProperty)
 {
     Q_ASSERT(m->as<NodeList>());
-    NodeList *r = static_cast<NodeList *>(m);
+    const NodeList *r = static_cast<const NodeList *>(m);
     QV4::ExecutionEngine *v4 = r->engine();
 
     name->makeIdentifier(v4);
index 0522e4c..f4d9af7 100644 (file)
@@ -1372,7 +1372,7 @@ static QV4::ReturnedValue writeToConsole(ConsoleLogTypes logType, CallContext *c
         if (i != 0)
             result.append(QLatin1Char(' '));
 
-        if (ctx->args()[i].asArrayObject())
+        if (ctx->args()[i].as<ArrayObject>())
             result.append(QStringLiteral("[") + ctx->args()[i].toQStringNoThrow() + QStringLiteral("]"));
         else
             result.append(ctx->args()[i].toQStringNoThrow());
index 201fd45..bb6d1a7 100644 (file)
@@ -2579,7 +2579,7 @@ void QQmlDelegateModelGroup::insert(QQmlV4Function *args)
         groups |= model->m_cacheMetaType->parseGroups(val);
     }
 
-    if (v->asArrayObject()) {
+    if (v->as<QV4::ArrayObject>()) {
         return;
     } else if (v->asObject()) {
         model->insert(before, v, groups);
@@ -3286,12 +3286,12 @@ public:
     quint32 count() const { return d()->changes.count(); }
     const QQmlChangeSet::Change &at(int index) const { return d()->changes.at(index); }
 
-    static QV4::ReturnedValue getIndexed(QV4::Managed *m, uint index, bool *hasProperty)
+    static QV4::ReturnedValue getIndexed(const QV4::Managed *m, uint index, bool *hasProperty)
     {
         Q_ASSERT(m->as<QQmlDelegateModelGroupChangeArray>());
-        QV4::ExecutionEngine *v4 = static_cast<QQmlDelegateModelGroupChangeArray *>(m)->engine();
+        QV4::ExecutionEngine *v4 = static_cast<const QQmlDelegateModelGroupChangeArray *>(m)->engine();
         QV4::Scope scope(v4);
-        QV4::Scoped<QQmlDelegateModelGroupChangeArray> array(scope, static_cast<QQmlDelegateModelGroupChangeArray *>(m));
+        QV4::Scoped<QQmlDelegateModelGroupChangeArray> array(scope, static_cast<const QQmlDelegateModelGroupChangeArray *>(m));
 
         if (index >= array->count()) {
             if (hasProperty)
@@ -3311,10 +3311,10 @@ public:
         return object.asReturnedValue();
     }
 
-    static QV4::ReturnedValue get(QV4::Managed *m, QV4::String *name, bool *hasProperty)
+    static QV4::ReturnedValue get(const QV4::Managed *m, QV4::String *name, bool *hasProperty)
     {
         Q_ASSERT(m->as<QQmlDelegateModelGroupChangeArray>());
-        QQmlDelegateModelGroupChangeArray *array = static_cast<QQmlDelegateModelGroupChangeArray *>(m);
+        const QQmlDelegateModelGroupChangeArray *array = static_cast<const QQmlDelegateModelGroupChangeArray *>(m);
 
         if (name->equals(array->engine()->id_length)) {
             if (hasProperty)
index ed97690..a82e7d5 100644 (file)
@@ -427,7 +427,7 @@ void ListModel::set(int elementIndex, QV4::Object *object, QVector<int> *roles)
         } else if (propertyValue->isNumber()) {
             const ListLayout::Role &r = m_layout->getRoleOrCreate(propertyName, ListLayout::Role::Number);
             roleIndex = e->setDoubleProperty(r, propertyValue->asDouble());
-        } else if (QV4::ArrayObject *a = propertyValue->asArrayObject()) {
+        } else if (QV4::ArrayObject *a = propertyValue->as<QV4::ArrayObject>()) {
             const ListLayout::Role &r = m_layout->getRoleOrCreate(propertyName, ListLayout::Role::List);
             ListModel *subModel = new ListModel(r.subLayout, 0, -1);
 
@@ -502,7 +502,7 @@ void ListModel::set(int elementIndex, QV4::Object *object)
             if (r.type == ListLayout::Role::Number) {
                 e->setDoublePropertyFast(r, propertyValue->asDouble());
             }
-        } else if (QV4::ArrayObject *a = propertyValue->asArrayObject()) {
+        } else if (QV4::ArrayObject *a = propertyValue->as<QV4::ArrayObject>()) {
             const ListLayout::Role &r = m_layout->getRoleOrCreate(propertyName, ListLayout::Role::List);
             if (r.type == ListLayout::Role::List) {
                 ListModel *subModel = new ListModel(r.subLayout, 0, -1);
@@ -1169,7 +1169,7 @@ int ListElement::setJsProperty(const ListLayout::Role &role, const QV4::Value &d
         roleIndex = setStringProperty(role, qstr);
     } else if (d.isNumber()) {
         roleIndex = setDoubleProperty(role, d.asDouble());
-    } else if (d.asArrayObject()) {
+    } else if (d.as<QV4::ArrayObject>()) {
         QV4::ScopedArrayObject a(scope, d);
         if (role.type == ListLayout::Role::List) {
             QV4::Scope scope(a->engine());
index 3f91ce8..9a8e2c9 100644 (file)
@@ -479,7 +479,7 @@ void QuickTestResult::stringify(QQmlV4Function *args)
     //Check for Object Type
     if (value->isObject()
         && !value->asFunctionObject()
-        && !value->asArrayObject()) {
+        && !value->as<QV4::ArrayObject>()) {
         QVariant v = scope.engine->toVariant(value, QMetaType::UnknownType);
         if (v.isValid()) {
             switch (v.type()) {
@@ -500,7 +500,7 @@ void QuickTestResult::stringify(QQmlV4Function *args)
 
     if (result.isEmpty()) {
         QString tmp = value->toQStringNoThrow();
-        if (value->asArrayObject())
+        if (value->as<QV4::ArrayObject>())
             result.append(QString::fromLatin1("[%1]").arg(tmp));
         else
             result.append(tmp);
index 4aa3b1c..724acc6 100644 (file)
@@ -884,7 +884,7 @@ struct QQuickJSContext2DPixelData : public QV4::Object
     V4_OBJECT2(QQuickJSContext2DPixelData, QV4::Object)
     V4_NEEDS_DESTROY
 
-    static QV4::ReturnedValue getIndexed(QV4::Managed *m, uint index, bool *hasProperty);
+    static QV4::ReturnedValue getIndexed(const QV4::Managed *m, uint index, bool *hasProperty);
     static void putIndexed(QV4::Managed *m, uint index, const QV4::Value &value);
 
     static QV4::ReturnedValue proto_get_length(QV4::CallContext *ctx);
@@ -3089,12 +3089,12 @@ QV4::ReturnedValue QQuickJSContext2DPixelData::proto_get_length(QV4::CallContext
     return QV4::Encode(r->d()->image.width() * r->d()->image.height() * 4);
 }
 
-QV4::ReturnedValue QQuickJSContext2DPixelData::getIndexed(QV4::Managed *m, uint index, bool *hasProperty)
+QV4::ReturnedValue QQuickJSContext2DPixelData::getIndexed(const QV4::Managed *m, uint index, bool *hasProperty)
 {
     Q_ASSERT(m->as<QQuickJSContext2DPixelData>());
-    QV4::ExecutionEngine *v4 = static_cast<QQuickJSContext2DPixelData *>(m)->engine();
+    QV4::ExecutionEngine *v4 = static_cast<const QQuickJSContext2DPixelData *>(m)->engine();
     QV4::Scope scope(v4);
-    QV4::Scoped<QQuickJSContext2DPixelData> r(scope, static_cast<QQuickJSContext2DPixelData *>(m));
+    QV4::Scoped<QQuickJSContext2DPixelData> r(scope, static_cast<const QQuickJSContext2DPixelData *>(m));
 
     if (index < static_cast<quint32>(r->d()->image.width() * r->d()->image.height() * 4)) {
         if (hasProperty)
index 3d28bf0..c1e3fbb 100644 (file)
@@ -942,7 +942,7 @@ QV4::ReturnedValue QQuickLoaderPrivate::extractInitialPropertyValues(QQmlV4Funct
     QV4::ScopedValue valuemap(scope, QV4::Primitive::undefinedValue());
     if (args->length() >= 2) {
         QV4::ScopedValue v(scope, (*args)[1]);
-        if (!v->isObject() || v->asArrayObject()) {
+        if (!v->isObject() || v->as<QV4::ArrayObject>()) {
             *error = true;
             qmlInfo(loader) << QQuickLoader::tr("setSource: value is not an object");
         } else {
index db9d1b9..3667374 100644 (file)
@@ -113,7 +113,7 @@ static void showException(QV4::ExecutionContext *ctx, const QV4::Value &exceptio
 {
     QV4::Scope scope(ctx);
     QV4::ScopedValue ex(scope, exception);
-    QV4::ErrorObject *e = ex->asErrorObject();
+    QV4::ErrorObject *e = ex->as<QV4::ErrorObject>();
     if (!e) {
         std::cerr << "Uncaught exception: " << qPrintable(ex->toQString()) << std::endl;
     } else {