From f9b7d5298b310e0c75ff5aafb7043c6fa0db0423 Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Tue, 26 Apr 2022 15:16:42 +0300 Subject: [PATCH] Fix testModifierOnlyShortcut If a window is destroyed before the frame is presented, the window pointer will be dangling. In order to make kwin handle that case correctly, the window is captured using a QPointer. --- src/wayland_server.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/wayland_server.cpp b/src/wayland_server.cpp index cad88456a5..fc2f2dfcc0 100644 --- a/src/wayland_server.cpp +++ b/src/wayland_server.cpp @@ -783,12 +783,15 @@ WaylandServer::LockScreenPresentationWatcher::LockScreenPresentationWatcher(Wayl { connect(server, &WaylandServer::windowAdded, this, [this](Window *window) { if (window->isLockScreen()) { - connect(window->output()->renderLoop(), &RenderLoop::framePresented, this, [this, window]() { - // only signal lockScreenShown once all outputs have been presented at least once - m_signaledOutputs << window->output(); - if (m_signaledOutputs.size() == kwinApp()->platform()->enabledOutputs().size()) { - ScreenLocker::KSldApp::self()->lockScreenShown(); - delete this; + // only signal lockScreenShown once all outputs have been presented at least once + connect(window->output()->renderLoop(), &RenderLoop::framePresented, this, [this, windowGuard = QPointer(window)]() { + // window might be destroyed before a frame is presented, so it's wrapped in QPointer + if (windowGuard) { + m_signaledOutputs << windowGuard->output(); + if (m_signaledOutputs.size() == kwinApp()->platform()->enabledOutputs().size()) { + ScreenLocker::KSldApp::self()->lockScreenShown(); + delete this; + } } }); }