From 037efe2d010f7983cb83879850e276af38d57a80 Mon Sep 17 00:00:00 2001 From: ritsuka Date: Tue, 3 Dec 2013 17:01:56 +0000 Subject: MacGUI: Release the cached images when the preview window is closed. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@5912 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- macosx/HBPreviewController.m | 3 ++- macosx/HBPreviewGenerator.h | 2 +- macosx/HBPreviewGenerator.m | 5 +++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/macosx/HBPreviewController.m b/macosx/HBPreviewController.m index 8cca74037..9d9d2c6fd 100644 --- a/macosx/HBPreviewController.m +++ b/macosx/HBPreviewController.m @@ -283,6 +283,7 @@ typedef enum ViewMode : NSUInteger { [self stopMovieTimer]; } + [self.generator purgeImageCache]; [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"PreviewWindowIsOpen"]; } @@ -634,7 +635,7 @@ typedef enum ViewMode : NSUInteger { { hb_title_t *title = self.title; - NSImage *fPreviewImage = [self.generator imageAtIndex:self.pictureIndex]; + NSImage *fPreviewImage = [self.generator imageAtIndex:self.pictureIndex shouldCache:YES]; NSSize imageScaledSize = [fPreviewImage size]; [self.pictureLayer setContents:fPreviewImage]; diff --git a/macosx/HBPreviewGenerator.h b/macosx/HBPreviewGenerator.h index e17114c45..438d078aa 100644 --- a/macosx/HBPreviewGenerator.h +++ b/macosx/HBPreviewGenerator.h @@ -22,7 +22,7 @@ - (id) initWithHandle: (hb_handle_t *) handle andTitle: (hb_title_t *) title; /* Still image generator */ -- (NSImage *) imageAtIndex: (NSUInteger) index; +- (NSImage *) imageAtIndex: (NSUInteger) index shouldCache: (BOOL) cache; - (NSUInteger) imagesCount; - (void) purgeImageCache; diff --git a/macosx/HBPreviewGenerator.m b/macosx/HBPreviewGenerator.m index 99ca20f86..25a7ec344 100644 --- a/macosx/HBPreviewGenerator.m +++ b/macosx/HBPreviewGenerator.m @@ -52,7 +52,7 @@ typedef enum EncodeState : NSUInteger { * * @param index picture index in title. */ -- (NSImage *) imageAtIndex: (NSUInteger) index +- (NSImage *) imageAtIndex: (NSUInteger) index shouldCache: (BOOL) cache { if (index >= self.imagesCount) return nil; @@ -67,7 +67,8 @@ typedef enum EncodeState : NSUInteger { libhb:self.handle title:self.title deinterlace:self.deinterlace]; - [self.picturePreviews setObject:theImage forKey:@(index)]; + if (cache) + [self.picturePreviews setObject:theImage forKey:@(index)]; } return theImage; -- cgit v1.2.3