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/qqmlabstractbinding.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/qqmlabstractbinding.cpp')
-rw-r--r-- | src/qml/qml/qqmlabstractbinding.cpp | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/src/qml/qml/qqmlabstractbinding.cpp b/src/qml/qml/qqmlabstractbinding.cpp index 71169abc98..51471d3b89 100644 --- a/src/qml/qml/qqmlabstractbinding.cpp +++ b/src/qml/qml/qqmlabstractbinding.cpp @@ -75,15 +75,12 @@ void QQmlAbstractBinding::addToObject() QObject *obj = object(); Q_ASSERT(obj); - int index = propertyIndex(); - QQmlData *data = QQmlData::get(obj, true); - if (index & 0xFFFF0000) { + int coreIndex; + if (QQmlPropertyData::decodeValueTypePropertyIndex(propertyIndex(), &coreIndex) != -1) { // Value type - int coreIndex = index & 0x0000FFFF; - // Find the value type proxy (if there is one) QQmlValueTypeProxyBinding *proxy = 0; if (data->hasBindingBit(coreIndex)) { @@ -110,7 +107,7 @@ void QQmlAbstractBinding::addToObject() setNextBinding(data->bindings); data->bindings = this; - data->setBindingBit(obj, index); + data->setBindingBit(obj, coreIndex); } setAddedToObject(true); @@ -123,16 +120,15 @@ void QQmlAbstractBinding::removeFromObject() { if (isAddedToObject()) { QObject *obj = object(); - int index = propertyIndex(); - QQmlData *data = QQmlData::get(obj, false); Q_ASSERT(data); - if (index & 0xFFFF0000) { + int coreIndex; + if (QQmlPropertyData::decodeValueTypePropertyIndex(propertyIndex(), &coreIndex) != -1) { // Find the value type binding QQmlAbstractBinding *vtbinding = data->bindings; - while (vtbinding->propertyIndex() != (index & 0x0000FFFF)) { + while (vtbinding->propertyIndex() != coreIndex) { vtbinding = vtbinding->nextBinding(); Q_ASSERT(vtbinding); } @@ -169,7 +165,7 @@ void QQmlAbstractBinding::removeFromObject() binding->setNextBinding(nextBinding()); } - data->clearBindingBit(index); + data->clearBindingBit(coreIndex); } setNextBinding(0); |