diff options
author | Michael Brasser <michael.brasser@nokia.com> | 2009-11-05 22:51:39 (GMT) |
---|---|---|
committer | Michael Brasser <michael.brasser@nokia.com> | 2009-11-05 22:51:39 (GMT) |
commit | 4266b0616bb5d67244173dbe4d9d417dbf4d302f (patch) | |
tree | 4d8320dfafe09657fb0e475bd6b36a50c4d79105 /src/declarative/qml | |
parent | ec543f79c7d036961eb6cdcd956b3e8ca28b8e54 (diff) | |
parent | 96f3abd4df881789bd2677100a2417c96fd2edb4 (diff) | |
download | Qt-4266b0616bb5d67244173dbe4d9d417dbf4d302f.zip Qt-4266b0616bb5d67244173dbe4d9d417dbf4d302f.tar.gz Qt-4266b0616bb5d67244173dbe4d9d417dbf4d302f.tar.bz2 |
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Diffstat (limited to 'src/declarative/qml')
-rw-r--r-- | src/declarative/qml/qmlengine.cpp | 5 | ||||
-rw-r--r-- | src/declarative/qml/qmlmetatype.cpp | 45 | ||||
-rw-r--r-- | src/declarative/qml/qmlmetatype.h | 3 | ||||
-rw-r--r-- | src/declarative/qml/qmlprivate.h | 3 | ||||
-rw-r--r-- | src/declarative/qml/qmlvaluetype_p.h | 20 |
5 files changed, 21 insertions, 55 deletions
diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp index 3df04b2..e46205d 100644 --- a/src/declarative/qml/qmlengine.cpp +++ b/src/declarative/qml/qmlengine.cpp @@ -626,6 +626,11 @@ QScriptValue QmlEnginePrivate::createQmlObject(QScriptContext *ctxt, QScriptEngi url = QUrl(ctxt->argument(2).toString()); QObject *parentArg = activeEnginePriv->objectClass->toQObject(ctxt->argument(1)); QmlContext *qmlCtxt = qmlContext(parentArg); + if(!parentArg || !qmlCtxt){ + //TODO: Could use a qmlInfo() like function for script functions + qWarning() << "createQmlObject called with invalid parent object"; + return engine->nullValue(); + } if (url.isEmpty()) { url = qmlCtxt->resolvedUrl(QUrl(QLatin1String("<Unknown File>"))); } else { diff --git a/src/declarative/qml/qmlmetatype.cpp b/src/declarative/qml/qmlmetatype.cpp index 6ecaa9f..5fb2f50 100644 --- a/src/declarative/qml/qmlmetatype.cpp +++ b/src/declarative/qml/qmlmetatype.cpp @@ -134,7 +134,6 @@ public: QmlCustomParser *m_customParser; mutable volatile bool m_isSetup:1; mutable QList<QmlProxyMetaObject::ProxyData> m_metaObjects; - mutable QByteArray m_hash; }; QmlTypePrivate::QmlTypePrivate() @@ -259,27 +258,6 @@ void QmlTypePrivate::init() const m_metaObjects.at(ii).metaObject->methodOffset(); } - // Calculate hash - QByteArray hashData; - - const QMetaObject *myMetaObject = m_metaObjects.isEmpty()?m_baseMetaObject:m_metaObjects.first().metaObject; - - for (int ii = 0; ii < myMetaObject->propertyCount(); ++ii) { - QMetaProperty prop = myMetaObject->property(ii); - hashData.append(prop.type()); - hashData.append("|"); - hashData.append(prop.name()); - hashData.append("|"); - } - - for (int ii = 0; ii < myMetaObject->methodCount(); ++ii) { - QMetaMethod method = myMetaObject->method(ii); - hashData.append(method.signature()); - hashData.append("|"); - } - - m_hash = QCryptographicHash::hash(hashData, QCryptographicHash::Md5); - m_isSetup = true; lock.unlock(); } @@ -297,13 +275,6 @@ QByteArray QmlType::qmlTypeName() const return d->m_name; } -QByteArray QmlType::hash() const -{ - d->init(); - - return d->m_hash; -} - QObject *QmlType::create() const { d->init(); @@ -804,17 +775,6 @@ const char *QmlMetaType::interfaceIId(int userType) return 0; } -bool QmlMetaType::isObject(const QMetaObject *mo) -{ - // ### Huh? - while(mo) { - if (mo == &QObject::staticMetaObject) - return true; - mo = mo->superClass(); - } - return false; -} - bool QmlMetaType::isQmlList(int userType) { QReadLocker lock(metaTypeDataLock()); @@ -851,6 +811,9 @@ int QmlMetaType::listCount(const QVariant &v) QVariant QmlMetaType::listAt(const QVariant &v, int idx) { + if (idx < 0) + return QVariant(); + int userType = v.userType(); QReadLocker lock(metaTypeDataLock()); @@ -861,7 +824,7 @@ QVariant QmlMetaType::listAt(const QVariant &v, int idx) if (type && type->qListTypeId() == userType) return type->listAt(v, idx); else - return 0; + return QVariant(); } /*! diff --git a/src/declarative/qml/qmlmetatype.h b/src/declarative/qml/qmlmetatype.h index e90c367..1f493f8 100644 --- a/src/declarative/qml/qmlmetatype.h +++ b/src/declarative/qml/qmlmetatype.h @@ -97,7 +97,6 @@ public: static bool isInterface(int); static const char *interfaceIId(int); static bool isObject(int); - static bool isObject(const QMetaObject *); static bool isList(int); static bool isList(const QVariant &); static bool isQmlList(int); @@ -121,8 +120,6 @@ public: int minorVersion() const; bool availableInVersion(int vmajor, int vminor) const; - QByteArray hash() const; - QObject *create() const; QmlCustomParser *customParser() const; diff --git a/src/declarative/qml/qmlprivate.h b/src/declarative/qml/qmlprivate.h index e5b1060..0eec43c 100644 --- a/src/declarative/qml/qmlprivate.h +++ b/src/declarative/qml/qmlprivate.h @@ -283,7 +283,8 @@ int QmlPrivate::list_op(QmlPrivate::ListOp op, int val, } break; case QmlPrivate::Value: - *((QVariant *)*out) = QVariant::fromValue(list->at(val)); + if (list->count() <= val) *((QVariant *)*out) = QVariant(); + else *((QVariant *)*out) = QVariant::fromValue(list->at(val)); break; } return 0; diff --git a/src/declarative/qml/qmlvaluetype_p.h b/src/declarative/qml/qmlvaluetype_p.h index 0af3813..e7566f9 100644 --- a/src/declarative/qml/qmlvaluetype_p.h +++ b/src/declarative/qml/qmlvaluetype_p.h @@ -62,7 +62,7 @@ QT_BEGIN_NAMESPACE -class QmlValueType : public QObject +class Q_AUTOTEST_EXPORT QmlValueType : public QObject { Q_OBJECT public: @@ -73,7 +73,7 @@ public: virtual void setValue(QVariant) = 0; }; -class QmlValueTypeFactory +class Q_AUTOTEST_EXPORT QmlValueTypeFactory { public: QmlValueTypeFactory(); @@ -84,7 +84,7 @@ public: QmlValueType *operator[](int idx) const { return valueTypes[idx]; } }; -class QmlPointFValueType : public QmlValueType +class Q_AUTOTEST_EXPORT QmlPointFValueType : public QmlValueType { Q_PROPERTY(qreal x READ x WRITE setX) Q_PROPERTY(qreal y READ y WRITE setY) @@ -106,7 +106,7 @@ private: QPointF point; }; -class QmlPointValueType : public QmlValueType +class Q_AUTOTEST_EXPORT QmlPointValueType : public QmlValueType { Q_PROPERTY(int x READ x WRITE setX) Q_PROPERTY(int y READ y WRITE setY) @@ -128,7 +128,7 @@ private: QPoint point; }; -class QmlSizeFValueType : public QmlValueType +class Q_AUTOTEST_EXPORT QmlSizeFValueType : public QmlValueType { Q_PROPERTY(qreal width READ width WRITE setWidth) Q_PROPERTY(qreal height READ height WRITE setHeight) @@ -150,7 +150,7 @@ private: QSizeF size; }; -class QmlSizeValueType : public QmlValueType +class Q_AUTOTEST_EXPORT QmlSizeValueType : public QmlValueType { Q_PROPERTY(int width READ width WRITE setWidth) Q_PROPERTY(int height READ height WRITE setHeight) @@ -172,7 +172,7 @@ private: QSize size; }; -class QmlRectFValueType : public QmlValueType +class Q_AUTOTEST_EXPORT QmlRectFValueType : public QmlValueType { Q_PROPERTY(qreal x READ x WRITE setX) Q_PROPERTY(qreal y READ y WRITE setY) @@ -201,7 +201,7 @@ private: QRectF rect; }; -class QmlRectValueType : public QmlValueType +class Q_AUTOTEST_EXPORT QmlRectValueType : public QmlValueType { Q_PROPERTY(int x READ x WRITE setX) Q_PROPERTY(int y READ y WRITE setY) @@ -230,7 +230,7 @@ private: QRect rect; }; -class QmlVector3DValueType : public QmlValueType +class Q_AUTOTEST_EXPORT QmlVector3DValueType : public QmlValueType { Q_PROPERTY(qreal x READ x WRITE setX) Q_PROPERTY(qreal y READ y WRITE setY) @@ -255,7 +255,7 @@ private: QVector3D vector; }; -class QmlFontValueType : public QmlValueType +class Q_AUTOTEST_EXPORT QmlFontValueType : public QmlValueType { Q_OBJECT Q_ENUMS(FontWeight) |