Fix the finished property/ivar is still not set. It should be set in setCompletedUnitCount: when fractionCompleted >= 1 and setting completedUnitCount does still not trigger KVO for fractionCompleted

This commit is contained in:
Gregory John Casamento 2019-09-28 04:13:11 -04:00
parent 2e513bb2e3
commit 761a761aa6

View file

@ -34,6 +34,7 @@
NSNumber *_throughput; \
int64_t _totalUnitCount; \
int64_t _completedUnitCount; \
double _fractionCompleted; \
NSMutableDictionary *_userInfo; \
BOOL _cancelled; \
BOOL _paused; \
@ -189,7 +190,6 @@ static NSMutableDictionary *__subscribers = nil;
{
int64_t completed = [__currentProgress completedUnitCount];
[__currentProgress setCompletedUnitCount: completed + [self totalUnitCount]];
__currentProgress = nil;
}
// Reporting progress
@ -211,6 +211,16 @@ static NSMutableDictionary *__subscribers = nil;
- (void) setCompletedUnitCount: (int64_t)count
{
internal->_completedUnitCount = count;
[self willChangeValueForKey: @"fractionCompleted"];
internal->_fractionCompleted = (double)((double)internal->_completedUnitCount
/ (double)internal->_totalUnitCount);
if(internal->_fractionCompleted >= 1)
{
internal->_finished = YES;
}
[self didChangeValueForKey: @"fractionCompleted"];
__currentProgress = nil;
}
- (NSString *) localizedDescription