Use qt.conf to override plugin path on Mac OS

Summary:
QCoreApplication::addLibraryPath is called before QCoreApplication
was constructed and this caused the returned string to be different
depending from which working directory it was called and not always
the intended binary path.
Using qt.conf has a fixed prefix relative to the binary path
inside the application bundle and therefore is easier to be used
with a relative path.

Reviewers: kbasan, msutcliffe

Reviewed By: msutcliffe

Differential Revision: https://dev.swift-project.org/D18
This commit is contained in:
Roland Winklmeier
2017-05-05 22:37:28 +01:00
committed by Mathew Sutcliffe
parent f952775665
commit cf2c0d0f35
21 changed files with 45 additions and 33 deletions

View File

@@ -26,9 +26,6 @@ using namespace BlackGui;
int main(int argc, char *argv[])
{
//! [SwiftApplicationDemo]
#ifdef Q_OS_MAC
QApplication::addLibraryPath(CDirectoryUtils::applicationDirectoryPath());
#endif
CGuiApplication::highDpiScreenSupport();
QApplication qa(argc, argv);
Q_UNUSED(qa); // init of qa is required, but qa not used

2
src/swiftcore/qt.conf Normal file
View File

@@ -0,0 +1,2 @@
[Paths]
Plugins = ../..

View File

@@ -29,4 +29,11 @@ DESTDIR = $$DestRoot/bin
target.path = $$PREFIX/bin
INSTALLS += target
macx {
# Modifies plugin path
qtconf.path = $$PREFIX/bin/swiftcore.app/Contents/Resources
qtconf.files = qt.conf
INSTALLS += qtconf
}
load(common_post)

View File

@@ -24,9 +24,6 @@ using namespace BlackGui;
int main(int argc, char *argv[])
{
#ifdef Q_OS_MAC
QApplication::addLibraryPath(CDirectoryUtils::applicationDirectoryPath());
#endif
CGuiApplication::highDpiScreenSupport();
QApplication qa(argc, argv);
Q_UNUSED(qa);

2
src/swiftdata/qt.conf Normal file
View File

@@ -0,0 +1,2 @@
[Paths]
Plugins = ../..

View File

@@ -30,4 +30,11 @@ DESTDIR = $$DestRoot/bin
target.path = $$PREFIX/bin
INSTALLS += target
macx {
# Modifies plugin path
qtconf.path = $$PREFIX/bin/swiftdata.app/Contents/Resources
qtconf.files = qt.conf
INSTALLS += qtconf
}
load(common_post)

View File

@@ -23,9 +23,6 @@ using namespace BlackCore;
int main(int argc, char *argv[])
{
//! [SwiftApplicationDemo]
#ifdef Q_OS_MAC
QApplication::addLibraryPath(CDirectoryUtils::applicationDirectoryPath());
#endif
CGuiApplication::highDpiScreenSupport();
QApplication qa(argc, argv);
Q_UNUSED(qa); // application init needed

View File

@@ -0,0 +1,2 @@
[Paths]
Plugins = ../..

View File

@@ -30,4 +30,11 @@ DESTDIR = $$DestRoot/bin
target.path = $$PREFIX/bin
INSTALLS += target
macx {
# Modifies plugin path
qtconf.path = $$PREFIX/bin/swiftguistd.app/Contents/Resources
qtconf.files = qt.conf
INSTALLS += qtconf
}
load(common_post)

View File

@@ -30,9 +30,6 @@ using namespace BlackCore::Db;
int main(int argc, char *argv[])
{
//! [SwiftApplicationDemo]
#ifdef Q_OS_MAC
QApplication::addLibraryPath(CDirectoryUtils::applicationDirectoryPath());
#endif
CGuiApplication::highDpiScreenSupport();
QApplication qa(argc, argv); // needed
Q_UNUSED(qa);

View File

@@ -0,0 +1,2 @@
[Paths]
Plugins = ../..

View File

@@ -31,4 +31,11 @@ DESTDIR = $$DestRoot/bin
target.path = $$PREFIX/bin
INSTALLS += target
macx {
# Modifies plugin path
qtconf.path = $$PREFIX/bin/swiftlauncher.app/Contents/Resources
qtconf.files = qt.conf
INSTALLS += qtconf
}
load(common_post)