changeset 509:451d3c087112

Override Qt library path on OS/X to avoid dependencies on unknown versions from outside the app bundle
author Chris Cannam
date Mon, 16 Jul 2012 10:29:38 +0100 (2012-07-16)
parents 26ebbe098bce
children f8833ed742fc
files deploy/osx/paths.sh main/main.cpp
diffstat 2 files changed, 24 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/deploy/osx/paths.sh	Mon Jul 02 12:46:25 2012 +0100
+++ b/deploy/osx/paths.sh	Mon Jul 16 10:29:38 2012 +0100
@@ -19,9 +19,13 @@
 install_name_tool -id QtNetwork "$app.app/Contents/Frameworks/QtNetwork"
 install_name_tool -id QtXml "$app.app/Contents/Frameworks/QtXml"
 
-for fwk in QtCore QtGui QtNetwork QtXml; do
+find "$app.app" -name \*.dylib -print | while read x; do
+    install_name_tool -id "`basename \"$x\"`" "$x"
+done
+
+for fwk in QtCore QtGui QtNetwork QtXml QtSvg; do
         find "$app.app" -type f -print | while read x; do
-                current=$(otool -L "$x" | grep "$fwk" | grep ramework | awk '{ print $1; }')
+                current=$(otool -L "$x" | grep "$fwk" | grep amework | awk '{ print $1; }')
                 [ -z "$current" ] && continue
                 echo "$x has $current"
                 relative=$(echo "$x" | sed -e "s,$app.app/Contents/,," \
--- a/main/main.cpp	Mon Jul 02 12:46:25 2012 +0100
+++ b/main/main.cpp	Mon Jul 16 10:29:38 2012 +0100
@@ -192,7 +192,24 @@
         m_readyForFiles(false),
         m_filepathQueue(QStringList()),
         m_mainWindow(0)
-        { }
+    {
+#ifdef Q_OS_MAC
+        // Override the Qt plugin load path. The default contains the
+        // Qt installation location as well as the application
+        // directory, but we don't ever want to load plugins from
+        // outside the app bundle because we don't know for sure what
+        // (potentially different) versions of the Qt framework
+        // libraries they may have dyld dependencies on.
+        QString apploc(applicationFilePath());
+        apploc.truncate(apploc.lastIndexOf(QLatin1Char('/')));
+        apploc = QDir(apploc).canonicalPath();
+        if (QFile::exists(apploc)) {
+            setLibraryPaths(QStringList() << apploc);
+        } else {
+            setLibraryPaths(QStringList());
+        }
+#endif
+    }
     virtual ~SVApplication() { }
 
     void setMainWindow(MainWindow *mw) { m_mainWindow = mw; }