summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2023-02-24 11:31:49 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2023-02-27 10:11:56 +0000
commit638b27505a7873289427943f0062f00729c8ac7a (patch)
treeb84291152093d8f64d44f02f439cded1718cc1db
parent42ae5cca5781435f02d62d34f9e0d76ac4d4e008 (diff)
downloadqtmultimedia-638b27505a7873289427943f0062f00729c8ac7a.tar.gz
QWindowsAudioSink: don't access deleted this object
If a slot connected to stateChanged deletes the sink (ie. because the sink went idle and the source has no more data), then we must not access the errorState member anymore. Fixes a crash seen occasionally in the Qt TextToSpeech test. Change-Id: I5f348844d73100ad4ca5f6e15b3493707f33746e Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Doris Verria <doris.verria@qt.io> (cherry picked from commit 7ae01fd8b637b59d0c1a0664e27ffd120c1f2deb) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/multimedia/windows/qwindowsaudiosink.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/multimedia/windows/qwindowsaudiosink.cpp b/src/multimedia/windows/qwindowsaudiosink.cpp
index deb660ec3..f0a58ccda 100644
--- a/src/multimedia/windows/qwindowsaudiosink.cpp
+++ b/src/multimedia/windows/qwindowsaudiosink.cpp
@@ -19,6 +19,7 @@
#include <QtCore/QDataStream>
#include <QtCore/qtimer.h>
#include <QtCore/qloggingcategory.h>
+#include <QtCore/qpointer.h>
#include <private/qaudiohelpers_p.h>
@@ -90,8 +91,11 @@ void QWindowsAudioSink::deviceStateChange(QAudio::State state, QAudio::Error err
qCDebug(qLcAudioOutput) << "Audio client stopped";
}
+ QPointer<QWindowsAudioSink> thisGuard(this);
deviceState = state;
emit stateChanged(deviceState);
+ if (!thisGuard)
+ return;
}
if (error != errorState) {