From e758b6fcbda482d1482c2a7258413711801bd746 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Wed, 19 May 2010 14:04:35 +0200 Subject: Search for QML import libraries also in application directory Add QCoreApplication::applicationLibraryPath again to the list of directories to search for possible QML plugins. Task-number: QTBUG-10771 Reviewed-by: mae --- src/declarative/qml/qdeclarativeengine.cpp | 10 ++++++---- src/declarative/qml/qdeclarativeimport.cpp | 14 ++++++++++---- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp index 79f8a17..3ab94d3 100644 --- a/src/declarative/qml/qdeclarativeengine.cpp +++ b/src/declarative/qml/qdeclarativeengine.cpp @@ -1550,8 +1550,9 @@ void QDeclarativeEngine::addImportPath(const QString& path) provided by that module. A \c qmldir file is required for defining the type version mapping and possibly declarative extensions plugins. - By default, the list contains the paths specified in the \c QML_IMPORT_PATH environment - variable, then the builtin \c ImportsPath from QLibraryInfo. + By default, the list contains the directory of the application executable, + paths specified in the \c QML_IMPORT_PATH environment variable, + and the builtin \c ImportsPath from QLibraryInfo. \sa addImportPath() setImportPathList() */ @@ -1565,8 +1566,9 @@ QStringList QDeclarativeEngine::importPathList() const Sets \a paths as the list of directories where the engine searches for installed modules in a URL-based directory structure. - By default, the list contains the paths specified in the \c QML_IMPORT_PATH environment - variable, then the builtin \c ImportsPath from QLibraryInfo. + By default, the list contains the directory of the application executable, + paths specified in the \c QML_IMPORT_PATH environment variable, + and the builtin \c ImportsPath from QLibraryInfo. \sa importPathList() addImportPath() */ diff --git a/src/declarative/qml/qdeclarativeimport.cpp b/src/declarative/qml/qdeclarativeimport.cpp index 576e048..cb36818 100644 --- a/src/declarative/qml/qdeclarativeimport.cpp +++ b/src/declarative/qml/qdeclarativeimport.cpp @@ -576,9 +576,9 @@ QDeclarativeImportDatabase::QDeclarativeImportDatabase(QDeclarativeEngine *e) { filePluginPath << QLatin1String("."); - QString builtinPath = QLibraryInfo::location(QLibraryInfo::ImportsPath); - if (!builtinPath.isEmpty()) - addImportPath(builtinPath); + // Search order is applicationDirPath(), $QML_IMPORT_PATH, QLibraryInfo::ImportsPath + + addImportPath(QLibraryInfo::location(QLibraryInfo::ImportsPath)); // env import paths QByteArray envImportPath = qgetenv("QML_IMPORT_PATH"); @@ -592,6 +592,8 @@ QDeclarativeImportDatabase::QDeclarativeImportDatabase(QDeclarativeEngine *e) for (int ii = paths.count() - 1; ii >= 0; --ii) addImportPath(paths.at(ii)); } + + addImportPath(QCoreApplication::applicationDirPath()); } QDeclarativeImportDatabase::~QDeclarativeImportDatabase() @@ -843,6 +845,9 @@ void QDeclarativeImportDatabase::addImportPath(const QString& path) if (qmlImportTrace()) qDebug() << "QDeclarativeImportDatabase::addImportPath" << path; + if (path.isEmpty()) + return; + QUrl url = QUrl(path); QString cPath; @@ -853,7 +858,8 @@ void QDeclarativeImportDatabase::addImportPath(const QString& path) cPath = path; } - if (!fileImportPath.contains(cPath)) + if (!cPath.isEmpty() + && !fileImportPath.contains(cPath)) fileImportPath.prepend(cPath); } -- cgit v0.12