[vlc-commits] [Git][videolan/vlc][master] macosx: Fix crash when clicking local locations in Browse view in list view mode

Felix Paul Kühne (@fkuehne) gitlab at videolan.org
Fri Apr 11 04:53:49 UTC 2025



Felix Paul Kühne pushed to branch master at VideoLAN / VLC


Commits:
dbc5acf1 by Claudio Cambra at 2025-04-11T04:53:35+00:00
macosx: Fix crash when clicking local locations in Browse view in list view mode

- - - - -


1 changed file:

- modules/gui/macosx/library/media-source/VLCMediaSourceBaseDataSource.m


Changes:

=====================================
modules/gui/macosx/library/media-source/VLCMediaSourceBaseDataSource.m
=====================================
@@ -49,7 +49,7 @@ NSString * const VLCMediaSourceBaseDataSourceNodeChanged = @"VLCMediaSourceBaseD
 @interface VLCMediaSourceBaseDataSource () <NSCollectionViewDataSource, NSCollectionViewDelegate, NSTableViewDelegate, NSTableViewDataSource>
 {
     NSArray<VLCMediaSource *> *_mediaSources;
-    NSArray *_discoveredLANdevices;
+    NSArray<VLCInputNode *> *_discoveredLANdevices;
     BOOL _gridViewMode;
 }
 @end
@@ -346,7 +346,7 @@ referenceSizeForHeaderInSection:(NSInteger)section
          * so the problem is well hidden and does not need this work-around */
         _discoveredLANdevices = nil;
 
-        NSMutableArray *currentDevices;
+        NSMutableArray<VLCInputNode *> *currentDevices;
         @synchronized (_mediaSources) {
             const NSInteger mediaSourceCount = _mediaSources.count;
             currentDevices = [[NSMutableArray alloc] initWithCapacity:mediaSourceCount];
@@ -401,14 +401,22 @@ referenceSizeForHeaderInSection:(NSInteger)section
         return;
     }
 
-    VLCMediaSource * const mediaSource = _mediaSources[selectedRow];
-
-    VLCInputNode *childNode;
+    VLCMediaSource *mediaSource = nil;
+    VLCInputNode *childNode = nil;
     if (_mediaSourceMode == VLCMediaSourceModeLAN) {
+        NSUInteger currentIter = 0;
+        NSInteger remainingRow = selectedRow;
+        while (currentIter < _mediaSources.count && remainingRow >= _mediaSources[currentIter].rootNode.numberOfChildren) {
+            remainingRow -= _mediaSources[currentIter].rootNode.numberOfChildren;
+            currentIter++;
+        }
+        mediaSource = _mediaSources[currentIter];
         childNode = _discoveredLANdevices[selectedRow];
     } else {
+        mediaSource = _mediaSources[selectedRow];
         childNode = mediaSource.rootNode;
     }
+    NSAssert(mediaSource != nil, @"Media source should not be nil");
     NSAssert(childNode != nil, @"Child node should not be nil");
 
     [self configureChildDataSourceWithNode:childNode andMediaSource:mediaSource];



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/dbc5acf1d3bd84fa948815cdfa8d7ca84670e87d

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/dbc5acf1d3bd84fa948815cdfa8d7ca84670e87d
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list