diff options
author | ritsuka <[email protected]> | 2015-03-17 13:56:21 +0000 |
---|---|---|
committer | ritsuka <[email protected]> | 2015-03-17 13:56:21 +0000 |
commit | 48a9e546878ae074202e0301f428193b7915d68f (patch) | |
tree | cf3f0f270fc8c7430dec870e954c826926c02a60 | |
parent | 220bd888e05696acbe1dd47f96ded78c389fc27f (diff) |
MacGui: convert the mac gui to Objective-C ARC.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6996 b64f7644-9d1e-0410-96f1-a4d463321fa5
77 files changed, 304 insertions, 700 deletions
diff --git a/macosx/DockTextField.h b/macosx/DockTextField.h index 593855b6b..ea9342bc4 100644 --- a/macosx/DockTextField.h +++ b/macosx/DockTextField.h @@ -8,9 +8,9 @@ @interface DockTextField : NSTextField -@property (nonatomic,retain) NSString *textToDisplay; -@property (nonatomic,retain) NSColor *startColor; -@property (nonatomic,retain) NSColor *endColor; +@property (nonatomic,strong) NSString *textToDisplay; +@property (nonatomic,strong) NSColor *startColor; +@property (nonatomic,strong) NSColor *endColor; - (void)changeGradientColors:(NSColor*)startColor endColor:(NSColor*)endColor; diff --git a/macosx/DockTextField.m b/macosx/DockTextField.m index 661dc45a0..f576f7964 100644 --- a/macosx/DockTextField.m +++ b/macosx/DockTextField.m @@ -43,7 +43,6 @@ NSGradient *gradient = [[NSGradient alloc] initWithStartingColor:self.startColor endingColor:self.endColor]; [gradient drawInBezierPath:[NSBezierPath bezierPathWithRoundedRect:blackOutlineFrame xRadius:radius yRadius:radius] angle:90]; - [gradient release]; NSMutableDictionary *drawStringAttributes = [[NSMutableDictionary alloc] init]; [drawStringAttributes setValue:[NSColor whiteColor] forKey:NSForegroundColorAttributeName]; @@ -56,7 +55,6 @@ [stringShadow setShadowOffset:shadowSize]; [stringShadow setShadowBlurRadius:6]; [drawStringAttributes setValue:stringShadow forKey:NSShadowAttributeName]; - [stringShadow release]; NSString *MRString = _textToDisplay; NSString *budgetString = [NSString stringWithFormat:@"%@", MRString]; @@ -65,7 +63,6 @@ centerPoint.x = (dirtyRect.size.width / 2) - (stringSize.width / 2); centerPoint.y = dirtyRect.size.height / 2 - (stringSize.height / 2) - 2; [budgetString drawAtPoint:centerPoint withAttributes:drawStringAttributes]; - [drawStringAttributes release]; } @end diff --git a/macosx/HBAddPresetController.h b/macosx/HBAddPresetController.h index f86b2e4f4..63be604d5 100644 --- a/macosx/HBAddPresetController.h +++ b/macosx/HBAddPresetController.h @@ -14,6 +14,6 @@ - (instancetype)initWithPreset:(HBPreset *)preset videoSize:(NSSize)size; -@property (readonly) HBPreset *preset; +@property (nonatomic, readonly) HBPreset *preset; @end diff --git a/macosx/HBAddPresetController.m b/macosx/HBAddPresetController.m index 82d965854..cdc0caf14 100644 --- a/macosx/HBAddPresetController.m +++ b/macosx/HBAddPresetController.m @@ -12,17 +12,17 @@ @interface HBAddPresetController () -@property (assign) IBOutlet NSTextField *name; -@property (assign) IBOutlet NSTextField *desc; +@property (unsafe_unretained) IBOutlet NSTextField *name; +@property (unsafe_unretained) IBOutlet NSTextField *desc; -@property (assign) IBOutlet NSPopUpButton *picSettingsPopUp; -@property (assign) IBOutlet NSTextField *picWidth; -@property (assign) IBOutlet NSTextField *picHeight; -@property (assign) IBOutlet NSBox *picWidthHeightBox; +@property (unsafe_unretained) IBOutlet NSPopUpButton *picSettingsPopUp; +@property (unsafe_unretained) IBOutlet NSTextField *picWidth; +@property (unsafe_unretained) IBOutlet NSTextField *picHeight; +@property (unsafe_unretained) IBOutlet NSBox *picWidthHeightBox; -@property (assign) IBOutlet NSButton *picFilters; +@property (unsafe_unretained) IBOutlet NSButton *picFilters; -@property (retain) HBPreset *preset; +@property (nonatomic, strong) HBPreset *preset; @property NSSize size; @end @@ -35,18 +35,12 @@ if (self) { NSParameterAssert(preset); - _preset = [preset retain]; + _preset = preset; _size = size; } return self; } -- (void)dealloc -{ - self.preset = nil;; - [super dealloc]; -} - - (void)windowDidLoad { [super windowDidLoad]; @@ -104,14 +98,13 @@ [alert setMessageText:NSLocalizedString(@"Warning!", @"")]; [alert setInformativeText:NSLocalizedString(@"You need to insert a name for the preset.", @"")]; [alert runModal]; - [alert release]; } else { self.preset.name = self.name.stringValue; self.preset.presetDescription = self.desc.stringValue; - NSMutableDictionary *dict = [[self.preset.content mutableCopy] autorelease]; + NSMutableDictionary *dict = [self.preset.content mutableCopy]; dict[@"PresetName"] = self.name.stringValue; dict[@"PresetDescription"] = self.desc.stringValue; @@ -126,7 +119,7 @@ // Get whether or not to use the current Picture Filter settings for the preset dict[@"UsesPictureFilters"] = @(self.picFilters.state); - self.preset.content = [[dict copy] autorelease]; + self.preset.content = [dict copy]; [[self window] orderOut:nil]; [NSApp endSheet:[self window] returnCode:NSModalResponseContinue]; diff --git a/macosx/HBAdvancedController.h b/macosx/HBAdvancedController.h index 4e590b9c6..8cf5a9ccc 100644 --- a/macosx/HBAdvancedController.h +++ b/macosx/HBAdvancedController.h @@ -13,7 +13,7 @@ */ @interface HBAdvancedController : NSViewController -@property (nonatomic, readwrite, retain) HBVideo *videoSettings; +@property (nonatomic, readwrite, strong) HBVideo *videoSettings; @property (nonatomic, readwrite, getter=isHidden) BOOL hidden; @property (nonatomic, readwrite, getter=isEnabled) BOOL enabled; diff --git a/macosx/HBAdvancedController.m b/macosx/HBAdvancedController.m index 8438aaae6..d4859a634 100644 --- a/macosx/HBAdvancedController.m +++ b/macosx/HBAdvancedController.m @@ -94,8 +94,7 @@ - (void)setVideoSettings:(HBVideo *)videoSettings { - [_videoSettings autorelease]; - _videoSettings = [videoSettings retain]; + _videoSettings = videoSettings; if (_videoSettings) { @@ -153,10 +152,6 @@ } } -- (void)dealloc -{ - [super dealloc]; -} /** * Populates the option widgets diff --git a/macosx/HBAppDelegate.m b/macosx/HBAppDelegate.m index 1a78e0815..872d61c3e 100644 --- a/macosx/HBAppDelegate.m +++ b/macosx/HBAppDelegate.m @@ -18,15 +18,15 @@ @interface HBAppDelegate () -@property (nonatomic, retain) HBPresetsManager *presetsManager; -@property (assign) IBOutlet NSMenu *presetsMenu; +@property (nonatomic, strong) HBPresetsManager *presetsManager; +@property (unsafe_unretained) IBOutlet NSMenu *presetsMenu; -@property (nonatomic, retain) HBPreferencesController *preferencesController; -@property (nonatomic, retain) HBQueueController *queueController; +@property (nonatomic, strong) HBPreferencesController *preferencesController; +@property (nonatomic, strong) HBQueueController *queueController; -@property (nonatomic, retain) HBOutputPanelController *outputPanel; +@property (nonatomic, strong) HBOutputPanelController *outputPanel; -@property (nonatomic, retain) HBController *mainController; +@property (nonatomic, strong) HBController *mainController; @end @@ -48,11 +48,6 @@ _outputPanel = [[HBOutputPanelController alloc] init]; - // Lets report the HandBrake version number here to the activity log and text log file - NSDictionary *infoDict = [[NSBundle mainBundle] infoDictionary]; - NSString *versionStringFull = [NSString stringWithFormat:@"Handbrake Version: %@ (%@)", infoDict[@"CFBundleShortVersionString"], infoDict[@"CFBundleVersion"]]; - [HBUtilities writeToActivityLog: "%s", versionStringFull.UTF8String]; - // we init the HBPresetsManager NSURL *presetsURL = [[HBUtilities appSupportURL] URLByAppendingPathComponent:@"UserPresets.plist"]; _presetsManager = [[HBPresetsManager alloc] initWithURL:presetsURL]; @@ -163,7 +158,6 @@ [self showQueueWindow:nil]; } - [alert release]; } } else @@ -210,7 +204,6 @@ [alert setAlertStyle:NSCriticalAlertStyle]; NSInteger result = [alert runModal]; - [alert release]; if (result == NSAlertFirstButtonReturn) { @@ -232,7 +225,6 @@ [alert addButtonWithTitle:NSLocalizedString(@"Don't Quit", nil)]; [alert setAlertStyle:NSCriticalAlertStyle]; NSInteger result = [alert runModal]; - [alert release]; if (result == NSAlertFirstButtonReturn) { return NSTerminateNow; @@ -250,9 +242,7 @@ { [self.presetsManager savePresets]; - [_mainController release]; _mainController = nil; - [_queueController release]; _queueController = nil; [HBCore closeGlobal]; @@ -314,7 +304,6 @@ [manager removeItemAtURL:fileURL error:NULL]; } } - [manager release]; } } @@ -340,7 +329,6 @@ [HBUtilities writeToActivityLog: "Could not remove existing preview at : %s", url.lastPathComponent.UTF8String]; } } - [manager release]; } } @@ -376,7 +364,6 @@ [alert setMessageText:@"HandBrake has determined your built in presets are out of dateā¦"]; [alert setInformativeText:@"HandBrake will now update your built-in presets."]; [alert runModal]; - [alert release]; } // when alert is dismissed, go ahead and update the built in presets [self.presetsManager generateBuiltInPresets]; @@ -398,7 +385,6 @@ [self.presetsMenu removeItem:item]; } } - [menuItems release]; __block NSUInteger i = 0; __block BOOL builtInEnded = NO; @@ -423,7 +409,6 @@ NSAttributedString *newTitle = [[NSAttributedString alloc] initWithString:[obj name] attributes:@{NSFontAttributeName: [NSFont boldSystemFontOfSize:14]}]; [item setAttributedTitle:newTitle]; - [newTitle release]; } // Add a separator line after the last builtIn preset if ([obj isBuiltIn] == NO && builtInEnded == NO) @@ -435,7 +420,6 @@ item.indentationLevel = idx.length - 1; [self.presetsMenu addItem:item]; - [item release]; } }]; } diff --git a/macosx/HBAttributedStringAdditions.m b/macosx/HBAttributedStringAdditions.m index fc685482d..3700eb964 100644 --- a/macosx/HBAttributedStringAdditions.m +++ b/macosx/HBAttributedStringAdditions.m @@ -12,8 +12,8 @@ - (void)appendString:(NSString *)aString withAttributes:(NSDictionary *)aDictionary { - NSAttributedString *s = [[[NSAttributedString alloc] initWithString:aString - attributes:aDictionary] autorelease]; + NSAttributedString *s = [[NSAttributedString alloc] initWithString:aString + attributes:aDictionary]; [self appendAttributedString:s]; } diff --git a/macosx/HBAudio.m b/macosx/HBAudio.m index 52d52f230..c58156443 100644 --- a/macosx/HBAudio.m +++ b/macosx/HBAudio.m @@ -19,8 +19,8 @@ NSString *HBAudioChangedNotification = @"HBAudioChangedNotification"; @interface HBAudio () <HBAudioTrackDataSource, HBAudioTrackDelegate> -@property (nonatomic, readonly) NSDictionary *noneTrack; -@property (nonatomic, readonly) NSArray *masterTrackArray; // the master list of audio tracks from the title +@property (nonatomic, readonly, strong) NSDictionary *noneTrack; +@property (nonatomic, readonly, strong) NSArray *masterTrackArray; // the master list of audio tracks from the title @property (nonatomic, readwrite) int container; // initially is the default HB_MUX_MP4 @@ -38,9 +38,9 @@ NSString *HBAudioChangedNotification = @"HBAudioChangedNotification"; _tracks = [[NSMutableArray alloc] init]; _defaults = [[HBAudioDefaults alloc] init]; - _noneTrack = [@{keyAudioTrackIndex: @0, + _noneTrack = @{keyAudioTrackIndex: @0, keyAudioTrackName: NSLocalizedString(@"None", @"None"), - keyAudioInputCodec: @0} retain]; + keyAudioInputCodec: @0}; NSMutableArray *sourceTracks = [NSMutableArray array]; [sourceTracks addObject:_noneTrack]; @@ -52,23 +52,6 @@ NSString *HBAudioChangedNotification = @"HBAudioChangedNotification"; return self; } -- (void)dealloc -{ - [_tracks release]; - _tracks = nil; - - [_defaults release]; - _defaults = nil; - - [_noneTrack release]; - _noneTrack = nil; - - [_masterTrackArray release]; - _masterTrackArray = nil; - - [super dealloc]; -} - - (void)addAllTracks { [self addTracksFromDefaults:YES]; @@ -172,7 +155,6 @@ NSString *HBAudioChangedNotification = @"HBAudioChangedNotification"; { [self removeObjectFromTracksAtIndex: [self countOfTracks] - 1]; } - [newAudio release]; if (firstOnly) { @@ -245,7 +227,6 @@ NSString *HBAudioChangedNotification = @"HBAudioChangedNotification"; firstTrack = self.defaults.secondaryEncoderMode ? YES : NO; [tracksAdded addIndexes:tracksIndexes]; } - [tracksIndexes release]; } // If no preferred Language was found, add standard track 1 @@ -296,7 +277,6 @@ NSString *HBAudioChangedNotification = @"HBAudioChangedNotification"; [newAudio setTrack: self.noneTrack]; [newAudio setDrc: @0.0f]; [newAudio setGain: @0.0f]; - [newAudio release]; } #pragma mark - @@ -382,7 +362,7 @@ NSString *HBAudioChangedNotification = @"HBAudioChangedNotification"; HBAudioTrack *trackCopy = [obj copy]; trackCopy.dataSource = copy; trackCopy.delegate = copy; - [copy->_tracks addObject:[trackCopy autorelease]]; + [copy->_tracks addObject:trackCopy]; } }]; diff --git a/macosx/HBAudioController.h b/macosx/HBAudioController.h index 2dcb94427..6af06693c 100644 --- a/macosx/HBAudioController.h +++ b/macosx/HBAudioController.h @@ -13,6 +13,6 @@ */ @interface HBAudioController : NSViewController -@property (nonatomic, readwrite, assign) HBAudio *audio; +@property (nonatomic, readwrite, unsafe_unretained) HBAudio *audio; @end diff --git a/macosx/HBAudioController.m b/macosx/HBAudioController.m index 343bd7124..ca051c9da 100644 --- a/macosx/HBAudioController.m +++ b/macosx/HBAudioController.m @@ -11,7 +11,7 @@ @interface HBAudioController () -@property (nonatomic, readwrite, retain) HBAudioDefaultsController *defaultsController; +@property (nonatomic, readwrite, strong) HBAudioDefaultsController *defaultsController; @end @@ -42,10 +42,10 @@ - (IBAction)showSettingsSheet:(id)sender { - self.defaultsController = [[[HBAudioDefaultsController alloc] initWithSettings:self.audio.defaults] autorelease]; + self.defaultsController = [[HBAudioDefaultsController alloc] initWithSettings:self.audio.defaults]; - [NSApp beginSheet:[self.defaultsController window] - modalForWindow:[[self view] window] + [NSApp beginSheet:self.defaultsController.window + modalForWindow:self.view.window modalDelegate:self didEndSelector:@selector(sheetDidEnd) contextInfo:NULL]; diff --git a/macosx/HBAudioDefaults.h b/macosx/HBAudioDefaults.h index 01a838517..b1654e6f7 100644 --- a/macosx/HBAudioDefaults.h +++ b/macosx/HBAudioDefaults.h @@ -20,9 +20,9 @@ typedef NS_ENUM(NSUInteger, HBAudioTrackSelectionBehavior) { @interface HBAudioDefaults : NSObject <NSCoding, NSCopying, HBPresetCoding> @property (nonatomic, readwrite) HBAudioTrackSelectionBehavior trackSelectionBehavior; -@property (nonatomic, readwrite, retain) NSMutableArray *trackSelectionLanguages; +@property (nonatomic, readwrite, strong) NSMutableArray *trackSelectionLanguages; -@property (nonatomic, readwrite, retain) NSMutableArray *tracksArray; +@property (nonatomic, readwrite, strong) NSMutableArray *tracksArray; /** * Adds a new track preset. diff --git a/macosx/HBAudioDefaults.m b/macosx/HBAudioDefaults.m index 693b29986..0454c4b9b 100644 --- a/macosx/HBAudioDefaults.m +++ b/macosx/HBAudioDefaults.m @@ -31,18 +31,10 @@ return self; } -- (void)dealloc -{ - [_trackSelectionLanguages release]; - [_tracksArray release]; - [super dealloc]; -} - - (void)addTrack { HBAudioTrackPreset *track = [[HBAudioTrackPreset alloc] initWithContainer:self.container]; [self insertObject:track inTracksArrayAtIndex:[self countOfTracksArray]]; - [track release]; } - (NSArray *)audioEncoderFallbacks @@ -58,7 +50,7 @@ [fallbacks addObject:@(audio_encoder->name)]; } } - return [fallbacks autorelease]; + return fallbacks; } - (NSString *)isoCodeForNativeLang:(NSString *)language @@ -168,7 +160,6 @@ newTrack.drc = [track[@"AudioTrackDRCSlider"] floatValue]; newTrack.gain = [track[@"AudioTrackGainSlider"] intValue]; [self.tracksArray addObject:newTrack]; - [newTrack release]; } } @@ -187,7 +178,7 @@ { preset[@"AudioTrackSelectionBehavior"] = @"none"; } - preset[@"AudioLanguageList"] = [[self.trackSelectionLanguages copy] autorelease]; + preset[@"AudioLanguageList"] = [self.trackSelectionLanguages copy]; // Passthru settings preset[@"AudioAllowAACPass"] = @(self.allowAACPassthru); @@ -220,7 +211,6 @@ } preset[@"AudioList"] = audioList; - [audioList release]; } - (void)validateEncoderFallbackForVideoContainer:(int)container @@ -257,10 +247,8 @@ if (copy) { copy->_trackSelectionBehavior = _trackSelectionBehavior; - [copy->_trackSelectionLanguages release]; copy->_trackSelectionLanguages = [_trackSelectionLanguages mutableCopy]; - [copy->_tracksArray release]; copy->_tracksArray = [[NSMutableArray alloc] initWithArray:_tracksArray copyItems:YES]; copy->_allowAACPassthru = _allowAACPassthru; diff --git a/macosx/HBAudioDefaultsController.m b/macosx/HBAudioDefaultsController.m index 31b8dee6c..dc693a3fc 100644 --- a/macosx/HBAudioDefaultsController.m +++ b/macosx/HBAudioDefaultsController.m @@ -12,13 +12,14 @@ static void *HBAudioDefaultsContex = &HBAudioDefaultsContex; @interface HBAudioDefaultsController () -@property (nonatomic, readonly) HBAudioDefaults *settings; +@property (nonatomic, readonly, strong) HBAudioDefaults *settings; -@property (nonatomic, readonly) HBLanguagesSelection *languagesList; -@property (assign) IBOutlet HBLanguageArrayController *tableController; -@property (assign) IBOutlet NSButton *showAllButton; +@property (nonatomic, readonly, strong) HBLanguagesSelection *languagesList; -@property (assign) IBOutlet NSArrayController *tracksController; +@property (unsafe_unretained) IBOutlet HBLanguageArrayController *tableController; +@property (unsafe_unretained) IBOutlet NSButton *showAllButton; + +@property (unsafe_unretained) IBOutlet NSArrayController *tracksController; @end @@ -29,7 +30,7 @@ static void *HBAudioDefaultsContex = &HBAudioDefaultsContex; self = [super initWithWindowNibName:@"AudioDefaults"]; if (self) { - _settings = [settings retain]; + _settings = settings; _languagesList = [[HBLanguagesSelection alloc] initWithLanguages:_settings.trackSelectionLanguages]; } return self; @@ -91,14 +92,11 @@ static void *HBAudioDefaultsContex = &HBAudioDefaultsContex; - (void)dealloc { - [_settings release]; - [_languagesList release]; @try { [self removeObserver:self forKeyPath:@"tableController.showSelectedOnly"]; } @catch (NSException * __unused exception) {} - [super dealloc]; } @end diff --git a/macosx/HBAudioTrack.h b/macosx/HBAudioTrack.h index 0cb2788e5..2bad1bd05 100644 --- a/macosx/HBAudioTrack.h +++ b/macosx/HBAudioTrack.h @@ -33,21 +33,21 @@ extern NSString *keyAudioBitrate; @interface HBAudioTrack : NSObject <NSCoding, NSCopying> -@property (nonatomic, retain) NSDictionary *track; -@property (nonatomic, retain) NSDictionary *codec; -@property (nonatomic, retain) NSDictionary *mixdown; -@property (nonatomic, retain) NSDictionary *sampleRate; -@property (nonatomic, retain) NSDictionary *bitRate; -@property (nonatomic, retain) NSNumber *drc; -@property (nonatomic, retain) NSNumber *gain; -@property (nonatomic, retain) NSNumber *videoContainerTag; -@property (nonatomic, assign) id<HBAudioTrackDataSource> dataSource; -@property (nonatomic, assign) id<HBAudioTrackDelegate> delegate; +@property (nonatomic, strong) NSDictionary *track; +@property (nonatomic, strong) NSDictionary *codec; +@property (nonatomic, strong) NSDictionary *mixdown; +@property (nonatomic, strong) NSDictionary *sampleRate; +@property (nonatomic, strong) NSDictionary *bitRate; +@property (nonatomic, strong) NSNumber *drc; +@property (nonatomic, strong) NSNumber *gain; +@property (nonatomic, strong) NSNumber *videoContainerTag; +@property (nonatomic, unsafe_unretained) id<HBAudioTrackDataSource> dataSource; +@property (nonatomic, unsafe_unretained) id<HBAudioTrackDelegate> delegate; -@property (nonatomic, retain) NSMutableArray *codecs; -@property (nonatomic, retain) NSMutableArray *mixdowns; +@property (nonatomic, strong) NSMutableArray *codecs; +@property (nonatomic, strong) NSMutableArray *mixdowns; @property (nonatomic, readonly) NSArray *sampleRates; -@property (nonatomic, retain) NSArray *bitRates; +@property (nonatomic, strong) NSArray *bitRates; @property (nonatomic, readonly) BOOL enabled; - (void) setTrackFromIndex: (int) aValue; diff --git a/macosx/HBAudioTrack.m b/macosx/HBAudioTrack.m index 5da6260f0..0c20f3437 100644 --- a/macosx/HBAudioTrack.m +++ b/macosx/HBAudioTrack.m @@ -324,37 +324,19 @@ static NSMutableArray *masterBitRateArray = nil; return masterSampleRateArray; } -- (void) dealloc -{ - [_track release]; - [_codec release]; - [_mixdown release]; - [_sampleRate release]; - [_bitRate release]; - [_drc release]; - [_gain release]; - [_videoContainerTag release]; - [_codecs release]; - [_mixdowns release]; - [_bitRates release]; - - [super dealloc]; -} - #pragma mark - #pragma mark Setters - (void)setVideoContainerTag:(NSNumber *)videoContainerTag { - [_videoContainerTag autorelease]; - _videoContainerTag = [videoContainerTag retain]; + _videoContainerTag = videoContainerTag; [self updateCodecs]; } - (void)setTrack:(NSDictionary *)track { NSDictionary *oldValue = _track; - _track = [track retain]; + _track = track; if (nil != _track) { [self updateCodecs]; @@ -372,29 +354,25 @@ static NSMutableArray *masterBitRateArray = nil; [self.delegate settingTrackToNone: self]; } } - [oldValue release]; } - (void)setCodec:(NSDictionary *)codec { - [_codec autorelease]; - _codec = [codec retain]; + _codec = codec; [self updateMixdowns: YES]; [self updateBitRates: YES]; } - (void)setMixdown:(NSDictionary *)mixdown { - [_mixdown autorelease]; - _mixdown = [mixdown retain]; + _mixdown = mixdown; [self updateBitRates: YES]; [self.delegate mixdownChanged]; } - (void)setSampleRate:(NSDictionary *)sampleRate { - [_sampleRate autorelease]; - _sampleRate = [sampleRate retain]; + _sampleRate = sampleRate; [self updateBitRates: NO]; } @@ -650,4 +628,3 @@ static NSMutableArray *masterBitRateArray = nil; } @end - diff --git a/macosx/HBAudioTrackPreset.m b/macosx/HBAudioTrackPreset.m index da7fd6748..80bcf918d 100644 --- a/macosx/HBAudioTrackPreset.m +++ b/macosx/HBAudioTrackPreset.m @@ -169,7 +169,7 @@ static void *HBAudioEncoderContex = &HBAudioEncoderContex; { [encoders addObject:@(audio_encoder->name)]; } - return [encoders autorelease]; + return encoders; } - (NSArray *)mixdowns @@ -184,7 +184,7 @@ static void *HBAudioEncoderContex = &HBAudioEncoderContex; [mixdowns addObject:@(mixdown->name)]; } } - return [mixdowns autorelease]; + return mixdowns; } - (NSArray *)samplerates @@ -196,7 +196,7 @@ static void *HBAudioEncoderContex = &HBAudioEncoderContex; { [samplerates addObject:@(audio_samplerate->name)]; } - return [samplerates autorelease]; + return samplerates; } - (NSArray *)bitrates @@ -219,7 +219,7 @@ static void *HBAudioEncoderContex = &HBAudioEncoderContex; [bitrates addObject:@(audio_bitrate->name)]; } } - return [bitrates autorelease]; + return bitrates; } + (NSSet *)keyPathsForValuesAffectingValueForKey:(NSString *)key diff --git a/macosx/HBChapterTitlesController.h b/macosx/HBChapterTitlesController.h index 89ce440c4..5cf628a49 100644 --- a/macosx/HBChapterTitlesController.h +++ b/macosx/HBChapterTitlesController.h @@ -13,6 +13,6 @@ */ @interface HBChapterTitlesController : NSViewController -@property (nonatomic, readwrite, assign) HBJob *job; +@property (nonatomic, readwrite, unsafe_unretained) HBJob *job; @end diff --git a/macosx/HBChapterTitlesController.m b/macosx/HBChapterTitlesController.m index 582e9bd52..b3daebc9e 100644 --- a/macosx/HBChapterTitlesController.m +++ b/macosx/HBChapterTitlesController.m @@ -13,7 +13,7 @@ IBOutlet NSTableColumn * fChapterTableNameColumn; } -@property (nonatomic, readwrite, retain) NSMutableArray *chapterTitles; +@property (nonatomic, readwrite, strong) NSMutableArray *chapterTitles; @end @@ -29,12 +29,6 @@ return self; } -- (void)dealloc -{ - [_chapterTitles release]; - [super dealloc]; -} - - (void)setJob:(HBJob *)job { _job = job; @@ -134,8 +128,7 @@ a timer to avoid interfering with the chain of events that handles the edit. */ { chapterName = [[NSString alloc] initWithContentsOfURL:[panel URL] encoding:NSUTF8StringEncoding error:NULL]; chaptersArray = [chapterName componentsSeparatedByString:@"\n"]; - [chapterName release]; - chaptersMutableArray = [[chaptersArray mutableCopy] autorelease]; + chaptersMutableArray = [chaptersArray mutableCopy]; chapters = [self numberOfRowsInTableView:fChapterTable]; if ([chaptersMutableArray count] > 0) { diff --git a/macosx/HBController.m b/macosx/HBController.m index 85d0fd12e..e320b3da7 100644 --- a/macosx/HBController.m +++ b/macosx/HBController.m @@ -31,11 +31,11 @@ @interface HBController () <HBPresetsViewControllerDelegate, HBPreviewControllerDelegate, HBPictureControllerDelegate, HBTitleSelectionDelegate> -@property (assign) IBOutlet NSView *openTitleView; +@property (unsafe_unretained) IBOutlet NSView *openTitleView; @property (nonatomic, readwrite) BOOL scanSpecificTitle; @property (nonatomic, readwrite) NSInteger scanSpecificTitleIdx; -@property (nonatomic, readwrite, retain) HBTitleSelectionController *titlesSelectionController; +@property (nonatomic, readwrite, strong) HBTitleSelectionController *titlesSelectionController; /** * The name of the source, it might differ from the source @@ -44,19 +44,19 @@ @property (nonatomic, copy) NSString *browsedSourceDisplayName; /// The current job. -@property (nonatomic, retain) HBJob *job; +@property (nonatomic, strong) HBJob *job; /// The job to be applied from the queue. -@property (nonatomic, retain) HBJob *jobFromQueue; +@property (nonatomic, strong) HBJob *jobFromQueue; /// The current selected preset. -@property (nonatomic, retain) HBPreset *selectedPreset; +@property (nonatomic, strong) HBPreset *selectedPreset; @property (nonatomic) BOOL customPreset; /// The HBCore used for scanning. -@property (nonatomic, retain) HBCore *core; +@property (nonatomic, strong) HBCore *core; -@property (nonatomic, readwrite) NSColor *labelColor; +@property (unsafe_unretained, nonatomic, readwrite) NSColor *labelColor; @end @@ -82,7 +82,7 @@ fQueueController.controller = self; presetManager = manager; - _selectedPreset = [presetManager.defaultPreset retain]; + _selectedPreset = presetManager.defaultPreset; } return self; @@ -91,18 +91,6 @@ - (void)dealloc { [[NSNotificationCenter defaultCenter] removeObserver:self]; - - [fPreviewController release]; - [fPictureController release]; - - [_browsedSourceDisplayName release]; - [_job release]; - [_jobFromQueue release]; - [_selectedPreset release]; - [_labelColor release]; - [_core release]; - - [super dealloc]; } - (void)windowDidLoad @@ -235,12 +223,10 @@ if (![[fMainTabView tabViewItems] containsObject:fAdvancedTab]) { [fMainTabView insertTabViewItem:fAdvancedTab atIndex:3]; - [fAdvancedTab release]; } } else { - [fAdvancedTab retain]; [fMainTabView removeTabViewItem:fAdvancedTab]; } } @@ -490,8 +476,7 @@ [self removeJobObservers]; // Retain the new job - [_job autorelease]; - _job = [job retain]; + _job = job; // Set the jobs info to the view controllers fPictureController.picture = job.picture; @@ -504,7 +489,7 @@ if (job) { - fPreviewController.generator = [[[HBPreviewGenerator alloc] initWithCore:self.core job:job] autorelease]; + fPreviewController.generator = [[HBPreviewGenerator alloc] initWithCore:self.core job:job]; } else { @@ -672,7 +657,6 @@ [alert addButtonWithTitle:@"Attempt Scan Anyway"]; [NSApp requestUserAttention:NSCriticalRequest]; NSInteger status = [alert runModal]; - [alert release]; if (status == NSAlertFirstButtonReturn) { @@ -885,7 +869,7 @@ } else { - self.job = [[[HBJob alloc] initWithTitle:title andPreset:self.selectedPreset] autorelease]; + self.job = [[HBJob alloc] initWithTitle:title andPreset:self.selectedPreset]; self.job.destURL = [self destURLForJob:self.job]; } @@ -1011,7 +995,7 @@ */ - (void)doAddToQueue { - [fQueueController addJob:[[self.job copy] autorelease]]; + [fQueueController addJob:[self.job copy]]; } /** @@ -1028,7 +1012,6 @@ [alert setMessageText:NSLocalizedString(@"Warning!", @"")]; [alert setInformativeText:NSLocalizedString(@"This is not a valid destination directory!", @"")]; [alert runModal]; - [alert release]; return; } @@ -1043,7 +1026,6 @@ [alert setAlertStyle:NSCriticalAlertStyle]; [alert beginSheetModalForWindow:self.window modalDelegate:self didEndSelector:@selector(overwriteAddToQueueAlertDone:returnCode:contextInfo:) contextInfo:NULL]; - [alert release]; } else if ([fQueueController jobExistAtURL:self.job.destURL]) { @@ -1056,7 +1038,6 @@ [alert setAlertStyle:NSCriticalAlertStyle]; [alert beginSheetModalForWindow:self.window modalDelegate:self didEndSelector:@selector(overwriteAddToQueueAlertDone:returnCode:contextInfo:) contextInfo:NULL]; - [alert release]; } else { @@ -1130,7 +1111,6 @@ [alert setMessageText:NSLocalizedString(@"Warning!", @"")]; [alert setInformativeText:NSLocalizedString(@"This is not a valid destination directory!", @"")]; [alert runModal]; - [alert release]; return; } @@ -1146,7 +1126,6 @@ [alert beginSheetModalForWindow:self.window modalDelegate:self didEndSelector:@selector(overWriteAlertDone:returnCode:contextInfo:) contextInfo:NULL]; // overWriteAlertDone: will be called when the alert is dismissed. It will call doRip. - [alert release]; } else { @@ -1178,7 +1157,7 @@ - (IBAction)addTitlesToQueue:(id)sender { - self.titlesSelectionController = [[[HBTitleSelectionController alloc] initWithTitles:self.core.titles delegate:self] autorelease]; + self.titlesSelectionController = [[HBTitleSelectionController alloc] initWithTitles:self.core.titles delegate:self]; [NSApp beginSheet:self.titlesSelectionController.window modalForWindow:self.window @@ -1211,7 +1190,6 @@ job.destURL = [self destURLForJob:job]; job.title = nil; [jobs addObject:job]; - [job release]; } } @@ -1234,7 +1212,6 @@ break; } } - [destinations release]; if (fileExists) { @@ -1246,13 +1223,11 @@ [alert addButtonWithTitle:NSLocalizedString(@"Overwrite", nil)]; [alert setAlertStyle:NSCriticalAlertStyle]; - [alert beginSheetModalForWindow:self.window modalDelegate:self didEndSelector:@selector(overwriteAddTitlesToQueueAlertDone:returnCode:contextInfo:) contextInfo:jobs]; - [alert release]; + [alert beginSheetModalForWindow:self.window modalDelegate:self didEndSelector:@selector(overwriteAddTitlesToQueueAlertDone:returnCode:contextInfo:) contextInfo:(__bridge void *)(jobs)]; } else { [fQueueController addJobsFromArray:jobs]; - [jobs release]; } } @@ -1262,9 +1237,8 @@ { if (returnCode == NSAlertSecondButtonReturn) { - NSArray *jobs = (NSArray *)contextInfo; + NSArray *jobs = (__bridge NSArray *)contextInfo; [fQueueController addJobsFromArray:jobs]; - [jobs release]; } } @@ -1342,19 +1316,18 @@ HBAddPresetController *addPresetController = [[HBAddPresetController alloc] initWithPreset:[self createPresetFromCurrentSettings] videoSize:NSMakeSize(self.job.picture.width, self.job.picture.height)]; - [NSApp beginSheet:addPresetController.window modalForWindow:self.window modalDelegate:self didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:) contextInfo:addPresetController]; + [NSApp beginSheet:addPresetController.window modalForWindow:self.window modalDelegate:self didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:) contextInfo:(__bridge void *)(addPresetController)]; } - (void)sheetDidEnd:(NSWindow *)sheet returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo { - HBAddPresetController *addPresetController = (HBAddPresetController *)contextInfo; + HBAddPresetController *addPresetController = (HBAddPresetController *)CFBridgingRelease(contextInfo); if (returnCode == NSModalResponseContinue) { [presetManager addPreset:addPresetController.preset]; } - [addPresetController release]; } - (HBPreset *)createPresetFromCurrentSettings @@ -1382,7 +1355,7 @@ [self.job applyCurrentSettingsToPreset:preset]; - return [[[HBPreset alloc] initWithName:preset[@"PresetName"] content:preset builtIn:NO] autorelease]; + return [[HBPreset alloc] initWithName:preset[@"PresetName"] content:preset builtIn:NO]; } #pragma mark - @@ -1409,7 +1382,7 @@ [[NSFileManager defaultManager] createFileAtPath:[exportPresetsFile path] contents:nil attributes:nil]; } - NSMutableArray *presetsToExport = [[[NSMutableArray alloc] initWithContentsOfURL:exportPresetsFile] autorelease]; + NSMutableArray *presetsToExport = [[NSMutableArray alloc] initWithContentsOfURL:exportPresetsFile]; if (presetsToExport == nil) { presetsToExport = [[NSMutableArray alloc] init]; @@ -1465,7 +1438,6 @@ // actually add the new preset to our presets array [presetManager addPresetFromDictionary:dict]; } - [presetsToImport autorelease]; }]; } diff --git a/macosx/HBCore.m b/macosx/HBCore.m index 6d6934fc5..bc37a128e 100644 --- a/macosx/HBCore.m +++ b/macosx/HBCore.m @@ -43,7 +43,7 @@ static void hb_error_handler(const char *errmsg) @property (nonatomic, readonly) dispatch_queue_t updateTimerQueue; /// Current scanned titles. -@property (nonatomic, readwrite, retain) NSArray *titles; +@property (nonatomic, readwrite, strong) NSArray *titles; /// Progress handler. @property (nonatomic, readwrite, copy) HBCoreProgressHandler progressHandler; @@ -72,7 +72,6 @@ static void hb_error_handler(const char *errmsg) + (void)closeGlobal { NSAssert(globalInitialized, @"[HBCore closeGlobal] global closed but not initialized"); - [errorHandler release]; hb_global_close(); } @@ -109,7 +108,6 @@ static void hb_error_handler(const char *errmsg) _hb_handle = hb_init(loggingLevel, 0); if (!_hb_handle) { - [self release]; return nil; } } @@ -129,14 +127,6 @@ static void hb_error_handler(const char *errmsg) hb_close(&_hb_handle); _hb_handle = NULL; free(_hb_state); - - [_name release]; - _name = nil; - - [_titles release]; - _titles = nil; - - [super dealloc]; } #pragma mark - Scan @@ -255,10 +245,10 @@ static void hb_error_handler(const char *errmsg) for (int i = 0; i < hb_list_count(title_set->list_title); i++) { hb_title_t *title = (hb_title_t *) hb_list_item(title_set->list_title, i); - [titles addObject:[[[HBTitle alloc] initWithTitle:title featured:(title->index == title_set->feature)] autorelease]]; + [titles addObject:[[HBTitle alloc] initWithTitle:title featured:(title->index == title_set->feature)]]; } - self.titles = [[titles copy] autorelease]; + self.titles = [titles copy]; [HBUtilities writeToActivityLog:"%s scan done", self.name.UTF8String]; @@ -527,10 +517,9 @@ static void hb_error_handler(const char *errmsg) { // Retain the completion block, because it could be replaced // inside the same block. - HBCoreCompletionHandler completionHandler = [self.completionHandler retain]; + HBCoreCompletionHandler completionHandler = self.completionHandler; self.completionHandler = nil; completionHandler(result); - [completionHandler release]; } } diff --git a/macosx/HBDVDDetector.m b/macosx/HBDVDDetector.m index 05ff786b1..8db9d36f2 100644 --- a/macosx/HBDVDDetector.m +++ b/macosx/HBDVDDetector.m @@ -31,7 +31,7 @@ + (HBDVDDetector *)detectorForPath: (NSString *)aPath { - return [[[self alloc] initWithPath:aPath] autorelease]; + return [[self alloc] initWithPath:aPath]; } @@ -40,23 +40,13 @@ NSAssert(aPath, @"nil string passed to drive detector."); if( self = [super init] ) { - path = [aPath retain]; + path = aPath; bsdName = nil; } return self; } -- (void)dealloc -{ - [path release]; - path = nil; - [bsdName release]; - bsdName = nil; - [super dealloc]; -} - - - (BOOL)isVideoDVD { return ( [self pathHasVideoTS] && [self deviceIsDVD] ); @@ -90,7 +80,7 @@ bsdName = [bsdName substringFromIndex:5]; } - return [bsdName retain]; + return bsdName; } diff --git a/macosx/HBDistributedArray.m b/macosx/HBDistributedArray.m index aef8dc4be..a8764cfbb 100644 --- a/macosx/HBDistributedArray.m +++ b/macosx/HBDistributedArray.m @@ -18,8 +18,8 @@ - (instancetype)initWithObject:(id)object; -@property (nonatomic, retain) id representedObject; -@property (nonatomic, readonly) NSString *uuid; +@property (nonatomic, strong) id representedObject; +@property (unsafe_unretained, nonatomic, readonly) NSString *uuid; @end @@ -27,17 +27,11 @@ - (instancetype)initWithObject:(id)object { - _representedObject = [object retain]; + _representedObject = object; return self; } -- (void)dealloc -{ - [_representedObject release]; - [super dealloc]; -} - - (NSMethodSignature *)methodSignatureForSelector:(SEL)selector { return [self.representedObject methodSignatureForSelector:selector]; @@ -113,20 +107,13 @@ NSString *HBDistributedArraWrittenToDisk = @"HBDistributedArraWrittenToDisk"; - (void)dealloc { + [[NSDistributedNotificationCenter defaultCenter] removeObserver:self]; + [self lock]; [self synchronize]; [self unlock]; - [_fileURL release]; - _fileURL = nil; - [_array release]; - _array = nil; - - [[NSDistributedNotificationCenter defaultCenter] removeObserver:self]; - sem_close(_mutex); - - [super dealloc]; } - (void)lock @@ -277,7 +264,7 @@ NSString *HBDistributedArraWrittenToDisk = @"HBDistributedArraWrittenToDisk"; } else { - return [[[HBProxyArrayObject alloc] initWithObject:anObject] autorelease]; + return [[HBProxyArrayObject alloc] initWithObject:anObject]; } } diff --git a/macosx/HBDockTile.m b/macosx/HBDockTile.m index bfbed37b7..f03e2fdff 100644 --- a/macosx/HBDockTile.m +++ b/macosx/HBDockTile.m @@ -13,10 +13,10 @@ NSString *dockTilePercentFormat = @"%2.1f%%"; @interface HBDockTile () -@property (nonatomic, retain) NSDockTile *dockTile; -@property (nonatomic, retain) NSImage *image; -@property (nonatomic, retain) DockTextField * percentField; -@property (nonatomic, retain) DockTextField * timeField; +@property (nonatomic, strong) NSDockTile *dockTile; +@property (nonatomic, strong) NSImage *image; +@property (nonatomic, strong) DockTextField * percentField; +@property (nonatomic, strong) DockTextField * timeField; @end @@ -27,8 +27,8 @@ NSString *dockTilePercentFormat = @"%2.1f%%"; self = [super init]; if (self) { - _dockTile = [dockTile retain]; - _image = [image retain]; + _dockTile = dockTile; + _image = image; NSImageView *iv = [[NSImageView alloc] init]; [iv setImage:_image]; @@ -41,21 +41,10 @@ NSString *dockTilePercentFormat = @"%2.1f%%"; _timeField = [[DockTextField alloc] initWithFrame:NSMakeRect(0.0f, 0.0f, [dockTile size].width, 30.0f)]; [_timeField changeGradientColors:[NSColor colorWithDeviceRed:0.6f green:0.4f blue:0.4f alpha:1.0f] endColor:[NSColor colorWithDeviceRed:0.4f green:0.2f blue:0.2f alpha:1.0f]]; [iv addSubview:_timeField]; - [iv release]; } return self; } -- (void)dealloc -{ - [_dockTile release]; - [_image release]; - [_percentField release]; - [_timeField release]; - - [super dealloc]; -} - - (void)updateDockIcon:(double)progress withETA:(NSString *)etaStr { if (progress < 0.0 || progress > 1.0) diff --git a/macosx/HBFilters+UIAdditions.h b/macosx/HBFilters+UIAdditions.h index 8b79a2056..c4dbaeaa7 100644 --- a/macosx/HBFilters+UIAdditions.h +++ b/macosx/HBFilters+UIAdditions.h @@ -37,7 +37,7 @@ */ @interface HBGenericDictionaryTransformer : NSValueTransformer -@property (nonatomic, retain) NSDictionary *dict; +@property (nonatomic, strong) NSDictionary *dict; @end @interface HBDenoisePresetTransformer : HBGenericDictionaryTransformer diff --git a/macosx/HBFilters.m b/macosx/HBFilters.m index 8bd627d96..90f3b932d 100644 --- a/macosx/HBFilters.m +++ b/macosx/HBFilters.m @@ -25,21 +25,21 @@ NSDictionary *_HandBrake_nlmeansTunesDict; { if (self == [HBFilters class]) { - _HandBrake_denoiseTypesDict = [@{NSLocalizedString(@"Off", nil): @"off", + _HandBrake_denoiseTypesDict = @{NSLocalizedString(@"Off", nil): @"off", NSLocalizedString(@"NLMeans", nil): @"nlmeans", - NSLocalizedString(@"HQDN3D", nil): @"hqdn3d"} retain]; + NSLocalizedString(@"HQDN3D", nil): @"hqdn3d"}; - _HandBrake_denoisePresetsDict = [@{NSLocalizedString(@"Custom", nil): @"none", + _HandBrake_denoisePresetsDict = @{NSLocalizedString(@"Custom", nil): @"none", NSLocalizedString(@"Ultralight", nil): @"ultralight", NSLocalizedString(@"Light", nil): @"light", NSLocalizedString(@"Medium", nil) : @"medium", - NSLocalizedString(@"Strong", nil) : @"strong"} retain]; + NSLocalizedString(@"Strong", nil) : @"strong"}; - _HandBrake_nlmeansTunesDict = [@{NSLocalizedString(@"None", nil): @"none", + _HandBrake_nlmeansTunesDict = @{NSLocalizedString(@"None", nil): @"none", NSLocalizedString(@"Film", nil): @"film", NSLocalizedString(@"Grain", nil): @"grain", NSLocalizedString(@"High Motion", nil): @"highmotion", - NSLocalizedString(@"Animation", nil) : @"animation"} retain]; + NSLocalizedString(@"Animation", nil) : @"animation"}; } } @@ -82,8 +82,6 @@ NSDictionary *_HandBrake_nlmeansTunesDict; // Override setter to avoid nil values. - (void)setDetelecineCustomString:(NSString *)detelecineCustomString { - [_detelecineCustomString autorelease]; - if (detelecineCustomString) { _detelecineCustomString = [detelecineCustomString copy]; @@ -104,8 +102,6 @@ NSDictionary *_HandBrake_nlmeansTunesDict; - (void)setDeinterlaceCustomString:(NSString *)deinterlaceCustomString { - [_deinterlaceCustomString autorelease]; - if (deinterlaceCustomString) { _deinterlaceCustomString = [deinterlaceCustomString copy]; @@ -126,8 +122,6 @@ NSDictionary *_HandBrake_nlmeansTunesDict; - (void)setDecombCustomString:(NSString *)decombCustomString { - [_decombCustomString autorelease]; - if (decombCustomString) { _decombCustomString = [decombCustomString copy]; @@ -142,8 +136,6 @@ NSDictionary *_HandBrake_nlmeansTunesDict; - (void)setDenoise:(NSString *)denoise { - [_denoise autorelease]; - if (denoise) { _denoise = [denoise copy]; @@ -158,8 +150,6 @@ NSDictionary *_HandBrake_nlmeansTunesDict; - (void)setDenoisePreset:(NSString *)denoisePreset { - [_denoisePreset autorelease]; - if (denoisePreset) { _denoisePreset = [denoisePreset copy]; @@ -174,8 +164,6 @@ NSDictionary *_HandBrake_nlmeansTunesDict; - (void)setDenoiseTune:(NSString *)denoiseTune { - [_denoiseTune autorelease]; - if (denoiseTune) { _denoiseTune = [denoiseTune copy]; @@ -190,8 +178,6 @@ NSDictionary *_HandBrake_nlmeansTunesDict; - (void)setDenoiseCustomString:(NSString *)denoiseCustomString { - [_denoiseCustomString autorelease]; - if (denoiseCustomString) { _denoiseCustomString = [denoiseCustomString copy]; diff --git a/macosx/HBHUDButtonCell.m b/macosx/HBHUDButtonCell.m index 245ebb125..3464a7499 100644 --- a/macosx/HBHUDButtonCell.m +++ b/macosx/HBHUDButtonCell.m @@ -10,9 +10,9 @@ - (NSRect)drawTitle:(NSAttributedString *)title withFrame:(NSRect)frame inView:(NSView *)controlView { - NSAttributedString *attrLabel = [[[NSAttributedString alloc] initWithString:[title string] + NSAttributedString *attrLabel = [[NSAttributedString alloc] initWithString:[title string] attributes:@{ NSFontAttributeName:[NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize:self.controlSize]], - NSForegroundColorAttributeName: [NSColor whiteColor]}] autorelease]; + NSForegroundColorAttributeName: [NSColor whiteColor]}]; return [super drawTitle:attrLabel withFrame:frame inView:controlView]; } diff --git a/macosx/HBHUDView.m b/macosx/HBHUDView.m index e80e79093..a183faf8e 100644 --- a/macosx/HBHUDView.m +++ b/macosx/HBHUDView.m @@ -54,7 +54,6 @@ { // If NSVisualEffectView class is loaded // release ourself and return a NSVisualEffectView instance instead. - [self release]; self = [[NSClassFromString(@"NSVisualEffectView") alloc] initWithFrame:frame]; if (self) { diff --git a/macosx/HBImageAndTextCell.m b/macosx/HBImageAndTextCell.m index eebe2efca..57a4b023b 100644 --- a/macosx/HBImageAndTextCell.m +++ b/macosx/HBImageAndTextCell.m @@ -91,17 +91,10 @@ scaleProportionally(NSSize imageSize, NSRect canvasRect) return self; } -- (void)dealloc -{ - [image release]; - image = nil; - [super dealloc]; -} - - copyWithZone:(NSZone *)zone { HBImageAndTextCell *cell = (HBImageAndTextCell *)[super copyWithZone:zone]; - cell->image = [image retain]; + cell->image = image; return cell; } @@ -109,8 +102,7 @@ scaleProportionally(NSSize imageSize, NSRect canvasRect) { if (anImage != image) { - [image release]; - image = [anImage retain]; + image = anImage; } } diff --git a/macosx/HBJob+UIAdditions.m b/macosx/HBJob+UIAdditions.m index d35565d79..500026a3a 100644 --- a/macosx/HBJob+UIAdditions.m +++ b/macosx/HBJob+UIAdditions.m @@ -69,7 +69,7 @@ static NSDictionary *shortHeightAttr; [containers addObject:title]; } - return [[containers copy] autorelease]; + return [containers copy]; } - (void)initStyles @@ -77,22 +77,22 @@ static NSDictionary *shortHeightAttr; if (!ps) { // Attributes - ps = [[[NSParagraphStyle defaultParagraphStyle] mutableCopy] retain]; + ps = [[NSParagraphStyle defaultParagraphStyle] mutableCopy]; [ps setHeadIndent: 40.0]; [ps setParagraphSpacing: 1.0]; [ps setTabStops:@[]]; // clear all tabs - [ps addTabStop: [[[NSTextTab alloc] initWithType: NSLeftTabStopType location: 20.0] autorelease]]; + [ps addTabStop: [[NSTextTab alloc] initWithType: NSLeftTabStopType location: 20.0]]; - detailAttr = [@{NSFontAttributeName: [NSFont systemFontOfSize:10.0], - NSParagraphStyleAttributeName: ps} retain]; + detailAttr = @{NSFontAttributeName: [NSFont systemFontOfSize:10.0], + NSParagraphStyleAttributeName: ps}; - detailBoldAttr = [@{NSFontAttributeName: [NSFont boldSystemFontOfSize:10.0], - NSParagraphStyleAttributeName: ps} retain]; + detailBoldAttr = @{NSFontAttributeName: [NSFont boldSystemFontOfSize:10.0], + NSParagraphStyleAttributeName: ps}; - titleAttr = [@{NSFontAttributeName: [NSFont systemFontOfSize:[NSFont systemFontSize]], - NSParagraphStyleAttributeName: ps} retain]; + titleAttr = @{NSFontAttributeName: [NSFont systemFontOfSize:[NSFont systemFontSize]], + NSParagraphStyleAttributeName: ps}; - shortHeightAttr = [@{NSFontAttributeName: [NSFont systemFontOfSize:2.0]} retain]; + shortHeightAttr = @{NSFontAttributeName: [NSFont systemFontOfSize:2.0]}; } } @@ -150,7 +150,7 @@ static NSDictionary *shortHeightAttr; } } - [finalString appendString:[NSString stringWithFormat:@"%@", self.fileURL.path.lastPathComponent] withAttributes:titleAttr]; + [finalString appendString:[NSString stringWithFormat:@"%@", self.description] withAttributes:titleAttr]; // lets add the output file name to the title string here NSString *outputFilenameString = self.destURL.lastPathComponent; @@ -459,7 +459,7 @@ static NSDictionary *shortHeightAttr; } } - return [finalString autorelease]; + return finalString; } @end diff --git a/macosx/HBJob.h b/macosx/HBJob.h index 046bebeaa..673592ee1 100644 --- a/macosx/HBJob.h +++ b/macosx/HBJob.h @@ -17,6 +17,8 @@ #import "HBAudio.h" #import "HBSubtitles.h" +#import "HBDistributedArray.h" + extern NSString *HBContainerChangedNotification; extern NSString *HBChaptersChangedNotification; @@ -33,32 +35,25 @@ typedef NS_ENUM(NSUInteger, HBJobState){ /** * HBJob */ -@interface HBJob : NSObject <NSCoding, NSCopying> +@interface HBJob : NSObject <NSCoding, NSCopying, HBUniqueObject> - (instancetype)initWithTitle:(HBTitle *)title andPreset:(HBPreset *)preset; - (void)applyPreset:(HBPreset *)preset; - (void)applyCurrentSettingsToPreset:(NSMutableDictionary *)dict; -/** - * Current state of the job. - */ +/// Current state of the job. @property (nonatomic, readwrite) HBJobState state; -@property (nonatomic, readwrite, copy) NSString *presetName; - @property (nonatomic, readwrite, assign) HBTitle *title; @property (nonatomic, readonly) int titleIdx; -@property (nonatomic, readonly) NSString *uuid; -/** - * The file URL of the source. - */ +@property (nonatomic, readwrite, copy) NSString *presetName; + +/// The file URL of the source. @property (nonatomic, readonly) NSURL *fileURL; -/** - * The file URL at which the new file will be created. - */ +/// The file URL at which the new file will be created. @property (nonatomic, readwrite, copy) NSURL *destURL; // Job settings diff --git a/macosx/HBJob.m b/macosx/HBJob.m index d991d9709..778e36210 100644 --- a/macosx/HBJob.m +++ b/macosx/HBJob.m @@ -17,8 +17,14 @@ NSString *HBContainerChangedNotification = @"HBContainerChangedNotification"; NSString *HBChaptersChangedNotification = @"HBChaptersChangedNotification"; +@interface HBJob () +@property (nonatomic, readonly) NSString *name; +@end + @implementation HBJob +@synthesize uuid = _uuid; + - (instancetype)initWithTitle:(HBTitle *)title andPreset:(HBPreset *)preset { self = [super init]; @@ -29,7 +35,8 @@ NSString *HBChaptersChangedNotification = @"HBChaptersChangedNotification"; _title = title; _titleIdx = title.index; - _fileURL = [[NSURL fileURLWithPath:@(title.hb_title->path)] retain]; + _name = [title.name copy]; + _fileURL = [NSURL fileURLWithPath:@(title.hb_title->path)]; _container = HB_MUX_MP4; _angle = 1; @@ -44,7 +51,7 @@ NSString *HBChaptersChangedNotification = @"HBChaptersChangedNotification"; _chapterTitles = [title.chapters mutableCopy]; - _uuid = [[[NSUUID UUID] UUIDString] retain]; + _uuid = [[NSUUID UUID] UUIDString]; [self applyPreset:preset]; } @@ -132,25 +139,9 @@ NSString *HBChaptersChangedNotification = @"HBChaptersChangedNotification"; return retval; } -- (void)dealloc +- (NSString *)description { - [_audio release]; - [_subtitles release]; - - [_fileURL release]; - [_destURL release]; - - [_range release]; - [_video release]; - [_picture release]; - [_filters release]; - - [_chapterTitles release]; - - [_uuid release]; - [_presetName release]; - - [super dealloc]; + return self.name; } #pragma mark - NSCopying @@ -162,9 +153,10 @@ NSString *HBChaptersChangedNotification = @"HBChaptersChangedNotification"; if (copy) { copy->_state = HBJobStateReady; + copy->_name = [_name copy]; copy->_presetName = [_presetName copy]; copy->_titleIdx = _titleIdx; - copy->_uuid = [[[NSUUID UUID] UUIDString] retain]; + copy->_uuid = [[NSUUID UUID] UUIDString]; copy->_fileURL = [_fileURL copy]; copy->_destURL = [_destURL copy]; @@ -198,6 +190,7 @@ NSString *HBChaptersChangedNotification = @"HBChaptersChangedNotification"; [coder encodeInt:1 forKey:@"HBVideoVersion"]; encodeInt(_state); + encodeObject(_name); encodeObject(_presetName); encodeInt(_titleIdx); encodeObject(_uuid); @@ -227,6 +220,7 @@ NSString *HBChaptersChangedNotification = @"HBChaptersChangedNotification"; self = [super init]; decodeInt(_state); + decodeObject(_name); decodeObject(_presetName); decodeInt(_titleIdx); decodeObject(_uuid); diff --git a/macosx/HBLanguagesSelection.h b/macosx/HBLanguagesSelection.h index c5d96052e..4bcfecb21 100644 --- a/macosx/HBLanguagesSelection.h +++ b/macosx/HBLanguagesSelection.h @@ -52,6 +52,6 @@ */ @property (nonatomic, readwrite) BOOL isDragginEnabled; -@property (assign) IBOutlet NSTableView *tableView; +@property (unsafe_unretained) IBOutlet NSTableView *tableView; @end diff --git a/macosx/HBLanguagesSelection.m b/macosx/HBLanguagesSelection.m index 7e9ad62ac..f848f9a10 100644 --- a/macosx/HBLanguagesSelection.m +++ b/macosx/HBLanguagesSelection.m @@ -14,8 +14,8 @@ self = [super init]; if (self) { - _language = [value retain]; - _iso639_2 = [code retain]; + _language = value; + _iso639_2 = code; } return self; } @@ -25,20 +25,12 @@ HBLang *lang = [[self class] allocWithZone:zone]; lang->_isSelected = self.isSelected; - lang->_language = [self.language retain]; - lang->_iso639_2 = [self.iso639_2 retain]; + lang->_language = self.language; + lang->_iso639_2 = self.iso639_2; return lang; } -- (void)dealloc -{ - [_language release]; - [_iso639_2 release]; - - [super dealloc]; -} - - (NSString *)description { return self.language; @@ -79,12 +71,11 @@ [internal addObject:item]; } - [item release]; } // Add the (Any) item. - HBLang *item = [[[HBLang alloc] initWithLanguage:@"(Any)" - iso639_2code:@"und"] autorelease]; + HBLang *item = [[HBLang alloc] initWithLanguage:@"(Any)" + iso639_2code:@"und"]; if ([languages containsObject:item.iso639_2]) { item.isSelected = YES; @@ -99,7 +90,6 @@ [internal insertObjects:selected atIndexes:[NSIndexSet indexSetWithIndexesInRange:(NSMakeRange(1, selected.count))]]; - [selected release]; _languagesArray = internal; } @@ -109,7 +99,7 @@ - (NSArray *)selectedLanguages { - NSMutableArray *selected = [[[NSMutableArray alloc] init] autorelease]; + NSMutableArray *selected = [[NSMutableArray alloc] init]; for (HBLang *lang in self.languagesArray) { if (lang.isSelected) @@ -118,15 +108,9 @@ } } - return [[selected copy] autorelease]; + return [selected copy]; } -- (void)dealloc -{ - [_languagesArray release]; - - [super dealloc]; -} @end @@ -203,7 +187,6 @@ NSString *kHBLanguagesDragRowsType = @"kHBLanguagesDragRowsType"; } data = [NSKeyedArchiver archivedDataWithRootObject:unfilteredIndexes]; - [filteredArray release]; } else { @@ -290,10 +273,8 @@ NSString *kHBLanguagesDragRowsType = @"kHBLanguagesDragRowsType"; id object = objects[removeIndex]; // Move the object - [object retain]; [self removeObjectAtArrangedObjectIndex:removeIndex]; [self insertObject:object atArrangedObjectIndex:insertIndex]; - [object release]; thisIndex = [indexSet indexLessThanIndex:thisIndex]; } diff --git a/macosx/HBOutputFileWriter.m b/macosx/HBOutputFileWriter.m index 7215c1723..27ac917c5 100644 --- a/macosx/HBOutputFileWriter.m +++ b/macosx/HBOutputFileWriter.m @@ -36,8 +36,6 @@ - (void)dealloc { fclose(f); - [_url release]; - [super dealloc]; } - (void)writeHeaderForReason:(NSString *)reason diff --git a/macosx/HBOutputPanelController.m b/macosx/HBOutputPanelController.m index 909fbe736..2fc5f3032 100644 --- a/macosx/HBOutputPanelController.m +++ b/macosx/HBOutputPanelController.m @@ -71,6 +71,11 @@ // Add ourself as stderr/stdout listener [[HBOutputRedirect stderrRedirect] addListener:self]; [[HBOutputRedirect stdoutRedirect] addListener:self]; + + // Lets report the HandBrake version number here to the activity log and text log file + NSDictionary *infoDict = [[NSBundle mainBundle] infoDictionary]; + NSString *versionStringFull = [NSString stringWithFormat:@"Handbrake Version: %@ (%@)", infoDict[@"CFBundleShortVersionString"], infoDict[@"CFBundleVersion"]]; + [HBUtilities writeToActivityLog: "%s", versionStringFull.UTF8String]; } return self; } @@ -82,10 +87,6 @@ { [[HBOutputRedirect stderrRedirect] removeListener:self]; [[HBOutputRedirect stdoutRedirect] removeListener:self]; - [outputTextStorage release]; - [_outputFile release]; - - [super dealloc]; } /** @@ -115,7 +116,6 @@ NSAttributedString *attributedString = [[NSAttributedString alloc] initWithString:text]; /* Actually write the libhb output to the text view (outputTextStorage) */ [outputTextStorage appendAttributedString:attributedString]; - [attributedString release]; /* remove text from outputTextStorage as defined by TextStorageUpperSizeLimit and TextStorageLowerSizeLimit */ if (outputTextStorage.length > TextStorageUpperSizeLimit) diff --git a/macosx/HBOutputRedirect.m b/macosx/HBOutputRedirect.m index 9856e840a..f0561888f 100644 --- a/macosx/HBOutputRedirect.m +++ b/macosx/HBOutputRedirect.m @@ -50,7 +50,6 @@ int stdoutwrite(void *inFD, const char *buffer, int size) { NSData *data = [[NSData alloc] initWithBytes:buffer length:size]; [g_stdoutRedirect performSelectorOnMainThread:@selector(forwardOutput:) withObject:data waitUntilDone:NO]; - [data release]; } return size; } @@ -61,7 +60,6 @@ int stderrwrite(void *inFD, const char *buffer, int size) { NSData *data = [[NSData alloc] initWithBytes:buffer length:size]; [g_stderrRedirect performSelectorOnMainThread:@selector(forwardOutput:) withObject:data waitUntilDone:NO]; - [data release]; } return size; } @@ -101,7 +99,6 @@ int stderrwrite(void *inFD, const char *buffer, int size) if (![listeners containsObject:aListener]) { [listeners addObject:aListener]; - [aListener release]; } if ([listeners count] > 0) @@ -115,7 +112,6 @@ int stderrwrite(void *inFD, const char *buffer, int size) { if ([listeners containsObject:aListener]) { - [aListener retain]; [listeners removeObject:aListener]; } @@ -125,7 +121,6 @@ int stderrwrite(void *inFD, const char *buffer, int size) if ([listeners count] == 0) { [self stopRedirect]; - [self autorelease]; if (self == g_stdoutRedirect) g_stdoutRedirect = nil; @@ -160,15 +155,6 @@ int stderrwrite(void *inFD, const char *buffer, int size) } /** - * Frees all the listeners and deallocs the object. - */ -- (void)dealloc -{ - [listeners release]; - [super dealloc]; -} - -/** * Starts redirecting the stream by redirecting its output to function * @c stdoutwrite() or @c stderrwrite(). Old _write function is stored to * @c oldWriteFunc so it can be restored. @@ -205,7 +191,6 @@ int stderrwrite(void *inFD, const char *buffer, int size) if (string) { [listeners makeObjectsPerformSelector:forwardingSelector withObject:string]; - [string release]; } } diff --git a/macosx/HBPicture+UIAdditions.m b/macosx/HBPicture+UIAdditions.m index 60b761588..8dfd019cd 100644 --- a/macosx/HBPicture+UIAdditions.m +++ b/macosx/HBPicture+UIAdditions.m @@ -104,7 +104,7 @@ self.cropTop, self.cropBottom, self.cropLeft, self.cropRight]; - return [[summary copy] autorelease]; + return [summary copy]; } @end diff --git a/macosx/HBPicture.h b/macosx/HBPicture.h index ce63e68c2..bf2f6ec5c 100644 --- a/macosx/HBPicture.h +++ b/macosx/HBPicture.h @@ -41,7 +41,7 @@ extern NSString * const HBPictureChangedNotification; @property (nonatomic, readwrite) int cropLeft; @property (nonatomic, readwrite) int cropRight; -@property (nonatomic, readwrite, assign) HBTitle *title; +@property (nonatomic, readwrite, unsafe_unretained) HBTitle *title; @end diff --git a/macosx/HBPictureController.h b/macosx/HBPictureController.h index 6328cc7ab..6efbcbe5b 100644 --- a/macosx/HBPictureController.h +++ b/macosx/HBPictureController.h @@ -17,10 +17,10 @@ @interface HBPictureController : NSWindowController <NSWindowDelegate> -@property (nonatomic, readwrite, retain) HBFilters *filters; -@property (nonatomic, readwrite, retain) HBPicture *picture; +@property (nonatomic, readwrite, strong) HBFilters *filters; +@property (nonatomic, readwrite, strong) HBPicture *picture; -@property (nonatomic, readwrite, assign) id <HBPictureControllerDelegate> delegate; +@property (nonatomic, readwrite, unsafe_unretained) id <HBPictureControllerDelegate> delegate; - (void)showPictureWindow; diff --git a/macosx/HBPictureController.m b/macosx/HBPictureController.m index ff69f2dde..73c09f1e2 100644 --- a/macosx/HBPictureController.m +++ b/macosx/HBPictureController.m @@ -81,11 +81,6 @@ static void *HBPictureControllerContext = &HBPictureControllerContext; } } @catch (NSException * __unused exception) {} - - self.filters = nil; - self.picture = nil; - - [super dealloc]; } - (void)windowDidLoad diff --git a/macosx/HBPreferencesController.m b/macosx/HBPreferencesController.m index 8bbb58015..2419efd06 100644 --- a/macosx/HBPreferencesController.m +++ b/macosx/HBPreferencesController.m @@ -35,12 +35,12 @@ label: (NSString *)label image: (NSImage *)image; -@property (assign) IBOutlet NSTokenField *formatTokenField; -@property (assign) IBOutlet NSTokenField *builtInTokenField; -@property (nonatomic, readonly) NSArray *buildInFormatTokens; -@property (nonatomic, retain) NSArray *matches; +@property (unsafe_unretained) IBOutlet NSTokenField *formatTokenField; +@property (unsafe_unretained) IBOutlet NSTokenField *builtInTokenField; +@property (nonatomic, readonly, strong) NSArray *buildInFormatTokens; +@property (nonatomic, strong) NSArray *matches; -@property (nonatomic, retain) HBLanguagesSelection *languages; +@property (nonatomic, strong) HBLanguagesSelection *languages; @end @@ -100,12 +100,6 @@ return self; } -- (void)dealloc -{ - [_languages release]; - [super dealloc]; -} - - (void)showWindow:(id)sender { if (!self.window.isVisible) @@ -125,7 +119,7 @@ */ - (void) awakeFromNib { - NSToolbar * toolbar = [[[NSToolbar alloc] initWithIdentifier: @"Preferences Toolbar"] autorelease]; + NSToolbar * toolbar = [[NSToolbar alloc] initWithIdentifier: @"Preferences Toolbar"]; [toolbar setDelegate: self]; [toolbar setAllowsUserCustomization: NO]; [toolbar setDisplayMode: NSToolbarDisplayModeIconAndLabel]; @@ -136,7 +130,7 @@ [self.formatTokenField setTokenizingCharacterSet:[NSCharacterSet characterSetWithCharactersInString:@"%%"]]; [self.formatTokenField setCompletionDelay:0.2]; - _buildInFormatTokens = [@[@"{Source}", @"{Title}", @"{Date}", @"{Time}", @"{Chapters}", @"{Quality/Bitrate}"] retain]; + _buildInFormatTokens = @[@"{Source}", @"{Title}", @"{Date}", @"{Time}", @"{Chapters}", @"{Quality/Bitrate}"]; [self.builtInTokenField setTokenizingCharacterSet:[NSCharacterSet characterSetWithCharactersInString:@"%%"]]; [self.builtInTokenField setStringValue:[self.buildInFormatTokens componentsJoinedByString:@"%%"]]; @@ -343,7 +337,7 @@ [item setImage:image]; [item setAction:@selector(setPrefView:)]; [item setAutovalidates:NO]; - return [item autorelease]; + return item; } @end diff --git a/macosx/HBPreset.h b/macosx/HBPreset.h index 25c1e3b5d..a0a10e7f6 100644 --- a/macosx/HBPreset.h +++ b/macosx/HBPreset.h @@ -20,7 +20,7 @@ @property (nonatomic, copy) NSString *name; @property (nonatomic, copy) NSString *presetDescription; -@property (nonatomic, retain) NSDictionary *content; +@property (nonatomic, strong) NSDictionary *content; @property (nonatomic) BOOL isDefault; @property (nonatomic, readonly) BOOL isBuiltIn; diff --git a/macosx/HBPreset.m b/macosx/HBPreset.m index 7cf979152..0ad0a8c86 100644 --- a/macosx/HBPreset.m +++ b/macosx/HBPreset.m @@ -15,7 +15,7 @@ { _name = [title copy]; _isBuiltIn = builtIn; - _content = [content retain]; + _content = content; _presetDescription = [content[@"PresetDescription"] copy]; } return self; @@ -45,15 +45,6 @@ return self; } -- (void)dealloc -{ - [_name release]; - [_content release]; - [_presetDescription release]; - - [super dealloc]; -} - - (id)copyWithZone:(NSZone *)zone { HBPreset *node = [[self class] allocWithZone:zone]; @@ -62,7 +53,7 @@ node->_presetDescription = [self.presetDescription copy]; for (HBPreset *children in self.children) { - [node.children addObject:[[children copy] autorelease]]; + [node.children addObject:[children copy]]; } return node; @@ -75,7 +66,6 @@ - (void)setName:(NSString *)name { - [_name autorelease]; _name = [name copy]; [self.delegate nodeDidChange]; diff --git a/macosx/HBPresetsManager.h b/macosx/HBPresetsManager.h index 4eddec365..453475152 100644 --- a/macosx/HBPresetsManager.h +++ b/macosx/HBPresetsManager.h @@ -27,7 +27,7 @@ extern NSString *HBPresetsChangedNotification; /** * defaultPreset and its index path in the tree */ -@property (nonatomic, readwrite, retain) HBPreset *defaultPreset; +@property (nonatomic, readwrite, strong) HBPreset *defaultPreset; /** * Returs a HBPresetManager with the presets loaded at the passed URL. diff --git a/macosx/HBPresetsManager.m b/macosx/HBPresetsManager.m index 108859cbb..523e7f906 100644 --- a/macosx/HBPresetsManager.m +++ b/macosx/HBPresetsManager.m @@ -42,16 +42,6 @@ NSString *HBPresetsChangedNotification = @"HBPresetsChangedNotification"; return self; } -- (void)dealloc -{ - [_fileURL release]; - [_defaultPreset release]; - - [_root release]; - - [super dealloc]; -} - - (NSIndexPath *)indexPathOfPreset:(HBPreset *)preset { __block NSIndexPath *retValue = nil; @@ -61,12 +51,12 @@ NSString *HBPresetsChangedNotification = @"HBPresetsChangedNotification"; { if ([obj isEqualTo:preset]) { - retValue = [idx retain]; + retValue = idx; *stop = YES; } }]; - return [retValue autorelease]; + return retValue; } #pragma mark - HBTreeNode delegate @@ -87,8 +77,6 @@ NSString *HBPresetsChangedNotification = @"HBPresetsChangedNotification"; [self.root.children addObject:[self loadFromDict:child]]; } - [presetsArray release]; - // If the preset list contains no leaf, // add back the built in presets. __block BOOL leafFound = NO; @@ -115,7 +103,7 @@ NSString *HBPresetsChangedNotification = @"HBPresetsChangedNotification"; - (BOOL)savePresetsToURL:(NSURL *)url { - NSMutableArray *presetsArray = [[[NSMutableArray alloc] init] autorelease]; + NSMutableArray *presetsArray = [[NSMutableArray alloc] init]; for (HBPreset *node in self.root.children) { @@ -142,8 +130,8 @@ NSString *HBPresetsChangedNotification = @"HBPresetsChangedNotification"; HBPreset *node = nil; if ([dict[@"Folder"] boolValue]) { - node = [[[HBPreset alloc] initWithFolderName:dict[@"PresetName"] - builtIn:![dict[@"Type"] boolValue]] autorelease]; + node = [[HBPreset alloc] initWithFolderName:dict[@"PresetName"] + builtIn:![dict[@"Type"] boolValue]]; for (NSDictionary *child in dict[@"ChildrenArray"]) { @@ -152,9 +140,9 @@ NSString *HBPresetsChangedNotification = @"HBPresetsChangedNotification"; } else { - node = [[[HBPreset alloc] initWithName:dict[@"PresetName"] + node = [[HBPreset alloc] initWithName:dict[@"PresetName"] content:dict - builtIn:![dict[@"Type"] boolValue]] autorelease]; + builtIn:![dict[@"Type"] boolValue]]; node.isDefault = [dict[@"Default"] boolValue]; if ([dict[@"Default"] boolValue]) @@ -190,10 +178,9 @@ NSString *HBPresetsChangedNotification = @"HBPresetsChangedNotification"; } output[@"ChildrenArray"] = childArray; - [childArray release]; } - return [output autorelease]; + return output; } #pragma mark - Presets Management @@ -226,7 +213,6 @@ NSString *HBPresetsChangedNotification = @"HBPresetsChangedNotification"; builtIn:NO]; [self.root insertObject:presetNode inChildrenAtIndex:[self.root countOfChildren]]; - [presetNode release]; [self savePresets]; } @@ -335,10 +321,9 @@ NSString *HBPresetsChangedNotification = @"HBPresetsChangedNotification"; if (_defaultPreset) { _defaultPreset.isDefault = NO; - [_defaultPreset autorelease]; } defaultPreset.isDefault = YES; - _defaultPreset = [defaultPreset retain]; + _defaultPreset = defaultPreset; [self nodeDidChange]; } @@ -372,14 +357,11 @@ NSString *HBPresetsChangedNotification = @"HBPresetsChangedNotification"; // each time the app checks the version. presetDict[@"PresetBuildNumber"] = [[NSBundle mainBundle] infoDictionary][@"CFBundleVersion"]; [obj setContent:presetDict]; - [presetDict release]; }]; [self.root insertObject:preset inChildrenAtIndex:0]; } - [presetsArray release]; - // set a new Default preset [self selectNewDefault]; @@ -398,7 +380,6 @@ NSString *HBPresetsChangedNotification = @"HBPresetsChangedNotification"; } } [self.root.children removeObjectsInArray:nodeToRemove]; - [nodeToRemove release]; [self didChangeValueForKey:@"root"]; } diff --git a/macosx/HBPresetsViewController.h b/macosx/HBPresetsViewController.h index 6dab68f1c..7c7efa15c 100644 --- a/macosx/HBPresetsViewController.h +++ b/macosx/HBPresetsViewController.h @@ -20,14 +20,14 @@ - (instancetype)initWithPresetManager:(HBPresetsManager *)presetManager; -@property (nonatomic, readwrite, assign) id<HBPresetsViewControllerDelegate> delegate; +@property (nonatomic, readwrite, unsafe_unretained) id<HBPresetsViewControllerDelegate> delegate; - (void)deselect; - (void)setSelection:(HBPreset *)preset; - (IBAction)insertFolder:(id)sender; -@property (nonatomic, readonly) HBPreset *selectedPreset; +@property (unsafe_unretained, nonatomic, readonly) HBPreset *selectedPreset; @property (nonatomic, readonly) NSUInteger indexOfSelectedItem; @property (nonatomic, readwrite, getter=isEnabled) BOOL enabled; diff --git a/macosx/HBPresetsViewController.m b/macosx/HBPresetsViewController.m index c5df7e6fb..aab6e29f5 100644 --- a/macosx/HBPresetsViewController.m +++ b/macosx/HBPresetsViewController.m @@ -13,20 +13,20 @@ @interface HBPresetsViewController () <NSOutlineViewDelegate> -@property (nonatomic, retain) HBPresetsManager *presets; -@property (nonatomic, assign) IBOutlet NSTreeController *treeController; +@property (nonatomic, strong) HBPresetsManager *presets; +@property (nonatomic, unsafe_unretained) IBOutlet NSTreeController *treeController; /** * Helper var for drag & drop */ -@property (nonatomic, retain) NSArray *dragNodesArray; +@property (nonatomic, strong) NSArray *dragNodesArray; /** * The status (expanded or not) of the folders. */ -@property (nonatomic, retain) NSMutableArray *expandedNodes; +@property (nonatomic, strong) NSMutableArray *expandedNodes; -@property (assign) IBOutlet NSOutlineView *outlineView; +@property (unsafe_unretained) IBOutlet NSOutlineView *outlineView; @end @@ -39,22 +39,13 @@ self = [super initWithNibName:@"Presets" bundle:nil]; if (self) { - _presets = [presetManager retain]; + _presets = presetManager; _expandedNodes = [[NSArray arrayWithArray:[[NSUserDefaults standardUserDefaults] objectForKey:@"HBPreviewViewExpandedStatus"]] mutableCopy]; } return self; } -- (void)dealloc -{ - self.presets = nil; - self.dragNodesArray = nil; - self.expandedNodes = nil; - - [super dealloc]; -} - - (void)loadView { [super loadView]; @@ -135,7 +126,6 @@ HBPreset *node = [[HBPreset alloc] initWithFolderName:@"New Folder" builtIn:NO]; [self.treeController insertObject:node atArrangedObjectIndexPath:selectionIndexPath]; - [node autorelease]; } - (IBAction)setDefault:(id)sender diff --git a/macosx/HBPreviewController.h b/macosx/HBPreviewController.h index a3984a272..9dd2ccf7f 100644 --- a/macosx/HBPreviewController.h +++ b/macosx/HBPreviewController.h @@ -18,6 +18,6 @@ - (id)initWithDelegate:(id <HBPreviewControllerDelegate>)delegate; -@property (nonatomic, retain) HBPreviewGenerator *generator; +@property (nonatomic, strong) HBPreviewGenerator *generator; @end diff --git a/macosx/HBPreviewController.m b/macosx/HBPreviewController.m index bbe9ba537..0996122eb 100644 --- a/macosx/HBPreviewController.m +++ b/macosx/HBPreviewController.m @@ -93,22 +93,22 @@ typedef enum ViewMode : NSUInteger { IBOutlet NSPopUpButton * fPreviewMovieLengthPopUp; } -@property (nonatomic, assign) id <HBPreviewControllerDelegate> delegate; +@property (nonatomic, unsafe_unretained) id <HBPreviewControllerDelegate> delegate; -@property (nonatomic) CALayer *backLayer; -@property (nonatomic) CALayer *pictureLayer; +@property (nonatomic, strong) CALayer *backLayer; +@property (nonatomic, strong) CALayer *pictureLayer; @property (nonatomic) CGFloat backingScaleFactor; @property (nonatomic) ViewMode currentViewMode; @property (nonatomic) BOOL scaleToScreen; -@property (nonatomic, retain) NSTimer *hudTimer; +@property (nonatomic, strong) NSTimer *hudTimer; @property (nonatomic) NSUInteger pictureIndex; -@property (nonatomic, retain) QTMovie *movie; -@property (nonatomic, retain) NSTimer *movieTimer; +@property (nonatomic, strong) QTMovie *movie; +@property (nonatomic, strong) NSTimer *movieTimer; /* Pictures HUD actions */ - (IBAction) previewDurationPopUpChanged: (id) sender; @@ -134,22 +134,12 @@ typedef enum ViewMode : NSUInteger { { if (self = [super initWithWindowNibName:@"PicturePreview"]) { - // NSWindowController likes to lazily load its window. However since - // this controller tries to set all sorts of outlets before the window - // is displayed, we need it to load immediately. The correct way to do - // this, according to the documentation, is simply to invoke the window - // getter once. - // - // If/when we switch a lot of this stuff to bindings, this can probably - // go away. - [self window]; _delegate = delegate; - } return self; } -- (void) awakeFromNib +- (void)windowDidLoad { [[self window] setDelegate:self]; @@ -234,10 +224,9 @@ typedef enum ViewMode : NSUInteger { { _generator.delegate = nil; [_generator cancel]; - [_generator autorelease]; } - _generator = [generator retain]; + _generator = generator; if (generator) { @@ -248,7 +237,6 @@ typedef enum ViewMode : NSUInteger { [fPictureSlider setNumberOfTickMarks: generator.imagesCount]; [self switchViewToMode:ViewModePicturePreview]; - [self displayPreview]; } } @@ -529,18 +517,11 @@ typedef enum ViewMode : NSUInteger { - (void) dealloc { - [_hudTimer invalidate]; - [_hudTimer release]; + [self removeMovieObservers]; + [_hudTimer invalidate]; [_movieTimer invalidate]; - [_movieTimer release]; - [_generator cancel]; - [_generator release]; - - [self removeMovieObservers]; - - [super dealloc]; } #pragma mark - @@ -675,8 +656,9 @@ typedef enum ViewMode : NSUInteger { if (self.window.isVisible) { - fPreviewImage = [self.generator imageAtIndex:self.pictureIndex shouldCache:YES]; - [self.pictureLayer setContents:(id)fPreviewImage]; + fPreviewImage = [self.generator copyImageAtIndex:self.pictureIndex shouldCache:YES]; + [self.pictureLayer setContents:(__bridge id)(fPreviewImage)]; + CFRelease(fPreviewImage); } else { @@ -848,7 +830,7 @@ typedef enum ViewMode : NSUInteger { @"QTMovieIsSteppableAttribute": @(YES), QTMovieApertureModeAttribute: QTMovieApertureModeClean}; - QTMovie *movie = [[[QTMovie alloc] initWithAttributes:movieAttributes error:&outError] autorelease]; + QTMovie *movie = [[QTMovie alloc] initWithAttributes:movieAttributes error:&outError]; if (!movie) { diff --git a/macosx/HBPreviewGenerator.h b/macosx/HBPreviewGenerator.h index 50fe42400..64805e62e 100644 --- a/macosx/HBPreviewGenerator.h +++ b/macosx/HBPreviewGenerator.h @@ -22,12 +22,12 @@ @interface HBPreviewGenerator : NSObject -@property (nonatomic, assign) id <HBPreviewGeneratorDelegate> delegate; +@property (nonatomic, unsafe_unretained) id <HBPreviewGeneratorDelegate> delegate; - (instancetype)initWithCore:(HBCore *)core job:(HBJob *)job; /* Still image generator */ -- (CGImageRef) imageAtIndex: (NSUInteger) index shouldCache: (BOOL) cache; +- (CGImageRef) copyImageAtIndex: (NSUInteger) index shouldCache: (BOOL) cache; - (NSUInteger) imagesCount; - (void) purgeImageCache; diff --git a/macosx/HBPreviewGenerator.m b/macosx/HBPreviewGenerator.m index 46352aa55..5c9f2a788 100644 --- a/macosx/HBPreviewGenerator.m +++ b/macosx/HBPreviewGenerator.m @@ -16,10 +16,10 @@ @property (nonatomic, readonly) NSMutableDictionary *picturePreviews; @property (nonatomic, readonly) NSUInteger imagesCount; -@property (nonatomic, readonly) HBCore *scanCore; -@property (nonatomic, readonly) HBJob *job; +@property (unsafe_unretained, nonatomic, readonly) HBCore *scanCore; +@property (unsafe_unretained, nonatomic, readonly) HBJob *job; -@property (nonatomic) HBCore *core; +@property (unsafe_unretained, nonatomic) HBCore *core; @end @@ -41,6 +41,12 @@ return self; } +- (void)dealloc +{ + [[NSNotificationCenter defaultCenter] removeObserver:self]; + [self.core cancelEncode]; +} + #pragma mark - #pragma mark Preview images @@ -49,29 +55,33 @@ * * @param index picture index in title. */ -- (CGImageRef) imageAtIndex: (NSUInteger) index shouldCache: (BOOL) cache +- (CGImageRef) copyImageAtIndex: (NSUInteger) index shouldCache: (BOOL) cache { if (index >= self.imagesCount) return nil; // The preview for the specified index may not currently exist, so this method // generates it if necessary. - CGImageRef theImage = (CGImageRef)[self.picturePreviews objectForKey:@(index)]; + CGImageRef theImage = (__bridge CGImageRef)[self.picturePreviews objectForKey:@(index)]; if (!theImage) { HBFilters *filters = self.job.filters; BOOL deinterlace = (filters.deinterlace && !filters.useDecomb) || (filters.decomb && filters.useDecomb); - theImage = (CGImageRef)[(id)[self.scanCore copyImageAtIndex:index + theImage = (CGImageRef)[self.scanCore copyImageAtIndex:index forTitle:self.job.title pictureFrame:self.job.picture - deinterlace:deinterlace] autorelease]; + deinterlace:deinterlace]; if (cache && theImage) { - [self.picturePreviews setObject:(id)theImage forKey:@(index)]; + [self.picturePreviews setObject:(__bridge id)theImage forKey:@(index)]; } } + else + { + CFRetain(theImage); + } return theImage; } @@ -149,7 +159,7 @@ // See if there is an existing preview file, if so, delete it. [[NSFileManager defaultManager] removeItemAtURL:destURL error:NULL]; - HBJob *job = [[self.job copy] autorelease]; + HBJob *job = [self.job copy]; job.title = self.job.title; job.destURL = destURL; @@ -164,7 +174,7 @@ // Init the libhb core int loggingLevel = [[[NSUserDefaults standardUserDefaults] objectForKey:@"LoggingLevel"] intValue]; - self.core = [[[HBCore alloc] initWithLoggingLevel:loggingLevel] autorelease]; + self.core = [[HBCore alloc] initWithLoggingLevel:loggingLevel]; self.core.name = @"PreviewCore"; // start the actual encode @@ -222,18 +232,4 @@ } } -#pragma mark - - -- (void) dealloc -{ - [[NSNotificationCenter defaultCenter] removeObserver:self]; - - [self.core cancelEncode]; - - [_picturePreviews release]; - _picturePreviews = nil; - - [super dealloc]; -} - @end diff --git a/macosx/HBQueueController.h b/macosx/HBQueueController.h index 0e00267b9..8ef32b1ae 100644 --- a/macosx/HBQueueController.h +++ b/macosx/HBQueueController.h @@ -18,8 +18,8 @@ /// The HBCore used for encoding. @property (nonatomic, readonly) HBCore *core; -@property (nonatomic, assign) HBController *controller; -@property (nonatomic, assign) HBAppDelegate *delegate; +@property (nonatomic, unsafe_unretained) HBController *controller; +@property (nonatomic, unsafe_unretained) HBAppDelegate *delegate; @property (nonatomic, readonly) NSUInteger count; @property (nonatomic, readonly) NSUInteger pendingItemsCount; diff --git a/macosx/HBQueueController.m b/macosx/HBQueueController.m index a4cf287a7..c52dd3b68 100644 --- a/macosx/HBQueueController.m +++ b/macosx/HBQueueController.m @@ -37,22 +37,22 @@ @property (nonatomic, readonly) HBDockTile *dockTile; @property (nonatomic, readwrite) double dockIconProgress; -@property (assign) IBOutlet NSTextField *progressTextField; -@property (assign) IBOutlet NSTextField *countTextField; -@property (assign) IBOutlet HBQueueOutlineView *outlineView; +@property (unsafe_unretained) IBOutlet NSTextField *progressTextField; +@property (unsafe_unretained) IBOutlet NSTextField *countTextField; +@property (unsafe_unretained) IBOutlet HBQueueOutlineView *outlineView; @property (nonatomic, readonly) NSMutableDictionary *descriptions; @property (nonatomic, readonly) HBDistributedArray *jobs; -@property (nonatomic, retain) HBJob *currentJob; -@property (nonatomic, retain) HBJobOutputFileWriter *currentLog; +@property (nonatomic, strong) HBJob *currentJob; +@property (nonatomic, strong) HBJobOutputFileWriter *currentLog; @property (nonatomic, readwrite) BOOL stop; @property (nonatomic, readwrite) NSUInteger pendingItemsCount; @property (nonatomic, readwrite) NSUInteger workingItemsCount; -@property (nonatomic, retain) NSArray *dragNodesArray; +@property (nonatomic, strong) NSArray *dragNodesArray; @end @@ -93,16 +93,6 @@ [[self window] setDelegate:nil]; [[NSNotificationCenter defaultCenter] removeObserver:self]; - - [_core release]; - [_jobs release]; - [_currentJob release]; - - [_dockTile release]; - [_descriptions release]; - [_dragNodesArray release]; - - [super dealloc]; } - (void)windowDidLoad @@ -428,10 +418,9 @@ insertIndex--; } - id object = [self.jobs[removeIndex] retain]; + id object = self.jobs[removeIndex]; [self.jobs removeObjectAtIndex:removeIndex]; [self.jobs insertObject:object atIndex:insertIndex]; - [object release]; // We save all of the Queue data here // and it also gets sent back to the queue controller @@ -458,7 +447,7 @@ self.currentJob.state = HBJobStateWorking; // Tell HB to output a new activity log file for this encode - self.currentLog = [[[HBJobOutputFileWriter alloc] initWithJob:self.currentJob] autorelease]; + self.currentLog = [[HBJobOutputFileWriter alloc] initWithJob:self.currentJob]; [[HBOutputRedirect stderrRedirect] addListener:self.currentLog]; [[HBOutputRedirect stdoutRedirect] addListener:self.currentLog]; @@ -781,7 +770,6 @@ [HBUtilities writeToActivityLog: "trying to send encode to: %s", [sendToApp UTF8String]]; NSAppleScript *myScript = [[NSAppleScript alloc] initWithSource: [NSString stringWithFormat: @"%@%@%@%@%@", @"tell application \"",sendToApp,@"\" to open (POSIX file \"", fileURL.path, @"\")"]]; [myScript executeAndReturnError: nil]; - [myScript release]; } } } @@ -804,7 +792,6 @@ [alert setInformativeText:NSLocalizedString(@"Your HandBrake queue is done!", @"")]; [NSApp requestUserAttention:NSCriticalRequest]; [alert runModal]; - [alert release]; } // If sleep has been selected @@ -815,7 +802,6 @@ NSAppleScript *scriptObject = [[NSAppleScript alloc] initWithSource: @"tell application \"Finder\" to sleep"]; [scriptObject executeAndReturnError: &errorDict]; - [scriptObject release]; } // If Shutdown has been selected if( [[[NSUserDefaults standardUserDefaults] stringForKey:@"AlertWhenDone"] isEqualToString: @"Shut Down Computer"] ) @@ -824,7 +810,6 @@ NSDictionary *errorDict; NSAppleScript *scriptObject = [[NSAppleScript alloc] initWithSource:@"tell application \"Finder\" to shut down"]; [scriptObject executeAndReturnError: &errorDict]; - [scriptObject release]; } } @@ -876,8 +861,7 @@ [alert beginSheetModalForWindow:targetWindow modalDelegate:self didEndSelector:@selector(didDimissCancelCurrentJob:returnCode:contextInfo:) - contextInfo:self.jobs[row]]; - [alert release]; + contextInfo:(__bridge void *)(self.jobs[row])]; } else if ([self.jobs[row] state] != HBJobStateWorking) { @@ -943,7 +927,6 @@ { [self.delegate showPreferencesWindow:nil]; } - [alert release]; } else if ([[[NSUserDefaults standardUserDefaults] stringForKey:@"AlertWhenDone"] isEqualToString:@"Shut Down Computer"]) { @@ -962,7 +945,6 @@ { [self.delegate showPreferencesWindow:nil]; } - [alert release]; } } @@ -1024,7 +1006,6 @@ modalDelegate:self didEndSelector:@selector(didDimissCancel:returnCode:contextInfo:) contextInfo:nil]; - [alert release]; } - (void)didDimissCancel:(NSAlert *)alert @@ -1113,13 +1094,12 @@ [alert beginSheetModalForWindow:docWindow modalDelegate:self didEndSelector:@selector(didDimissCancelCurrentJob:returnCode:contextInfo:) - contextInfo:job]; - [alert release]; + contextInfo:(__bridge void *)(job)]; } else { // since we are not a currently encoding item, we can just be cancelled - HBJob *item = [[[self.jobs[row] representedObject] copy] autorelease]; + HBJob *item = [[self.jobs[row] representedObject] copy]; [self.controller rescanJobToMainWindow:item]; // Now that source is loaded and settings applied, delete the queue item from the queue diff --git a/macosx/HBQueueOutlineView.m b/macosx/HBQueueOutlineView.m index 2408f9129..53e7a3fac 100644 --- a/macosx/HBQueueOutlineView.m +++ b/macosx/HBQueueOutlineView.m @@ -91,7 +91,7 @@ [rowIndexes addIndexes:selectedRowIndexes]; } - return [[rowIndexes copy] autorelease]; + return [rowIndexes copy]; } @end diff --git a/macosx/HBRange.h b/macosx/HBRange.h index fcf455b2f..ac0985661 100644 --- a/macosx/HBRange.h +++ b/macosx/HBRange.h @@ -42,6 +42,6 @@ typedef NS_ENUM(NSUInteger, HBRangeType) { @property (nonatomic, readonly) NSString *duration; -@property (nonatomic, readwrite, assign) HBTitle *title; +@property (nonatomic, readwrite, unsafe_unretained) HBTitle *title; @end diff --git a/macosx/HBSubtitles.h b/macosx/HBSubtitles.h index ac8483f63..4b3eb2288 100644 --- a/macosx/HBSubtitles.h +++ b/macosx/HBSubtitles.h @@ -42,13 +42,13 @@ extern NSString *keySubTrackLanguageIndex; @property (nonatomic, readonly) NSMutableArray *masterTrackArray; // the master list of audio tracks from the title @property (nonatomic, readonly) NSMutableArray *tracks; -@property (nonatomic, readwrite, retain) NSString *foreignAudioSearchTrackName; +@property (nonatomic, readwrite, strong) NSString *foreignAudioSearchTrackName; @property (nonatomic, readonly) NSArray *charCodeArray; @property (nonatomic, readonly) NSArray *languagesArray; @property (nonatomic, readonly) NSInteger languagesArrayDefIndex; -@property (nonatomic, readwrite, retain) HBSubtitlesDefaults *defaults; +@property (nonatomic, readwrite, strong) HBSubtitlesDefaults *defaults; /** * For internal use diff --git a/macosx/HBSubtitles.m b/macosx/HBSubtitles.m index a8fed1cae..a0d7402bd 100644 --- a/macosx/HBSubtitles.m +++ b/macosx/HBSubtitles.m @@ -85,23 +85,6 @@ NSString *keySubTrackLanguageIndex = @"keySubTrackLanguageIndex"; return self; } -- (void)dealloc -{ - [_tracks release]; - _tracks = nil; - - [_defaults release]; - _defaults = nil; - - [_masterTrackArray release]; - _masterTrackArray = nil; - - [_foreignAudioSearchTrackName release]; - _foreignAudioSearchTrackName = nil; - - [super dealloc]; -} - - (void)addAllTracks { [self.tracks removeAllObjects]; @@ -164,7 +147,7 @@ NSString *keySubTrackLanguageIndex = @"keySubTrackLanguageIndex"; newSubtitleTrack[keySubTrackBurned] = @0; newSubtitleTrack[keySubTrackDefault] = @0; - return [newSubtitleTrack autorelease]; + return newSubtitleTrack; } /** @@ -358,7 +341,6 @@ NSString *keySubTrackLanguageIndex = @"keySubTrackLanguageIndex"; } } [self.tracks removeObjectsInArray:tracksToDelete]; - [tracksToDelete release]; } // Add an empty track @@ -424,7 +406,6 @@ NSString *keySubTrackLanguageIndex = @"keySubTrackLanguageIndex"; } [self didChangeValueForKey:@"tracks"]; - [tracksToDelete release]; } #pragma mark - Languages @@ -435,7 +416,7 @@ NSString *keySubTrackLanguageIndex = @"keySubTrackLanguageIndex"; { if (!_languagesArray) { - _languagesArray = [[self populateLanguageArray] retain]; + _languagesArray = [self populateLanguageArray]; } return _languagesArray; @@ -443,7 +424,7 @@ NSString *keySubTrackLanguageIndex = @"keySubTrackLanguageIndex"; - (NSArray *)populateLanguageArray { - NSMutableArray *languages = [[[NSMutableArray alloc] init] autorelease]; + NSMutableArray *languages = [[NSMutableArray alloc] init]; for (const iso639_lang_t * lang = lang_get_next(NULL); lang != NULL; lang = lang_get_next(lang)) { @@ -454,7 +435,7 @@ NSString *keySubTrackLanguageIndex = @"keySubTrackLanguageIndex"; _languagesArrayDefIndex = [languages count] - 1; } } - return [[languages copy] autorelease]; + return [languages copy]; } @synthesize charCodeArray = _charCodeArray; @@ -464,11 +445,11 @@ NSString *keySubTrackLanguageIndex = @"keySubTrackLanguageIndex"; if (!_charCodeArray) { // populate the charCodeArray. - _charCodeArray = [@[@"ANSI_X3.4-1968", @"ANSI_X3.4-1986", @"ANSI_X3.4", @"ANSI_X3.110-1983", @"ANSI_X3.110", @"ASCII", + _charCodeArray = @[@"ANSI_X3.4-1968", @"ANSI_X3.4-1986", @"ANSI_X3.4", @"ANSI_X3.110-1983", @"ANSI_X3.110", @"ASCII", @"ECMA-114", @"ECMA-118", @"ECMA-128", @"ECMA-CYRILLIC", @"IEC_P27-1", @"ISO-8859-1", @"ISO-8859-2", @"ISO-8859-3", @"ISO-8859-4", @"ISO-8859-5", @"ISO-8859-6", @"ISO-8859-7", @"ISO-8859-8", @"ISO-8859-9", @"ISO-8859-9E", @"ISO-8859-10", @"ISO-8859-11", @"ISO-8859-13", @"ISO-8859-14", @"ISO-8859-15", @"ISO-8859-16", - @"UTF-7", @"UTF-8", @"UTF-16", @"UTF-16LE", @"UTF-16BE", @"UTF-32", @"UTF-32LE", @"UTF-32BE"] retain]; + @"UTF-7", @"UTF-8", @"UTF-16", @"UTF-16LE", @"UTF-16BE", @"UTF-32", @"UTF-32LE", @"UTF-32BE"]; } return _charCodeArray; } @@ -491,7 +472,7 @@ NSString *keySubTrackLanguageIndex = @"keySubTrackLanguageIndex"; if (idx < _tracks.count) { NSMutableDictionary *trackCopy = [obj copy]; - [copy->_tracks addObject:[trackCopy autorelease]]; + [copy->_tracks addObject:trackCopy]; } }]; diff --git a/macosx/HBSubtitlesController.h b/macosx/HBSubtitlesController.h index b65cb35e2..df72a30dd 100644 --- a/macosx/HBSubtitlesController.h +++ b/macosx/HBSubtitlesController.h @@ -13,6 +13,6 @@ */ @interface HBSubtitlesController : NSViewController -@property (nonatomic, readwrite, assign) HBSubtitles *subtitles; +@property (nonatomic, readwrite, unsafe_unretained) HBSubtitles *subtitles; @end diff --git a/macosx/HBSubtitlesController.m b/macosx/HBSubtitlesController.m index 5f2c7ef5b..509ab0de5 100644 --- a/macosx/HBSubtitlesController.m +++ b/macosx/HBSubtitlesController.m @@ -18,10 +18,10 @@ static void *HBSubtitlesControllerContext = &HBSubtitlesControllerContext; @interface HBSubtitlesController () <NSTableViewDataSource, NSTableViewDelegate> // IBOutles -@property (assign) IBOutlet NSTableView *fTableView; +@property (unsafe_unretained) IBOutlet NSTableView *fTableView; // Defaults -@property (nonatomic, readwrite, retain) HBSubtitlesDefaultsController *defaultsController; +@property (nonatomic, readwrite, strong) HBSubtitlesDefaultsController *defaultsController; // Cached table view's cells @property (nonatomic, readonly) NSPopUpButtonCell *languagesCell; @@ -103,7 +103,7 @@ static void *HBSubtitlesControllerContext = &HBSubtitlesControllerContext; - (IBAction)showSettingsSheet:(id)sender { - self.defaultsController = [[[HBSubtitlesDefaultsController alloc] initWithSettings:self.subtitles.defaults] autorelease]; + self.defaultsController = [[HBSubtitlesDefaultsController alloc] initWithSettings:self.subtitles.defaults]; [NSApp beginSheet:[self.defaultsController window] modalForWindow:[[self view] window] @@ -377,7 +377,7 @@ static void *HBSubtitlesControllerContext = &HBSubtitlesControllerContext; [[cellTrackPopup menu] addItemWithTitle:track[keySubTrackName] action:NULL keyEquivalent:@""]; } - return [cellTrackPopup autorelease]; + return cellTrackPopup; } else if ([[tableColumn identifier] isEqualToString:@"srt_lang"]) { diff --git a/macosx/HBSubtitlesDefaults.h b/macosx/HBSubtitlesDefaults.h index 793e31d3a..60127b437 100644 --- a/macosx/HBSubtitlesDefaults.h +++ b/macosx/HBSubtitlesDefaults.h @@ -23,7 +23,7 @@ typedef NS_ENUM(NSUInteger, HBSubtitleTrackBurnInBehavior) { @interface HBSubtitlesDefaults : NSObject <NSCoding, NSCopying, HBPresetCoding> @property (nonatomic, readwrite) HBSubtitleTrackSelectionBehavior trackSelectionBehavior; -@property (nonatomic, readwrite, retain) NSMutableArray *trackSelectionLanguages; +@property (nonatomic, readwrite, strong) NSMutableArray *trackSelectionLanguages; @property (nonatomic, readwrite) BOOL addForeignAudioSearch; @property (nonatomic, readwrite) BOOL addForeignAudioSubtitle; diff --git a/macosx/HBSubtitlesDefaults.m b/macosx/HBSubtitlesDefaults.m index ef31e0726..e634ecda9 100644 --- a/macosx/HBSubtitlesDefaults.m +++ b/macosx/HBSubtitlesDefaults.m @@ -76,7 +76,7 @@ preset[@"SubtitleTrackSelectionBehavior"] = @"none"; } - preset[@"SubtitleLanguageList"] = [[self.trackSelectionLanguages copy] autorelease]; + preset[@"SubtitleLanguageList"] = [self.trackSelectionLanguages copy]; preset[@"SubtitleAddCC"] = @(self.addCC); preset[@"SubtitleAddForeignAudioSearch"] = @(self.addForeignAudioSearch); preset[@"SubtitleAddForeignAudioSubtitle"] = @(self.addForeignAudioSubtitle); @@ -111,7 +111,6 @@ if (copy) { copy->_trackSelectionBehavior = _trackSelectionBehavior; - [copy->_trackSelectionLanguages release]; copy->_trackSelectionLanguages = [_trackSelectionLanguages mutableCopy]; copy->_addForeignAudioSearch = _addForeignAudioSearch; @@ -162,10 +161,5 @@ return self; } -- (void)dealloc -{ - [_trackSelectionLanguages release]; - [super dealloc]; -} @end diff --git a/macosx/HBSubtitlesDefaultsController.m b/macosx/HBSubtitlesDefaultsController.m index f98423394..9d1c7f875 100644 --- a/macosx/HBSubtitlesDefaultsController.m +++ b/macosx/HBSubtitlesDefaultsController.m @@ -15,8 +15,8 @@ static void *HBSubtitlesDefaultsContex = &HBSubtitlesDefaultsContex; @property (nonatomic, readonly) HBSubtitlesDefaults *settings; @property (nonatomic, readonly) HBLanguagesSelection *languagesList; -@property (assign) IBOutlet HBLanguageArrayController *tableController; -@property (assign) IBOutlet NSButton *showAllButton; +@property (unsafe_unretained) IBOutlet HBLanguageArrayController *tableController; +@property (unsafe_unretained) IBOutlet NSButton *showAllButton; @end @@ -27,7 +27,7 @@ static void *HBSubtitlesDefaultsContex = &HBSubtitlesDefaultsContex; self = [super initWithWindowNibName:@"SubtitlesDefaults"]; if (self) { - _settings = [settings retain]; + _settings = settings; _languagesList = [[HBLanguagesSelection alloc] initWithLanguages:_settings.trackSelectionLanguages]; } return self; @@ -74,14 +74,9 @@ static void *HBSubtitlesDefaultsContex = &HBSubtitlesDefaultsContex; - (void)dealloc { - [_settings release]; - [_languagesList release]; - @try { [self removeObserver:self forKeyPath:@"tableController.showSelectedOnly"]; } @catch (NSException * __unused exception) {} - - [super dealloc]; } @end diff --git a/macosx/HBTitle.m b/macosx/HBTitle.m index 7d44baef3..be5158327 100644 --- a/macosx/HBTitle.m +++ b/macosx/HBTitle.m @@ -33,7 +33,7 @@ extern NSString *keySubTrackSrtCharCode; @interface HBTitle () -@property (nonatomic, readwrite) NSString *name; +@property (nonatomic, readwrite, strong) NSString *name; @property (nonatomic, readwrite) NSArray *audioTracks; @property (nonatomic, readwrite) NSArray *subtitlesTracks; @@ -50,7 +50,6 @@ extern NSString *keySubTrackSrtCharCode; { if (!title) { - [self release]; return nil; } @@ -61,16 +60,6 @@ extern NSString *keySubTrackSrtCharCode; return self; } -- (void)dealloc -{ - [_name release]; - [_audioTracks release]; - [_subtitlesTracks release]; - [_chapters release]; - - [super dealloc]; -} - - (NSString *)name { if (!_name) @@ -82,8 +71,6 @@ extern NSString *keySubTrackSrtCharCode; { _name = [@(self.hb_title->path) lastPathComponent]; } - - [_name retain]; } return _name; @@ -233,5 +220,4 @@ extern NSString *keySubTrackSrtCharCode; return _chapters; } - @end diff --git a/macosx/HBTitleSelectionController.m b/macosx/HBTitleSelectionController.m index 814c78991..e7d4d4a70 100644 --- a/macosx/HBTitleSelectionController.m +++ b/macosx/HBTitleSelectionController.m @@ -12,7 +12,7 @@ @property (nonatomic, readonly) NSArray *titles; @property (nonatomic, readonly) NSMutableArray *selection; -@property (nonatomic, readonly) id<HBTitleSelectionDelegate> delegate; +@property (nonatomic, readonly, unsafe_unretained) id<HBTitleSelectionDelegate> delegate; @end @@ -23,7 +23,7 @@ self = [super initWithWindowNibName:@"HBTitleSelection"]; if (self) { - _titles = [titles retain]; + _titles = titles; _selection = [[NSMutableArray alloc] initWithCapacity:titles.count]; _delegate = delegate; @@ -36,17 +36,6 @@ return self; } -- (void)dealloc -{ - [_titles release]; - _titles = nil; - - [_selection release]; - _selection = nil; - - [super dealloc]; -} - - (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView { return self.titles.count; diff --git a/macosx/HBTreeNode.h b/macosx/HBTreeNode.h index e3c3d34b3..1c804b94d 100644 --- a/macosx/HBTreeNode.h +++ b/macosx/HBTreeNode.h @@ -26,7 +26,7 @@ @property (nonatomic, readonly) NSMutableArray *children; @property (nonatomic) BOOL isLeaf; -@property (nonatomic, assign) id<HBTreeNodeDelegate> delegate; +@property (nonatomic, unsafe_unretained) id<HBTreeNodeDelegate> delegate; /** * Executes a given block using each object in the tree, starting with the root object and continuing through the tree to the last object. diff --git a/macosx/HBTreeNode.m b/macosx/HBTreeNode.m index c6a8f0959..a2a69f406 100644 --- a/macosx/HBTreeNode.m +++ b/macosx/HBTreeNode.m @@ -18,12 +18,6 @@ return self; } -- (void)dealloc -{ - [_children release]; - [super dealloc]; -} - - (NSUInteger)countOfChildren { return self.children.count; @@ -57,7 +51,7 @@ NSMutableArray *indexesQueue = [[NSMutableArray alloc] init]; [queue addObject:self]; - [indexesQueue addObject:[[[NSIndexPath alloc] init] autorelease]]; + [indexesQueue addObject:[[NSIndexPath alloc] init]]; HBTreeNode *node = nil; while ((node = [queue lastObject]) != nil) @@ -87,9 +81,6 @@ [queue addObject:childNode]; } } - - [queue release]; - [indexesQueue release]; } @end diff --git a/macosx/HBUtilities.m b/macosx/HBUtilities.m index 3e4fdb272..cf57feb35 100644 --- a/macosx/HBUtilities.m +++ b/macosx/HBUtilities.m @@ -54,7 +54,7 @@ bitrate:(int)bitrate videoCodec:(uint32_t)codec { - NSMutableString *name = [[[NSMutableString alloc] init] autorelease]; + NSMutableString *name = [[NSMutableString alloc] init]; // The format array contains the tokens as NSString NSArray *format = [[NSUserDefaults standardUserDefaults] objectForKey:@"HBAutoNamingFormat"]; @@ -132,7 +132,7 @@ } } - return [[name copy] autorelease]; + return [name copy]; } diff --git a/macosx/HBVideo+UIAdditions.m b/macosx/HBVideo+UIAdditions.m index ad5d1e1a6..5c4461835 100644 --- a/macosx/HBVideo+UIAdditions.m +++ b/macosx/HBVideo+UIAdditions.m @@ -31,7 +31,7 @@ [encoders addObject:@(video_encoder->name)]; } } - return [[encoders copy] autorelease]; + return [encoders copy]; } - (NSArray *)frameRates @@ -64,7 +64,7 @@ [framerates addObject:itemTitle]; } - return [[framerates copy] autorelease]; + return [framerates copy]; } - (BOOL)fastDecodeSupported diff --git a/macosx/HBVideo.h b/macosx/HBVideo.h index 257c6d29c..04aa1aa36 100644 --- a/macosx/HBVideo.h +++ b/macosx/HBVideo.h @@ -46,7 +46,7 @@ extern NSString * const HBVideoChangedNotification; @property (nonatomic, readwrite) BOOL fastDecode; -@property (nonatomic, readwrite, assign) HBJob *job; +@property (nonatomic, readwrite, unsafe_unretained) HBJob *job; @property (nonatomic, readonly) NSString *completeTune; @end diff --git a/macosx/HBVideo.m b/macosx/HBVideo.m index a5bbd15d7..f4cdaf424 100644 --- a/macosx/HBVideo.m +++ b/macosx/HBVideo.m @@ -162,15 +162,12 @@ NSString * const HBVideoChangedNotification = @"HBVideoChangedNotification"; - (void)setPreset:(NSString *)preset { - [_preset autorelease]; _preset = [preset copy]; [self postChangedNotification]; } - (void)setTune:(NSString *)tune { - [_tune autorelease]; - if (![tune isEqualToString:@"none"]) { _tune = [tune copy]; @@ -185,21 +182,18 @@ NSString * const HBVideoChangedNotification = @"HBVideoChangedNotification"; - (void)setProfile:(NSString *)profile { - [_profile autorelease]; _profile = [profile copy]; [self postChangedNotification]; } - (void)setLevel:(NSString *)level { - [_level autorelease]; _level = [level copy]; [self postChangedNotification]; } - (void)setVideoOptionExtra:(NSString *)videoOptionExtra { - [_videoOptionExtra autorelease]; if (videoOptionExtra != nil) { _videoOptionExtra = [videoOptionExtra copy]; @@ -305,7 +299,7 @@ NSString * const HBVideoChangedNotification = @"HBVideoChangedNotification"; } } - return [[temp copy] autorelease]; + return [temp copy]; } - (NSArray *)tunes @@ -325,7 +319,7 @@ NSString * const HBVideoChangedNotification = @"HBVideoChangedNotification"; } } - return [[temp copy] autorelease]; + return [temp copy]; } - (NSArray *)profiles @@ -338,7 +332,7 @@ NSString * const HBVideoChangedNotification = @"HBVideoChangedNotification"; [temp addObject:@(profiles[i])]; } - return [[temp copy] autorelease]; + return [temp copy]; } - (NSArray *)levels @@ -355,7 +349,7 @@ NSString * const HBVideoChangedNotification = @"HBVideoChangedNotification"; [temp addObject:@"auto"]; } - return [[temp copy] autorelease]; + return [temp copy]; } #pragma mark - NSCopying @@ -497,7 +491,7 @@ NSString * const HBVideoChangedNotification = @"HBVideoChangedNotification"; [string appendString:@"fastdecode"]; } - return [string autorelease]; + return string; } - (void)applyPreset:(NSDictionary *)preset diff --git a/macosx/HBVideoController.h b/macosx/HBVideoController.h index d62edf45a..6ea8bc41c 100644 --- a/macosx/HBVideoController.h +++ b/macosx/HBVideoController.h @@ -16,6 +16,6 @@ - (instancetype)initWithAdvancedController:(HBAdvancedController *)advancedController; -@property (nonatomic, readwrite, assign) HBJob *job; +@property (nonatomic, readwrite, unsafe_unretained) HBJob *job; @end diff --git a/macosx/HBVideoController.m b/macosx/HBVideoController.m index 16b1c6d7e..0ffc87b5d 100644 --- a/macosx/HBVideoController.m +++ b/macosx/HBVideoController.m @@ -36,8 +36,8 @@ static void *HBVideoControllerContext = &HBVideoControllerContext; IBOutlet NSTextField *fDisplayX264PresetsUnparseTextField; } -@property (nonatomic, retain, readwrite) HBAdvancedController *advancedController; -@property (nonatomic, readwrite, assign) HBVideo *video; +@property (nonatomic, strong, readwrite) HBAdvancedController *advancedController; +@property (nonatomic, readwrite, unsafe_unretained) HBVideo *video; @property (nonatomic, readwrite) BOOL presetViewEnabled; @@ -52,7 +52,7 @@ static void *HBVideoControllerContext = &HBVideoControllerContext; self = [self init]; if (self) { - _advancedController = [advancedController retain]; + _advancedController = advancedController; } return self; } @@ -62,7 +62,7 @@ static void *HBVideoControllerContext = &HBVideoControllerContext; self = [super initWithNibName:@"Video" bundle:nil]; if (self) { - _labelColor = [[NSColor disabledControlTextColor] retain]; + _labelColor = [NSColor disabledControlTextColor]; // Observe the advanced tab pref shown/hided state. [[NSUserDefaultsController sharedUserDefaultsController] addObserver:self @@ -196,7 +196,7 @@ static void *HBVideoControllerContext = &HBVideoControllerContext; // Replace the slider transformer with a new one, // configured with the new max/min/direction values. [fVidQualitySlider unbind:@"value"]; - HBQualityTransformer *transformer = [[[HBQualityTransformer alloc] initWithReversedDirection:(direction != 0) min:minValue max:maxValue] autorelease]; + HBQualityTransformer *transformer = [[HBQualityTransformer alloc] initWithReversedDirection:(direction != 0) min:minValue max:maxValue]; [fVidQualitySlider bind:@"value" toObject:self withKeyPath:@"self.video.quality" options:@{NSValueTransformerBindingOption: transformer}]; } @@ -280,7 +280,7 @@ static void *HBVideoControllerContext = &HBVideoControllerContext; // Bind the slider value to a custom value transformer, // done here because it can't be done in IB. [fPresetsSlider unbind:@"value"]; - HBPresetsTransformer *transformer = [[[HBPresetsTransformer alloc] initWithEncoder:self.video.encoder] autorelease]; + HBPresetsTransformer *transformer = [[HBPresetsTransformer alloc] initWithEncoder:self.video.encoder]; [fPresetsSlider bind:@"value" toObject:self withKeyPath:@"self.video.preset" options:@{NSValueTransformerBindingOption: transformer}]; } diff --git a/macosx/HandBrake.xcodeproj/project.pbxproj b/macosx/HandBrake.xcodeproj/project.pbxproj index 2b2ae6f3c..d4581b9b5 100644 --- a/macosx/HandBrake.xcodeproj/project.pbxproj +++ b/macosx/HandBrake.xcodeproj/project.pbxproj @@ -1128,7 +1128,7 @@ 273F1FE014AD9DA40021BE6D /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0620; + LastUpgradeCheck = 0630; }; buildConfigurationList = 273F1FE314AD9DA40021BE6D /* Build configuration list for PBXProject "HandBrake" */; compatibilityVersion = "Xcode 3.2"; @@ -1502,6 +1502,7 @@ EXTERNAL_SRC = ..; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_ENABLE_OBJC_EXCEPTIONS = YES; + GCC_NO_COMMON_BLOCKS = YES; GCC_OPTIMIZATION_LEVEL = 0; GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", @@ -1554,6 +1555,7 @@ EXTERNAL_SRC = ..; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_ENABLE_OBJC_EXCEPTIONS = YES; + GCC_NO_COMMON_BLOCKS = YES; GCC_VERSION = com.apple.compilers.llvm.clang.1_0; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES; @@ -1613,6 +1615,7 @@ 273F205414ADBC210021BE6D /* debug */ = { isa = XCBuildConfiguration; buildSettings = { + CLANG_ENABLE_OBJC_ARC = YES; COMBINE_HIDPI_IMAGES = YES; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -1637,6 +1640,7 @@ 273F205514ADBC210021BE6D /* release */ = { isa = XCBuildConfiguration; buildSettings = { + CLANG_ENABLE_OBJC_ARC = YES; COMBINE_HIDPI_IMAGES = YES; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", diff --git a/macosx/HandBrake.xcodeproj/xcshareddata/xcschemes/HandBrake [DEBUG].xcscheme b/macosx/HandBrake.xcodeproj/xcshareddata/xcschemes/HandBrake [DEBUG].xcscheme index a4579d8bc..689602912 100644 --- a/macosx/HandBrake.xcodeproj/xcshareddata/xcschemes/HandBrake [DEBUG].xcscheme +++ b/macosx/HandBrake.xcodeproj/xcshareddata/xcschemes/HandBrake [DEBUG].xcscheme @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <Scheme - LastUpgradeVersion = "0620" + LastUpgradeVersion = "0630" version = "1.3"> <BuildAction parallelizeBuildables = "YES" diff --git a/macosx/HandBrake.xcodeproj/xcshareddata/xcschemes/HandBrake [RELEASE].xcscheme b/macosx/HandBrake.xcodeproj/xcshareddata/xcschemes/HandBrake [RELEASE].xcscheme index ff1af58b1..0409cfdd9 100644 --- a/macosx/HandBrake.xcodeproj/xcshareddata/xcschemes/HandBrake [RELEASE].xcscheme +++ b/macosx/HandBrake.xcodeproj/xcshareddata/xcschemes/HandBrake [RELEASE].xcscheme @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <Scheme - LastUpgradeVersion = "0620" + LastUpgradeVersion = "0630" version = "1.3"> <BuildAction parallelizeBuildables = "YES" diff --git a/macosx/NSCodingMacro.h b/macosx/NSCodingMacro.h index 842da1121..7cfbfc755 100644 --- a/macosx/NSCodingMacro.h +++ b/macosx/NSCodingMacro.h @@ -18,6 +18,6 @@ #define decodeInteger(x) x = [decoder decodeIntegerForKey:OBJC_STRINGIFY(x)] #define decodeBool(x) x = [decoder decodeBoolForKey:OBJC_STRINGIFY(x)] #define decodeDouble(x) x = [decoder decodeDoubleForKey:OBJC_STRINGIFY(x)] -#define decodeObject(x) x = [[decoder decodeObjectForKey:OBJC_STRINGIFY(x)] retain] +#define decodeObject(x) x = [decoder decodeObjectForKey:OBJC_STRINGIFY(x)] #endif |