Skip to content
This repository has been archived by the owner on May 6, 2020. It is now read-only.

avoid crashing: when filter combine is already deinitialized, but still processing (weak==nil) #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions IGRFilterCombine/IGRFilterCombine.m
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,11 @@ - (void)setOriginalImage:(UIImage *)originalImage
[weak setFilteredPreviewImage:thumbImage toIndex:idx];
[filter processImage:thumbImage
completeBlock:^(UIImage * _Nullable processedImage) {
[weak setFilteredPreviewImage:processedImage toIndex:idx];
weak.processedPreviewImagesCompletion(processedImage, idx);
__strong __typeof(weak) strongSelf = weak;
if (strongSelf != nil) {
[strongSelf setFilteredPreviewImage:processedImage toIndex:idx];
strongSelf.processedPreviewImagesCompletion(processedImage, idx);
}
}];
}];

Expand All @@ -112,8 +115,11 @@ - (void)setOriginalImage:(UIImage *)originalImage
[weak setFilteredImage:originalImage toIndex:idx];
IGRBaseShaderFilterCancelBlock cancelBlock = [filter processImage:originalImage
completeBlock:^(UIImage * _Nullable processedImage) {
[weak setFilteredImage:processedImage toIndex:idx];
weak.processedImagesCompletion(processedImage, idx);
__strong __typeof(weak) strongSelf = weak;
if (strongSelf != nil) {
[strongSelf setFilteredImage:processedImage toIndex:idx];
strongSelf.processedImagesCompletion(processedImage, idx);
}
}];
[weak setCancelBlock:cancelBlock toIndex:idx];
}];
Expand Down