Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-49443

QStandardPaths::standardLocations() returns wrong paths for AppDataLocation, AppLocalDataLocation on OS X

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 5.6.0
    • 5.3.0
    • Core: I/O
    • None
    • OS X
    • macOS
    • bc7d0da

    Description

      Of the multiple paths returned for these location values. Those that involve the Application Bundle path are missing the 'Contents/Resources' path component.

      Apple's documentation is here: https://developer.apple.com/library/mac/documentation/CoreFoundation/Conceptual/CFBundles/BundleTypes/BundleTypes.html
      Also note that OS X is different than iOS. This bug report is only specific to OS X.

      Looking at the source code, it would appear that a mistake was made in a cut&paste operation.

      in: QStringList QStandardPaths::standardLocations(StandardLocation type)
      from: http://code.qt.io/cgit/qt/qtbase.git/tree/src/corelib/io/qstandardpaths_mac.mm

      CFURLRef resourcesUrl = CFBundleCopyResourcesDirectoryURL(mainBundle);
      CFStringRef cfResourcesPath = CFURLCopyPath(bundleUrl);
      QString resourcesPath = QCFString::toQString(cfResourcesPath);
      CFRelease(cfResourcesPath);
      CFRelease(resourcesUrl);

      Should be changed to:

      CFURLRef resourcesUrl = CFBundleCopyResourcesDirectoryURL(mainBundle);
      CFStringRef cfResourcesPath = CFURLCopyPath(resourcesUrl);
      QString resourcesPath = QCFString::toQString(cfResourcesPath);
      CFRelease(cfResourcesPath);
      CFRelease(resourcesUrl);

      Also note that the documentation http://doc.qt.io/qt-5/qstandardpaths.html
      correctly lists one of the paths for these on OS X to be '<APPDIR>/../Resources'

      So, this is a bug against Qt documentation as well.

      Attached diff.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            jakepetroules Jake Petroules (DO NOT ASSIGN ISSUES)
            amccann Andrew McCannn
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes