From d0a0c70d9ceeb9f6a309275770f38f80b5b892e6 Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Thu, 12 Aug 2021 13:10:20 +0300 Subject: [PATCH] Add aboutToBeDestroyed signal to various xdg-shell classes With the aboutToBeDestroyed signal, the compositor will be able to perform cleanup before the QObject::destroyed signal is emitted, which saves us some nullptr checks. --- src/wayland/xdgshell_interface.cpp | 3 +++ src/wayland/xdgshell_interface.h | 15 +++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/src/wayland/xdgshell_interface.cpp b/src/wayland/xdgshell_interface.cpp index ed95ed7157..13d40865db 100644 --- a/src/wayland/xdgshell_interface.cpp +++ b/src/wayland/xdgshell_interface.cpp @@ -182,6 +182,7 @@ XdgSurfaceInterfacePrivate *XdgSurfaceInterfacePrivate::get(XdgSurfaceInterface void XdgSurfaceInterfacePrivate::xdg_surface_destroy_resource(Resource *resource) { Q_UNUSED(resource) + Q_EMIT q->aboutToBeDestroyed(); XdgShellInterfacePrivate::get(shell)->unregisterXdgSurface(q); delete q; } @@ -374,6 +375,7 @@ void XdgToplevelInterfacePrivate::reset() void XdgToplevelInterfacePrivate::xdg_toplevel_destroy_resource(Resource *resource) { Q_UNUSED(resource) + Q_EMIT q->aboutToBeDestroyed(); delete q; } @@ -695,6 +697,7 @@ void XdgPopupInterfacePrivate::reset() void XdgPopupInterfacePrivate::xdg_popup_destroy_resource(Resource *resource) { Q_UNUSED(resource) + Q_EMIT q->aboutToBeDestroyed(); delete q; } diff --git a/src/wayland/xdgshell_interface.h b/src/wayland/xdgshell_interface.h index 3d7bdc7e62..fcd3154a5f 100644 --- a/src/wayland/xdgshell_interface.h +++ b/src/wayland/xdgshell_interface.h @@ -162,6 +162,11 @@ public: static XdgSurfaceInterface *get(::wl_resource *resource); Q_SIGNALS: + /** + * This signal is emitted when the xdg-surface is about to be destroyed. + */ + void aboutToBeDestroyed(); + /** * This signal is emitted when a configure event with serial \a serial has been acknowledged. */ @@ -280,6 +285,11 @@ public: static XdgToplevelInterface *get(::wl_resource *resource); Q_SIGNALS: + /** + * This signal is emitted when the xdg-toplevel is about to be destroyed. + */ + void aboutToBeDestroyed(); + /** * This signal is emitted when the xdg-toplevel has commited the initial state and wants to * be configured. After initializing the toplevel, you must send a configure event. @@ -537,6 +547,11 @@ public: static XdgPopupInterface *get(::wl_resource *resource); Q_SIGNALS: + /** + * This signal is emitted when the xdg-popup is about to be destroyed. + */ + void aboutToBeDestroyed(); + /** * This signal is emitted when the xdg-popup has commited the initial state and wants to * be configured. After initializing the popup, you must send a configure event.