]> git.sesse.net Git - vlc/commitdiff
Mac OS X gui: Fix a crash when waking up from sleep.
authorPierre d'Herbemont <pdherbemont@videolan.org>
Thu, 10 May 2007 12:24:23 +0000 (12:24 +0000)
committerPierre d'Herbemont <pdherbemont@videolan.org>
Thu, 10 May 2007 12:24:23 +0000 (12:24 +0000)
modules/gui/macosx/playlist.m

index 144f2682a4fb46331803ed9b1db8d3e7f609b89f..0d0b5450d61b51ad0ab2025893f813f089f89509 100644 (file)
 {
     id o_value = nil;
     playlist_item_t *p_item;
-    
-    if( item == nil || ![item isKindOfClass: [NSValue class]] ) return( @"error" );
+
+    /* For error handling */
+    static BOOL attempted_reload = NO;
+
+    if( item == nil || ![item isKindOfClass: [NSValue class]] )
+    {
+        /* Attempt to fix the error by asking for a data redisplay
+         * This might cause infinite loop, so add a small check */
+        if( !attempted_reload )
+        {
+            attempted_reload = YES;
+            [outlineView reloadData];
+        }
+        return @"error" ;
+    }
     
     p_item = (playlist_item_t *)[item pointerValue];
-    if( p_item == NULL )
+    if( !p_item || !p_item->p_input )
     {
-        return( @"error");
+        /* Attempt to fix the error by asking for a data redisplay
+         * This might cause infinite loop, so add a small check */
+        if( !attempted_reload )
+        {
+            attempted_reload = YES;
+            [outlineView reloadData];
+        }
+        return @"error";
     }
     
+    attempted_reload = NO;
+
     if( [[o_tc identifier] isEqualToString:@"1"] )
     {
         /* sanity check to prevent the NSString class from crashing */