[vlc-commits] macosx: Fix model rebuilding after drop operation

David Fuhrmann git at videolan.org
Wed Aug 8 23:09:19 CEST 2018


vlc/vlc-3.0 | branch: master | David Fuhrmann <dfuhrmann at videolan.org> | Wed Aug  8 23:02:31 2018 +0200| [d3ea392e08a9773a5251b0d96fef6c3a99ce8cf7] | committer: David Fuhrmann

macosx: Fix model rebuilding after drop operation

The old code does not take into account the index shifts if
dragging an item down the list.
Easy fix is to reload the whole model for now.

(cherry picked from commit 7cb147a34148621551e89cdfe0448244f34252b6)
Signed-off-by: David Fuhrmann <dfuhrmann at videolan.org>

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

 modules/gui/macosx/VLCPLModel.m | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/modules/gui/macosx/VLCPLModel.m b/modules/gui/macosx/VLCPLModel.m
index 2ca2fae823..5ea1d46603 100644
--- a/modules/gui/macosx/VLCPLModel.m
+++ b/modules/gui/macosx/VLCPLModel.m
@@ -705,14 +705,19 @@ static int VolumeUpdated(vlc_object_t *p_this, const char *psz_var,
         PL_UNLOCK;
         free(pp_items);
 
+        // FIXME: Fix below code to avoid rebuilding the whole model
         // rebuild our model
-        NSUInteger filteredItemsCount = [o_filteredItems count];
-        for(NSUInteger i = 0; i < filteredItemsCount; ++i) {
-            VLCPLItem *o_item = [o_filteredItems objectAtIndex:i];
-            NSLog(@"delete child from parent %p", [o_item parent]);
-            [[o_item parent] deleteChild:o_item];
-            [targetItem addChild:o_item atPos:index + i];
-        }
+//        NSUInteger filteredItemsCount = [o_filteredItems count];
+//        for(int i = 0; i < filteredItemsCount; ++i) {
+//            VLCPLItem *o_item = [o_filteredItems objectAtIndex:i];
+//            NSLog(@"delete child from parent %p", [o_item parent]);
+//            [[o_item parent] deleteChild:o_item];
+//            [targetItem addChild:o_item atPos:(int)index + i];
+//        }
+
+        PL_LOCK;
+        [self rebuildVLCPLItem:_rootItem];
+        PL_UNLOCK;
 
         [_outlineView reloadData];
 



More information about the vlc-commits mailing list