From 1f046ccd5efeebb721c1b3e5e80dcf059409115f Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Wed, 16 Feb 2022 14:53:44 +0100 Subject: [PATCH] macOS: Do case-insensitive compare in auto-launch code Case-sensitive compares will give problems when a launchd plist file exists, but the executable gets upated, and the name only has a different case (e.g.: owncloud -> ownCloud). Signed-off-by: Camila Ayres --- src/common/utility_mac.mm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/common/utility_mac.mm b/src/common/utility_mac.mm index a9d5a40fbb..c430a2466f 100644 --- a/src/common/utility_mac.mm +++ b/src/common/utility_mac.mm @@ -108,7 +108,8 @@ bool Utility::hasLaunchOnStartup(const QString &appName) // ... and yes, it's the correct app-id... if (id program = plist[@"Program"]) { // .. and there is a program mentioned ... - if ([QCoreApplication::applicationFilePath().toNSString() isEqualToString:program]) { + // (Note: case insensitive compare, because most fs setups on mac are case insensitive) + if ([QCoreApplication::applicationFilePath().toNSString() compare:program options:NSCaseInsensitiveSearch] == NSOrderedSame) { // ... and it's our executable .. if (NSNumber *value = plist[@"RunAtLoad"]) { // yes, there is even a RunAtLoad key, so use it! @@ -194,7 +195,7 @@ void Utility::setLaunchOnStartup(const QString &appName, const QString &guiName, if (!result) { qCWarning(lcUtility) << result.error(); } - } else if ([fullPath isEqualToString:programValue]) { + } else if ([fullPath compare:programValue options:NSCaseInsensitiveSearch] == NSOrderedSame) { // (Note: case insensitive compare, because most fs setups on mac are case insensitive) // Wohoo, it's ours! Now carefully change only the RunAtLoad entry. If any value for // e.g. KeepAlive was changed, we leave it as-is. auto result = modifyPlist(plistFile, plist, enable);