Jelajahi Sumber

MacOSX/Framework/VLCMediaList,VLCMediaListAspect: Correct the sanity check for added item.

Pierre d'Herbemont 17 tahun lalu
induk
melakukan
11d947f40f
2 mengubah file dengan 4 tambahan dan 4 penghapusan
  1. 2 2
      Sources/VLCMediaList.m
  2. 2 2
      Sources/VLCMediaListAspect.m

+ 2 - 2
Sources/VLCMediaList.m

@@ -306,8 +306,8 @@ static void HandleMediaListItemDeleted( const libvlc_event_t * event, void * use
         int index = [[args objectForKey:@"index"] intValue];
         VLCMedia * media = [args objectForKey:@"media"];
         /* Sanity check */
-        if( index && index >= [cachedMedia count] )
-            index = [cachedMedia count] - 1;
+        if( index && index > [cachedMedia count] )
+            index = [cachedMedia count];
         [cachedMedia insertObject:media atIndex:index];
     }
     [self didChange:NSKeyValueChangeInsertion valuesAtIndexes:[NSIndexSet indexSetWithIndexesInRange:range] forKey:@"media"];

+ 2 - 2
Sources/VLCMediaListAspect.m

@@ -264,8 +264,8 @@ static void HandleMediaListViewItemDeleted( const libvlc_event_t * event, void *
         [node setMedia:media];
         [node setChildren:[self childrenAtIndex:index]];
         /* Sanity check */
-        if( index && index >= [cachedNode count] )
-            index = [cachedNode count] - 1;
+        if( index && index > [cachedNode count] )
+            index = [cachedNode count];
         [cachedNode insertObject:node atIndex:index];
     }
     [self didChange:NSKeyValueChangeInsertion valuesAtIndexes:[NSIndexSet indexSetWithIndexesInRange:range] forKey:@"node"];