diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2019-09-02 10:49:32 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2019-09-04 15:51:48 +0200 |
commit | f862b3edeb8a96a49a5d12620506d33d5a5aadca (patch) | |
tree | 14e2a1398a029ab3c2bb7a92599baed5235e8444 /src/plugins | |
parent | 258143c07a900c895f597dd135fa6eea51b65111 (diff) |
Make QQmlValueTypeFactory::valueType() and isValueType() consistent
If isValueType() returns true, we should really return a non-null value
from valueType(). Otherwise the assumption that
QQmlValueTypeWrapper::valueType is never null breaks. In particular, the
unknown type and various primitive types are _not_ value types. We
special case the, probably common, UnknownType and check the actual
return value of valueType() for anything else. In order to avoid looking
up the metaobject each time we request a type that is not a value type,
we keep an invalid value type as marker for "not checked yet" and
replace that with nullptr once we determine that the type in question is
indeed not a value type.
Fixes: QTBUG-76866
Change-Id: I797f4cdd4db48ffc1b8fa2d919afc8022f67fa94
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/qmltooling/qmldbg_debugger/qqmlenginedebugservice.cpp | 20 | ||||
-rw-r--r-- | src/plugins/qmltooling/qmldbg_debugger/qqmlwatcher.cpp | 7 |
2 files changed, 9 insertions, 18 deletions
diff --git a/src/plugins/qmltooling/qmldbg_debugger/qqmlenginedebugservice.cpp b/src/plugins/qmltooling/qmldbg_debugger/qqmlenginedebugservice.cpp index d0f9833c2e..be83f63bfc 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qqmlenginedebugservice.cpp +++ b/src/plugins/qmltooling/qmldbg_debugger/qqmlenginedebugservice.cpp @@ -191,22 +191,18 @@ QQmlEngineDebugServiceImpl::propertyData(QObject *obj, int propIdx) if (binding) rv.binding = binding->expression(); - if (QQmlValueTypeFactory::isValueType(prop.userType())) { - rv.type = QQmlObjectProperty::Basic; - } else if (QQmlMetaType::isQObject(prop.userType())) { + rv.value = valueContents(prop.read(obj)); + + if (QQmlMetaType::isQObject(prop.userType())) { rv.type = QQmlObjectProperty::Object; } else if (QQmlMetaType::isList(prop.userType())) { rv.type = QQmlObjectProperty::List; } else if (prop.userType() == QMetaType::QVariant) { rv.type = QQmlObjectProperty::Variant; + } else if (rv.value.isValid()) { + rv.type = QQmlObjectProperty::Basic; } - QVariant value; - if (rv.type != QQmlObjectProperty::Unknown && prop.userType() != 0) { - value = prop.read(obj); - } - rv.value = valueContents(value); - return rv; } @@ -269,10 +265,10 @@ QVariant QQmlEngineDebugServiceImpl::valueContents(QVariant value) const return s; } } - - if (isSaveable(value)) - return value; } + + if (isSaveable(value)) + return value; } if (QQmlMetaType::isQObject(userType)) { diff --git a/src/plugins/qmltooling/qmldbg_debugger/qqmlwatcher.cpp b/src/plugins/qmltooling/qmldbg_debugger/qqmlwatcher.cpp index 86571e6cbe..8caa5ac23e 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qqmlwatcher.cpp +++ b/src/plugins/qmltooling/qmldbg_debugger/qqmlwatcher.cpp @@ -109,12 +109,7 @@ QQmlWatchProxy::QQmlWatchProxy(int id, void QQmlWatchProxy::notifyValueChanged() { - QVariant v; - if (m_expr) - v = m_expr->evaluate(); - else if (QQmlValueTypeFactory::isValueType(m_property.userType())) - v = m_property.read(m_object); - + const QVariant v = m_expr ? m_expr->evaluate() : m_property.read(m_object); emit m_watch->propertyChanged(m_id, m_debugId, m_property, v); } |