From 71c4dab8d0881988bbe92b94e73bec0b4584ad2a Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Sat, 21 Dec 2024 11:49:56 +0400 Subject: [PATCH] QWaylandWindow: prevent a crash when calling requestXdgActivationToken It could crash if it's called when there's no mShellSurface Pick-to: 6.9 6.8 Change-Id: I9b279e915ea661b121da672ebd46be458a1a9218 Reviewed-by: David Edmundson --- src/plugins/platforms/wayland/qwaylandwindow.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/plugins/platforms/wayland/qwaylandwindow.cpp b/src/plugins/platforms/wayland/qwaylandwindow.cpp index 393f33cfd47..7b46ba22d54 100644 --- a/src/plugins/platforms/wayland/qwaylandwindow.cpp +++ b/src/plugins/platforms/wayland/qwaylandwindow.cpp @@ -1787,12 +1787,20 @@ void QWaylandWindow::setOpaqueArea(const QRegion &opaqueArea) void QWaylandWindow::requestXdgActivationToken(uint serial) { + if (!mShellSurface) { + qCWarning(lcQpaWayland) << "requestXdgActivationToken is called with no surface role created, emitting synthetic signal"; + Q_EMIT xdgActivationTokenCreated({}); + return; + } mShellSurface->requestXdgActivationToken(serial); } void QWaylandWindow::setXdgActivationToken(const QString &token) { - mShellSurface->setXdgActivationToken(token); + if (mShellSurface) + mShellSurface->setXdgActivationToken(token); + else + qCWarning(lcQpaWayland) << "setXdgActivationToken is called with no surface role created, token" << token << "discarded"; } void QWaylandWindow::addChildPopup(QWaylandWindow *child)