diff options
author | Jake Petroules <jake.petroules@theqtcompany.com> | 2016-02-18 01:06:49 -0800 |
---|---|---|
committer | Jake Petroules <jake.petroules@theqtcompany.com> | 2016-02-25 16:52:38 +0000 |
commit | fcfe2a5f67f0045e8ed606f60330df5e24cf03b2 (patch) | |
tree | 95d966f8d01d677cca35fbe4096010c1bbca3e6d /src/corelib/kernel | |
parent | 3ed944b843c107b6d4e9b493745a761e42005dda (diff) |
Also search the main bundle plugin path for plugins on Apple OSes.
The default value of QLibraryInfo::PluginsPath is $prefix/plugins,
where $prefix is the path to the bundle's contents directory
(for example, .../foo.app/Contents/ on OS X, or .../foo.app/ on iOS).
On Apple platforms the directory is actually called "PlugIns".
Plugins could previously be loaded on OS X by coincidence, but
if the system is using an HFS+ Case Sensitive filesystem (and this
is ALWAYS the case on iOS-like operating systems), the case
mismatch would cause plugins in an application bundle not to be
found/loaded.
This change allows plugins to be located in application bundles
on Apple platforms regardless of the HFS+ case sensitivity mode
and without needing to specify a qt.conf file.
Change-Id: Ie0a0f7448fbf5fb410aa77944ba0d01895bb05e3
Reviewed-by: Morten Johan Sørvig <morten.sorvig@theqtcompany.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Diffstat (limited to 'src/corelib/kernel')
-rw-r--r-- | src/corelib/kernel/qcoreapplication.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index 79a3254a39..38efc44399 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -2498,6 +2498,26 @@ QStringList QCoreApplication::libraryPaths() } } +#ifdef Q_OS_DARWIN + // Check the main bundle's PlugIns directory as this is a standard location for Apple OSes. + // Note that the QLibraryInfo::PluginsPath below will coincidentally be the same as this value + // but with a different casing, so it can't be relied upon when the underlying filesystem + // is case sensitive (and this is always the case on newer OSes like iOS). + if (CFBundleRef bundleRef = CFBundleGetMainBundle()) { + if (QCFType<CFURLRef> urlRef = CFBundleCopyBuiltInPlugInsURL(bundleRef)) { + if (QCFType<CFURLRef> absoluteUrlRef = CFURLCopyAbsoluteURL(urlRef)) { + if (QCFString path = CFURLCopyFileSystemPath(absoluteUrlRef, kCFURLPOSIXPathStyle)) { + if (QFile::exists(path)) { + path = QDir(path).canonicalPath(); + if (!app_libpaths->contains(path)) + app_libpaths->append(path); + } + } + } + } + } +#endif // Q_OS_DARWIN + QString installPathPlugins = QLibraryInfo::location(QLibraryInfo::PluginsPath); if (QFile::exists(installPathPlugins)) { // Make sure we convert from backslashes to slashes. |