diff options
author | Thorbjørn Lindeijer <thorbjorn.lindeijer@nokia.com> | 2009-04-09 11:00:40 +0200 |
---|---|---|
committer | Thorbjørn Lindeijer <thorbjorn.lindeijer@nokia.com> | 2009-04-09 11:16:24 +0200 |
commit | cb75dd05ea34e4554e2247bfca98e55f3c2d2e39 (patch) | |
tree | 2f2e769a9876b1c05804a232f3f812a51c8da9c8 | |
parent | a0fa38323506a8c51fe194bee9f71eab5b79ead5 (diff) |
Prevent endless loop when no matching brace is found
Would show up when typing ")," where the closing brace doesn't have a
matching opening brace, for example.
Done with Roberto Raggi.
-rw-r--r-- | src/libs/cplusplus/ExpressionUnderCursor.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/libs/cplusplus/ExpressionUnderCursor.cpp b/src/libs/cplusplus/ExpressionUnderCursor.cpp index 9cbaeb9753..53dc9b4f2d 100644 --- a/src/libs/cplusplus/ExpressionUnderCursor.cpp +++ b/src/libs/cplusplus/ExpressionUnderCursor.cpp @@ -265,9 +265,14 @@ int ExpressionUnderCursor::startOfFunctionCall(const QTextCursor &cursor) break; else if (tk.is(T_LPAREN)) return startPosition + tk.position(); - else if (tk.is(T_RPAREN)) - index = startOfMatchingBrace(tokens, index); - else + else if (tk.is(T_RPAREN)) { + int matchingBrace = startOfMatchingBrace(tokens, index); + + if (matchingBrace == index) // If no matching brace found + return -1; + + index = matchingBrace; + } else --index; } |