diff options
author | Damiano Galassi <[email protected]> | 2015-09-29 19:23:23 +0200 |
---|---|---|
committer | Damiano Galassi <[email protected]> | 2015-09-29 19:23:23 +0200 |
commit | 3a0453a7b705b9a15941eafb2997bbd18b00cfc7 (patch) | |
tree | c3f4d26275a19d092963a71af1a9b5801f63497b /macosx | |
parent | 291243c3fcd34282a700b059995c27a993b12e71 (diff) |
MacGui: read the actual preview count so we don't try to load a non existing image
Diffstat (limited to 'macosx')
-rw-r--r-- | macosx/HBCore.h | 5 | ||||
-rw-r--r-- | macosx/HBCore.m | 5 | ||||
-rw-r--r-- | macosx/HBPreviewController.m | 5 | ||||
-rw-r--r-- | macosx/HBPreviewGenerator.m | 2 |
4 files changed, 16 insertions, 1 deletions
diff --git a/macosx/HBCore.h b/macosx/HBCore.h index 1d7a4e279..c8817b220 100644 --- a/macosx/HBCore.h +++ b/macosx/HBCore.h @@ -137,6 +137,11 @@ typedef void (^HBCoreCompletionHandler)(BOOL success); deinterlace:(BOOL)deinterlace CF_RETURNS_RETAINED; /** + * Returns the counts of the available previews images. + */ +- (NSUInteger)imagesCountForTitle:(HBTitle *)title; + +/** * Initiates an asynchronous encode operation and returns immediately. * * @param job the job to encode diff --git a/macosx/HBCore.m b/macosx/HBCore.m index 13344f8b7..7acbf3490 100644 --- a/macosx/HBCore.m +++ b/macosx/HBCore.m @@ -331,6 +331,11 @@ static void hb_error_handler(const char *errmsg) return img; } +- (NSUInteger)imagesCountForTitle:(HBTitle *)title +{ + return title.hb_title->preview_count; +} + #pragma mark - Encodes - (void)encodeJob:(HBJob *)job progressHandler:(HBCoreProgressHandler)progressHandler completionHandler:(HBCoreCompletionHandler)completionHandler; diff --git a/macosx/HBPreviewController.m b/macosx/HBPreviewController.m index 7449c342d..9be3bae5b 100644 --- a/macosx/HBPreviewController.m +++ b/macosx/HBPreviewController.m @@ -231,6 +231,11 @@ typedef enum ViewMode : NSUInteger { [fPictureSlider setMaxValue: generator.imagesCount - 1.0]; [fPictureSlider setNumberOfTickMarks: generator.imagesCount]; + if (self.pictureIndex > generator.imagesCount) + { + self.pictureIndex = generator.imagesCount - 1; + } + [self switchViewToMode:ViewModePicturePreview]; [self displayPreview]; } diff --git a/macosx/HBPreviewGenerator.m b/macosx/HBPreviewGenerator.m index 60db556f9..cd7cfd690 100644 --- a/macosx/HBPreviewGenerator.m +++ b/macosx/HBPreviewGenerator.m @@ -42,7 +42,7 @@ // Limit the cache to 60 1080p previews, the cost is in pixels _picturePreviews.totalCostLimit = 60 * 1920 * 1080; - _imagesCount = [[[NSUserDefaults standardUserDefaults] objectForKey:@"PreviewsNumber"] intValue]; + _imagesCount = [_scanCore imagesCountForTitle:self.job.title]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(imagesSettingsDidChange) name:HBPictureChangedNotification object:job.picture]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(imagesSettingsDidChange) name:HBFiltersChangedNotification object:job.filters]; |