Check whether m_toplevel exists before dereferencing it

The parent surface could be a popup. In that case m_toplevel would be
nullptr. Since xdgshell doesn't allow an xdg_popup to be the parent of
an xdg_toplevel, the best we can do is pretend there is no parent in
this case.

Fixes: QTBUG-130128
Pick-to: 6.8
Change-Id: Ib0367429b71ee96cbd1c3119e77769c511370624
Reviewed-by: Vlad Zahorodnii <vlad.zahorodnii@kde.org>
This commit is contained in:
Paul Olav Tvete 2024-10-30 12:49:54 +01:00
parent ac879a0200
commit 43d385e949

View File

@ -34,8 +34,8 @@ QWaylandXdgSurface::Toplevel::Toplevel(QWaylandXdgSurface *xdgSurface)
requestWindowStates(window->windowStates());
requestWindowFlags(window->flags());
if (auto transientParent = xdgSurface->window()->transientParent()) {
if (auto parentSurface =
qobject_cast<QWaylandXdgSurface *>(transientParent->shellSurface())) {
auto parentSurface = qobject_cast<QWaylandXdgSurface *>(transientParent->shellSurface());
if (parentSurface && parentSurface->m_toplevel) {
set_parent(parentSurface->m_toplevel->object());
if (window->modality() != Qt::NonModal && m_xdgSurface->m_shell->m_xdgDialogWm) {
m_xdgDialog.reset(m_xdgSurface->m_shell->m_xdgDialogWm->getDialog(object()));