[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kdevelop] languages/cpp: Fix a potential UI lockup
From:       David Nolden <david.nolden.kde () art-master ! de>
Date:       2016-01-31 15:15:26
Message-ID: E1aPtio-0000QI-Tq () scm ! kde ! org
[Download RAW message or body]

Git commit 9a1c1c1a724edfb7003683130757f8760db01d9d by David Nolden.
Committed on 31/01/2016 at 15:15.
Pushed by zwabel into branch 'master'.

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/9a1c1c1a724edfb7003683130757f8760db01d9d

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