From 43d385e9495e7a458eeafa4831c5c11fac7a5943 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Wed, 30 Oct 2024 12:49:54 +0100 Subject: [PATCH] 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 --- .../plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp b/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp index ce0ab795732..148739bdcde 100644 --- a/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp +++ b/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp @@ -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(transientParent->shellSurface())) { + auto parentSurface = qobject_cast(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()));