From c257144bab23e90a82db6c138514199a3b7f3ed3 Mon Sep 17 00:00:00 2001 From: Stefan Fuchs Date: Tue, 18 Apr 2017 23:35:43 +0200 Subject: 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 --- desktop-widgets/simplewidgets.cpp | 3 +++ 1 file changed, 3 insertions(+) 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); -- cgit v1.2.3-70-g09d2