From ded22c154d0f05a18d1a95aa742213e1b3068d36 Mon Sep 17 00:00:00 2001 From: kleuter Date: Fri, 14 May 2021 11:45:07 +0200 Subject: [PATCH] 5.15.2: fix for QTBUG-88309 (QGraphicsItem crash if click right button of mouse) --- 5.15.2/qtbase/src/widgets/widgets/qwidgettextcontrol.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/5.15.2/qtbase/src/widgets/widgets/qwidgettextcontrol.cpp b/5.15.2/qtbase/src/widgets/widgets/qwidgettextcontrol.cpp index 40b8af6..e2a07c0 100644 --- a/5.15.2/qtbase/src/widgets/widgets/qwidgettextcontrol.cpp +++ b/5.15.2/qtbase/src/widgets/widgets/qwidgettextcontrol.cpp @@ -1942,10 +1942,14 @@ void QWidgetTextControlPrivate::contextMenuEvent(const QPoint &screenPos, const if (!menu) return; menu->setAttribute(Qt::WA_DeleteOnClose); - if (auto *window = static_cast(parent)->window()->windowHandle()) { - QMenuPrivate::get(menu)->topData()->initialScreenIndex = + + if (auto *widget = qobject_cast(parent)) { + if (auto *window = widget->window()->windowHandle()) { + QMenuPrivate::get(menu)->topData()->initialScreenIndex = QGuiApplication::screens().indexOf(window->screen()); + } } + menu->popup(screenPos); #endif }