Add missing null check to QQuickTextEdit::hoveredLink()
authorJ-P Nurmi <jpnurmi@gmail.com>
Tue, 18 Jun 2013 07:54:24 +0000 (09:54 +0200)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Sun, 23 Jun 2013 09:17:36 +0000 (11:17 +0200)
Change-Id: Ie0cb144bb5596f566584b8bb80e334983dd2b50e
Reviewed-by: Alan Alpert <aalpert@blackberry.com>
src/quick/items/qquicktextedit.cpp

index 4ddef5e..6e22628 100644 (file)
@@ -2512,12 +2512,13 @@ QString QQuickTextEdit::hoveredLink() const
         return d->control->hoveredLink();
     } else {
 #ifndef QT_NO_CURSOR
-        QPointF pos = QCursor::pos(window()->screen()) - window()->position() - mapToScene(QPointF(0, 0));
-        return d->control->anchorAt(pos);
-#else
-        return QString();
+        if (QQuickWindow *wnd = window()) {
+            QPointF pos = QCursor::pos(wnd->screen()) - wnd->position() - mapToScene(QPointF(0, 0));
+            return d->control->anchorAt(pos);
+        }
 #endif // QT_NO_CURSOR
     }
+    return QString();
 }
 
 void QQuickTextEdit::hoverEnterEvent(QHoverEvent *event)