Commit 2a3b34ae authored by David Edmundson's avatar David Edmundson
Browse files

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
parent a2489a41
......@@ -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();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment