summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTim Blechmann <tim@klingt.org>2024-04-22 08:38:57 +0800
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2024-04-23 02:17:16 +0000
commit58b2e97b3aadd77f0a5e107b64e375665f6f89f9 (patch)
treecea7c6d7d48b39c5694184b77b23ed82725eeb21
parentf47c1454fcff4d29b62d79a2045e7ebbccf57ccb (diff)
Tests: Fix use after scope
`videoFrameChanged` can be called from `~QMediaPlayer`, causing stack-use-after-scope address sanitizer errors. We need to make sure that the counters outlive the QMediaPlayer. Pick-to: 6.5 Change-Id: I05d9d225a8f5a4b8b6c8c1bf120d93d070e7fc1b Reviewed-by: Artem Dyomin <artem.dyomin@qt.io> Reviewed-by: Jøger Hansegård <joger.hansegard@qt.io> (cherry picked from commit 2713dac55412a49f79ddcec20efd667d11b3427c) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--tests/auto/integration/qmediaplayerbackend/tst_qmediaplayerbackend.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/tests/auto/integration/qmediaplayerbackend/tst_qmediaplayerbackend.cpp b/tests/auto/integration/qmediaplayerbackend/tst_qmediaplayerbackend.cpp
index 52e89a2be..3867ba577 100644
--- a/tests/auto/integration/qmediaplayerbackend/tst_qmediaplayerbackend.cpp
+++ b/tests/auto/integration/qmediaplayerbackend/tst_qmediaplayerbackend.cpp
@@ -2806,6 +2806,9 @@ void tst_QMediaPlayerBackend::lazyLoadVideo()
void tst_QMediaPlayerBackend::videoSinkSignals()
{
+ std::atomic<int> videoFrameCounter = 0;
+ std::atomic<int> videoSizeCounter = 0;
+
// TODO: come up with custom frames source,
// create the test target tst_QVideoSinkBackend,
// and move the test there
@@ -2816,9 +2819,6 @@ void tst_QMediaPlayerBackend::videoSinkSignals()
QMediaPlayer player;
player.setVideoSink(&sink);
- std::atomic<int> videoFrameCounter = 0;
- std::atomic<int> videoSizeCounter = 0;
-
player.setSource(*m_localVideoFile2);
QTRY_COMPARE(player.mediaStatus(), QMediaPlayer::MediaStatus::LoadedMedia);