wayland: Fix backend idleCallbacks destruction (#151)

This commit is contained in:
Lee Bousfield 2025-03-06 11:37:11 -06:00 committed by GitHub
parent b236a43699
commit 81498562d0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -508,7 +508,6 @@ Aquamarine::CWaylandOutput::CWaylandOutput(const std::string& name_, Hyprutils::
}
Aquamarine::CWaylandOutput::~CWaylandOutput() {
backend->idleCallbacks.clear(); // FIXME: mega hack to avoid a UAF in frame events
events.destroy.emit();
if (waylandState.xdgToplevel)
waylandState.xdgToplevel->sendDestroy();
@ -769,8 +768,12 @@ void Aquamarine::CWaylandOutput::scheduleFrame(const scheduleFrameReason reason)
if (waylandState.frameCallback)
frameScheduledWhileWaiting = true;
else
backend->idleCallbacks.emplace_back([this]() { sendFrameAndSetCallback(); });
else {
backend->idleCallbacks.emplace_back([w = self]() {
if (auto o = w.lock())
o->sendFrameAndSetCallback();
});
}
}
Aquamarine::CWaylandBuffer::CWaylandBuffer(SP<IBuffer> buffer_, Hyprutils::Memory::CWeakPointer<CWaylandBackend> backend_) : buffer(buffer_), backend(backend_) {