[vlc-devel] [PATCH 1/1] macosx: cancel the resume dialog after switching playlist items

Clemens Werther clemenswerther at googlemail.com
Thu Jun 30 23:06:24 CEST 2016


fix bug where VLC segfaults on OSX: After switching a playlist item
while presented a resume dialog, the resume dialog still shows for
the previous item. Clicking "continue" crashes VLC.
---
 modules/gui/macosx/ResumeDialogController.h |  4 ++++
 modules/gui/macosx/ResumeDialogController.m | 25 +++++++++++++++----------
 modules/gui/macosx/VLCPlaylist.m            |  2 ++
 3 files changed, 21 insertions(+), 10 deletions(-)

diff --git a/modules/gui/macosx/ResumeDialogController.h b/modules/gui/macosx/ResumeDialogController.h
index d6d937d..7790947 100644
--- a/modules/gui/macosx/ResumeDialogController.h
+++ b/modules/gui/macosx/ResumeDialogController.h
@@ -42,6 +42,8 @@ typedef void(^CompletionBlock)(enum ResumeResult);
     IBOutlet id o_restart_btn;
     IBOutlet id o_resume_btn;
     IBOutlet id o_always_resume_btn;
+
+    NSTimer *o_countdown_timer;
 }
 
 - (IBAction)buttonClicked:(id)sender;
@@ -50,4 +52,6 @@ typedef void(^CompletionBlock)(enum ResumeResult);
 
 - (void)updateCocoaWindowLevel:(NSInteger)i_level;
 
+- (void)cancel;
+
 @end
diff --git a/modules/gui/macosx/ResumeDialogController.m b/modules/gui/macosx/ResumeDialogController.m
index 7fbfe79..9ecebf6 100644
--- a/modules/gui/macosx/ResumeDialogController.m
+++ b/modules/gui/macosx/ResumeDialogController.m
@@ -55,11 +55,6 @@
 {
     NSWindow *w = [self window];
 
-    if ([w isVisible]) {
-        msg_Err(getIntf(), "Resume dialog in use already");
-        return;
-    }
-
     currentResumeTimeout = 10;
     completionBlock = [block copy];
 
@@ -74,11 +69,11 @@
     NSString *labelString = [NSString stringWithFormat:_NS("Playback of \"%@\" will continue at %@"), o_title, [[VLCStringUtility sharedInstance] stringForTime:pos]];
     [o_text_lbl setStringValue:labelString];
 
-    NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:1
-                                             target:self
-                                           selector:@selector(updateAlertWindow:)
-                                           userInfo:nil
-                                            repeats:YES];
+    o_countdown_timer = [NSTimer scheduledTimerWithTimeInterval:1
+                                                         target:self
+                                                       selector:@selector(updateAlertWindow:)
+                                                       userInfo:nil
+                                                        repeats:YES];
 
     [w setLevel:[[[VLCMain sharedInstance] voutController] currentStatusWindowLevel]];
     [w center];
@@ -126,4 +121,14 @@
         [self.window setLevel: i_level];
 }
 
+- (void)cancel
+{
+    if (o_countdown_timer != nil) {
+        [o_countdown_timer invalidate];
+        o_countdown_timer = nil;
+    }
+
+    [[self window] close];
+}
+
 @end
diff --git a/modules/gui/macosx/VLCPlaylist.m b/modules/gui/macosx/VLCPlaylist.m
index bdf8819..d43e65b 100644
--- a/modules/gui/macosx/VLCPlaylist.m
+++ b/modules/gui/macosx/VLCPlaylist.m
@@ -867,6 +867,8 @@
 
 - (void)continuePlaybackWhereYouLeftOff:(input_thread_t *)p_input_thread
 {
+   [[[VLCMain sharedInstance] resumeDialog] cancel];
+
     NSDictionary *recentlyPlayedFiles = [[NSUserDefaults standardUserDefaults] objectForKey:@"recentlyPlayedMedia"];
     if (!recentlyPlayedFiles)
         return;
-- 
2.9.0



More information about the vlc-devel mailing list