Commit 1982415f authored by David Redondo's avatar David Redondo 🏎
Browse files

Fix crash when target is destroyed before monitor

The target is saved as a QPointer inside VolumeMonitor. This is generally
a good idea since its lifetime is managed somewhere else. However in this
case this means we are not noticing when it is deleted and cannot distinguish
that from not having a set target. When the VolumeObject is deleted before
the monitor, it would fail to unset the pulseaudio callbacks resulting in
them being called after destruction.
parent 6bebee67
......@@ -46,7 +46,7 @@ void VolumeMonitor::updateVolume(qreal volume)
QPulseAudio::VolumeObject *QPulseAudio::VolumeMonitor::target() const
return m_target;
void QPulseAudio::VolumeMonitor::setTarget(QPulseAudio::VolumeObject *target)
......@@ -67,6 +67,9 @@ void QPulseAudio::VolumeMonitor::setTarget(QPulseAudio::VolumeObject *target)
m_target = target;
if (target) {
connect(target, &QObject::destroyed, this, [this] {
......@@ -59,7 +59,7 @@ private:
static void read_callback(pa_stream *s, size_t length, void *userdata);
static void suspended_callback(pa_stream *s, void *userdata);
QPointer<VolumeObject> m_target;
VolumeObject *m_target;
pa_stream *m_stream = nullptr;
qreal m_volume = 0;
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