vlc | branch: master | Felix Paul Kühne <[email protected]> | Wed Sep 25 21:41:26 
2019 +0200| [8fc06287a82f3f23587fcae52994d2aead22311d] | committer: Felix Paul 
Kühne

macosx/resume dialog: make sure the filename in question is always displayed

Previously, the file name label was set before the window was actually loaded 
so this silently failed as the object was nil. This ensures the label to be set 
once the window was loaded when resuming a media item for the first time during 
the lifetime of the app.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=8fc06287a82f3f23587fcae52994d2aead22311d
---

 .../panels/dialogs/VLCResumeDialogController.m     | 29 ++++++++++++++++------
 1 file changed, 22 insertions(+), 7 deletions(-)

diff --git a/modules/gui/macosx/panels/dialogs/VLCResumeDialogController.m 
b/modules/gui/macosx/panels/dialogs/VLCResumeDialogController.m
index 287d08c85c..952d4a5043 100644
--- a/modules/gui/macosx/panels/dialogs/VLCResumeDialogController.m
+++ b/modules/gui/macosx/panels/dialogs/VLCResumeDialogController.m
@@ -35,6 +35,8 @@
     int _currentResumeTimeout;
     CompletionBlock _completionBlock;
     NSTimer *_countdownTimer;
+    VLCInputItem *_inputItem;
+    NSInteger _lastPosition;
 }
 @end
 
@@ -63,20 +65,18 @@
     [_resumeButton setTitle:_NS("Continue playback")];
 
     [_alwaysResumeCheckbox setTitle:_NS("Always continue media playback")];
+
+    [self updateTextLabels];
 }
 
 - (void)showWindowWithItem:(VLCInputItem *)inputItem 
withLastPosition:(NSInteger)pos completionBlock:(CompletionBlock)block
 {
+    _inputItem = inputItem;
+    _lastPosition = pos;
     _currentResumeTimeout = 10;
     _completionBlock = [block copy];
 
-    NSString *restartButtonLabel = _NS("Restart playback");
-    restartButtonLabel = [restartButtonLabel stringByAppendingFormat:@" (%d)", 
_currentResumeTimeout];
-    [_restartButton setTitle:restartButtonLabel];
-
-    NSString *labelString = [NSString stringWithFormat:_NS("Playback of \"%@\" 
will continue at %@"), inputItem.title, [NSString stringWithTime:pos]];
-    [_descriptionLabel setStringValue:labelString];
-    [_alwaysResumeCheckbox setState:NSOffState];
+    [self updateTextLabels];
 
     _countdownTimer = [NSTimer scheduledTimerWithTimeInterval:1
                                                        target:self
@@ -90,6 +90,21 @@
     [window makeKeyAndOrderFront:nil];
 }
 
+- (void)updateTextLabels
+{
+    NSString *restartButtonLabel = _NS("Restart playback");
+    restartButtonLabel = [restartButtonLabel stringByAppendingFormat:@" (%d)", 
_currentResumeTimeout];
+    [_restartButton setTitle:restartButtonLabel];
+
+    if (!_inputItem) {
+        return;
+    }
+
+    NSString *labelString = [NSString stringWithFormat:_NS("Playback of \"%@\" 
will continue at %@"), _inputItem.title, [NSString 
stringWithTime:_lastPosition]];
+    [_descriptionLabel setStringValue:labelString];
+    [_alwaysResumeCheckbox setState:NSOffState];
+}
+
 - (void)updateAlertWindow:(NSTimer *)timer
 {
     --_currentResumeTimeout;

_______________________________________________
vlc-commits mailing list
[email protected]
https://mailman.videolan.org/listinfo/vlc-commits

Reply via email to