Fix Windows drag and drop crash

When QGuiApplication::primaryScreen() is empty,
dragging it causes a crash

Change-Id: I6c5e48be44db90acec5126957bee60b8514b10a7
Pick-to: 6.7 6.5
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
(cherry picked from commit f8e7dfe93ab9622f77aade23707cd6f0b9386379)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Wang Yu 2024-08-16 09:11:39 +08:00 committed by Qt Cherry-pick Bot
parent d6bef9a6f9
commit ee09375bba

View File

@ -254,8 +254,9 @@ void QWindowsOleDropSource::createCursors()
if (const QScreen *primaryScreen = QGuiApplication::primaryScreen())
platformScreen = primaryScreen->handle();
}
Q_ASSERT(platformScreen);
QPlatformCursor *platformCursor = platformScreen->cursor();
QPlatformCursor *platformCursor = nullptr;
if (platformScreen)
platformCursor = platformScreen->cursor();
if (GetSystemMetrics (SM_REMOTESESSION) != 0) {
/* Workaround for RDP issues with large cursors.