summaryrefslogtreecommitdiff
path: root/src/plugins/clangcodemodel/clangdiagnosticmanager.cpp
diff options
context:
space:
mode:
authorDavid Schulz <david.schulz@qt.io>2017-07-12 09:34:30 +0200
committerDavid Schulz <david.schulz@qt.io>2017-07-17 07:14:06 +0000
commit635750aa11db284d5ee3b0e97f6d1e035a8c54e3 (patch)
treed1e7343c5c8d5f3393aeb37bbd77c33e90a12ce1 /src/plugins/clangcodemodel/clangdiagnosticmanager.cpp
parent892026a6196b9d69fe0946afedab8b4eaf6c5208 (diff)
downloadqt-creator-635750aa11db284d5ee3b0e97f6d1e035a8c54e3.tar.gz
Clang: delay text mark update
Reducing display of unwanted line annotations while typing in small files. Change-Id: I51864bbc3056ad792d5ee4b96f63e954dfba79dd Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io> Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
Diffstat (limited to 'src/plugins/clangcodemodel/clangdiagnosticmanager.cpp')
-rw-r--r--src/plugins/clangcodemodel/clangdiagnosticmanager.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/plugins/clangcodemodel/clangdiagnosticmanager.cpp b/src/plugins/clangcodemodel/clangdiagnosticmanager.cpp
index c8da6e6c6a..1dd003c7c1 100644
--- a/src/plugins/clangcodemodel/clangdiagnosticmanager.cpp
+++ b/src/plugins/clangcodemodel/clangdiagnosticmanager.cpp
@@ -278,6 +278,8 @@ namespace Internal {
ClangDiagnosticManager::ClangDiagnosticManager(TextEditor::TextDocument *textDocument)
: m_textDocument(textDocument)
{
+ m_textMarkDelay.setInterval(1500);
+ m_textMarkDelay.setSingleShot(true);
}
ClangDiagnosticManager::~ClangDiagnosticManager()
@@ -295,6 +297,7 @@ void ClangDiagnosticManager::cleanMarks()
}
void ClangDiagnosticManager::generateTextMarks()
{
+ QObject::disconnect(&m_textMarkDelay, &QTimer::timeout, 0, 0);
cleanMarks();
m_clangTextMarks.reserve(m_warningDiagnostics.size() + m_errorDiagnostics.size());
addClangTextMarks(m_warningDiagnostics);
@@ -350,6 +353,7 @@ ClangDiagnosticManager::diagnosticsAt(uint line, uint column) const
void ClangDiagnosticManager::invalidateDiagnostics()
{
+ m_textMarkDelay.start();
if (m_diagnosticsInvalidated)
return;
@@ -383,9 +387,18 @@ void ClangDiagnosticManager::processNewDiagnostics(
m_showTextMarkAnnotations = showTextMarkAnnotations;
filterDiagnostics(allDiagnostics);
- generateTextMarks();
generateEditorSelections();
generateFixItAvailableMarkers();
+ if (m_firstDiagnostics) {
+ m_firstDiagnostics = false;
+ generateTextMarks();
+ } else if (!m_textMarkDelay.isActive()) {
+ generateTextMarks();
+ } else {
+ QObject::connect(&m_textMarkDelay, &QTimer::timeout, [this]() {
+ generateTextMarks();
+ });
+ }
}
const QVector<ClangBackEnd::DiagnosticContainer> &