diff options
author | Simon Hausmann <simon.hausmann@theqtcompany.com> | 2014-11-10 08:03:08 +0100 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@digia.com> | 2014-12-10 14:52:21 +0100 |
commit | fbcffd48e2face5184b523ff9674c329847ecdd9 (patch) | |
tree | 051d0516c6ea0abcf016fd7c2108ac7adf1d8980 /src/qml/qml/qqmlproperty.cpp | |
parent | 7a0542d45e9f675f361477927bec1bbb0fa7a88d (diff) |
Changed value type property index encoding
We used to encode property index and value type property index in one int
with 16 bits each, for example font.pixelSize with index of "font" in the
lower 16 bits and "pixelSize" in the upper 16 bits.
Detecting if a given encoded index was using value types or not was based on
whether the value type index (upper 16 bits) were non-zero. That assumption
holds given that all valid property indicies of value types are > 0 because
they are all sub-classes of QObject, which provides the first property
(objectName).
With the introduction of gadgets property index zero will become popular again,
and value types are a core use-case for gadgets. Therefore we need to change
the encoding to allow for zero to be a valid value type property index. This is
implemented by centralizing all decoding call sites to call one function that
indicates -1 as non-present value type core index return value. That way we can
encode the index with an offset of 1.
Change-Id: I266abf140211a4f7204b47b94d07c364f0a8f408
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/qml/qml/qqmlproperty.cpp')
-rw-r--r-- | src/qml/qml/qqmlproperty.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/qml/qml/qqmlproperty.cpp b/src/qml/qml/qqmlproperty.cpp index 2a888b7a1e..635e4d4a54 100644 --- a/src/qml/qml/qqmlproperty.cpp +++ b/src/qml/qml/qqmlproperty.cpp @@ -734,8 +734,8 @@ QQmlPropertyPrivate::setBinding(const QQmlProperty &that, QObject *object = newBinding->object(); int pi = newBinding->propertyIndex(); - int core = pi & 0x0000FFFF; - int vt = (pi & 0xFFFF0000)?(pi >> 16):-1; + int core; + int vt = QQmlPropertyData::decodeValueTypePropertyIndex(pi, &core); return setBinding(object, core, vt, newBinding, flags); } else { @@ -776,7 +776,7 @@ QQmlPropertyPrivate::binding(QObject *object, int coreIndex, int valueTypeIndex) if (binding && valueTypeIndex != -1) { if (binding->bindingType() == QQmlAbstractBinding::ValueTypeProxy) { - int index = coreIndex | (valueTypeIndex << 16); + int index = QQmlPropertyData::encodeValueTypePropertyIndex(coreIndex, valueTypeIndex); binding = static_cast<QQmlValueTypeProxyBinding *>(binding)->binding(index); } } @@ -787,8 +787,8 @@ QQmlPropertyPrivate::binding(QObject *object, int coreIndex, int valueTypeIndex) void QQmlPropertyPrivate::findAliasTarget(QObject *object, int bindingIndex, QObject **targetObject, int *targetBindingIndex) { - int coreIndex = bindingIndex & 0x0000FFFF; - int valueTypeIndex = (bindingIndex & 0xFFFF0000)?(bindingIndex >> 16):-1; + int coreIndex; + int valueTypeIndex = QQmlPropertyData::decodeValueTypePropertyIndex(bindingIndex, &coreIndex); QQmlData *data = QQmlData::get(object, false); if (data) { @@ -804,9 +804,9 @@ void QQmlPropertyPrivate::findAliasTarget(QObject *object, int bindingIndex, int aBindingIndex = aCoreIndex; if (aValueTypeIndex != -1) - aBindingIndex |= aValueTypeIndex << 16; + aBindingIndex = QQmlPropertyData::encodeValueTypePropertyIndex(aBindingIndex, aValueTypeIndex); else if (valueTypeIndex != -1) - aBindingIndex |= valueTypeIndex << 16; + aBindingIndex = QQmlPropertyData::encodeValueTypePropertyIndex(aBindingIndex, valueTypeIndex); findAliasTarget(aObject, aBindingIndex, targetObject, targetBindingIndex); return; @@ -853,7 +853,7 @@ QQmlPropertyPrivate::setBinding(QObject *object, int coreIndex, int valueTypeInd int index = coreIndex; if (valueTypeIndex != -1) - index |= (valueTypeIndex << 16); + index = QQmlPropertyData::encodeValueTypePropertyIndex(index, valueTypeIndex); if (binding && valueTypeIndex != -1 && binding->bindingType() == QQmlAbstractBinding::ValueTypeProxy) binding = static_cast<QQmlValueTypeProxyBinding *>(binding)->binding(index); @@ -912,7 +912,7 @@ QQmlPropertyPrivate::setBindingNoEnable(QObject *object, int coreIndex, int valu int index = coreIndex; if (valueTypeIndex != -1) - index |= (valueTypeIndex << 16); + index = QQmlPropertyData::encodeValueTypePropertyIndex(index, valueTypeIndex); if (binding && valueTypeIndex != -1 && binding->bindingType() == QQmlAbstractBinding::ValueTypeProxy) binding = static_cast<QQmlValueTypeProxyBinding *>(binding)->binding(index); |