Always show a submenu on its parent menu's screen, if possible

Amends c068edcecf6876c7b57abbe302ad8b1347e4445e with another
nullptr check.

Fixes: QTCREATORBUG-24195
Task-number: QTBUG-76162
Change-Id: Ifaafe9b45fafaae220da54bbf3bc7a568e7953f9
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
This commit is contained in:
Shawn Rutledge 2020-06-16 13:31:17 +02:00
parent 710777d5d3
commit 3a29996548

View File

@ -2376,9 +2376,10 @@ void QMenu::popup(const QPoint &p, QAction *atAction)
d->itemsDirty = true;
screenSet = true;
} else if (QMenu *parentMenu = qobject_cast<QMenu *>(parent())) {
// a submenu is always opened from an open parent menu,
// a submenu is normally opened from an open parent menu,
// so show it on the same screen where the parent is.
if (d->setScreen(QMenuPrivate::get(parentMenu)->windowHandle()->screen()))
if (QMenuPrivate::get(parentMenu)->windowHandle() &&
d->setScreen(QMenuPrivate::get(parentMenu)->windowHandle()->screen()))
d->itemsDirty = true;
screenSet = true;
}