[vlc-commits] macosx: fix rare crash in VLCTimeField
David Fuhrmann
git at videolan.org
Mon Mar 2 23:14:44 CET 2015
vlc | branch: master | David Fuhrmann <dfuhrmann at videolan.org> | Mon Mar 2 22:45:03 2015 +0100| [fd21eb02b4b769bf836c5f0491e9066046b4b946] | committer: 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.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=fd21eb02b4b769bf836c5f0491e9066046b4b946
---
modules/gui/macosx/misc.h | 2 --
modules/gui/macosx/misc.m | 28 +++++++---------------------
2 files changed, 7 insertions(+), 23 deletions(-)
diff --git a/modules/gui/macosx/misc.h b/modules/gui/macosx/misc.h
index a84437a..bbad861 100644
--- a/modules/gui/macosx/misc.h
+++ b/modules/gui/macosx/misc.h
@@ -188,8 +188,6 @@
}
@property (readonly) BOOL timeRemaining;
--(id)initWithFrame:(NSRect)frameRect;
-
- (void)setRemainingIdentifier:(NSString *)o_string;
@end
diff --git a/modules/gui/macosx/misc.m b/modules/gui/macosx/misc.m
index 7e9794f..9769172 100644
--- a/modules/gui/macosx/misc.m
+++ b/modules/gui/macosx/misc.m
@@ -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;
More information about the vlc-commits
mailing list