diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2023-02-24 11:31:49 +0100 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2023-02-27 10:57:28 +0000 |
commit | 5743d07aa7d55690188170b8b16e372a561951f7 (patch) | |
tree | 1c2c0dfec85200b7637cac70b69609c1384fd78a | |
parent | ea28fc584c1836ac042d621753bdf12c8431a5c4 (diff) | |
download | qtmultimedia-5743d07aa7d55690188170b8b16e372a561951f7.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: Volker Hilsheimer <volker.hilsheimer@qt.io>
-rw-r--r-- | src/multimedia/windows/qwindowsaudiosink.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/multimedia/windows/qwindowsaudiosink.cpp b/src/multimedia/windows/qwindowsaudiosink.cpp index edde1fa52..69b95dc49 100644 --- a/src/multimedia/windows/qwindowsaudiosink.cpp +++ b/src/multimedia/windows/qwindowsaudiosink.cpp @@ -18,6 +18,7 @@ #include <QtEndian> #include <QtCore/QDataStream> #include <QtCore/qtimer.h> +#include <QtCore/qpointer.h> #include <private/qaudiohelpers_p.h> @@ -112,8 +113,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) { |