diff options
author | Damiano Galassi <[email protected]> | 2015-10-28 08:15:52 +0100 |
---|---|---|
committer | Damiano Galassi <[email protected]> | 2015-10-28 08:15:52 +0100 |
commit | 89c0a25d548575ac2ad9e867fa0f506fed7ad625 (patch) | |
tree | 6ae99c75b0558cb04af6842ea8b5b53bdac5c0aa | |
parent | 5adcef6070a6b8f91a92d2c22e5449dab3b15a34 (diff) |
MacGui: annotate the type of some arrays, and check the count of the input jobs in HBQueueController addJobsFromArray:, so we don't add an empty undo command.
-rw-r--r-- | macosx/HBDistributedArray.h | 2 | ||||
-rw-r--r-- | macosx/HBDistributedArray.m | 4 | ||||
-rw-r--r-- | macosx/HBPictureController.m | 2 | ||||
-rw-r--r-- | macosx/HBPictureViewController.m | 4 | ||||
-rw-r--r-- | macosx/HBQueueController.h | 2 | ||||
-rw-r--r-- | macosx/HBQueueController.m | 13 | ||||
-rw-r--r-- | macosx/HBSubtitlesDefaultsController.m | 8 |
7 files changed, 19 insertions, 16 deletions
diff --git a/macosx/HBDistributedArray.h b/macosx/HBDistributedArray.h index 483f1ac57..dee8bfc12 100644 --- a/macosx/HBDistributedArray.h +++ b/macosx/HBDistributedArray.h @@ -33,7 +33,7 @@ typedef NS_ENUM(NSUInteger, HBDistributedArrayContent) { * * It is safe to keep a reference to an array object. */ -@interface HBDistributedArray : NSMutableArray +@interface HBDistributedArray<ObjectType> : NSMutableArray - (instancetype)initWithURL:(NSURL *)fileURL; diff --git a/macosx/HBDistributedArray.m b/macosx/HBDistributedArray.m index 867ee4ffb..97b8378c3 100644 --- a/macosx/HBDistributedArray.m +++ b/macosx/HBDistributedArray.m @@ -52,9 +52,9 @@ NSString *HBDistributedArrayChanged = @"HBDistributedArrayChanged"; NSString *HBDistributedArraWrittenToDisk = @"HBDistributedArraWrittenToDisk"; -@interface HBDistributedArray () +@interface HBDistributedArray<ObjectType> () -@property (nonatomic, readonly) NSMutableArray *array; +@property (nonatomic, readonly) NSMutableArray<ObjectType> *array; @property (nonatomic, readonly) NSURL *fileURL; @property (nonatomic, readwrite) NSTimeInterval modifiedTime; diff --git a/macosx/HBPictureController.m b/macosx/HBPictureController.m index 083bc2340..8dee13187 100644 --- a/macosx/HBPictureController.m +++ b/macosx/HBPictureController.m @@ -54,7 +54,7 @@ static void *HBPictureControllerContext = &HBPictureControllerContext; { for (NSString *keyPath in observerdKeyPaths) { - [self removeObserver:self forKeyPath:keyPath]; + [self removeObserver:self forKeyPath:keyPath context:HBPictureControllerContext]; } } @catch (NSException * __unused exception) {} diff --git a/macosx/HBPictureViewController.m b/macosx/HBPictureViewController.m index 344580ec6..87618cb97 100644 --- a/macosx/HBPictureViewController.m +++ b/macosx/HBPictureViewController.m @@ -38,7 +38,7 @@ static void *HBPictureViewControllerContext = &HBPictureViewControllerContext; { @try { - [self removeObserver:self forKeyPath:@"self.picture.modulus"]; + [self removeObserver:self forKeyPath:@"self.picture.modulus" context:HBPictureViewControllerContext]; } @catch (NSException * __unused exception) {} } @@ -64,7 +64,7 @@ static void *HBPictureViewControllerContext = &HBPictureViewControllerContext; { if (context == HBPictureViewControllerContext) { - // Set the increment here, it's not possible with bidings. + // Set the increment here, it's not possible with bindings. if ([keyPath isEqualToString:@"self.picture.modulus"]) { [self.widthStepper setIncrement:self.picture.modulus]; diff --git a/macosx/HBQueueController.h b/macosx/HBQueueController.h index ff8ca5aaf..3584f7737 100644 --- a/macosx/HBQueueController.h +++ b/macosx/HBQueueController.h @@ -29,7 +29,7 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic, readonly) NSUInteger pendingItemsCount; - (void)addJob:(HBJob *)item; -- (void)addJobsFromArray:(NSArray *)items; +- (void)addJobsFromArray:(NSArray<HBJob *> *)items; - (BOOL)jobExistAtURL:(NSURL *)url; diff --git a/macosx/HBQueueController.m b/macosx/HBQueueController.m index 624d03700..537e8c86b 100644 --- a/macosx/HBQueueController.m +++ b/macosx/HBQueueController.m @@ -44,7 +44,7 @@ @property (nonatomic, readonly) NSMutableDictionary *descriptions; -@property (nonatomic, readonly) HBDistributedArray *jobs; +@property (nonatomic, readonly) HBDistributedArray<HBJob *> *jobs; @property (nonatomic) HBJob *currentJob; @property (nonatomic) HBJobOutputFileWriter *currentLog; @@ -53,7 +53,7 @@ @property (nonatomic, readwrite) NSUInteger pendingItemsCount; @property (nonatomic, readwrite) NSUInteger completedItemsCount; -@property (nonatomic) NSArray *dragNodesArray; +@property (nonatomic) NSArray<HBJob *> *dragNodesArray; @end @@ -213,10 +213,13 @@ [self addJobsFromArray:@[item]]; } -- (void)addJobsFromArray:(NSArray *)items; +- (void)addJobsFromArray:(NSArray<HBJob *> *)items; { NSParameterAssert(items); - [self addQueueItems:items]; + if (items.count) + { + [self addQueueItems:items]; + } } - (BOOL)jobExistAtURL:(NSURL *)url @@ -937,7 +940,7 @@ if ([targetedRows containsIndexes:workingIndexes]) { [targetedRows removeIndexes:workingIndexes]; - NSArray *workingJobs = [self.jobs filteredArrayUsingBlock:^BOOL(HBJob *item) { + NSArray<HBJob *> *workingJobs = [self.jobs filteredArrayUsingBlock:^BOOL(HBJob *item) { return item.state == HBJobStateWorking; }]; diff --git a/macosx/HBSubtitlesDefaultsController.m b/macosx/HBSubtitlesDefaultsController.m index 678ceb204..a78a14b48 100644 --- a/macosx/HBSubtitlesDefaultsController.m +++ b/macosx/HBSubtitlesDefaultsController.m @@ -8,7 +8,7 @@ #import "HBSubtitlesDefaults.h" #import "HBLanguagesSelection.h" -static void *HBSubtitlesDefaultsContex = &HBSubtitlesDefaultsContex; +static void *HBSubtitlesDefaultsContext = &HBSubtitlesDefaultsContext; @interface HBSubtitlesDefaultsController () @@ -36,7 +36,7 @@ static void *HBSubtitlesDefaultsContex = &HBSubtitlesDefaultsContex; - (void)windowDidLoad { - [self addObserver:self forKeyPath:@"tableController.showSelectedOnly" options:0 context:HBSubtitlesDefaultsContex]; + [self addObserver:self forKeyPath:@"tableController.showSelectedOnly" options:0 context:HBSubtitlesDefaultsContext]; if (self.settings.trackSelectionLanguages.count) { @@ -46,7 +46,7 @@ static void *HBSubtitlesDefaultsContex = &HBSubtitlesDefaultsContex; - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { - if (context == HBSubtitlesDefaultsContex) + if (context == HBSubtitlesDefaultsContext) { if ([keyPath isEqualToString:@"tableController.showSelectedOnly"]) { @@ -77,7 +77,7 @@ static void *HBSubtitlesDefaultsContex = &HBSubtitlesDefaultsContex; - (void)dealloc { @try { - [self removeObserver:self forKeyPath:@"tableController.showSelectedOnly"]; + [self removeObserver:self forKeyPath:@"tableController.showSelectedOnly" context:HBSubtitlesDefaultsContext]; } @catch (NSException * __unused exception) {} } |