Commit be3dbd26 authored by Erik Verbruggen's avatar Erik Verbruggen

CppEditor: copy snapshot before FunctionDeclDefLink change calculation.

FunctionDeclDefLink::changes is called from
CPPEditorWidget::updateFunctionDeclDefLinkNow() where it receives the
snapshot by reference from the semantic info. The semantic info is
recalculated in a/the future, so it might change the snapshot or its
documents while it's still being used by the decl/def link finder.

So, this patch takes a copy of all relevant semantic info (snapshot and
document) before starting to calculate the changes.

Change-Id: I78244a4ca8149233403b3c35ee05a2d4ed4b2770
Reviewed-by: default avatarNikolai Kosjar <>
parent bc03271f
...@@ -1029,22 +1029,24 @@ void CPPEditorWidget::updateFunctionDeclDefLinkNow() ...@@ -1029,22 +1029,24 @@ void CPPEditorWidget::updateFunctionDeclDefLinkNow()
{ {
if (Core::EditorManager::currentEditor() != editor()) if (Core::EditorManager::currentEditor() != editor())
return; return;
const Snapshot semanticSnapshot = d->m_lastSemanticInfo.snapshot;
const Document::Ptr semanticDoc = d->m_lastSemanticInfo.doc;
if (d->m_declDefLink) { if (d->m_declDefLink) {
// update the change marker // update the change marker
const Utils::ChangeSet changes = d->m_declDefLink->changes(d->m_lastSemanticInfo.snapshot); const Utils::ChangeSet changes = d->m_declDefLink->changes(semanticSnapshot);
if (changes.isEmpty()) if (changes.isEmpty())
d->m_declDefLink->hideMarker(this); d->m_declDefLink->hideMarker(this);
else else
d->m_declDefLink->showMarker(this); d->m_declDefLink->showMarker(this);
return; return;
} }
if (!d->m_lastSemanticInfo.doc || isOutdated()) if (semanticDoc.isNull() || isOutdated())
return; return;
Snapshot snapshot = CppModelManagerInterface::instance()->snapshot(); Snapshot snapshot = CppModelManagerInterface::instance()->snapshot();
snapshot.insert(d->m_lastSemanticInfo.doc); snapshot.insert(semanticDoc);
d->m_declDefLinkFinder->startFindLinkAt(textCursor(), d->m_lastSemanticInfo.doc, snapshot); d->m_declDefLinkFinder->startFindLinkAt(textCursor(), semanticDoc, snapshot);
} }
void CPPEditorWidget::onFunctionDeclDefLinkFound(QSharedPointer<FunctionDeclDefLink> link) void CPPEditorWidget::onFunctionDeclDefLinkFound(QSharedPointer<FunctionDeclDefLink> link)
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment