Commit cacd6619 authored by Nikolai Kosjar's avatar Nikolai Kosjar

CppEditor: Avoid premature calls to recalculateSemanticInfoNow

Now recalculateSemanticInfoNow is called only once instead of three
times when a new editor is opened/created.

Change-Id: Ife84fc9ca90cdbf2a417123e6a2b9e1e068dfdc4
Reviewed-by: default avatarErik Verbruggen <erik.verbruggen@digia.com>
parent 7313203c
......@@ -1132,7 +1132,10 @@ void CPPEditorWidget::updateUses()
{
if (editorRevision() != m_highlightRevision)
m_highlighter.cancel();
m_updateUsesTimer->start();
// Block premature semantic info calculation when editor is created.
if (m_modelManager->cppEditorSupport(editor())->initialized())
m_updateUsesTimer->start();
}
void CPPEditorWidget::updateUsesNow()
......
......@@ -175,6 +175,11 @@ void CppEditorSupport::setExtraDiagnostics(const QString &key,
emit diagnosticsChanged();
}
bool CppEditorSupport::initialized()
{
return m_initialized;
}
SemanticInfo CppEditorSupport::recalculateSemanticInfo(bool emitSignalWhenFinished)
{
m_futureSemanticInfo.cancel();
......@@ -186,6 +191,11 @@ SemanticInfo CppEditorSupport::recalculateSemanticInfo(bool emitSignalWhenFinish
void CppEditorSupport::recalculateSemanticInfoDetached(bool force)
{
// Block premature calculation caused by CppEditorPlugin::currentEditorChanged
// when the editor is created.
if (!m_initialized)
return;
m_futureSemanticInfo.cancel();
SemanticInfo::Source source = currentSource(force);
m_futureSemanticInfo = QtConcurrent::run<CppEditorSupport, void>(
......
......@@ -98,12 +98,17 @@ public:
void setExtraDiagnostics(const QString &key,
const QList<CPlusPlus::Document::DiagnosticMessage> &messages);
/// True after the document was parsed/updated for the first time
/// and the first semantic info calculation was started.
bool initialized();
/// Retrieve the semantic info, which will get recalculated on the current
/// thread if it is outdate.
SemanticInfo recalculateSemanticInfo(bool emitSignalWhenFinished = true);
/// Recalculates the semantic info in a future, and will emit the semanticInfoUpdated() signal
/// when finished.
/// Recalculates the semantic info in a future, and will emit the
/// semanticInfoUpdated() signal when finished.
/// Requires that initialized() is true.
/// \param force do not check if the old semantic info is still valid
void recalculateSemanticInfoDetached(bool force = false);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment