forked from qt-creator/qt-creator
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: Erik Verbruggen <erik.verbruggen@digia.com>
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user