[vlc-commits] macosx: Fix initializing the Cells in Slider subclasses

Marvin Scholz git at videolan.org
Mon Jul 31 18:12:34 CEST 2017


vlc | branch: master | Marvin Scholz <epirat07 at gmail.com> | Thu Jul 27 13:39:39 2017 +0200| [7bf473ddc6c23c497f50595192e70e2fda8529ad] | committer: Marvin Scholz

macosx: Fix initializing the Cells in Slider subclasses

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

 modules/gui/macosx/VLCDefaultValueSlider.m | 13 ++++++++-----
 modules/gui/macosx/VLCSlider.m             | 17 +++++++++++++++++
 2 files changed, 25 insertions(+), 5 deletions(-)

diff --git a/modules/gui/macosx/VLCDefaultValueSlider.m b/modules/gui/macosx/VLCDefaultValueSlider.m
index 1de71872b3..1aec1d3187 100644
--- a/modules/gui/macosx/VLCDefaultValueSlider.m
+++ b/modules/gui/macosx/VLCDefaultValueSlider.m
@@ -28,18 +28,21 @@
 
 - (instancetype)initWithCoder:(NSCoder *)coder
 {
-    if ([coder isKindOfClass: [NSKeyedUnarchiver class]]) {
-        NSKeyedUnarchiver *keyedUnarchiver = (id)coder;
-        NSString *oldClass = NSStringFromClass([self.superclass cellClass]);
-        [keyedUnarchiver setClass:[VLCDefaultValueSliderCell class] forClassName:oldClass];
-    }
     self = [super initWithCoder:coder];
     if (self) {
+        if (![self.cell isKindOfClass:[VLCDefaultValueSliderCell class]]) {
+            self.cell = [[VLCDefaultValueSliderCell alloc] init];
+        }
         _isScrollable = YES;
     }
     return self;
 }
 
++ (Class)cellClass
+{
+    return [VLCDefaultValueSliderCell class];
+}
+
 - (void)scrollWheel:(NSEvent *)event
 {
     if (!_isScrollable)
diff --git a/modules/gui/macosx/VLCSlider.m b/modules/gui/macosx/VLCSlider.m
index e7eba8ae05..787721ecf3 100644
--- a/modules/gui/macosx/VLCSlider.m
+++ b/modules/gui/macosx/VLCSlider.m
@@ -26,6 +26,23 @@
 
 @implementation VLCSlider
 
+- (instancetype)initWithCoder:(NSCoder *)coder
+{
+    self = [super initWithCoder:coder];
+
+    if (self) {
+        if (![self.cell isKindOfClass:[VLCSliderCell class]]) {
+            self.cell = [[VLCSliderCell alloc] init];
+        }
+    }
+    return self;
+}
+
++ (Class)cellClass
+{
+    return [VLCSliderCell class];
+}
+
 // Workaround for 10.7
 // http://stackoverflow.com/questions/3985816/custom-nsslidercell
 - (void)setNeedsDisplayInRect:(NSRect)invalidRect {



More information about the vlc-commits mailing list