diff options
author | VaL Doroshchuk <valentyn.doroshchuk@qt.io> | 2020-06-25 16:06:43 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2020-06-30 16:38:33 +0000 |
commit | 0377d99f1c2a7f988c5cae4ae5d91fa411e6194a (patch) | |
tree | 9a3cf4b8dbabd1e294c4de445ada0f74ed401ec5 | |
parent | 8337692ea357da48e8914e6ab87d6cb6baf17dc7 (diff) | |
download | qtmultimedia-0377d99f1c2a7f988c5cae4ae5d91fa411e6194a.tar.gz |
Don't map QMemoryVideoBuffer when there is no data inside
Task-number: QTBUG-85202
Change-Id: If40af4af211af86311c0e04a8bdd0627dc34a939
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
(cherry picked from commit d97efea0caaa9741f21e7e30b394d292ea80c9b0)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | src/multimedia/video/qmemoryvideobuffer.cpp | 2 | ||||
-rw-r--r-- | tests/auto/unit/qvideoframe/tst_qvideoframe.cpp | 12 |
2 files changed, 13 insertions, 1 deletions
diff --git a/src/multimedia/video/qmemoryvideobuffer.cpp b/src/multimedia/video/qmemoryvideobuffer.cpp index e05210d9d..febcd66c8 100644 --- a/src/multimedia/video/qmemoryvideobuffer.cpp +++ b/src/multimedia/video/qmemoryvideobuffer.cpp @@ -101,7 +101,7 @@ uchar *QMemoryVideoBuffer::map(MapMode mode, int *numBytes, int *bytesPerLine) { Q_D(QMemoryVideoBuffer); - if (d->mapMode == NotMapped && d->data.data() && mode != NotMapped) { + if (d->mapMode == NotMapped && d->data.size() && mode != NotMapped) { d->mapMode = mode; if (numBytes) diff --git a/tests/auto/unit/qvideoframe/tst_qvideoframe.cpp b/tests/auto/unit/qvideoframe/tst_qvideoframe.cpp index bb77b7cca..e99c4bf77 100644 --- a/tests/auto/unit/qvideoframe/tst_qvideoframe.cpp +++ b/tests/auto/unit/qvideoframe/tst_qvideoframe.cpp @@ -31,6 +31,7 @@ #include <QtTest/QtTest> #include <qvideoframe.h> +#include "private/qmemoryvideobuffer_p.h" #include <QtGui/QImage> #include <QtCore/QPointer> #include <QtMultimedia/private/qtmultimedia-config_p.h> @@ -89,6 +90,8 @@ private slots: void image_data(); void image(); + + void emptyData(); }; Q_DECLARE_METATYPE(QImage::Format) @@ -1299,6 +1302,15 @@ void tst_QVideoFrame::image() QCOMPARE(img.bytesPerLine(), bytesPerLine); } +void tst_QVideoFrame::emptyData() +{ + QByteArray data(nullptr, 0); + QVideoFrame f(new QMemoryVideoBuffer(data, 600), + QSize(800, 600), + QVideoFrame::Format_ARGB32); + QVERIFY(!f.map(QAbstractVideoBuffer::ReadOnly)); +} + QTEST_MAIN(tst_QVideoFrame) #include "tst_qvideoframe.moc" |