[vlc-commits] qt: update the current item in the PlaylistController on items updated callback

Pierre Lamot git at videolan.org
Thu Feb 20 13:56:41 CET 2020


vlc | branch: master | Pierre Lamot <pierre at videolabs.io> | Wed Feb 12 18:19:50 2020 +0100| [3200ea3dcfd5d6e7cbed9982aea6925399fb7058] | committer: Jean-Baptiste Kempf

qt: update the current item in the PlaylistController on items updated callback

  The current item can change without having the current index changing.

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=3200ea3dcfd5d6e7cbed9982aea6925399fb7058
---

 modules/gui/qt/playlist/playlist_controller.cpp | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/modules/gui/qt/playlist/playlist_controller.cpp b/modules/gui/qt/playlist/playlist_controller.cpp
index 3bbebe3b89..9abc3725fe 100644
--- a/modules/gui/qt/playlist/playlist_controller.cpp
+++ b/modules/gui/qt/playlist/playlist_controller.cpp
@@ -156,6 +156,14 @@ on_playlist_items_updated(vlc_playlist_t *playlist, size_t index,
         if (that->m_playlist != playlist)
             return;
         emit that->q_func()->itemsUpdated(index, vec);
+        if (that->m_currentIndex != -1) {
+            size_t currentIndex = static_cast<size_t>(that->m_currentIndex);
+            if (currentIndex >= index && currentIndex < index + len)
+            {
+                that->m_currentItem = vec[currentIndex - index];
+                emit that->q_func()->currentItemChanged();
+            }
+        }
     });
 }
 



More information about the vlc-commits mailing list