summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@qt.io>2023-04-21 14:07:53 +0200
committerJoerg Bornemann <joerg.bornemann@qt.io>2023-04-24 06:05:35 +0000
commitd7c1429b5515c38288e3a33992bf2582c243df5a (patch)
treef41a66ef7da594da2f1576f412e2c98b515efb49
parentbc11658197a8e1e401351459882cca6542c0ecd1 (diff)
downloadqtmultimedia-d7c1429b5515c38288e3a33992bf2582c243df5a.tar.gz
Fix crash with sequential QIODevice as media source on Windows
The sample in QTBUG-110005 uses a QNetworkReply as source for QMediaPlayer. This is a sequential QIODevice. As such, it doesn't have the concept of size. The sequence leading to the crash is - BeginCreateObjectFromByteStream() is called - MFStream::GetLength() return zero - that's why MFStream::BeginRead() is not called, and m_currentReadResult stays nullptr - QNetworkReply::readyRead() is emitted - MFStream::doRead() is called, because of the latter signal - MFStream::doRead() accesses m_currentReadResult, which is still nullptr (see above), and we witness the crash The desirable sequence is (as one can inspect by playing a video from a qrc:// URL): - BeginCreateObjectFromByteStream() is called - MFStream::GetLength() returns the video stream's size - MFStream::BeginRead() is called and initializes m_currentReadResult - MFStream::BeginRead() posts a custom event to the MFStream object - MFStream::doRead() is called when handling that custom event - MFStream::EndRead() tears down m_currentReadResult There is never a situation where QIODevice::readRead() should trigger a MFStream::doRead(). Calling doRead() outside of the BeginRead()/EndRead() pair cannot work. Therefore, this patch removes the handling of the stream's readyRead() signal. Note that this patch only fixes the crash in favor of an error code that's written to the program's console. Handling sequential QIODevice streams will require some more work. See further comments in the issue. Pick-to: 6.5 6.2 Fixes: QTBUG-110005 Change-Id: I2fc70f873a2e3a257e8e081d83862c53dabb6cac Reviewed-by: Lars Knoll <lars@knoll.priv.no> Reviewed-by: Artem Dyomin <artem.dyomin@qt.io>
-rw-r--r--src/plugins/multimedia/windows/mfstream.cpp7
-rw-r--r--src/plugins/multimedia/windows/mfstream_p.h3
2 files changed, 0 insertions, 10 deletions
diff --git a/src/plugins/multimedia/windows/mfstream.cpp b/src/plugins/multimedia/windows/mfstream.cpp
index abbf45c9f..fb37ce293 100644
--- a/src/plugins/multimedia/windows/mfstream.cpp
+++ b/src/plugins/multimedia/windows/mfstream.cpp
@@ -18,7 +18,6 @@ MFStream::MFStream(QIODevice *stream, bool ownStream)
//to make sure invocations on stream
//are happened in the same thread of stream object
this->moveToThread(stream->thread());
- connect(stream, &QIODevice::readyRead, this, &MFStream::handleReadyRead);
}
MFStream::~MFStream()
@@ -252,12 +251,6 @@ void MFStream::doRead()
}
}
-
-void MFStream::handleReadyRead()
-{
- doRead();
-}
-
void MFStream::customEvent(QEvent *event)
{
if (event->type() != QEvent::User) {
diff --git a/src/plugins/multimedia/windows/mfstream_p.h b/src/plugins/multimedia/windows/mfstream_p.h
index b8868a01e..a5221ed75 100644
--- a/src/plugins/multimedia/windows/mfstream_p.h
+++ b/src/plugins/multimedia/windows/mfstream_p.h
@@ -114,9 +114,6 @@ private:
void doRead();
-private Q_SLOTS:
- void handleReadyRead();
-
protected:
void customEvent(QEvent *event) override;
IMFAsyncResult *m_currentReadResult;