[vlc-commits] macosx: replace controlsbar updating code by a safer helper

David Fuhrmann git at videolan.org
Thu Aug 13 21:14:08 CEST 2015


vlc | branch: master | David Fuhrmann <dfuhrmann at videolan.org> | Thu Aug 13 21:06:24 2015 +0200| [b2c77d44972b6736eccb3111f8c1f45dc0d6b3ce] | committer: David Fuhrmann

macosx: replace controlsbar updating code by a safer helper

In the previous implementation was so unsafe that the ARC
compiler was not able work properly and printed a warning.

While there was no real problem here, switch to blocks to
silence the compiler and see potential errors earlier.

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

 modules/gui/macosx/MainWindow.m              |   16 ++++++++++++----
 modules/gui/macosx/VLCVoutWindowController.h |    3 ++-
 modules/gui/macosx/VLCVoutWindowController.m |    9 +++++----
 3 files changed, 19 insertions(+), 9 deletions(-)

diff --git a/modules/gui/macosx/MainWindow.m b/modules/gui/macosx/MainWindow.m
index 73f54dc..78d3a71 100644
--- a/modules/gui/macosx/MainWindow.m
+++ b/modules/gui/macosx/MainWindow.m
@@ -654,7 +654,9 @@ static const float f_min_window_height = 307.;
     [self.controlsBar updateTimeSlider];
     [self.fspanel updatePositionAndTime];
 
-    [[[VLCMain sharedInstance] voutController] updateWindowsControlsBarWithSelector:@selector(updateTimeSlider)];
+    [[[VLCMain sharedInstance] voutController] updateControlsBarsUsingBlock:^(VLCControlsBarCommon *controlsBar) {
+        [controlsBar updateTimeSlider];
+    }];
 
     [[VLCCoreInteraction sharedInstance] updateAtoB];
 }
@@ -722,7 +724,9 @@ static const float f_min_window_height = 307.;
 - (void)updateWindow
 {
     [self.controlsBar updateControls];
-    [[[VLCMain sharedInstance] voutController] updateWindowsControlsBarWithSelector:@selector(updateControls)];
+    [[[VLCMain sharedInstance] voutController] updateControlsBarsUsingBlock:^(VLCControlsBarCommon *controlsBar) {
+        [controlsBar updateControls];
+    }];
 
     bool b_seekable = false;
 
@@ -756,7 +760,9 @@ static const float f_min_window_height = 307.;
     [self.controlsBar setPause];
     [self.fspanel setPause];
 
-    [[[VLCMain sharedInstance] voutController] updateWindowsControlsBarWithSelector:@selector(setPause)];
+    [[[VLCMain sharedInstance] voutController] updateControlsBarsUsingBlock:^(VLCControlsBarCommon *controlsBar) {
+        [controlsBar setPause];
+    }];
 }
 
 - (void)setPlay
@@ -764,7 +770,9 @@ static const float f_min_window_height = 307.;
     [self.controlsBar setPlay];
     [self.fspanel setPlay];
 
-    [[[VLCMain sharedInstance] voutController] updateWindowsControlsBarWithSelector:@selector(setPlay)];
+    [[[VLCMain sharedInstance] voutController] updateControlsBarsUsingBlock:^(VLCControlsBarCommon *controlsBar) {
+        [controlsBar setPlay];
+    }];
 }
 
 - (void)updateVolumeSlider
diff --git a/modules/gui/macosx/VLCVoutWindowController.h b/modules/gui/macosx/VLCVoutWindowController.h
index fbc81a5..183dda3 100644
--- a/modules/gui/macosx/VLCVoutWindowController.h
+++ b/modules/gui/macosx/VLCVoutWindowController.h
@@ -27,6 +27,7 @@
 #import <vlc_vout_window.h>
 #import "KeyboardBacklight.h"
 
+ at class VLCControlsBarCommon;
 @class VLCVideoWindowCommon;
 @class VLCVoutView;
 
@@ -42,7 +43,7 @@
 - (void)setWindowLevel:(NSInteger)i_level forWindow:(vout_window_t *)p_wnd;
 - (void)setFullscreen:(int)i_full forWindow:(vout_window_t *)p_wnd withAnimation:(BOOL)b_animation;
 
-- (void)updateWindowsControlsBarWithSelector:(SEL)aSel;
+- (void)updateControlsBarsUsingBlock:(void (^)(VLCControlsBarCommon *controlsBar))block;
 - (void)updateWindowsUsingBlock:(void (^)(VLCVideoWindowCommon *o_window))windowUpdater;
 
 - (void)updateWindowLevelForHelperWindows:(NSInteger)i_level;
diff --git a/modules/gui/macosx/VLCVoutWindowController.m b/modules/gui/macosx/VLCVoutWindowController.m
index 1196231..9db2312 100644
--- a/modules/gui/macosx/VLCVoutWindowController.m
+++ b/modules/gui/macosx/VLCVoutWindowController.m
@@ -554,13 +554,14 @@ void WindowClose(vout_window_t *p_wnd)
 #pragma mark -
 #pragma mark Misc methods
 
-- (void)updateWindowsControlsBarWithSelector:(SEL)aSel
+- (void)updateControlsBarsUsingBlock:(void (^)(VLCControlsBarCommon *controlsBar))block
 {
     [o_vout_dict enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
+
         if ([obj respondsToSelector:@selector(controlsBar)]) {
-            id o_controlsBar = [obj controlsBar];
-            if (o_controlsBar)
-                [o_controlsBar performSelector:aSel];
+            VLCControlsBarCommon *o_controlsBar = [obj controlsBar];
+            if (o_controlsBar && block)
+                block(o_controlsBar);
         }
     }];
 }



More information about the vlc-commits mailing list