macosx: Fix initializing the Cells in Slider subclasses
authorMarvin Scholz <epirat07@gmail.com>
Thu, 27 Jul 2017 11:39:39 +0000 (13:39 +0200)
committerMarvin Scholz <epirat07@gmail.com>
Mon, 31 Jul 2017 16:10:27 +0000 (18:10 +0200)
modules/gui/macosx/VLCDefaultValueSlider.m
modules/gui/macosx/VLCSlider.m

index 1de7187..1aec1d3 100644 (file)
 
 - (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)
index e7eba8a..787721e 100644 (file)
 
 @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 {