From 096bd6f6509dbf241eb33685f672112c38991c53 Mon Sep 17 00:00:00 2001 From: Johan Klokkhammer Helsing Date: Thu, 3 Oct 2019 10:05:20 +0200 Subject: Compositor: Fix crash when trying to maximize an XdgToplevel with no output This cherry-pick also fixes a shadowed, unused variable introduced in the original commit. Fixes: QTBUG-78969 Change-Id: I4ecde3725b5307251070e331c97d96df328a3772 (cherry picked from commit 11f2e7df5762a23e66d1755b34f5f3d07208ae32) Reviewed-by: Paul Olav Tvete --- .../extensions/qwaylandxdgshellintegration.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/compositor/extensions/qwaylandxdgshellintegration.cpp b/src/compositor/extensions/qwaylandxdgshellintegration.cpp index cc8faf6c7..863efa758 100644 --- a/src/compositor/extensions/qwaylandxdgshellintegration.cpp +++ b/src/compositor/extensions/qwaylandxdgshellintegration.cpp @@ -179,8 +179,12 @@ void XdgToplevelIntegration::handleUnsetMaximized() void XdgToplevelIntegration::handleMaximizedChanged() { if (m_toplevel->maximized()) { - QWaylandOutput *output = m_item->view()->output(); - m_item->moveItem()->setPosition(output->position() + output->availableGeometry().topLeft()); + if (auto *output = m_item->view()->output()) { + m_item->moveItem()->setPosition(output->position() + output->availableGeometry().topLeft()); + } else { + qCWarning(qLcWaylandCompositor) << "The view does not have a corresponding output," + << "ignoring maximized state"; + } } else { m_item->moveItem()->setPosition(windowedGeometry.initialPosition); } @@ -231,8 +235,12 @@ void XdgToplevelIntegration::handleUnsetFullscreen() void XdgToplevelIntegration::handleFullscreenChanged() { if (m_toplevel->fullscreen()) { - QWaylandOutput *output = m_item->view()->output(); - m_item->moveItem()->setPosition(output->position() + output->geometry().topLeft()); + if (auto *output = m_item->view()->output()) { + m_item->moveItem()->setPosition(output->position() + output->geometry().topLeft()); + } else { + qCWarning(qLcWaylandCompositor) << "The view does not have a corresponding output," + << "ignoring fullscreen state"; + } } else { m_item->moveItem()->setPosition(windowedGeometry.initialPosition); } -- cgit v1.2.3