From c1a18d3edf3208cebd4538eac513160430be8461 Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Sat, 21 Dec 2024 11:48:46 +0400 Subject: [PATCH] QWaylandXdgSurface: Always clean up xdg_activation_token in more places If the token arrives after the surface has already been destroyed, the lambda containing the deleteLater would never be called. Amends 638c9bd2595704606b53ba319c67568b479f9fc0 Pick-to: 6.9 6.8 Change-Id: Ibebeb441d9c115b0203703b8042a58e986ccff47 Reviewed-by: Vlad Zahorodnii Reviewed-by: Kai Uwe Broulik --- .../shellintegration/xdg-shell/qwaylandxdgshell.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 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 1431e84b2b0..29489acda89 100644 --- a/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp +++ b/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp @@ -603,11 +603,8 @@ void QWaylandXdgSurface::requestXdgActivationToken(quint32 serial) if (auto *activation = m_shell->activation()) { auto tokenProvider = activation->requestXdgActivationToken( m_shell->m_display, m_window->wlSurface(), serial, m_appId); - connect(tokenProvider, &QWaylandXdgActivationTokenV1::done, this, - [this, tokenProvider](const QString &token) { - Q_EMIT m_window->xdgActivationTokenCreated(token); - tokenProvider->deleteLater(); - }); + connect(tokenProvider, &QWaylandXdgActivationTokenV1::done, m_window, &QWaylandWindow::xdgActivationTokenCreated); + connect(tokenProvider, &QWaylandXdgActivationTokenV1::done, tokenProvider, &QObject::deleteLater); } else { QWaylandShellSurface::requestXdgActivationToken(serial); } @@ -639,10 +636,10 @@ void QWaylandXdgSurface::setAlertState(bool enabled) const auto tokenProvider = activation->requestXdgActivationToken( m_shell->m_display, m_window->wlSurface(), std::nullopt, m_appId); connect(tokenProvider, &QWaylandXdgActivationTokenV1::done, this, - [this, tokenProvider](const QString &token) { + [this](const QString &token) { m_shell->activation()->activate(token, m_window->wlSurface()); - tokenProvider->deleteLater(); }); + connect(tokenProvider, &QWaylandXdgActivationTokenV1::done, tokenProvider, &QObject::deleteLater); } QString QWaylandXdgSurface::externWindowHandle()