[vlc-commits] macosx: fix rare crash in VLCTimeField
David Fuhrmann
git at videolan.org
Mon Mar 2 22:58:12 CET 2015
vlc | branch: master | David Fuhrmann <dfuhrmann at videolan.org> | Mon Mar 2 22:45:03 2015 +0100| [30b1d150bcfa3ff445e543d47428aa79c68f0568] | 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=30b1d150bcfa3ff445e543d47428aa79c68f0568
---
modules/gui/macosx/misc.h | 2 --
modules/gui/macosx/misc.m | 31 +++++--------------------------
2 files changed, 5 insertions(+), 28 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..64efb27 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,27 +784,15 @@ 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 {
- b_time_remaining = !b_time_remaining;
+ b_time_remaining = !b_time_remaining;
+ if (o_remaining_identifier)
[[NSUserDefaults standardUserDefaults] setObject:(b_time_remaining ? @"YES" : @"NO") forKey:o_remaining_identifier];
- }
}
}
- (BOOL)timeRemaining
{
- if (![o_remaining_identifier isEqualToString: @""])
- return [[NSUserDefaults standardUserDefaults] boolForKey:o_remaining_identifier];
- else
- return b_time_remaining;
+ return b_time_remaining;
}
@end
More information about the vlc-commits
mailing list