diff --git a/src/gui/macOS/fileprovidersettingscontroller_mac.mm b/src/gui/macOS/fileprovidersettingscontroller_mac.mm index 98e245414..0459085e1 100644 --- a/src/gui/macOS/fileprovidersettingscontroller_mac.mm +++ b/src/gui/macOS/fileprovidersettingscontroller_mac.mm @@ -196,9 +196,9 @@ private: const id enumerator = [managerForDomain enumeratorForMaterializedItems]; Q_ASSERT(enumerator != nil); - FileProviderStorageUseEnumerationObserver *const storageUseObserver = [[FileProviderStorageUseEnumerationObserver alloc] init]; + __block FileProviderStorageUseEnumerationObserver *const storageUseObserver = [[FileProviderStorageUseEnumerationObserver alloc] init]; - storageUseObserver.enumerationFinishedHandler = ^(NSNumber *const usage, NSError *const error) { + storageUseObserver.enumerationFinishedHandler = ^(NSError *const error) { if (error != nil) { qCWarning(lcFileProviderSettingsController) << "Error while enumerating storage use" << error.localizedDescription; [storageUseObserver release]; @@ -206,16 +206,16 @@ private: return; } - Q_ASSERT(usage != nil); + const NSUInteger usage = storageUseObserver.usage; // Remember that OCC::Account::userIdAtHost == domain.identifier for us NSMutableDictionary *const mutableStorageDictCopy = _storageUsage.mutableCopy; qCDebug(lcFileProviderSettingsController) << "Local storage use for" << domain.identifier - << usage.unsignedLongLongValue; + << usage; - [mutableStorageDictCopy setObject:usage forKey:domain.identifier]; + [mutableStorageDictCopy setObject:@(usage) forKey:domain.identifier]; _storageUsage = mutableStorageDictCopy.copy; const auto qDomainIdentifier = QString::fromNSString(domain.identifier); diff --git a/src/gui/macOS/fileproviderstorageuseenumerationobserver.h b/src/gui/macOS/fileproviderstorageuseenumerationobserver.h index db7141430..285b159c3 100644 --- a/src/gui/macOS/fileproviderstorageuseenumerationobserver.h +++ b/src/gui/macOS/fileproviderstorageuseenumerationobserver.h @@ -15,10 +15,11 @@ #import #import -typedef void(^UsageEnumerationFinishedHandler)(NSNumber *const usage, NSError *const error); +typedef void(^UsageEnumerationFinishedHandler)(NSError *const error); @interface FileProviderStorageUseEnumerationObserver : NSObject @property (readwrite, strong) UsageEnumerationFinishedHandler enumerationFinishedHandler; +@property (readonly) NSUInteger usage; @end diff --git a/src/gui/macOS/fileproviderstorageuseenumerationobserver.m b/src/gui/macOS/fileproviderstorageuseenumerationobserver.m index 94ba10d8f..c88fa8228 100644 --- a/src/gui/macOS/fileproviderstorageuseenumerationobserver.m +++ b/src/gui/macOS/fileproviderstorageuseenumerationobserver.m @@ -14,11 +14,6 @@ #import "fileproviderstorageuseenumerationobserver.h" -@interface FileProviderStorageUseEnumerationObserver () - -@property (readwrite) NSUInteger usage; - -@end @implementation FileProviderStorageUseEnumerationObserver @@ -26,7 +21,7 @@ { self = [super init]; if (self) { - self.usage = 0ULL; + _usage = 0ULL; } return self; } @@ -35,22 +30,24 @@ - (void)didEnumerateItems:(NSArray> *)updatedItems { for (const id item in updatedItems) { - NSLog(@"StorageUseEnumerationObserver: Enumerating %@ with size %llu", item.filename, item.documentSize.unsignedLongLongValue); - self.usage += item.documentSize.unsignedLongLongValue; + NSLog(@"StorageUseEnumerationObserver: Enumerating %@ with size %llu", + item.filename, item.documentSize.unsignedLongLongValue); + + _usage += item.documentSize.unsignedLongLongValue; } } - (void)finishEnumeratingWithError:(NSError *)error { dispatch_async(dispatch_get_main_queue(), ^{ - self.enumerationFinishedHandler(nil, error); + self.enumerationFinishedHandler(error); }); } - (void)finishEnumeratingUpToPage:(NSFileProviderPage)nextPage { dispatch_async(dispatch_get_main_queue(), ^{ - self.enumerationFinishedHandler(@(self.usage), nil); + self.enumerationFinishedHandler(nil); }); }