Skip to content

Commit

Permalink
Utilize the resources when building statically.
Browse files Browse the repository at this point in the history
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 <simon.hausmann@theqtcompany.com>
  • Loading branch information
Andy Shaw committed Dec 2, 2015
1 parent c3a818d commit ec5a886
Show file tree
Hide file tree
Showing 12 changed files with 84 additions and 5 deletions.
8 changes: 8 additions & 0 deletions src/imports/folderlistmodel/plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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"));
Expand Down
11 changes: 9 additions & 2 deletions src/imports/localstorage/plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@
#include <private/qv4scopedvalue_p.h>
#include <private/qv4objectiterator_p.h>

static void initResources()
{
#ifdef QT_STATIC
Q_INIT_RESOURCE(qmake_QtQuick_LocalStorage);
#endif
}

QT_BEGIN_NAMESPACE

#define V4THROW_SQL(error, desc) { \
Expand Down Expand Up @@ -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");
Expand Down
8 changes: 8 additions & 0 deletions src/imports/models/plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@

#include <private/qqmlmodelsmodule_p.h>

static void initResources()
{
#ifdef QT_STATIC
Q_INIT_RESOURCE(qmake_QtQml_Models_2);
#endif
}

QT_BEGIN_NAMESPACE

/*!
Expand Down Expand Up @@ -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"));
Expand Down
8 changes: 8 additions & 0 deletions src/imports/particles/plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@

#include <private/qquickparticlesmodule_p.h>

static void initResources()
{
#ifdef QT_STATIC
Q_INIT_RESOURCE(qmake_QtQuick_Particles_2);
#endif
}

QT_BEGIN_NAMESPACE

//![class decl]
Expand All @@ -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"));
Expand Down
8 changes: 8 additions & 0 deletions src/imports/qtquick2/plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@

#include <private/qtquick2_p.h>

static void initResources()
{
#ifdef QT_STATIC
Q_INIT_RESOURCE(qmake_QtQuick_2);
#endif
}

QT_BEGIN_NAMESPACE

//![class decl]
Expand All @@ -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"));
Expand Down
8 changes: 8 additions & 0 deletions src/imports/settings/plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"));
Expand Down
8 changes: 8 additions & 0 deletions src/imports/statemachine/plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@
#include <QQmlExtensionPlugin>
#include <qqml.h>

static void initResources()
{
#ifdef QT_STATIC
Q_INIT_RESOURCE(qmake_QtQml_StateMachine);
#endif
}

QT_BEGIN_NAMESPACE

class QtQmlStateMachinePlugin : public QQmlExtensionPlugin
Expand All @@ -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<State>(uri, 1, 0, "State");
Expand Down
8 changes: 8 additions & 0 deletions src/imports/testlib/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ QML_DECLARE_TYPE(QuickTestEvent)

#include <QtDebug>

static void initResources()
{
#ifdef QT_STATIC
Q_INIT_RESOURCE(qmake_QtTest);
#endif
}

QT_BEGIN_NAMESPACE

class QuickTestUtil : public QObject
Expand Down Expand Up @@ -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"));
Expand Down
9 changes: 8 additions & 1 deletion src/imports/window/plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@

#include <private/qquickwindowmodule_p.h>

static void initResources()
{
#ifdef QT_STATIC
Q_INIT_RESOURCE(qmake_QtQuick_Window_2);
#endif
}

QT_BEGIN_NAMESPACE

/*!
Expand All @@ -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"));
Expand Down
8 changes: 8 additions & 0 deletions src/imports/xmllistmodel/plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"));
Expand Down
1 change: 1 addition & 0 deletions src/qml/doc/src/qmllanguageref/syntax/imports.qdoc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/qml/qml/qqmlimport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit ec5a886

Please sign in to comment.