[vlc-commits] macosx: don't make the main singleton responsible for saving window states

Felix Paul Kühne git at videolan.org
Tue Jun 11 12:24:58 CEST 2019


vlc | branch: master | Felix Paul Kühne <felix at feepk.net> | Tue Jun 11 12:20:16 2019 +0200| [cce17dd0943774df175b9213fa26e6b4dfebb4f3] | committer: Felix Paul Kühne

macosx: don't make the main singleton responsible for saving window states

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

 modules/gui/macosx/main/VLCMain.m                         | 12 +++++-------
 .../gui/macosx/panels/VLCAudioEffectsWindowController.h   |  1 -
 .../gui/macosx/panels/VLCAudioEffectsWindowController.m   | 15 ++++++++++-----
 .../gui/macosx/panels/VLCVideoEffectsWindowController.h   |  2 --
 .../gui/macosx/panels/VLCVideoEffectsWindowController.m   | 15 ++++++++++-----
 5 files changed, 25 insertions(+), 20 deletions(-)

diff --git a/modules/gui/macosx/main/VLCMain.m b/modules/gui/macosx/main/VLCMain.m
index d33e8ea0e6..ce1d839691 100644
--- a/modules/gui/macosx/main/VLCMain.m
+++ b/modules/gui/macosx/main/VLCMain.m
@@ -312,20 +312,18 @@ static VLCMain *sharedInstance = nil;
     if (b_intf_terminating)
         return;
     b_intf_terminating = true;
+    NSNotificationCenter *notiticationCenter = [NSNotificationCenter defaultCenter];
 
     _continuityController = nil;
 
-    if (notification == nil)
-        [[NSNotificationCenter defaultCenter] postNotificationName: NSApplicationWillTerminateNotification object: nil];
-
-    /* save current video and audio profiles */
-    [[self videoEffectsPanel] saveCurrentProfileAtTerminate];
-    [[self audioEffectsPanel] saveCurrentProfileAtTerminate];
+    if (notification == nil) {
+        [notiticationCenter postNotificationName: NSApplicationWillTerminateNotification object: nil];
+    }
 
     libvlc_int_t *libvlc = vlc_object_instance(p_intf);
     var_DelCallback(libvlc, "intf-boss", BossCallback, (__bridge void *)self);
 
-    [[NSNotificationCenter defaultCenter] removeObserver: self];
+    [notiticationCenter removeObserver: self];
 
     // closes all open vouts
     _voutProvider = nil;
diff --git a/modules/gui/macosx/panels/VLCAudioEffectsWindowController.h b/modules/gui/macosx/panels/VLCAudioEffectsWindowController.h
index 4eb4635a38..bb5a1c8c08 100644
--- a/modules/gui/macosx/panels/VLCAudioEffectsWindowController.h
+++ b/modules/gui/macosx/panels/VLCAudioEffectsWindowController.h
@@ -114,7 +114,6 @@
 - (IBAction)applyProfileCheckboxChanged:(id)sender;
 
 - (void)toggleWindow:(id)sender;
-- (void)saveCurrentProfileAtTerminate;
 
 /* Equalizer */
 - (IBAction)equalizerBandSliderUpdated:(id)sender;
