[vlc-commits] [Git][videolan/vlc][master] macosx: fix crash when deleting a playlist

Felix Paul Kühne (@fkuehne) gitlab at videolan.org
Mon Nov 9 15:24:51 UTC 2026



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


Commits:
aa58853d by Serhii Bykov at 2026-11-09T15:09:12+01:00
macosx: fix crash when deleting a playlist

- - - - -


2 changed files:

- modules/gui/macosx/library/playlist-library/VLCLibraryPlaylistDataSource.m
- modules/gui/macosx/library/playlist-library/VLCLibraryPlaylistViewController.m


Changes:

=====================================
modules/gui/macosx/library/playlist-library/VLCLibraryPlaylistDataSource.m
=====================================
@@ -206,42 +206,45 @@ typedef NS_ENUM(NSInteger, VLCLibraryDataSourceCacheAction) {
           withPlaylistID:(const int64_t)playlistID
                 playlist:(VLCMediaLibraryPlaylist * _Nullable const)playlist
 {
-    dispatch_barrier_async(_playlistQueue, ^{
-        NSMutableArray *mutablePlaylists = [self->_playlists mutableCopy];
-        if (mutablePlaylists == nil) {
-            return;
-        }
+    if (!NSThread.isMainThread) {
+        dispatch_async(dispatch_get_main_queue(), ^{
+            [self applyCacheAction:action withPlaylistID:playlistID playlist:playlist];
+        });
+        return;
+    }
 
-        const NSUInteger idx =
-            [mutablePlaylists indexOfObjectPassingTest:^BOOL(const VLCMediaLibraryPlaylist *item, 
-                                                             const NSUInteger __unused index,
-                                                             BOOL * const __unused stop) {
-            return item.libraryID == playlistID;
-        }];
+    NSMutableArray *mutablePlaylists = [self.playlists mutableCopy];
+    if (mutablePlaylists == nil) {
+        return;
+    }
 
-        if (idx == NSNotFound) {
-            return;
-        }
+    const NSUInteger idx =
+        [mutablePlaylists indexOfObjectPassingTest:^BOOL(const VLCMediaLibraryPlaylist *item,
+                                                         const NSUInteger __unused index,
+                                                         BOOL * const __unused stop) {
+        return item.libraryID == playlistID;
+    }];
 
-        switch (action) {
-            case VLCLibraryDataSourceCacheUpdateAction:
-                NSAssert(playlist != nil, @"Playlist must not be nil for update action");
-                if (playlist != nil) {
-                    [mutablePlaylists replaceObjectAtIndex:idx withObject:playlist];
-                }
-                break;
-            case VLCLibraryDataSourceCacheDeleteAction:
-                [mutablePlaylists removeObjectAtIndex:idx];
-                break;
-            default:
-                NSAssert(false, @"Invalid playlist cache action");
-        }
-        self->_playlists = [mutablePlaylists copy];
+    if (idx == NSNotFound) {
+        return;
+    }
 
-        dispatch_async(dispatch_get_main_queue(), ^{
-            [self reloadViewsAtIndex:idx dueToCacheAction:action];
-        });
-    });
+    switch (action) {
+        case VLCLibraryDataSourceCacheUpdateAction:
+            NSAssert(playlist != nil, @"Playlist must not be nil for update action");
+            if (playlist != nil) {
+                [mutablePlaylists replaceObjectAtIndex:idx withObject:playlist];
+            }
+            break;
+        case VLCLibraryDataSourceCacheDeleteAction:
+            [mutablePlaylists removeObjectAtIndex:idx];
+            break;
+        default:
+            NSAssert(false, @"Invalid playlist cache action");
+    }
+    self.playlists = mutablePlaylists;
+
+    [self reloadViewsAtIndex:idx dueToCacheAction:action];
 }
 
 #pragma mark - table view data source


=====================================
modules/gui/macosx/library/playlist-library/VLCLibraryPlaylistViewController.m
=====================================
@@ -335,9 +335,16 @@
 - (void)libraryModelPlaylistDeleted:(NSNotification *)notification
 {
     NSParameterAssert(notification);
-    if (self.libraryWindow.librarySegmentType == VLCLibraryPlaylistsSegmentType &&
-        !self.libraryWindow.embeddedVideoPlaybackActive) {
-        [self updatePresentedView];
+    if (self.libraryWindow.librarySegmentType != VLCLibraryPlaylistsSegmentType ||
+        self.libraryWindow.embeddedVideoPlaybackActive ||
+        [self.dataSource.libraryModel numberOfPlaylistsOfType:self.dataSource.playlistType] > 0) {
+        return;
+    }
+
+    if (self.dataSource.libraryModel.filterString.length > 0) {
+        [self.libraryWindow displayNoResultsMessage];
+    } else {
+        [self presentPlaceholderPlaylistLibraryView];
     }
 }
 



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

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/aa58853d864c15366b1e6371517d8ebed9bb5479
You're receiving this email because of your account on code.videolan.org. Manage all notifications: https://code.videolan.org/-/profile/notifications | Help: https://code.videolan.org/help




More information about the vlc-commits mailing list