summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qstandardpaths_mac.mm
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/io/qstandardpaths_mac.mm')
-rw-r--r--src/corelib/io/qstandardpaths_mac.mm29
1 files changed, 9 insertions, 20 deletions
diff --git a/src/corelib/io/qstandardpaths_mac.mm b/src/corelib/io/qstandardpaths_mac.mm
index e25339a7d1..3bb7a7877a 100644
--- a/src/corelib/io/qstandardpaths_mac.mm
+++ b/src/corelib/io/qstandardpaths_mac.mm
@@ -203,28 +203,17 @@ QStringList QStandardPaths::standardLocations(StandardLocation type)
if (type == AppDataLocation || type == AppLocalDataLocation) {
CFBundleRef mainBundle = CFBundleGetMainBundle();
if (mainBundle) {
- CFURLRef bundleUrl = CFBundleCopyBundleURL(mainBundle);
- CFStringRef cfBundlePath = CFURLCopyFileSystemPath(bundleUrl, kCFURLPOSIXPathStyle);
- QString bundlePath = QString::fromCFString(cfBundlePath);
- CFRelease(cfBundlePath);
- CFRelease(bundleUrl);
-
- CFURLRef resourcesUrl = CFBundleCopyResourcesDirectoryURL(mainBundle);
- CFStringRef cfResourcesPath = CFURLCopyFileSystemPath(resourcesUrl,
- kCFURLPOSIXPathStyle);
- QString resourcesPath = QString::fromCFString(cfResourcesPath);
- CFRelease(cfResourcesPath);
- CFRelease(resourcesUrl);
-
- // Handle bundled vs unbundled executables. CFBundleGetMainBundle() returns
- // a valid bundle in both cases. CFBundleCopyResourcesDirectoryURL() returns
- // an absolute path for unbundled executables.
- if (resourcesPath.startsWith(QLatin1Char('/')))
- dirs.append(resourcesPath);
- else
- dirs.append(bundlePath + resourcesPath);
+ if (QCFType<CFURLRef> resourcesURL = CFBundleCopyResourcesDirectoryURL(mainBundle)) {
+ if (QCFType<CFURLRef> absoluteResouresURL = CFURLCopyAbsoluteURL(resourcesURL)) {
+ if (QCFType<CFStringRef> path = CFURLCopyFileSystemPath(absoluteResouresURL,
+ kCFURLPOSIXPathStyle)) {
+ dirs.append(QString::fromCFString(path));
+ }
+ }
+ }
}
}
+
const QString localDir = writableLocation(type);
if (!localDir.isEmpty())
dirs.prepend(localDir);