summaryrefslogtreecommitdiffstats
path: root/desktop-widgets/simplewidgets.cpp
diff options
context:
space:
mode:
authorGravatar Stefan Fuchs <sfuchs@gmx.de>2017-04-18 23:35:43 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2017-04-18 18:13:52 -0700
commitc257144bab23e90a82db6c138514199a3b7f3ed3 (patch)
tree314f9854545456852be151843d066b29307cf0aa /desktop-widgets/simplewidgets.cpp
parent58a25d33ce03c2b4944f0b187da29a635410e86b (diff)
downloadsubsurface-c257144bab23e90a82db6c138514199a3b7f3ed3.tar.gz
Fix a crash in the URL handling for the dive notes
URLs in the dive notes are detected today. A tooltip is displayed and one can follow the URL by Ctrl-click. In the function fromCursorTilWhitespace there is an issue with incorrect return value of Qt (5.7?!) function cursor->movePosition(). This value is erroneous true in some condition e.g. if the cursor is inside a table at the very beginning or the very end of a table line and not moving any more. This can cause the function end up in an infinite loop. Bugfix adds an additional exit criteria for the loop if the string is not growing any more. Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
Diffstat (limited to 'desktop-widgets/simplewidgets.cpp')
-rw-r--r--desktop-widgets/simplewidgets.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/desktop-widgets/simplewidgets.cpp b/desktop-widgets/simplewidgets.cpp
index 049ce6549..5680ad867 100644
--- a/desktop-widgets/simplewidgets.cpp
+++ b/desktop-widgets/simplewidgets.cpp
@@ -748,6 +748,7 @@ QString TextHyperlinkEventFilter::fromCursorTilWhitespace(QTextCursor *cursor, c
QString grownText;
QString noSpaces;
bool movedOk = false;
+ int oldSize = -1;
do {
result = grownText; // this is a no-op on the first visit.
@@ -759,6 +760,8 @@ QString TextHyperlinkEventFilter::fromCursorTilWhitespace(QTextCursor *cursor, c
}
grownText = cursor->selectedText();
+ if (grownText.size() == oldSize) movedOk = false;
+ oldSize = grownText.size();
noSpaces = grownText.simplified().replace(" ", "");
} while (grownText == noSpaces && movedOk);