diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2019-12-02 11:10:45 +0100 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2019-12-02 11:09:35 +0000 |
commit | 2808f633ec3bf617dbeb8f67d54bc4896f26443f (patch) | |
tree | d261754a22f05dd2c1342bde2d44c88b707e105c /src | |
parent | e69f8f20489db9c5bb8ab083a014a104f958fe59 (diff) | |
download | qt-creator-2808f633ec3bf617dbeb8f67d54bc4896f26443f.tar.gz |
Debugger: Further robustify QmlInspectorAgent
When (re-)querying the root contexts, make sure we clear the old queries
first. One of the QML engines in the target may have created an object,
causing the contexts to be re-queried while queries for other engines
are still running. This would cause mismatches between the m_engines and
m_rootContextQueryIds arrays. In turn, in onResult() we would access an
invalid index in the m_engines array. Furthermore, make the assert that
guards against such an invalid access a QTC_GUARD and log the pending
queries before they are cleared.
When the target replies to the now-invalid root context queries we will
end up in the default branch of onResult,
m_qmlEngine->expressionEvaluated(), and that one silently ignores
unknown query IDs.
Task-number: QTCREATORBUG-22654
Change-Id: I1fe4751ea3592eb26c494696bea3d84fa3e62617
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: hjk <hjk@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/debugger/qml/qmlinspectoragent.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/plugins/debugger/qml/qmlinspectoragent.cpp b/src/plugins/debugger/qml/qmlinspectoragent.cpp index 3f4599c49b..4057e0aeca 100644 --- a/src/plugins/debugger/qml/qmlinspectoragent.cpp +++ b/src/plugins/debugger/qml/qmlinspectoragent.cpp @@ -262,8 +262,7 @@ void QmlInspectorAgent::onResult(quint32 queryId, const QVariant &value, if (index < 0) { if (QTC_GUARD(m_qmlEngine)) m_qmlEngine->expressionEvaluated(queryId, value); - } else { - Q_ASSERT(index < m_engines.length()); + } else if (QTC_GUARD(index < m_engines.length())) { const int engineId = m_engines.at(index).debugId(); m_rootContexts.insert(engineId, qvariant_cast<ContextReference>(value)); if (m_rootContexts.size() == m_engines.size()) { @@ -373,7 +372,7 @@ void QmlInspectorAgent::reloadEngines() void QmlInspectorAgent::queryEngineContext() { - qCDebug(qmlInspectorLog) << __FUNCTION__; + qCDebug(qmlInspectorLog) << __FUNCTION__ << "pending queries:" << m_rootContextQueryIds; if (!isConnected() || !boolSetting(ShowQmlObjectTree)) return; @@ -381,6 +380,7 @@ void QmlInspectorAgent::queryEngineContext() log(LogSend, "LIST_OBJECTS"); m_rootContexts.clear(); + m_rootContextQueryIds.clear(); for (const auto &engine : qAsConst(m_engines)) m_rootContextQueryIds.append(m_engineClient->queryRootContexts(engine)); } |