diff options
author | Nikolai Kosjar <nikolai.kosjar@theqtcompany.com> | 2015-07-07 15:02:14 +0200 |
---|---|---|
committer | Nikolai Kosjar <nikolai.kosjar@theqtcompany.com> | 2015-07-10 14:04:07 +0000 |
commit | 442bdbded2b2268efcb3be1a969d432533023366 (patch) | |
tree | 9bda03fd90c90de0385bde77d25d32f15cc9856b /src/plugins/clangcodemodel/clangeditordocumentparser.cpp | |
parent | 91c497b1aebaf4b24ac1e5b884940820c6a0a88c (diff) |
CppTools: Avoid unnecessary blocking of main thread
Among others, BaseEditorDocumentParser::projectPart() was a blocking
operation in case the parser was running. This led to noticeable GUI
freezes for the ClangCodeModel since the function was called from the
main thread.
Rework *EditorDocumentParser to clearly separate the configuration data
(input) from the actual object state. Querying/setting configuration or
(last) state does not block anymore. update() is supposed to get the
necessary configuration and the last state at the beginning and to set
the new state at end.
Change-Id: Ib4b534fa6ff373c3059826726b3f10ece95acc21
Reviewed-by: Erik Verbruggen <erik.verbruggen@theqtcompany.com>
Diffstat (limited to 'src/plugins/clangcodemodel/clangeditordocumentparser.cpp')
-rw-r--r-- | src/plugins/clangcodemodel/clangeditordocumentparser.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/plugins/clangcodemodel/clangeditordocumentparser.cpp b/src/plugins/clangcodemodel/clangeditordocumentparser.cpp index 9b342bd7d1a..fd2c60dbaee 100644 --- a/src/plugins/clangcodemodel/clangeditordocumentparser.cpp +++ b/src/plugins/clangcodemodel/clangeditordocumentparser.cpp @@ -91,21 +91,25 @@ ClangEditorDocumentParser::ClangEditorDocumentParser(const QString &filePath) void ClangEditorDocumentParser::update(CppTools::WorkingCopy workingCopy) { QTC_ASSERT(m_marker, return); - QMutexLocker lock(m_marker->mutex()); - QMutexLocker lock2(&m_mutex); + QMutexLocker locker(&m_updateIsRunning); - m_projectPart = determineProjectPart(); - const QStringList options = createOptions(filePath(), projectPart(), true); + // Determine project part + State state_ = state(); + state_.projectPart = determineProjectPart(filePath(), configuration(), state_); + setState(state_); + // Determine command line arguments + const QStringList options = createOptions(filePath(), state_.projectPart, true); qCDebug(log, "Reparse options (cmd line equivalent): %s", commandLine(options, filePath()).toUtf8().constData()); - QTime t; t.start(); + // Run + QTime t; t.start(); + QMutexLocker lock(m_marker->mutex()); m_marker->setFileName(filePath()); m_marker->setCompilationOptions(options); const Internal::UnsavedFiles unsavedFiles = Utils::createUnsavedFiles(workingCopy); m_marker->reparse(unsavedFiles); - qCDebug(log) << "Reparse took" << t.elapsed() << "ms."; } |