diff --git a/xdgshellclient.cpp b/xdgshellclient.cpp index cfb3d4ca40..8655971099 100644 --- a/xdgshellclient.cpp +++ b/xdgshellclient.cpp @@ -715,11 +715,16 @@ void XdgToplevelClient::showOnScreenEdge() if (!m_plasmaShellSurface) { return; } - hideClient(false); - workspace()->raiseClient(this); - if (m_plasmaShellSurface->panelBehavior() == PlasmaShellSurfaceInterface::PanelBehavior::AutoHide) { - m_plasmaShellSurface->showAutoHidingPanel(); - } + + // ShowOnScreenEdge can be called by an Edge, and hideClient could destroy the Edge + // Use the singleshot to avoid use-after-free + QTimer::singleShot(0, [this](){ + hideClient(false); + workspace()->raiseClient(this); + if (m_plasmaShellSurface->panelBehavior() == PlasmaShellSurfaceInterface::PanelBehavior::AutoHide) { + m_plasmaShellSurface->showAutoHidingPanel(); + } + }); } void XdgToplevelClient::closeWindow()