macosx: Fix model rebuilding after drop operation
authorDavid Fuhrmann <dfuhrmann@videolan.org>
Wed, 8 Aug 2018 21:02:31 +0000 (23:02 +0200)
committerDavid Fuhrmann <dfuhrmann@videolan.org>
Wed, 8 Aug 2018 21:05:29 +0000 (23:05 +0200)
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.

modules/gui/macosx/VLCPLModel.m

index baf898e..7a2b168 100644 (file)
@@ -713,14 +713,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(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];
-        }
+//        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];