aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/texteditor/colorpreviewhoverhandler.cpp
diff options
context:
space:
mode:
authorDavid Schulz <david.schulz@theqtcompany.com>2016-03-23 08:53:16 +0100
committerDavid Schulz <david.schulz@theqtcompany.com>2016-03-23 08:43:22 +0000
commit5da8ea0432743f58c67f708dbc5d141305378d31 (patch)
treef35a31db3fac19fca7dd20447affdeecdd690627 /src/plugins/texteditor/colorpreviewhoverhandler.cpp
parentf3fab4423f7d2c3f64f6b424a88420d645f9e7f6 (diff)
Editor: Fix assert in color preview.
The event that triggers the hoverhandler can occur on the last position in a textline. This position is identical to the text length. Change-Id: Ia73685b69793fc305094db6611c95c3f03e3a8eb Reviewed-by: Christian Stenger <christian.stenger@theqtcompany.com>
Diffstat (limited to 'src/plugins/texteditor/colorpreviewhoverhandler.cpp')
-rw-r--r--src/plugins/texteditor/colorpreviewhoverhandler.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/plugins/texteditor/colorpreviewhoverhandler.cpp b/src/plugins/texteditor/colorpreviewhoverhandler.cpp
index f680e3b5dd..448c40de41 100644
--- a/src/plugins/texteditor/colorpreviewhoverhandler.cpp
+++ b/src/plugins/texteditor/colorpreviewhoverhandler.cpp
@@ -133,9 +133,9 @@ static QColor checkColorText(const QString &str)
// looks backwards through a string for the opening brace of a function
static int findOpeningBrace(const QString &s, int startIndex)
{
- QTC_ASSERT(startIndex >= 0 && startIndex < s.length(), return -1);
+ QTC_ASSERT(startIndex >= 0 && startIndex <= s.length(), return -1);
- int index = startIndex;
+ int index = startIndex == s.length() ? startIndex - 1 : startIndex;
while (index > 0) {
const QChar c = s[index];
if (c == QLatin1Char('(') || c == QLatin1Char('{'))
@@ -149,9 +149,9 @@ static int findOpeningBrace(const QString &s, int startIndex)
static int findClosingBrace(const QString &s, int startIndex)
{
- QTC_ASSERT(startIndex >= 0 && startIndex < s.length(), return -1);
+ QTC_ASSERT(startIndex >= 0 && startIndex <= s.length(), return -1);
- int index = startIndex;
+ int index = startIndex == s.length() ? startIndex - 1 : startIndex;
const int len = s.length();
while (index < len) {
const QChar c = s[index];
@@ -167,9 +167,9 @@ static int findClosingBrace(const QString &s, int startIndex)
// returns the index of the first character of the func, or negative if not valid
static int findFuncStart(const QString &s, int startIndex)
{
- QTC_ASSERT(startIndex >= 0 && startIndex < s.length(), return -1);
+ QTC_ASSERT(startIndex >= 0 && startIndex <= s.length(), return -1);
- int index = startIndex;
+ int index = startIndex == s.length() ? startIndex - 1 : startIndex;
while (index >= 0) {
const QChar c = s[index];
if (!c.isLetterOrNumber()) {