gui/macOS: Correctly release objects received via FileProviderUtils functions

Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
Claudio Cambra 2025-03-26 13:31:00 +01:00 committed by backportbot[bot]
parent 1b56f2e38a
commit 6eca65b888
4 changed files with 15 additions and 1 deletions

View File

@ -147,6 +147,8 @@ QString FileProviderItemMetadata::getUserVisiblePath() const
dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
dispatch_release(semaphore);
[manager release];
return returnPath;
}

View File

@ -59,6 +59,8 @@ void FileProviderMaterialisedItemsModel::evictItem(const QString &identifier, co
}];
dispatch_semaphore_wait(semaphore, dispatch_time(DISPATCH_TIME_NOW, 3 * NSEC_PER_SEC));
[manager release];
if (successfullyDeleted == NO) {
return;
}

View File

@ -167,6 +167,7 @@ public:
qCInfo(lcFileProviderSettingsController) << "Signalling file provider domain" << userIdAtHost;
NSFileProviderDomain * const domain = FileProviderUtils::domainForIdentifier(userIdAtHost);
NSFileProviderManager * const manager = [NSFileProviderManager managerForDomain:domain];
[domain release];
[manager signalEnumeratorForContainerItemIdentifier:NSFileProviderRootContainerItemIdentifier
completionHandler:^(NSError *const error) {
if (error != nil) {
@ -186,6 +187,7 @@ public:
}
public slots:
// NOTE: This method will release the provided args so make sure to retain them beforehand
void enumerateMaterialisedFilesForDomainManager(NSFileProviderManager * const managerForDomain,
NSFileProviderDomain * const domain)
{
@ -228,6 +230,9 @@ public slots:
[storageUseObserver release];
[enumerator release];
[managerForDomain release];
[domain release];
};
[enumerator enumerateItemsForObserver:storageUseObserver startingAtPage:NSFileProviderInitialPageSortedByName];
}
@ -283,7 +288,8 @@ private:
<< ", returning early.";
return;
}
[managerForDomain retain];
[domain retain];
enumerateMaterialisedFilesForDomainManager(managerForDomain, domain);
}
}];

View File

@ -29,6 +29,10 @@ class QString;
*
* You should threfore try to avoid using this in C++ code wherever possible
* and only use this in *_mac.mm implementation files.
*
* IMPORTANT: All Objective-C objects returned here need to be released!
* They have been internally retained due to the async nature of the
* FileProvider API.
*/
namespace OCC {