summaryrefslogtreecommitdiff
path: root/share
diff options
context:
space:
mode:
authorTopi Reinio <topi.reinio@digia.com>2012-10-23 12:42:14 +0200
committerChristian Kandeler <christian.kandeler@digia.com>2012-10-26 10:37:57 +0200
commit2982545dbd5b45d765ed5c721017e1054c2822d8 (patch)
treee84cb42c717a4df3052de754730462dee65468c1 /share
parent40966bb1a9466b5338e438f9f13a94e9f84459fa (diff)
downloadqt-creator-2982545dbd5b45d765ed5c721017e1054c2822d8.tar.gz
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 <christian.kandeler@digia.com>
Diffstat (limited to 'share')
-rw-r--r--share/qtcreator/templates/qtquickapp/qmlapplicationviewer/qmlapplicationviewer.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/share/qtcreator/templates/qtquickapp/qmlapplicationviewer/qmlapplicationviewer.cpp b/share/qtcreator/templates/qtquickapp/qmlapplicationviewer/qmlapplicationviewer.cpp
index f422178079..9166a92f80 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;
}