summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Shambir <sergey.shambir.auto@gmail.com>2013-12-03 23:33:50 +0400
committerErik Verbruggen <erik.verbruggen@digia.com>2013-12-10 12:52:23 +0100
commitcdac81f896ef4b052d76f96485a08e6ec13696b8 (patch)
treeef60bfbb4eeb63b39740be083f377cb1abb63fe9
parent63f16dd473e73116f2fbff0f1ad09967d6c9280c (diff)
downloadqt-creator-cdac81f896ef4b052d76f96485a08e6ec13696b8.tar.gz
Clang: fixed assertion failure in highlighting.
Highlighting called asynchronously, and a few lines at the end of editing file can be deleted for this time. Assertion failed in debug builds, highlighting failed in release. Change-Id: Ia15dd27f791fe2721b672eb4528a0b9d3f1831d6 Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
-rw-r--r--src/plugins/clangcodemodel/semanticmarker.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/plugins/clangcodemodel/semanticmarker.cpp b/src/plugins/clangcodemodel/semanticmarker.cpp
index 24c11a125a..5a42a1165b 100644
--- a/src/plugins/clangcodemodel/semanticmarker.cpp
+++ b/src/plugins/clangcodemodel/semanticmarker.cpp
@@ -326,7 +326,16 @@ QList<SourceMarker> SemanticMarker::sourceMarkersInRange(unsigned firstLine,
QList<SourceMarker> result;
- if (firstLine > lastLine || !m_unit->isLoaded())
+ if (!m_unit->isLoaded())
+ return result;
+
+ // Highlighting called asynchronously, and a few lines at the end can be deleted for this time.
+ CXSourceRange unitRange = clang_getCursorExtent(m_unit->getTranslationUnitCursor());
+ SourceLocation unitEnd = getExpansionLocation(clang_getRangeEnd(unitRange));
+ if (lastLine > unitEnd.line())
+ lastLine = unitEnd.line();
+
+ if (firstLine > lastLine)
return result;
IdentifierTokens idTokens(*m_unit, firstLine, lastLine);