diff --git a/modules/gui/macosx/panels/VLCAudioEffectsWindowController.m b/modules/gui/macosx/panels/VLCAudioEffectsWindowController.m
index 2b4af84f4e..2929cb85b2 100644
--- a/modules/gui/macosx/panels/VLCAudioEffectsWindowController.m
+++ b/modules/gui/macosx/panels/VLCAudioEffectsWindowController.m
@@ -204,10 +204,15 @@ NSString *VLCAudioEffectsProfileNamesKey = @"AudioEffectProfileNames";
 
 - (void)windowDidLoad
 {
-    [[NSNotificationCenter defaultCenter] addObserver:self
-                                             selector:@selector(updateCocoaWindowLevel:)
-                                                 name:VLCWindowShouldUpdateLevel
-                                               object:nil];
+    NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
+    [notificationCenter addObserver:self
+                           selector:@selector(updateCocoaWindowLevel:)
+                               name:VLCWindowShouldUpdateLevel
+                             object:nil];
+    [notificationCenter addObserver:self
+                           selector:@selector(saveCurrentProfileAtTerminate:)
+                               name:NSApplicationWillTerminateNotification
+                             object:nil];
 
     [_applyProfileCheckbox setState:[[NSUserDefaults standardUserDefaults] boolForKey:@"AudioEffectApplyProfileOnStartup"]];
     [_applyProfileCheckbox setTitle:_NS("Apply profile at next launch")];
@@ -403,7 +408,7 @@ NSString *VLCAudioEffectsProfileNamesKey = @"AudioEffectProfileNames";
     [defaults setObject:[NSArray arrayWithArray:workArray] forKey:VLCAudioEffectsProfilesKey];
 }
 
-- (void)saveCurrentProfileAtTerminate
+- (void)saveCurrentProfileAtTerminate:(NSNotification *)notification
 {
     if ([self currentProfileIndex] > 0) {
         [self saveCurrentProfile];
diff --git a/modules/gui/macosx/panels/VLCVideoEffectsWindowController.h b/modules/gui/macosx/panels/VLCVideoEffectsWindowController.h
index cab80a0de6..2adee19826 100644
--- a/modules/gui/macosx/panels/VLCVideoEffectsWindowController.h
+++ b/modules/gui/macosx/panels/VLCVideoEffectsWindowController.h
@@ -167,8 +167,6 @@
 @property (nonatomic) int posterizeValue;
 
 /* generic */
-- (void)saveCurrentProfileAtTerminate;
-
 - (void)toggleWindow:(id)sender;
 - (IBAction)profileSelectorAction:(id)sender;
 - (IBAction)applyProfileCheckboxChanged:(id)sender;
diff --git a/modules/gui/macosx/panels/VLCVideoEffectsWindowController.m b/modules/gui/macosx/panels/VLCVideoEffectsWindowController.m
index 05b602329e..6f233cc651 100644
--- a/modules/gui/macosx/panels/VLCVideoEffectsWindowController.m
+++ b/modules/gui/macosx/panels/VLCVideoEffectsWindowController.m
@@ -72,10 +72,15 @@ NSString *VLCVideoEffectsProfileNamesKey = @"VideoEffectProfileNames";
 {
     self = [super initWithWindowNibName:@"VideoEffects"];
     if (self) {
-        [[NSNotificationCenter defaultCenter] addObserver:self
-                                                 selector:@selector(updateCocoaWindowLevel:)
-                                                     name:VLCWindowShouldUpdateLevel
-                                                   object:nil];
+        NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
+        [notificationCenter addObserver:self
+                               selector:@selector(updateCocoaWindowLevel:)
+                                   name:VLCWindowShouldUpdateLevel
+                                 object:nil];
+        [notificationCenter addObserver:self
+                               selector:@selector(saveCurrentProfileAtTerminate:)
+                                   name:NSApplicationWillTerminateNotification
+                                 object:nil];
 
         self.popupPanel = [[VLCPopupPanelController alloc] init];
         self.textfieldPanel = [[VLCTextfieldPanelController alloc] init];
@@ -726,7 +731,7 @@ NSString *VLCVideoEffectsProfileNamesKey = @"VideoEffectProfileNames";
     [defaults setObject:[NSArray arrayWithArray:workArray] forKey:VLCVideoEffectsProfilesKey];
 }
 
-- (void)saveCurrentProfileAtTerminate
+- (void)saveCurrentProfileAtTerminate:(NSNotification *)aNotification
 {
     if ([self currentProfileIndex] > 0) {
         [self saveCurrentProfile];



More information about the vlc-commits mailing list