]> git.sesse.net Git - vlc/blobdiff - modules/gui/macosx/MainWindow.m
osx: fix crash with --no-media-library
[vlc] / modules / gui / macosx / MainWindow.m
index 259589a2cc35b55c859c77c5e98477a4ea5fb878..2a499cf3a5fbf6822a7c2a98b71d9251c20bc24f 100644 (file)
@@ -737,14 +737,17 @@ static VLCMainWindow *_o_sharedInstance = nil;
 #pragma mark -
 #pragma mark Video Output handling
 
+- (void)videoplayWillBeStarted
+{
+    if (!b_fullscreen)
+        frameBeforePlayback = [self frame];
+}
+
 - (void)setVideoplayEnabled
 {
     BOOL b_videoPlayback = [[VLCMain sharedInstance] activeVideoPlayback];
-
-    if (b_videoPlayback) {
-        if (!b_fullscreen)
-            frameBeforePlayback = [self frame];
-    } else {
+        
+    if (!b_videoPlayback) {
         if (!b_nonembedded && (!b_nativeFullscreenMode || (b_nativeFullscreenMode && !b_fullscreen)) && frameBeforePlayback.size.width > 0 && frameBeforePlayback.size.height > 0)
             [[self animator] setFrame:frameBeforePlayback display:YES];
 
@@ -911,7 +914,7 @@ static VLCMainWindow *_o_sharedInstance = nil;
 - (NSInteger)sourceList:(PXSourceList*)aSourceList badgeValueForItem:(id)item
 {
     playlist_t * p_playlist = pl_Get(VLCIntf);
-    NSInteger i_playlist_size;
+    NSInteger i_playlist_size = 0;
 
     if ([[item identifier] isEqualToString: @"playlist"]) {
         PL_LOCK;
@@ -922,7 +925,8 @@ static VLCMainWindow *_o_sharedInstance = nil;
     }
     if ([[item identifier] isEqualToString: @"medialibrary"]) {
         PL_LOCK;
-        i_playlist_size = p_playlist->p_ml_category->i_children;
+        if (p_playlist->p_ml_category)
+            i_playlist_size = p_playlist->p_ml_category->i_children;
         PL_UNLOCK;
 
         return i_playlist_size;
@@ -1011,7 +1015,8 @@ static VLCMainWindow *_o_sharedInstance = nil;
     if ([[item identifier] isEqualToString:@"playlist"]) {
         [[[VLCMain sharedInstance] playlist] setPlaylistRoot:p_playlist->p_local_category];
     } else if ([[item identifier] isEqualToString:@"medialibrary"]) {
-        [[[VLCMain sharedInstance] playlist] setPlaylistRoot:p_playlist->p_ml_category];
+        if (p_playlist->p_ml_category)
+            [[[VLCMain sharedInstance] playlist] setPlaylistRoot:p_playlist->p_ml_category];
     } else {
         playlist_item_t * pl_item;
         PL_LOCK;