[vlc-commits] macosx: fix intf variable callbacks

Felix Paul Kühne git at videolan.org
Sat Apr 13 22:09:55 CEST 2019


vlc | branch: master | Felix Paul Kühne <felix at feepk.net> | Sat Apr 13 19:37:34 2019 +0200| [63e84a0635b69c1e48a6b9cfc1ccc2852d049a53] | committer: Felix Paul Kühne

macosx: fix intf variable callbacks

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

 modules/gui/macosx/coreinteraction/VLCClickerManager.m | 17 ++++++++---------
 .../gui/macosx/coreinteraction/VLCCoreInteraction.m    | 18 +++++++++---------
 modules/gui/macosx/main/VLCMain.m                      | 11 ++++++-----
 3 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/modules/gui/macosx/coreinteraction/VLCClickerManager.m b/modules/gui/macosx/coreinteraction/VLCClickerManager.m
index 44611bab84..e3cccd7fe2 100644
--- a/modules/gui/macosx/coreinteraction/VLCClickerManager.m
+++ b/modules/gui/macosx/coreinteraction/VLCClickerManager.m
@@ -66,15 +66,14 @@
                                selector:@selector(coreChangedAppleRemoteSetting:)
                                    name:VLCAppleRemoteSettingChangedNotification
                                  object:nil];
-        [[NSNotificationCenter defaultCenter] addObserver:self
-                                                 selector:@selector(startListeningWithAppleRemote)
-                                                     name:NSApplicationDidBecomeActiveNotification
-                                                   object:nil];
-
-        [[NSNotificationCenter defaultCenter] addObserver:self
-                                                 selector:@selector(stopListeningWithAppleRemote)
-                                                     name:NSApplicationDidResignActiveNotification
-                                                   object:nil];
+        [notificationCenter addObserver:self
+                               selector:@selector(startListeningWithAppleRemote)
+                                   name:NSApplicationDidBecomeActiveNotification
+                                 object:nil];
+        [notificationCenter addObserver:self
+                               selector:@selector(stopListeningWithAppleRemote)
+                                   name:NSApplicationDidResignActiveNotification
+                                 object:nil];
 
         /* init Apple Remote support */
         _remote = [[AppleRemote alloc] init];
diff --git a/modules/gui/macosx/coreinteraction/VLCCoreInteraction.m b/modules/gui/macosx/coreinteraction/VLCCoreInteraction.m
index 4d511161ae..c4297b0b7d 100644
--- a/modules/gui/macosx/coreinteraction/VLCCoreInteraction.m
+++ b/modules/gui/macosx/coreinteraction/VLCCoreInteraction.m
@@ -81,20 +81,19 @@ static int BossCallback(vlc_object_t *p_this, const char *psz_var,
 {
     self = [super init];
     if (self) {
-        intf_thread_t *p_intf = getIntf();
-
         NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
         [notificationCenter addObserver:self
-                          selector:@selector(applicationWillTerminate:)
-                              name:NSApplicationWillTerminateNotification
-                            object:nil];
+                               selector:@selector(applicationWillTerminate:)
+                                   name:NSApplicationWillTerminateNotification
+                                 object:nil];
 
         _clickerManager = [[VLCClickerManager alloc] init];
         _playlistController = [[VLCMain sharedInstance] playlistController];
         _playerController = [_playlistController playerController];
 
-        // FIXME: this variable will live on the current libvlc instance now. Depends on a future patch
-        var_AddCallback(p_intf, "intf-boss", BossCallback, (__bridge void *)self);
+        intf_thread_t *p_intf = getIntf();
+        libvlc_int_t* libvlc = vlc_object_instance(p_intf);
+        var_AddCallback(libvlc, "intf-boss", BossCallback, (__bridge void *)self);
     }
     return self;
 }
@@ -102,8 +101,9 @@ static int BossCallback(vlc_object_t *p_this, const char *psz_var,
 - (void)applicationWillTerminate:(NSNotification *)notification
 {
     // Dealloc is never called because this is a singleton, so we should cleanup manually before termination
-    // FIXME: this variable will live on the current libvlc instance now. Depends on a future patch
-    var_DelCallback(getIntf(), "intf-boss", BossCallback, (__bridge void *)self);
+    intf_thread_t *p_intf = getIntf();
+    libvlc_int_t* libvlc = vlc_object_instance(p_intf);
+    var_DelCallback(libvlc, "intf-boss", BossCallback, (__bridge void *)self);
     [[NSNotificationCenter defaultCenter] removeObserver: self];
     _clickerManager = nil;
     _usedHotkeys = nil;
diff --git a/modules/gui/macosx/main/VLCMain.m b/modules/gui/macosx/main/VLCMain.m
index cdcec49a57..4f1f66c857 100644
--- a/modules/gui/macosx/main/VLCMain.m
+++ b/modules/gui/macosx/main/VLCMain.m
@@ -243,9 +243,9 @@ static VLCMain *sharedInstance = nil;
         _mainWindowController = [[NSWindowController alloc] initWithWindowNibName:@"MainWindow"];
         _libraryWindowController = [[VLCLibraryWindowController alloc] initWithLibraryWindow];
 
-        // FIXME: those variables will live on the current libvlc instance now. Depends on a future patch
-        var_AddCallback(p_intf, "intf-toggle-fscontrol", ShowController, (__bridge void *)self);
-        var_AddCallback(p_intf, "intf-show", ShowController, (__bridge void *)self);
+        libvlc_int_t *libvlc = vlc_object_instance(p_intf);
+        var_AddCallback(libvlc, "intf-toggle-fscontrol", ShowController, (__bridge void *)self);
+        var_AddCallback(libvlc, "intf-show", ShowController, (__bridge void *)self);
 
         // Load them here already to apply stored profiles
         _videoEffectsPanel = [[VLCVideoEffectsWindowController alloc] init];
@@ -337,8 +337,9 @@ static VLCMain *sharedInstance = nil;
     [[self videoEffectsPanel] saveCurrentProfileAtTerminate];
     [[self audioEffectsPanel] saveCurrentProfileAtTerminate];
 
-    var_DelCallback(p_intf, "intf-toggle-fscontrol", ShowController, (__bridge void *)self);
-    var_DelCallback(p_intf, "intf-show", ShowController, (__bridge void *)self);
+    libvlc_int_t *libvlc = vlc_object_instance(p_intf);
+    var_DelCallback(libvlc, "intf-toggle-fscontrol", ShowController, (__bridge void *)self);
+    var_DelCallback(libvlc, "intf-show", ShowController, (__bridge void *)self);
 
     [[NSNotificationCenter defaultCenter] removeObserver: self];
 



More information about the vlc-commits mailing list