From ec5a886d4b92a18669d5bbd01b43a57f7d81b856 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Sat, 20 Jun 2015 01:26:48 +0200 Subject: Utilize the resources when building statically. This is needed so that the qmldir file is picked up correctly when using a static build of the plugins in the application as this gets taken care of automatically by qmake. The Q_INIT_RESOURCES line itself is only needed statically because no resource file is needed for dynamic libraries so it is protected with the QT_STATIC define. Task-number: QTBUG-35754 Change-Id: I9059e10c0846548f365fe4f95dd9c6100eeb43cd Reviewed-by: Simon Hausmann --- src/imports/folderlistmodel/plugin.cpp | 8 ++++++++ src/imports/localstorage/plugin.cpp | 11 +++++++++-- src/imports/models/plugin.cpp | 8 ++++++++ src/imports/particles/plugin.cpp | 8 ++++++++ src/imports/qtquick2/plugin.cpp | 8 ++++++++ src/imports/settings/plugin.cpp | 8 ++++++++ src/imports/statemachine/plugin.cpp | 8 ++++++++ src/imports/testlib/main.cpp | 8 ++++++++ src/imports/window/plugin.cpp | 9 ++++++++- src/imports/xmllistmodel/plugin.cpp | 8 ++++++++ src/qml/doc/src/qmllanguageref/syntax/imports.qdoc | 1 + src/qml/qml/qqmlimport.cpp | 4 ++-- 12 files changed, 84 insertions(+), 5 deletions(-) diff --git a/src/imports/folderlistmodel/plugin.cpp b/src/imports/folderlistmodel/plugin.cpp index 7280fcd1dc..33c1167719 100644 --- a/src/imports/folderlistmodel/plugin.cpp +++ b/src/imports/folderlistmodel/plugin.cpp @@ -36,6 +36,13 @@ #include "qquickfolderlistmodel.h" +static void initResources() +{ +#ifdef QT_STATIC + Q_INIT_RESOURCE(qmake_Qt_labs_folderlistmodel); +#endif +} + QT_BEGIN_NAMESPACE //![class decl] @@ -45,6 +52,7 @@ class QmlFolderListModelPlugin : public QQmlExtensionPlugin Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") public: + QmlFolderListModelPlugin(QObject *parent = 0) : QQmlExtensionPlugin(parent) { initResources(); } virtual void registerTypes(const char *uri) { Q_ASSERT(QLatin1String(uri) == QLatin1String("Qt.labs.folderlistmodel")); diff --git a/src/imports/localstorage/plugin.cpp b/src/imports/localstorage/plugin.cpp index ada50774a7..5b55a2711f 100644 --- a/src/imports/localstorage/plugin.cpp +++ b/src/imports/localstorage/plugin.cpp @@ -54,6 +54,13 @@ #include #include +static void initResources() +{ +#ifdef QT_STATIC + Q_INIT_RESOURCE(qmake_QtQuick_LocalStorage); +#endif +} + QT_BEGIN_NAMESPACE #define V4THROW_SQL(error, desc) { \ @@ -744,10 +751,10 @@ class QQmlLocalStoragePlugin : public QQmlExtensionPlugin Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") public: - QQmlLocalStoragePlugin() + QQmlLocalStoragePlugin(QObject *parent = 0) : QQmlExtensionPlugin(parent) { + initResources(); } - void registerTypes(const char *uri) { Q_ASSERT(QLatin1String(uri) == "QtQuick.LocalStorage"); diff --git a/src/imports/models/plugin.cpp b/src/imports/models/plugin.cpp index c2b0d2ae94..4ba1ddea14 100644 --- a/src/imports/models/plugin.cpp +++ b/src/imports/models/plugin.cpp @@ -35,6 +35,13 @@ #include +static void initResources() +{ +#ifdef QT_STATIC + Q_INIT_RESOURCE(qmake_QtQml_Models_2); +#endif +} + QT_BEGIN_NAMESPACE /*! @@ -64,6 +71,7 @@ class QtQmlModelsPlugin : public QQmlExtensionPlugin Q_OBJECT Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface/1.0") public: + QtQmlModelsPlugin(QObject *parent = 0) : QQmlExtensionPlugin(parent) { initResources(); } virtual void registerTypes(const char *uri) { Q_ASSERT(QLatin1String(uri) == QLatin1String("QtQml.Models")); diff --git a/src/imports/particles/plugin.cpp b/src/imports/particles/plugin.cpp index 56b611a408..609efd0bad 100644 --- a/src/imports/particles/plugin.cpp +++ b/src/imports/particles/plugin.cpp @@ -35,6 +35,13 @@ #include +static void initResources() +{ +#ifdef QT_STATIC + Q_INIT_RESOURCE(qmake_QtQuick_Particles_2); +#endif +} + QT_BEGIN_NAMESPACE //![class decl] @@ -43,6 +50,7 @@ class QtQuick2ParticlesPlugin : public QQmlExtensionPlugin Q_OBJECT Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface/1.0") public: + QtQuick2ParticlesPlugin(QObject *parent = 0) : QQmlExtensionPlugin(parent) { initResources(); } virtual void registerTypes(const char *uri) { Q_ASSERT(QLatin1String(uri) == QLatin1String("QtQuick.Particles")); diff --git a/src/imports/qtquick2/plugin.cpp b/src/imports/qtquick2/plugin.cpp index 36a57112b2..4cb77dcd4b 100644 --- a/src/imports/qtquick2/plugin.cpp +++ b/src/imports/qtquick2/plugin.cpp @@ -35,6 +35,13 @@ #include +static void initResources() +{ +#ifdef QT_STATIC + Q_INIT_RESOURCE(qmake_QtQuick_2); +#endif +} + QT_BEGIN_NAMESPACE //![class decl] @@ -43,6 +50,7 @@ class QtQuick2Plugin : public QQmlExtensionPlugin Q_OBJECT Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface/1.0") public: + QtQuick2Plugin(QObject *parent = 0) : QQmlExtensionPlugin(parent) { initResources(); } virtual void registerTypes(const char *uri) { Q_ASSERT(QLatin1String(uri) == QLatin1String("QtQuick")); diff --git a/src/imports/settings/plugin.cpp b/src/imports/settings/plugin.cpp index c32d370537..49ee8ab9bf 100644 --- a/src/imports/settings/plugin.cpp +++ b/src/imports/settings/plugin.cpp @@ -36,6 +36,13 @@ #include "qqmlsettings_p.h" +static void initResources() +{ +#ifdef QT_STATIC + Q_INIT_RESOURCE(qmake_Qt_labs_settings); +#endif +} + QT_BEGIN_NAMESPACE class QmlSettingsPlugin : public QQmlExtensionPlugin @@ -44,6 +51,7 @@ class QmlSettingsPlugin : public QQmlExtensionPlugin Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") public: + QmlSettingsPlugin(QObject *parent = 0) : QQmlExtensionPlugin(parent) { initResources(); } virtual void registerTypes(const char *uri) { Q_ASSERT(QByteArray(uri) == QByteArray("Qt.labs.settings")); diff --git a/src/imports/statemachine/plugin.cpp b/src/imports/statemachine/plugin.cpp index 4a711a3278..e0fea01d8f 100644 --- a/src/imports/statemachine/plugin.cpp +++ b/src/imports/statemachine/plugin.cpp @@ -41,6 +41,13 @@ #include #include +static void initResources() +{ +#ifdef QT_STATIC + Q_INIT_RESOURCE(qmake_QtQml_StateMachine); +#endif +} + QT_BEGIN_NAMESPACE class QtQmlStateMachinePlugin : public QQmlExtensionPlugin @@ -49,6 +56,7 @@ class QtQmlStateMachinePlugin : public QQmlExtensionPlugin Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtQml.StateMachine/1.0") public: + QtQmlStateMachinePlugin(QObject *parent = 0) : QQmlExtensionPlugin(parent) { initResources(); } void registerTypes(const char *uri) { qmlRegisterType(uri, 1, 0, "State"); diff --git a/src/imports/testlib/main.cpp b/src/imports/testlib/main.cpp index c42ece5da5..b2ea10fa38 100644 --- a/src/imports/testlib/main.cpp +++ b/src/imports/testlib/main.cpp @@ -48,6 +48,13 @@ QML_DECLARE_TYPE(QuickTestEvent) #include +static void initResources() +{ +#ifdef QT_STATIC + Q_INIT_RESOURCE(qmake_QtTest); +#endif +} + QT_BEGIN_NAMESPACE class QuickTestUtil : public QObject @@ -137,6 +144,7 @@ class QTestQmlModule : public QQmlExtensionPlugin Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") public: + QTestQmlModule(QObject *parent = 0) : QQmlExtensionPlugin(parent) { initResources(); } virtual void registerTypes(const char *uri) { Q_ASSERT(QLatin1String(uri) == QLatin1String("QtTest")); diff --git a/src/imports/window/plugin.cpp b/src/imports/window/plugin.cpp index 010e9b3eed..2946cae679 100644 --- a/src/imports/window/plugin.cpp +++ b/src/imports/window/plugin.cpp @@ -35,6 +35,13 @@ #include +static void initResources() +{ +#ifdef QT_STATIC + Q_INIT_RESOURCE(qmake_QtQuick_Window_2); +#endif +} + QT_BEGIN_NAMESPACE /*! @@ -53,13 +60,13 @@ QT_BEGIN_NAMESPACE */ - //![class decl] class QtQuick2WindowPlugin : public QQmlExtensionPlugin { Q_OBJECT Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface/1.0") public: + QtQuick2WindowPlugin(QObject *parent = 0) : QQmlExtensionPlugin(parent) { initResources(); } virtual void registerTypes(const char *uri) { Q_ASSERT(QLatin1String(uri) == QLatin1String("QtQuick.Window")); diff --git a/src/imports/xmllistmodel/plugin.cpp b/src/imports/xmllistmodel/plugin.cpp index 8a9d4379c4..514a44fe14 100644 --- a/src/imports/xmllistmodel/plugin.cpp +++ b/src/imports/xmllistmodel/plugin.cpp @@ -36,6 +36,13 @@ #include "qqmlxmllistmodel_p.h" +static void initResources() +{ +#ifdef QT_STATIC + Q_INIT_RESOURCE(qmake_QtQuick_XmlListModel); +#endif +} + QT_BEGIN_NAMESPACE class QmlXmlListModelPlugin : public QQmlExtensionPlugin @@ -44,6 +51,7 @@ class QmlXmlListModelPlugin : public QQmlExtensionPlugin Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") public: + QmlXmlListModelPlugin(QObject *parent = 0) : QQmlExtensionPlugin(parent) { initResources(); } virtual void registerTypes(const char *uri) { Q_ASSERT(QLatin1String(uri) == QLatin1String("QtQuick.XmlListModel")); diff --git a/src/qml/doc/src/qmllanguageref/syntax/imports.qdoc b/src/qml/doc/src/qmllanguageref/syntax/imports.qdoc index 9eb792bd2e..71db34695c 100644 --- a/src/qml/doc/src/qmllanguageref/syntax/imports.qdoc +++ b/src/qml/doc/src/qmllanguageref/syntax/imports.qdoc @@ -291,6 +291,7 @@ default locations to be searched by the engine. By default, this list contains: \li The directory of the current file \li The location specified by QLibraryInfo::Qml2ImportsPath \li Paths specified by the \c QML2_IMPORT_PATH environment variable +\li The qrc:/qt-project.org/imports path inside the resources. \endlist Additional import paths can be added through QQmlEngine::addImportPath() or the diff --git a/src/qml/qml/qqmlimport.cpp b/src/qml/qml/qqmlimport.cpp index c5b5947c11..76a367c5c8 100644 --- a/src/qml/qml/qqmlimport.cpp +++ b/src/qml/qml/qqmlimport.cpp @@ -1563,8 +1563,8 @@ QQmlImportDatabase::QQmlImportDatabase(QQmlEngine *e) : engine(e) { filePluginPath << QLatin1String("."); - - // Search order is applicationDirPath(), $QML2_IMPORT_PATH, QLibraryInfo::Qml2ImportsPath + addImportPath(QStringLiteral("qrc:/qt-project.org/imports")); + // Search order is applicationDirPath(), qrc:/qt-project.org/imports, $QML2_IMPORT_PATH, QLibraryInfo::Qml2ImportsPath QString installImportsPath = QLibraryInfo::location(QLibraryInfo::Qml2ImportsPath); addImportPath(installImportsPath); -- cgit v1.2.3