[vlc-commits] qml: ensure bound checks while manipulating the playlist in PlaylistView
Pierre Lamot
git at videolan.org
Tue Nov 19 16:50:06 CET 2019
vlc | branch: master | Pierre Lamot <pierre at videolabs.io> | Mon Nov 18 14:56:35 2019 +0100| [053f32f553a826d7bf933baeaca92908efa7b974] | committer: Jean-Baptiste Kempf
qml: ensure bound checks while manipulating the playlist in PlaylistView
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=053f32f553a826d7bf933baeaca92908efa7b974
---
modules/gui/qt/qml/playlist/PlaylistListView.qml | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
diff --git a/modules/gui/qt/qml/playlist/PlaylistListView.qml b/modules/gui/qt/qml/playlist/PlaylistListView.qml
index 367eed9888..cc3c657dd5 100644
--- a/modules/gui/qt/qml/playlist/PlaylistListView.qml
+++ b/modules/gui/qt/qml/playlist/PlaylistListView.qml
@@ -108,6 +108,8 @@ Utils.NavigableFocusScope {
view.forceActiveFocus()
if (view.mode == "move") {
var selectedIndexes = root.plmodel.getSelection()
+ if (selectedIndexes.length === 0)
+ return
var preTarget = index
/* move to _above_ the clicked item if move up, but
* _below_ the clicked item if move down */
@@ -146,7 +148,8 @@ Utils.NavigableFocusScope {
console.log("update selection select")
} else if (mode == "move") {
var selectedIndexes = root.plmodel.getSelection()
-
+ if (selectedIndexes.length === 0)
+ return
/* always move relative to the first item of the selection */
var target = selectedIndexes[0];
if (newIndex > oldIndex) {
@@ -190,6 +193,9 @@ Utils.NavigableFocusScope {
}
onActionAtIndex: {
+ if (index < 0)
+ return
+
if (mode === "select")
root.plmodel.toggleSelected(index)
else //normal
@@ -199,12 +205,16 @@ Utils.NavigableFocusScope {
function onPlay() {
let selection = root.plmodel.getSelection()
- if (selection.length > 0)
- mainPlaylistController.goTo(selection[0], true)
+ if (selection.length === 0)
+ return
+ mainPlaylistController.goTo(selection[0], true)
}
function onDelete() {
- root.plmodel.removeItems(root.plmodel.getSelection())
+ let selection = root.plmodel.getSelection()
+ if (selection.length === 0)
+ return
+ root.plmodel.removeItems(selection)
}
function _addRange(from, to) {
More information about the vlc-commits
mailing list