macosx: replace controlsbar updating code by a safer helper
authorDavid Fuhrmann <dfuhrmann@videolan.org>
Thu, 13 Aug 2015 19:06:24 +0000 (21:06 +0200)
committerDavid Fuhrmann <dfuhrmann@videolan.org>
Thu, 13 Aug 2015 19:11:45 +0000 (21:11 +0200)
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.

modules/gui/macosx/MainWindow.m
modules/gui/macosx/VLCVoutWindowController.h
modules/gui/macosx/VLCVoutWindowController.m

index 73f54dc..78d3a71 100644 (file)
@@ -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
index fbc81a5..183dda3 100644 (file)
@@ -27,6 +27,7 @@
 #import <vlc_vout_window.h>
 #import "KeyboardBacklight.h"
 
+@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;
index 1196231..9db2312 100644 (file)
@@ -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);
         }
     }];
 }