forked from qt-creator/qt-creator
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>
This commit is contained in:
committed by
Christian Kandeler
parent
40966bb1a9
commit
2982545dbd
@@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user