[vlc-commits] [Git][videolan/vlc][master] macosx: Perform group cache refresh if group change affects cache membership or ordering

Claudio Cambra (@claucambra) gitlab at videolan.org
Sat Oct 10 19:31:48 UTC 2026



Claudio Cambra pushed to branch master at VideoLAN / VLC


Commits:
465c2b08 by Claudio Cambra at 2026-10-10T18:46:52+00:00
macosx: Perform group cache refresh if group change affects cache membership or ordering

This happens if e.g. using alphabetical ordering and the group name changes

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -


1 changed file:

- modules/gui/macosx/library/VLCLibraryModel.m


Changes:

=====================================
modules/gui/macosx/library/VLCLibraryModel.m
=====================================
@@ -2245,33 +2245,33 @@ static void libraryCallback(void *p_data, const vlc_ml_event_t *p_event)
     }
 
     dispatch_barrier_async(_groupCacheModificationQueue, ^{
-        NSArray<VLCMediaLibraryGroup *> * const cachedGroups = self->_cachedListOfGroups;
-        if (cachedGroups == nil) {
-            return;
-        }
-
-        const NSUInteger groupIdx = 
-            [cachedGroups indexOfObjectPassingTest:^BOOL(VLCMediaLibraryGroup * const group,
-                                                         const NSUInteger __unused idx,
-                                                         BOOL * const __unused stop) {
-            NSAssert(group != nil, @"Cache list should not contain nil groups");
-            return group.libraryID == itemId;
-        }];
+        [self performCacheMutationForGetter:@selector(cachedListOfGroups) block:^{
+            NSArray<VLCMediaLibraryGroup *> * const cachedGroups = self->_cachedListOfGroups;
+            if (cachedGroups == nil) {
+                return;
+            }
 
-        if (groupIdx == NSNotFound) {
-            NSLog(@"Could not handle update of group with id %lld in model", itemId);
-            return;
-        }
+            const NSUInteger groupIdx =
+                [cachedGroups indexOfObjectPassingTest:^BOOL(VLCMediaLibraryGroup * const group,
+                                                             const NSUInteger __unused idx,
+                                                             BOOL * const __unused stop) {
+                NSAssert(group != nil, @"Cache list should not contain nil groups");
+                return group.libraryID == itemId;
+            }];
+            VLCMediaLibraryGroup * const previousGroup = groupIdx == NSNotFound ? nil : cachedGroups[groupIdx];
+            if ([self shouldReloadCacheForUpdatedItem:group previousItem:previousGroup]) {
+                [self resetCachedListOfGroups];
+                return;
+            }
 
-        NSMutableArray * const mutableGroups = cachedGroups.mutableCopy;
-        [mutableGroups replaceObjectAtIndex:groupIdx withObject:group];
-        [self performCacheMutationForGetter:@selector(cachedListOfGroups) block:^{
+            NSMutableArray * const mutableGroups = cachedGroups.mutableCopy;
+            [mutableGroups replaceObjectAtIndex:groupIdx withObject:group];
             self->_cachedListOfGroups = mutableGroups.copy;
-        }];
 
-        [self performAfterCacheWritesOnQueue:self->_groupCacheModificationQueue block:^{
-            [self->_defaultNotificationCenter postNotificationName:VLCLibraryModelGroupUpdated
-                                                            object:group];
+            [self performAfterCacheWritesOnQueue:self->_groupCacheModificationQueue block:^{
+                [self->_defaultNotificationCenter postNotificationName:VLCLibraryModelGroupUpdated
+                                                                object:group];
+            }];
         }];
     });
 }



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

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/465c2b089cafb93d0d847dc6fa28177e0b5a9061
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