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>
This commit is contained in:
Jake Petroules 2016-02-18 01:06:49 -08:00
parent 3ed944b843
commit fcfe2a5f67

View File

@ -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.