]> granicus.if.org Git - handbrake/commitdiff
MacGui: read the actual preview count so we don't try to load a non existing image
authorDamiano Galassi <damiog@gmail.com>
Tue, 29 Sep 2015 17:23:23 +0000 (19:23 +0200)
committerDamiano Galassi <damiog@gmail.com>
Tue, 29 Sep 2015 17:23:23 +0000 (19:23 +0200)
macosx/HBCore.h
macosx/HBCore.m
macosx/HBPreviewController.m
macosx/HBPreviewGenerator.m

index 1d7a4e279018ab466c077e885d832de5a5a98a44..c8817b2206f8b456cd0b8f07d427e5ba2fcf3927 100644 (file)
@@ -136,6 +136,11 @@ typedef void (^HBCoreCompletionHandler)(BOOL success);
                            pictureFrame:(HBPicture *)frame
                             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.
  *
index 13344f8b7e8e72effa6e9dd6f28f9e57fca5e0e3..7acbf34901cd5a0a8e716bf9f88ca12596f89c09 100644 (file)
@@ -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;
index 7449c342dd419dc82c46d3f50a1d73603aafa967..9be3bae5bfeeea5cb03b3008b9252024019c6c7d 100644 (file)
@@ -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];
     }
index 60db556f968a66af5212b73fd539256cab14ae05..cd7cfd690d8dfbd4aa918c19ef625b9628cf95b0 100644 (file)
@@ -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];