summaryrefslogtreecommitdiffstats
path: root/macosx/HBPreviewGenerator.m
diff options
context:
space:
mode:
authorDamiano Galassi <[email protected]>2018-10-16 13:57:40 +0200
committerDamiano Galassi <[email protected]>2018-10-16 13:57:40 +0200
commit8150402d59c01f1a00587b7d169390710c4af58f (patch)
tree288361a0b59e8faed37564fb726fc55841d41a9d /macosx/HBPreviewGenerator.m
parentacee00072b04e9a86f9238fd1430e33e3b08a5d1 (diff)
MacGui: improve touch bar support, add touch bars to the add titles to queue and add preset sheets.
Diffstat (limited to 'macosx/HBPreviewGenerator.m')
-rw-r--r--macosx/HBPreviewGenerator.m6
1 files changed, 5 insertions, 1 deletions
diff --git a/macosx/HBPreviewGenerator.m b/macosx/HBPreviewGenerator.m
index 6ac4e76bd..fa486832c 100644
--- a/macosx/HBPreviewGenerator.m
+++ b/macosx/HBPreviewGenerator.m
@@ -18,6 +18,7 @@
@property (nonatomic, readonly) NSCache<NSNumber *, id> *smallPreviewsCache;
@property (nonatomic, readonly) dispatch_semaphore_t sem;
+@property (nonatomic, readonly) _Atomic bool invalidated;
@property (nonatomic, strong) HBCore *core;
@@ -59,6 +60,8 @@
- (void)dealloc
{
+ _invalidated = true;
+
[[NSNotificationCenter defaultCenter] removeObserver:self];
[[NSRunLoop mainRunLoop] cancelPerformSelectorsWithTarget:self];
[self.core cancelEncode];
@@ -154,7 +157,8 @@
- (void)copySmallImageAtIndex:(NSUInteger)index completionHandler:(void (^)(__nullable CGImageRef result))handler
{
dispatch_semaphore_wait(_sem, DISPATCH_TIME_FOREVER);
- if (index >= self.imagesCount)
+
+ if (_invalidated || index >= self.imagesCount)
{
handler(NULL);
dispatch_semaphore_signal(_sem);