From 761a761aa67656965e11d803290adfae3ccc4a1a Mon Sep 17 00:00:00 2001 From: Gregory John Casamento Date: Sat, 28 Sep 2019 04:13:11 -0400 Subject: [PATCH] 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 --- Source/NSProgress.m | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Source/NSProgress.m b/Source/NSProgress.m index f8f8dd1b9..6092060f5 100644 --- a/Source/NSProgress.m +++ b/Source/NSProgress.m @@ -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