MacOSX/Framework/VLCMediaList,VLCMediaListAspect: Correct the sanity check for added...
authorPierre d'Herbemont <pdherbemont@videolan.org>
Wed, 16 Jan 2008 00:25:33 +0000 (00:25 +0000)
committerPierre d'Herbemont <pdherbemont@videolan.org>
Wed, 16 Jan 2008 00:25:33 +0000 (00:25 +0000)
extras/MacOSX/Framework/Sources/VLCMediaList.m
extras/MacOSX/Framework/Sources/VLCMediaListAspect.m

index a6d0378..f6a5d19 100644 (file)
@@ -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"];
index 7361942..eeeb8d4 100644 (file)
@@ -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"];