From 2982545dbd5b45d765ed5c721017e1054c2822d8 Mon Sep 17 00:00:00 2001 From: Topi Reinio Date: Tue, 23 Oct 2012 12:42:14 +0200 Subject: [PATCH] QmlApplicationViewer: properly resolve install paths This change makes QmlApplicationViewer applications find their qml resources also in non-installed builds, regardless of the current working directory. On non-unix platforms applicationDirPath() is not used at all, and on unix, it's used only for searching applicationDirPath/../path, which is valid only after install. In-source or shadow-built apps find their qml resources only if working directory == application (executable) directory. Path may refer to subdirectory in application directory. On windows, non-installed application binary can also reside in /Release or /Debug, so its resources need to be searched under parent directory as well. Change-Id: I81f602406787c20830c656fd5dffd11aa9b4afba Reviewed-by: Christian Kandeler --- .../qmlapplicationviewer/qmlapplicationviewer.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/share/qtcreator/templates/qtquickapp/qmlapplicationviewer/qmlapplicationviewer.cpp b/share/qtcreator/templates/qtquickapp/qmlapplicationviewer/qmlapplicationviewer.cpp index f4221780796..9166a92f805 100644 --- a/share/qtcreator/templates/qtquickapp/qmlapplicationviewer/qmlapplicationviewer.cpp +++ b/share/qtcreator/templates/qtquickapp/qmlapplicationviewer/qmlapplicationviewer.cpp @@ -56,7 +56,6 @@ class QmlApplicationViewerPrivate QString QmlApplicationViewerPrivate::adjustPath(const QString &path) { -#ifdef Q_OS_UNIX #ifdef Q_OS_MAC if (!QDir::isAbsolutePath(path)) return QString::fromLatin1("%1/../Resources/%2") @@ -65,11 +64,14 @@ QString QmlApplicationViewerPrivate::adjustPath(const QString &path) if (!QDir::isAbsolutePath(path)) return QString::fromLatin1("app/native/%1").arg(path); #elif !defined(Q_OS_ANDROID) - const QString pathInInstallDir = + QString pathInInstallDir = QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); if (QFileInfo(pathInInstallDir).exists()) return pathInInstallDir; -#endif + pathInInstallDir = + QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path); + if (QFileInfo(pathInInstallDir).exists()) + return pathInInstallDir; #endif return path; }