diff options
Diffstat (limited to 'src/qml/qml/qqmlpropertycache_p.h')
-rw-r--r-- | src/qml/qml/qqmlpropertycache_p.h | 69 |
1 files changed, 47 insertions, 22 deletions
diff --git a/src/qml/qml/qqmlpropertycache_p.h b/src/qml/qml/qqmlpropertycache_p.h index 6f4879baa2..5553fe6b80 100644 --- a/src/qml/qml/qqmlpropertycache_p.h +++ b/src/qml/qml/qqmlpropertycache_p.h @@ -245,12 +245,36 @@ public: _coreIndex = qint16(idx); } - int revision() const { return _revision; } - void setRevision(int rev) + quint8 revision() const { return _revision; } + void setRevision(quint8 rev) { - Q_ASSERT(rev >= std::numeric_limits<qint16>::min()); - Q_ASSERT(rev <= std::numeric_limits<qint16>::max()); - _revision = qint16(rev); + Q_ASSERT(rev <= std::numeric_limits<quint8>::max()); + _revision = quint8(rev); + } + + /* If a property is a C++ type, then we store the minor + * version of this type. + * This is required to resolve property or signal revisions + * if this property is used as a grouped property. + * + * Test.qml + * property TextEdit someTextEdit: TextEdit {} + * + * Test { + * someTextEdit.preeditText: "test" //revision 7 + * someTextEdit.onEditingFinished: console.log("test") //revision 6 + * } + * + * To determine if these properties with revisions are available we need + * the minor version of TextEdit as imported in Test.qml. + * + */ + + quint8 typeMinorVersion() const { return _typeMinorVersion; } + void setTypeMinorVersion(quint8 rev) + { + Q_ASSERT(rev <= std::numeric_limits<quint8>::max()); + _typeMinorVersion = quint8(rev); } QQmlPropertyCacheMethodArguments *arguments() const { return _arguments; } @@ -284,7 +308,8 @@ private: qint16 _notifyIndex; qint16 _overrideIndex; - qint16 _revision; + quint8 _revision; + quint8 _typeMinorVersion; qint16 _metaObjectOffset; QQmlPropertyCacheMethodArguments *_arguments; @@ -325,7 +350,7 @@ public: inline void readProperty(QObject *target, void *property) const { - void *args[] = { property, 0 }; + void *args[] = { property, nullptr }; readPropertyWithArgs(target, args); } @@ -342,7 +367,7 @@ public: bool writeProperty(QObject *target, void *value, WriteFlags flags) const { int status = -1; - void *argv[] = { value, 0, &status, &flags }; + void *argv[] = { value, nullptr, &status, &flags }; if (flags.testFlag(BypassInterceptor) && hasStaticMetaCallFunction()) staticMetaCallFunction()(target, QMetaObject::WriteProperty, relativePropertyIndex(), argv); else if (flags.testFlag(BypassInterceptor) && isDirect()) @@ -378,10 +403,10 @@ private: struct QQmlEnumValue { - QQmlEnumValue() : value(-1) {} + QQmlEnumValue() {} QQmlEnumValue(const QString &n, int v) : namedValue(n), value(v) {} QString namedValue; - int value; + int value = -1; }; struct QQmlEnumData @@ -396,7 +421,7 @@ class Q_QML_PRIVATE_EXPORT QQmlPropertyCache : public QQmlRefCount public: QQmlPropertyCache(); QQmlPropertyCache(const QMetaObject *); - virtual ~QQmlPropertyCache(); + ~QQmlPropertyCache() override; void update(const QMetaObject *); void invalidate(const QMetaObject *); @@ -417,9 +442,9 @@ public: QQmlPropertyCache *copyAndReserve(int propertyCount, int methodCount, int signalCount, int enumCount); void appendProperty(const QString &, QQmlPropertyRawData::Flags flags, int coreIndex, - int propType, int notifyIndex); + int propType, int revision, int notifyIndex); void appendSignal(const QString &, QQmlPropertyRawData::Flags, int coreIndex, - const int *types = 0, const QList<QByteArray> &names = QList<QByteArray>()); + const int *types = nullptr, const QList<QByteArray> &names = QList<QByteArray>()); void appendMethod(const QString &, QQmlPropertyData::Flags flags, int coreIndex, const QList<QByteArray> &names = QList<QByteArray>()); void appendEnum(const QString &, const QVector<QQmlEnumValue> &); @@ -467,7 +492,7 @@ public: static int originalClone(QObject *, int index); QList<QByteArray> signalParameterNames(int index) const; - static QString signalParameterStringForJS(QV4::ExecutionEngine *engine, const QList<QByteArray> ¶meterNameList, QString *errorString = 0); + static QString signalParameterStringForJS(QV4::ExecutionEngine *engine, const QList<QByteArray> ¶meterNameList, QString *errorString = nullptr); const char *className() const; @@ -741,7 +766,7 @@ inline const QMetaObject *QQmlPropertyCache::metaObject() const // QML inline const QMetaObject *QQmlPropertyCache::firstCppMetaObject() const { - while (_parent && (_metaObject == 0 || _ownMetaObject)) + while (_parent && (_metaObject == nullptr || _ownMetaObject)) return _parent->firstCppMetaObject(); return _metaObject; } @@ -749,7 +774,7 @@ inline const QMetaObject *QQmlPropertyCache::firstCppMetaObject() const inline QQmlPropertyData *QQmlPropertyCache::property(int index) const { if (index < 0 || index >= (propertyIndexCacheStart + propertyIndexCache.count())) - return 0; + return nullptr; if (index < propertyIndexCacheStart) return _parent->property(index); @@ -761,7 +786,7 @@ inline QQmlPropertyData *QQmlPropertyCache::property(int index) const inline QQmlPropertyData *QQmlPropertyCache::method(int index) const { if (index < 0 || index >= (methodIndexCacheStart + methodIndexCache.count())) - return 0; + return nullptr; if (index < methodIndexCacheStart) return _parent->method(index); @@ -777,7 +802,7 @@ inline QQmlPropertyData *QQmlPropertyCache::method(int index) const inline QQmlPropertyData *QQmlPropertyCache::signal(int index) const { if (index < 0 || index >= (signalHandlerIndexCacheStart + signalHandlerIndexCache.count())) - return 0; + return nullptr; if (index < signalHandlerIndexCacheStart) return _parent->signal(index); @@ -790,7 +815,7 @@ inline QQmlPropertyData *QQmlPropertyCache::signal(int index) const inline QQmlEnumData *QQmlPropertyCache::qmlEnum(int index) const { if (index < 0 || index >= enumCache.count()) - return 0; + return nullptr; return const_cast<QQmlEnumData *>(&enumCache.at(index)); } @@ -821,7 +846,7 @@ QQmlPropertyData * QQmlPropertyCache::overrideData(QQmlPropertyData *data) const { if (!data->hasOverride()) - return 0; + return nullptr; if (data->overrideIndexIsProperty()) return property(data->overrideIndex()); @@ -923,7 +948,7 @@ bool QQmlMetaObject::isNull() const const char *QQmlMetaObject::className() const { if (_m.isNull()) { - return 0; + return nullptr; } else if (_m.isT1()) { return _m.asT1()->className(); } else { @@ -949,7 +974,7 @@ bool QQmlMetaObject::hasMetaObject() const const QMetaObject *QQmlMetaObject::metaObject() const { - if (_m.isNull()) return 0; + if (_m.isNull()) return nullptr; if (_m.isT1()) return _m.asT1()->createMetaObject(); else return _m.asT2(); } |