Fix QGraphicsItem crash if click right button of mouse
In this case, the 'parent' is QGraphicsTextItem which isn't a object inheriting from QWidget. Converting QGraphicsTextItem to QWidget by static_cast and using it as QWidget leads to crash. Fixes: QTBUG-88309 Pick-to: 5.15 Change-Id: I3c583f43125eb36841848434d1fa9a135b0e9f57 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>bb10
parent
34304e3100
commit
4df5f93018
|
|
@ -1943,8 +1943,12 @@ void QWidgetTextControlPrivate::contextMenuEvent(const QPoint &screenPos, const
|
|||
if (!menu)
|
||||
return;
|
||||
menu->setAttribute(Qt::WA_DeleteOnClose);
|
||||
if (auto *window = static_cast<QWidget *>(parent)->window()->windowHandle())
|
||||
QMenuPrivate::get(menu)->topData()->initialScreen = window->screen();
|
||||
|
||||
if (auto *widget = qobject_cast<QWidget *>(parent)) {
|
||||
if (auto *window = widget->window()->windowHandle())
|
||||
QMenuPrivate::get(menu)->topData()->initialScreen = window->screen();
|
||||
}
|
||||
|
||||
menu->popup(screenPos);
|
||||
#endif
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue