From 2a3b34ae6a3be3cffffc997c924a6e19b8667bb3 Mon Sep 17 00:00:00 2001 From: David Edmundson Date: Tue, 24 Jul 2018 13:36:46 +0200 Subject: [PATCH] Cleanup RemoteAccess buffers on aboutToBeUnbound instead of object destruction Summary: The destructor or Resource::~Resource will delete the d-pointer used by Resource before we reach QObject::~QObject() of the resource which emits the destroyed signal. This means this lamba is accessing deleted contents. Based on https://build.kde.org/view/Frameworks/job/Frameworks%20kwayland%20kf5-qt5%20SUSEQt5.10/71/testReport/ aboutToBeUnbound is emitted before object destruction. Test Plan: Relevant unit test still passes and this lambda is still invoked. Reviewers: #kwin, romangg Reviewed By: #kwin, romangg Subscribers: romangg, kde-frameworks-devel Tags: #frameworks Differential Revision: https://phabricator.kde.org/D14291 --- src/wayland/server/remote_access_interface.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/wayland/server/remote_access_interface.cpp b/src/wayland/server/remote_access_interface.cpp index 5f7d453a37..f8610f60ff 100644 --- a/src/wayland/server/remote_access_interface.cpp +++ b/src/wayland/server/remote_access_interface.cpp @@ -241,13 +241,12 @@ void RemoteAccessManagerInterface::Private::getBufferCallback(wl_client *client, return; } - QObject::connect(rbuf, &QObject::destroyed, [p, rbuf, resource, &bh] { + QObject::connect(rbuf, &Resource::aboutToBeUnbound, p->q, [p, rbuf, resource, &bh] { if (!p->clientResources.contains(resource)) { // remote buffer destroy confirmed after client is already gone // all relevant buffers are already unreferenced return; } - qCDebug(KWAYLAND_SERVER) << "Remote buffer returned, client" << wl_resource_get_id(resource) << ", id" << rbuf->id() << ", fd" << bh.buf->fd();