From 087d7891aa54084236a27b5b77767e9d5106e108 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Arve=20S=C3=A6ther?= Date: Tue, 20 Oct 2020 16:58:11 +0200 Subject: Do not crash if QPA plugin does not support cursors This was the case on Android, and caused a crash Fixes: QTBUG-83916 Change-Id: Iabc17237498091d815241730a2b14ece5a45d0b9 Reviewed-by: Volker Hilsheimer Reviewed-by: Assam Boudjelthia (cherry picked from commit 2a5afb88dbf675c39e0671b11870596fdb3b6725) Reviewed-by: Qt Cherry-pick Bot --- src/widgets/kernel/qtooltip.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/widgets/kernel/qtooltip.cpp b/src/widgets/kernel/qtooltip.cpp index 661568dcad..0c9db61f91 100644 --- a/src/widgets/kernel/qtooltip.cpp +++ b/src/widgets/kernel/qtooltip.cpp @@ -406,7 +406,10 @@ void QTipLabel::placeTip(const QPoint &pos, QWidget *w) QGuiApplication::primaryScreen()); // a QScreen's handle *should* never be null, so this is a bit paranoid if (const QPlatformScreen *platformScreen = screen ? screen->handle() : nullptr) { - const QSize cursorSize = QHighDpi::fromNativePixels(platformScreen->cursor()->size(), + QPlatformCursor *cursor = platformScreen->cursor(); + // default implementation of QPlatformCursor::size() returns QSize(16, 16) + const QSize nativeSize = cursor ? cursor->size() : QSize(16, 16); + const QSize cursorSize = QHighDpi::fromNativePixels(nativeSize, platformScreen); QPoint offset(2, cursorSize.height()); // assuming an arrow shape, we can just move to the side for very large cursors -- cgit v1.2.3