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/qqmlvmemetaobject_p.h | |
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/qqmlvmemetaobject_p.h')
-rw-r--r-- | src/qml/qml/qqmlvmemetaobject_p.h | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/qml/qml/qqmlvmemetaobject_p.h b/src/qml/qml/qqmlvmemetaobject_p.h index a8a9a02102..a7df7c6e53 100644 --- a/src/qml/qml/qqmlvmemetaobject_p.h +++ b/src/qml/qml/qqmlvmemetaobject_p.h @@ -90,19 +90,21 @@ struct QQmlVMEMetaData return propertyIdx == -1; } bool isPropertyAlias() const { - return !isObjectAlias() && !(propertyIdx & 0xFFFF0000); + return !isObjectAlias() && valueTypeIndex() == -1; } bool isValueTypeAlias() const { - return !isObjectAlias() && (propertyIdx & 0xFFFF0000); + return !isObjectAlias() && valueTypeIndex() != -1; } int propertyIndex() const { - return propertyIdx & 0x0000FFFF; + int index; + QQmlPropertyData::decodeValueTypePropertyIndex(propertyIdx, &index); + return index; } int valueTypeIndex() const { - return (propertyIdx & 0xFFFF0000) >> 16; + return QQmlPropertyData::decodeValueTypePropertyIndex(propertyIdx); } int valueType() const { - return (propertyIdx & 0xFFFF0000) ? propType : 0; + return (valueTypeIndex() != -1) ? propType : 0; } }; |