Don't use Qt::UniqueConnection on a lambda

It won't detect properly, instead the same code is moved into a member
function.
This commit is contained in:
David Edmundson 2020-10-29 12:48:21 +00:00
parent 74c1b0f336
commit a8883c35a5
2 changed files with 17 additions and 14 deletions

View file

@ -313,20 +313,7 @@ void SurfaceInterfacePrivate::surface_attach(Resource *resource, struct ::wl_res
return;
}
pending.buffer = BufferInterface::get(compositor->display(), buffer);
QObject::connect(pending.buffer, &BufferInterface::aboutToBeDestroyed, q,
[this](BufferInterface *buffer) {
if (pending.buffer == buffer) {
pending.buffer = nullptr;
}
if (cached.buffer == buffer) {
cached.buffer = nullptr;
}
if (current.buffer == buffer) {
current.buffer->unref();
current.buffer = nullptr;
}
},
Qt::UniqueConnection);
QObject::connect(pending.buffer, &BufferInterface::aboutToBeDestroyed, q, &SurfaceInterface::handleBufferRemoved, Qt::UniqueConnection);
}
void SurfaceInterfacePrivate::surface_damage(Resource *, int32_t x, int32_t y, int32_t width, int32_t height)
@ -1011,4 +998,18 @@ QMatrix4x4 SurfaceInterface::surfaceToBufferMatrix() const
return d->surfaceToBufferMatrix;
}
void SurfaceInterface::handleBufferRemoved(BufferInterface *buffer)
{
if (d->pending.buffer == buffer) {
d->pending.buffer = nullptr;
}
if (d->cached.buffer == buffer) {
d->cached.buffer = nullptr;
}
if (d->current.buffer == buffer) {
d->current.buffer->unref();
d->current.buffer = nullptr;
}
}
} // namespace KWaylandServer

View file

@ -480,6 +480,8 @@ Q_SIGNALS:
void committed();
private:
void handleBufferRemoved(BufferInterface *buffer);
QScopedPointer<SurfaceInterfacePrivate> d;
friend class SurfaceInterfacePrivate;
};