[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [kdevelop/5.0] languages/cpp: Fix a potential UI lockup
From: David Nolden <david.nolden.kde () art-master ! de>
Date: 2016-01-31 21:21:01
Message-ID: E1aPzQb-0000dB-9s () scm ! kde ! org
[Download RAW message or body]
Git commit 2efeedb32ee8c1581fa6754d7856ce1613eca8a2 by David Nolden.
Committed on 31/01/2016 at 21:20.
Pushed by zwabel into branch '5.0'.
Fix a potential UI lockup
The search for closing braces of multi-line macro invocations
causes quadratic effort, and when no closing brace was found,
then it would lock up the UI. Solution: Simply give up after
50 lines of searching for the closing brace.
M +6 -1 languages/cpp/cpplanguagesupport.cpp
http://commits.kde.org/kdevelop/2efeedb32ee8c1581fa6754d7856ce1613eca8a2
diff --git a/languages/cpp/cpplanguagesupport.cpp \
b/languages/cpp/cpplanguagesupport.cpp index d2d6e9d..ce5f17a 100644
--- a/languages/cpp/cpplanguagesupport.cpp
+++ b/languages/cpp/cpplanguagesupport.cpp
@@ -638,8 +638,13 @@ QWidget* \
CppLanguageSupport::specialLanguageObjectNavigationWidget(const QUrl &u int \
foundClosingBrace = findClose( tail, 0 );
KDevelop::IDocument* doc = core()->documentController()->documentForUrl(url);
if(doc && doc->activeTextView() && foundClosingBrace < 0) {
+ // this causes quadratic effort in worst-case,
+ // so limit the number of expanded lines
+ const int limit = 50;
const int lines = doc->textDocument()->lines();
- for (int lineNumber = position.line() + 1; foundClosingBrace < 0 && \
lineNumber < lines; lineNumber++) { + for (int lineNumber = position.line() + \
1; + foundClosingBrace < 0 && lineNumber < std::min(lines, \
position.line()+limit); + lineNumber++) {
tail += doc->textDocument()->line(lineNumber).trimmed();
if(tail.endsWith('\\'))
tail.truncate(tail.length() - 1);
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic