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

@@ -33,9 +33,6 @@ int main(int argc, char *argv[])
{
// I use CGuiApplication and not core application
// otherwise no QPixmap metadata (metadata sample)
#ifdef Q_OS_MAC
QCoreApplication::addLibraryPath(CDirectoryUtils::applicationDirectoryPath());
#endif
QCoreApplication qa(argc, argv);
CApplication a(CApplicationInfo::Sample);
Q_UNUSED(qa);

View File

@@ -38,9 +38,6 @@ int main(int argc, char *argv[])
// is just for testing, I did not split it up
BlackMisc::registerMetadata();
#ifdef Q_OS_MAC
QCoreApplication::addLibraryPath(CDirectoryUtils::applicationDirectoryPath());
#endif
QCoreApplication a(argc, argv);
QTextStream out(stdout, QIODevice::WriteOnly);
QTextStream qtin(stdin);

View File

@@ -29,9 +29,6 @@ using namespace BlackCore;
//! main
int main(int argc, char *argv[])
{
#ifdef Q_OS_MAC
QCoreApplication::addLibraryPath(CDirectoryUtils::applicationDirectoryPath());
#endif
QCoreApplication qa(argc, argv);
CApplication a;
Q_UNUSED(a);

View File

@@ -30,9 +30,6 @@ using namespace BlackMisc;
//! main
int main(int argc, char *argv[])
{
#ifdef Q_OS_MAC
QCoreApplication::addLibraryPath(CDirectoryUtils::applicationDirectoryPath());
#endif
QCoreApplication qa(argc, argv);
BlackCore::CApplication a;
Q_UNUSED(a);

View File

@@ -24,9 +24,6 @@ using namespace BlackMisc;
//! main
int main(int argc, char *argv[])
{
#ifdef Q_OS_MAC
QCoreApplication::addLibraryPath(CDirectoryUtils::applicationDirectoryPath());
#endif
QCoreApplication app (argc, argv);
BlackMisc::CLogHandler::instance()->install();

View File

@@ -22,9 +22,6 @@ using namespace BlackGui;
//! main
int main(int argc, char *argv[])
{
#ifdef Q_OS_MAC
QApplication::addLibraryPath(CDirectoryUtils::applicationDirectoryPath());
#endif
CGuiApplication::highDpiScreenSupport();
QApplication qa(argc, argv);
CGuiApplication a("samplehotkey", BlackMisc::CApplicationInfo::Sample, QPixmap());

2
samples/hotkey/qt.conf Normal file
View File

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

View File

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

View File

@@ -27,9 +27,6 @@ using namespace BlackMisc::PhysicalQuantities;
//! main
int main(int argc, char *argv[])
{
#ifdef Q_OS_MAC
QCoreApplication::addLibraryPath(CDirectoryUtils::applicationDirectoryPath());
#endif
QCoreApplication a(argc, argv);
BlackMisc::registerMetadata();
CLogHandler::instance()->install(true);

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)