summaryrefslogtreecommitdiffstats
path: root/macosx
diff options
context:
space:
mode:
authorDamiano Galassi <[email protected]>2016-01-15 19:45:08 +0100
committerDamiano Galassi <[email protected]>2016-01-15 19:45:08 +0100
commit65acd5b2e6659517f7e1dd5528a4fe99eb89e63b (patch)
tree61172d99f5b571c5d09abbee99bab2b5ac48d24c /macosx
parent6ad1d603b266319d97a69fd53dcf3eeab88bde63 (diff)
MacGui: batch the preview updates so we don't reload the same preview multiple times.
Diffstat (limited to 'macosx')
-rw-r--r--macosx/HBPreviewGenerator.m17
1 files changed, 16 insertions, 1 deletions
diff --git a/macosx/HBPreviewGenerator.m b/macosx/HBPreviewGenerator.m
index 06f442317..bf27b10e7 100644
--- a/macosx/HBPreviewGenerator.m
+++ b/macosx/HBPreviewGenerator.m
@@ -21,6 +21,8 @@
@property (nonatomic, strong) HBCore *core;
+@property (nonatomic) BOOL reloadInQueue;
+
@end
@implementation HBPreviewGenerator
@@ -53,6 +55,7 @@
- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
+ [[NSRunLoop mainRunLoop] cancelPerformSelectorsWithTarget:self];
[self.core cancelEncode];
}
@@ -117,9 +120,21 @@
{
// Purge the existing picture previews so they get recreated the next time
// they are needed.
-
[self purgeImageCache];
+
+ // Enquee the reload call on the main runloop
+ // to avoid reloading the same image multiple times.
+ if (self.reloadInQueue == NO)
+ {
+ [[NSRunLoop mainRunLoop] performSelector:@selector(postReloadNotification) target:self argument:nil order:0 modes:@[NSDefaultRunLoopMode]];
+ self.reloadInQueue = YES;
+ }
+}
+
+- (void)postReloadNotification
+{
[self.delegate reloadPreviews];
+ self.reloadInQueue = NO;
}
- (NSString *)info