[vlc-commits] macosx: fix off-by-one when deleting items from the playlist model
Felix Paul Kühne
git at videolan.org
Thu Jan 31 17:58:42 CET 2019
vlc | branch: master | Felix Paul Kühne <felix at feepk.net> | Thu Jan 31 17:55:23 2019 +0100| [e346a21d35910fe7c9d04d851da75dd05028b966] | committer: Felix Paul Kühne
macosx: fix off-by-one when deleting items from the playlist model
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=e346a21d35910fe7c9d04d851da75dd05028b966
---
modules/gui/macosx/VLCPlaylistController.m | 5 ++---
modules/gui/macosx/VLCPlaylistModel.h | 2 +-
modules/gui/macosx/VLCPlaylistModel.m | 4 ++--
3 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/modules/gui/macosx/VLCPlaylistController.m b/modules/gui/macosx/VLCPlaylistController.m
index e4aa8e3736..22b604db93 100644
--- a/modules/gui/macosx/VLCPlaylistController.m
+++ b/modules/gui/macosx/VLCPlaylistController.m
@@ -192,9 +192,8 @@ static const struct vlc_playlist_callbacks playlist_callbacks = {
{
NSLog(@"%s", __func__);
- for (size_t i = index + numberOfItems; i > index; i--) {
- [_playlistModel removeItemAtIndex:i];
- }
+ NSRange range = NSMakeRange(index, numberOfItems);
+ [_playlistModel removeItemsInRange:range];
[_playlistDataSource performSelectorOnMainThread:@selector(playlistUpdated) withObject:nil waitUntilDone:NO];
}
diff --git a/modules/gui/macosx/VLCPlaylistModel.h b/modules/gui/macosx/VLCPlaylistModel.h
index 855d622b86..601c5af44d 100644
--- a/modules/gui/macosx/VLCPlaylistModel.h
+++ b/modules/gui/macosx/VLCPlaylistModel.h
@@ -37,7 +37,7 @@ NS_ASSUME_NONNULL_BEGIN
- (VLCPlaylistItem *)playlistItemAtIndex:(NSInteger)index;
- (void)addItem:(vlc_playlist_item_t *)item;
- (void)addItem:(vlc_playlist_item_t *)item atIndex:(size_t)index;
-- (void)removeItemAtIndex:(size_t)index;
+- (void)removeItemsInRange:(NSRange)range;
- (void)updateItemAtIndex:(size_t)index;
@end
diff --git a/modules/gui/macosx/VLCPlaylistModel.m b/modules/gui/macosx/VLCPlaylistModel.m
index 2183b76f8d..5b9246d869 100644
--- a/modules/gui/macosx/VLCPlaylistModel.m
+++ b/modules/gui/macosx/VLCPlaylistModel.m
@@ -75,9 +75,9 @@
[_playlistArray insertObject:playlistItem atIndex:index];
}
-- (void)removeItemAtIndex:(size_t)index
+- (void)removeItemsInRange:(NSRange)range
{
- [_playlistArray removeObjectAtIndex:index];
+ [_playlistArray removeObjectsInRange:range];
}
- (void)updateItemAtIndex:(size_t)index
More information about the vlc-commits
mailing list