[vlc-devel] [PATCH] qt: playlist: ensure we don't add zero media

Alexandre Janniaux ajanni at videolabs.io
Wed Oct 9 19:02:49 CEST 2019


It might already assert when calling vlc_playlist_GoTo but it doesn't
assert when startPlaying is false.
---
 modules/gui/qt/components/playlist/playlist_controller.cpp | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/modules/gui/qt/components/playlist/playlist_controller.cpp b/modules/gui/qt/components/playlist/playlist_controller.cpp
index 8b0137138e7..11933b3d84b 100644
--- a/modules/gui/qt/components/playlist/playlist_controller.cpp
+++ b/modules/gui/qt/components/playlist/playlist_controller.cpp
@@ -361,6 +361,9 @@ PlaylistControllerModel::append(const QVector<Media> &media, bool startPlaying)
     PlaylistLocker locker(d->m_playlist);

     auto rawMedia = toRaw<input_item_t *>(media);
+    /* We can't append an empty media. */
+    assert(rawMedia.size() > 0);
+
     int ret = vlc_playlist_Append(d->m_playlist,
                                   rawMedia.constData(), rawMedia.size());
     if (ret != VLC_SUCCESS)
@@ -382,6 +385,9 @@ PlaylistControllerModel::insert(size_t index, const QVector<Media> &media, bool
     PlaylistLocker locker(d->m_playlist);

     auto rawMedia = toRaw<input_item_t *>(media);
+    /* We can't insert an empty media. */
+    assert(rawMedia.size() > 0);
+
     int ret = vlc_playlist_RequestInsert(d->m_playlist, index,
                                          rawMedia.constData(), rawMedia.size());
     if (ret != VLC_SUCCESS)
--
2.23.0


More information about the vlc-devel mailing list