aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@digia.com>2014-06-13 16:04:39 +0200
committerSimon Hausmann <simon.hausmann@digia.com>2014-07-22 13:49:20 +0200
commitda9d5016613d04f002c6433e2b3083143fec34cb (patch)
treedb73090d9a3c79c2cf777aecc35612faa9797194 /src/qml/qml
parentb393c405b7568e80628bc99501a9c53bbd0e678d (diff)
Fix Managed::as<>() method
The as<> casting method was not doing the right thing in 100% of the cases. It only checked if the object in question was exactly of the type being asked for. It however didn't check if the object was derived from the type. This commit fixes this by adding a parent chain to the vtables, that is then being used to check this safely at runtime. Change-Id: I9e0b13adbda668aee8c7451e2bb71cd6d4e316d9 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/qml')
-rw-r--r--src/qml/qml/qqmlcomponent.cpp2
-rw-r--r--src/qml/qml/qqmlcontextwrapper_p.h4
-rw-r--r--src/qml/qml/qqmllistwrapper_p.h2
-rw-r--r--src/qml/qml/qqmllocale_p.h2
-rw-r--r--src/qml/qml/qqmltypewrapper_p.h2
-rw-r--r--src/qml/qml/qqmlvaluetypewrapper.cpp4
-rw-r--r--src/qml/qml/qqmlvaluetypewrapper_p.h2
-rw-r--r--src/qml/qml/qqmlxmlhttprequest.cpp12
-rw-r--r--src/qml/qml/v8/qqmlbuiltinfunctions_p.h4
9 files changed, 17 insertions, 17 deletions
diff --git a/src/qml/qml/qqmlcomponent.cpp b/src/qml/qml/qqmlcomponent.cpp
index 3cf39bd494..a6a41ae365 100644
--- a/src/qml/qml/qqmlcomponent.cpp
+++ b/src/qml/qml/qqmlcomponent.cpp
@@ -1094,7 +1094,7 @@ struct QmlIncubatorObject : public QV4::Object
QV4::Value statusChanged;
} __data;
- V4_OBJECT
+ V4_OBJECT(QV4::Object)
static QV4::ReturnedValue method_get_statusChanged(QV4::CallContext *ctx);
static QV4::ReturnedValue method_set_statusChanged(QV4::CallContext *ctx);
diff --git a/src/qml/qml/qqmlcontextwrapper_p.h b/src/qml/qml/qqmlcontextwrapper_p.h
index a2cb0960d4..73747cadfc 100644
--- a/src/qml/qml/qqmlcontextwrapper_p.h
+++ b/src/qml/qml/qqmlcontextwrapper_p.h
@@ -94,7 +94,7 @@ struct Q_QML_EXPORT QmlContextWrapper : Object
QQmlIdObjectsArray *idObjectsWrapper;
} __data;
- V4_OBJECT
+ V4_OBJECT(Object)
static ReturnedValue qmlScope(QV8Engine *e, QQmlContextData *ctxt, QObject *scope);
static ReturnedValue urlScope(QV8Engine *e, const QUrl &);
@@ -130,7 +130,7 @@ struct QQmlIdObjectsArray : public Object
QmlContextWrapper *contextWrapper;
} __data;
- V4_OBJECT
+ V4_OBJECT(Object)
static ReturnedValue getIndexed(Managed *m, uint index, bool *hasProperty);
static void markObjects(Managed *that, ExecutionEngine *engine);
diff --git a/src/qml/qml/qqmllistwrapper_p.h b/src/qml/qml/qqmllistwrapper_p.h
index 670321bcd7..70f686b73c 100644
--- a/src/qml/qml/qqmllistwrapper_p.h
+++ b/src/qml/qml/qqmllistwrapper_p.h
@@ -84,7 +84,7 @@ struct Q_QML_EXPORT QmlListWrapper : Object
int propertyType;
} __data;
- V4_OBJECT
+ V4_OBJECT(Object)
static ReturnedValue create(QV8Engine *v8, QObject *object, int propId, int propType);
static ReturnedValue create(QV8Engine *v8, const QQmlListProperty<QObject> &prop, int propType);
diff --git a/src/qml/qml/qqmllocale_p.h b/src/qml/qml/qqmllocale_p.h
index d5812ef78a..dcf4a349c4 100644
--- a/src/qml/qml/qqmllocale_p.h
+++ b/src/qml/qml/qqmllocale_p.h
@@ -143,7 +143,7 @@ struct QQmlLocaleData : public QV4::Object
QLocale locale;
} __data;
- V4_OBJECT
+ V4_OBJECT(Object)
static QLocale *getThisLocale(QV4::CallContext *ctx) {
QQmlLocaleData *thisObject = ctx->d()->callData->thisObject.asObject()->as<QQmlLocaleData>();
diff --git a/src/qml/qml/qqmltypewrapper_p.h b/src/qml/qml/qqmltypewrapper_p.h
index a54fe99de1..effebf8806 100644
--- a/src/qml/qml/qqmltypewrapper_p.h
+++ b/src/qml/qml/qqmltypewrapper_p.h
@@ -91,7 +91,7 @@ struct Q_QML_EXPORT QmlTypeWrapper : Object
const void *importNamespace;
} __data;
- V4_OBJECT
+ V4_OBJECT(Object)
private:
public:
diff --git a/src/qml/qml/qqmlvaluetypewrapper.cpp b/src/qml/qml/qqmlvaluetypewrapper.cpp
index 52b45bd1bb..f228d96603 100644
--- a/src/qml/qml/qqmlvaluetypewrapper.cpp
+++ b/src/qml/qml/qqmlvaluetypewrapper.cpp
@@ -72,7 +72,7 @@ struct QmlValueTypeReference : public QmlValueTypeWrapper
QPointer<QObject> object;
int property;
} __data;
- V4_OBJECT
+ V4_OBJECT(QmlValueTypeWrapper)
};
DEFINE_OBJECT_VTABLE(QmlValueTypeReference);
@@ -88,7 +88,7 @@ struct QmlValueTypeCopy : public QmlValueTypeWrapper
{
QVariant value;
} __data;
- V4_OBJECT
+ V4_OBJECT(QmlValueTypeWrapper)
};
DEFINE_OBJECT_VTABLE(QmlValueTypeCopy);
diff --git a/src/qml/qml/qqmlvaluetypewrapper_p.h b/src/qml/qml/qqmlvaluetypewrapper_p.h
index 22fe628ab5..7647c0c8cc 100644
--- a/src/qml/qml/qqmlvaluetypewrapper_p.h
+++ b/src/qml/qml/qqmlvaluetypewrapper_p.h
@@ -81,7 +81,7 @@ struct Q_QML_EXPORT QmlValueTypeWrapper : Object
mutable QQmlValueType *type;
} __data;
- V4_OBJECT
+ V4_OBJECT(Object)
public:
diff --git a/src/qml/qml/qqmlxmlhttprequest.cpp b/src/qml/qml/qqmlxmlhttprequest.cpp
index d864c1f0b0..0ba4eabbca 100644
--- a/src/qml/qml/qqmlxmlhttprequest.cpp
+++ b/src/qml/qml/qqmlxmlhttprequest.cpp
@@ -209,7 +209,7 @@ public:
NodeImpl *d;
} __data;
- V4_OBJECT
+ V4_OBJECT(Object)
// C++ API
static ReturnedValue create(QV8Engine *, NodeImpl *, const QList<NodeImpl *> &);
@@ -247,7 +247,7 @@ public:
NodeImpl *d;
} __data;
- V4_OBJECT
+ V4_OBJECT(Object)
// JS API
static void destroy(Managed *that) {
@@ -288,7 +288,7 @@ public:
o->defineAccessorProperty(QStringLiteral("attributes"), method_get_attributes, 0);
}
};
- V4_OBJECT
+ V4_OBJECT(Object)
static void initClass(ExecutionEngine *engine);
@@ -339,7 +339,7 @@ struct Node : public Object
struct {
NodeImpl *d;
} __data;
- V4_OBJECT
+ V4_OBJECT(Object)
// JS API
@@ -1629,7 +1629,7 @@ struct QQmlXMLHttpRequestWrapper : public Object
QQmlXMLHttpRequest *request;
} __data;
- V4_OBJECT
+ V4_OBJECT(Object)
static void destroy(Managed *that) {
that->as<QQmlXMLHttpRequestWrapper>()->d()->~Data();
@@ -1664,7 +1664,7 @@ struct QQmlXMLHttpRequestCtor : public FunctionObject
Object *proto;
} __data;
- V4_OBJECT
+ V4_OBJECT(FunctionObject)
static void markObjects(Managed *that, ExecutionEngine *e) {
QQmlXMLHttpRequestCtor *c = that->as<QQmlXMLHttpRequestCtor>();
if (c->d()->proto)
diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions_p.h b/src/qml/qml/v8/qqmlbuiltinfunctions_p.h
index 73c3b8da28..b4e680a4a3 100644
--- a/src/qml/qml/v8/qqmlbuiltinfunctions_p.h
+++ b/src/qml/qml/v8/qqmlbuiltinfunctions_p.h
@@ -75,7 +75,7 @@ struct QtObject : Object
QObject *application;
} __data;
- V4_OBJECT
+ V4_OBJECT(Object)
static ReturnedValue method_isQtObject(CallContext *ctx);
@@ -167,7 +167,7 @@ struct QQmlBindingFunction : public QV4::FunctionObject
QQmlSourceLocation bindingLocation;
} __data;
- V4_OBJECT
+ V4_OBJECT(QV4::FunctionObject)
void initBindingLocation(); // from caller stack trace