diff --git a/CHANGELOG.md b/CHANGELOG.md index 0dd7124..3ec843f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ ## master * Add your own contributions to the next release on the line below this with your name. +- [fix] Fix group can add operations and set completion multiple times when the group start. [#22](https://github.com/pinterest/PINOperation/pull/22) + ## 1.1.1 -- 2018 February 3 * Cleanup warnings [garrett](https://github.com/garrettmoon) diff --git a/Source/PINOperationGroup.m b/Source/PINOperationGroup.m index ddd2ed0..98539e9 100644 --- a/Source/PINOperationGroup.m +++ b/Source/PINOperationGroup.m @@ -76,6 +76,7 @@ - (void)start [self lock]; NSAssert(_canceled == NO, @"Operation group canceled."); if (_started == NO && _canceled == NO) { + _started = YES; for (NSUInteger idx = 0; idx < _operations.count; idx++) { dispatch_group_enter(_group); dispatch_block_t originalOperation = _operations[idx]; @@ -167,6 +168,7 @@ - (void)runCompletionIfNeeded [self lock]; completion = _completion; _completion = nil; + _started = NO; [self unlock]; if (completion) {