Commit 43bb985e authored by David Fuhrmann's avatar David Fuhrmann

macosx: fix rare crash in VLCTimeField

initWithFrame: is not always the designated initializer, thus the
object got improperly initialized. Use default initialization and
simplify code.

(cherry picked from commit fd21eb02b4b769bf836c5f0491e9066046b4b946)
Signed-off-by: default avatarDavid Fuhrmann <dfuhrmann@videolan.org>
parent 4a1bde1e
......@@ -188,8 +188,6 @@
}
@property (readonly) BOOL timeRemaining;
-(id)initWithFrame:(NSRect)frameRect;
- (void)setRemainingIdentifier:(NSString *)o_string;
@end
......
......@@ -731,7 +731,8 @@ void _drawFrameInRect(NSRect frameRect)
*****************************************************************************/
@implementation VLCTimeField
+ (void)initialize{
+ (void)initialize
{
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSDictionary *appDefaults = [NSDictionary dictionaryWithObjectsAndKeys:
@"NO", @"DisplayTimeAsTimeRemaining",
......@@ -741,16 +742,6 @@ void _drawFrameInRect(NSRect frameRect)
[defaults registerDefaults:appDefaults];
}
- (id)initWithFrame:(NSRect)frameRect
{
if (self = [super initWithFrame:frameRect]) {
textAlignment = NSCenterTextAlignment;
o_remaining_identifier = @"";
}
return self;
}
- (void)setRemainingIdentifier:(NSString *)o_string
{
o_remaining_identifier = o_string;
......@@ -793,24 +784,19 @@ void _drawFrameInRect(NSRect frameRect)
[[[VLCMain sharedInstance] controls] goToSpecificTime: nil];
else
{
if (![o_remaining_identifier isEqualToString: @""]) {
if ([[NSUserDefaults standardUserDefaults] boolForKey:o_remaining_identifier]) {
[[NSUserDefaults standardUserDefaults] setObject:@"NO" forKey:o_remaining_identifier];
b_time_remaining = NO;
} else {
[[NSUserDefaults standardUserDefaults] setObject:@"YES" forKey:o_remaining_identifier];
b_time_remaining = YES;
}
} else {
if (o_remaining_identifier) {
b_time_remaining = [[NSUserDefaults standardUserDefaults] boolForKey:o_remaining_identifier];
b_time_remaining = !b_time_remaining;
[[NSUserDefaults standardUserDefaults] setObject:(b_time_remaining ? @"YES" : @"NO") forKey:o_remaining_identifier];
} else {
b_time_remaining = !b_time_remaining;
}
}
}
- (BOOL)timeRemaining
{
if (![o_remaining_identifier isEqualToString: @""])
if (o_remaining_identifier)
return [[NSUserDefaults standardUserDefaults] boolForKey:o_remaining_identifier];
else
return b_time_remaining;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment