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

David Fuhrmann git at videolan.org
Wed Aug 8 23:05:47 CEST 2018


vlc | branch: master | David Fuhrmann <dfuhrmann at videolan.org> | Wed Aug  8 23:02:31 2018 +0200| [7cb147a34148621551e89cdfe0448244f34252b6] | 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.

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

 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 baf898efd1..7a2b16879b 100644
--- a/modules/gui/macosx/VLCPLModel.m
+++ b/modules/gui/macosx/VLCPLModel.m
@@ -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];
 



More information about the vlc-commits mailing list