mirror of
https://git.outfoxxed.me/quickshell/quickshell.git
synced 2025-11-04 19:04:56 +11:00
services/pipewire: destroy qml ifaces early to avoid user callbacks
Consumers of defaultAudio*Changed signals can run code between safeDestroy being called and PwObjectIface destruction due to signal connection order. This change destroys ifaces earlier so they are nulled by the time a changed signal is fired from destruction, preventing access between ~PwNode() and ~QObject() completion. Fixes #116 #122 #124
This commit is contained in:
parent
201c559dcd
commit
91dcb41d22
2 changed files with 14 additions and 1 deletions
|
|
@ -18,6 +18,16 @@
|
|||
|
||||
namespace qs::service::pipewire {
|
||||
|
||||
PwObjectIface::PwObjectIface(PwBindableObject* object): QObject(object), object(object) {
|
||||
// We want to destroy the interface before QObject::destroyed is fired, as handlers
|
||||
// connected before PwObjectIface will run first and emit signals that hit user code,
|
||||
// which can then try to reference the iface again after ~PwNode() has been called but
|
||||
// before ~QObject() has finished.
|
||||
QObject::connect(object, &PwBindableObject::destroying, this, &PwObjectIface::onObjectDestroying);
|
||||
}
|
||||
|
||||
void PwObjectIface::onObjectDestroying() { delete this; }
|
||||
|
||||
void PwObjectIface::ref() {
|
||||
this->refcount++;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue