Skip to content

Commit

Permalink
Fixes infinite loops when call endProcess by adding a flag to check i…
Browse files Browse the repository at this point in the history
…f the filter has already started the end process
  • Loading branch information
Andrew Chambers committed Nov 8, 2013
1 parent 49fcf22 commit abe404b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
1 change: 1 addition & 0 deletions framework/Source/GPUImageFilter.h
Expand Up @@ -57,6 +57,7 @@ typedef struct GPUMatrix3x3 GPUMatrix3x3;
GLfloat backgroundColorRed, backgroundColorGreen, backgroundColorBlue, backgroundColorAlpha;

BOOL preparedToCaptureImage;
BOOL isEndProcessing;

// Texture caches are an iOS-specific capability
#if TARGET_IPHONE_SIMULATOR || TARGET_OS_IPHONE
Expand Down
9 changes: 7 additions & 2 deletions framework/Source/GPUImageFilter.m
Expand Up @@ -1002,9 +1002,14 @@ - (CGSize)maximumOutputSize;

- (void)endProcessing
{
for (id<GPUImageInput> currentTarget in targets)
if (!isEndProcessing)
{
[currentTarget endProcessing];
isEndProcessing = YES;

for (id<GPUImageInput> currentTarget in targets)
{
[currentTarget endProcessing];
}
}
}

Expand Down
1 change: 1 addition & 0 deletions framework/Source/GPUImageFilterGroup.h
Expand Up @@ -4,6 +4,7 @@
@interface GPUImageFilterGroup : GPUImageOutput <GPUImageInput, GPUImageTextureDelegate>
{
NSMutableArray *filters;
BOOL isEndProcessing;
}

@property(readwrite, nonatomic, strong) GPUImageOutput<GPUImageInput> *terminalFilter;
Expand Down
9 changes: 7 additions & 2 deletions framework/Source/GPUImageFilterGroup.m
Expand Up @@ -182,9 +182,14 @@ - (CGSize)maximumOutputSize;

- (void)endProcessing;
{
for (GPUImageOutput<GPUImageInput> *currentFilter in _initialFilters)
if (!isEndProcessing)
{
[currentFilter endProcessing];
isEndProcessing = YES;

for (id<GPUImageInput> currentTarget in targets)
{
[currentTarget endProcessing];
}
}
}

Expand Down

0 comments on commit abe404b

Please sign in to comment.