From 392c7b99348e2a96ef11adb5712095fbd13fb780 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20L=C3=B6sch?= Date: Thu, 24 Mar 2016 12:09:31 +0100 Subject: Instantiate static Qml plugins declaring QQmlExtensionInterface only When instantiating static plugins no check is done whether the QQmlExtensionInterface is declared. Therefore all user plugins are instantiated in the Qml thread, which may cause problems. Task-number: QTBUG-52012 Change-Id: Ia91ec5ec7b2a9721bd11e3648cdc161855b4454e Reviewed-by: Simon Hausmann --- examples/qml/qmlextensionplugins/plugin.cpp | 2 +- .../tutorials/extending-qml/chapter6-plugins/import/chartsplugin.h | 2 +- examples/quick/customitems/painteditem/TextBalloonPlugin/plugin.h | 2 +- examples/quick/imageprovider/imageprovider.cpp | 5 +---- examples/quick/imageresponseprovider/imageresponseprovider.cpp | 5 +---- 5 files changed, 5 insertions(+), 11 deletions(-) (limited to 'examples') diff --git a/examples/qml/qmlextensionplugins/plugin.cpp b/examples/qml/qmlextensionplugins/plugin.cpp index 56057b7f06..e04cfa57d8 100644 --- a/examples/qml/qmlextensionplugins/plugin.cpp +++ b/examples/qml/qmlextensionplugins/plugin.cpp @@ -141,7 +141,7 @@ MinuteTimer *TimeModel::timer=0; class QExampleQmlPlugin : public QQmlExtensionPlugin { Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") + Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) public: void registerTypes(const char *uri) diff --git a/examples/qml/tutorials/extending-qml/chapter6-plugins/import/chartsplugin.h b/examples/qml/tutorials/extending-qml/chapter6-plugins/import/chartsplugin.h index 3c0f84fe34..2a9c2446bd 100644 --- a/examples/qml/tutorials/extending-qml/chapter6-plugins/import/chartsplugin.h +++ b/examples/qml/tutorials/extending-qml/chapter6-plugins/import/chartsplugin.h @@ -46,7 +46,7 @@ class ChartsPlugin : public QQmlExtensionPlugin { Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") + Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) public: void registerTypes(const char *uri); diff --git a/examples/quick/customitems/painteditem/TextBalloonPlugin/plugin.h b/examples/quick/customitems/painteditem/TextBalloonPlugin/plugin.h index f1f4de7fb7..5bbede6780 100644 --- a/examples/quick/customitems/painteditem/TextBalloonPlugin/plugin.h +++ b/examples/quick/customitems/painteditem/TextBalloonPlugin/plugin.h @@ -38,7 +38,7 @@ class TextBalloonPlugin : public QQmlExtensionPlugin { Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") + Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) public: void registerTypes(const char *uri) { diff --git a/examples/quick/imageprovider/imageprovider.cpp b/examples/quick/imageprovider/imageprovider.cpp index f402ce0ce8..1e4f53e736 100644 --- a/examples/quick/imageprovider/imageprovider.cpp +++ b/examples/quick/imageprovider/imageprovider.cpp @@ -87,7 +87,7 @@ public: class ImageProviderExtensionPlugin : public QQmlExtensionPlugin { Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") + Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) public: void registerTypes(const char *uri) { @@ -103,7 +103,4 @@ public: }; -#define QQmlExtensionInterface_iid "org.qt-project.Qt.QQmlExtensionInterface" - - #include "imageprovider.moc" diff --git a/examples/quick/imageresponseprovider/imageresponseprovider.cpp b/examples/quick/imageresponseprovider/imageresponseprovider.cpp index bdec29114b..a888c823a6 100644 --- a/examples/quick/imageresponseprovider/imageresponseprovider.cpp +++ b/examples/quick/imageresponseprovider/imageresponseprovider.cpp @@ -102,7 +102,7 @@ private: class ImageProviderExtensionPlugin : public QQmlExtensionPlugin { Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") + Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) public: void registerTypes(const char *uri) { @@ -117,7 +117,4 @@ public: }; - -#define QQmlExtensionInterface_iid "org.qt-project.Qt.QQmlExtensionInterface" - #include "imageresponseprovider.moc" -- cgit v1.2.3 From 35e2f29cde8dc8280b5ce1986533fca63f902d5e Mon Sep 17 00:00:00 2001 From: Topi Reinio Date: Tue, 12 Jan 2016 13:37:42 +0100 Subject: QML extensions tutorial: Add import plugin to app. bundle on OS X The application in chapter 6 of this tutorial failed to import the custom extension plugin on OS X, as it could not see it's import path outside the application bundle. Change-Id: Icdca1f0553020e0460e4efabc5461a3447b32086 Task-number: QTBUG-47003 Reviewed-by: Leena Miettinen Reviewed-by: Jake Petroules --- examples/qml/tutorials/extending-qml/chapter6-plugins/app.pro | 11 ++++++++--- .../qml/tutorials/extending-qml/chapter6-plugins/main.cpp | 10 +++++++--- 2 files changed, 15 insertions(+), 6 deletions(-) (limited to 'examples') diff --git a/examples/qml/tutorials/extending-qml/chapter6-plugins/app.pro b/examples/qml/tutorials/extending-qml/chapter6-plugins/app.pro index c55db00d27..4d0e807417 100644 --- a/examples/qml/tutorials/extending-qml/chapter6-plugins/app.pro +++ b/examples/qml/tutorials/extending-qml/chapter6-plugins/app.pro @@ -1,10 +1,15 @@ TARGET = chapter6-plugins QT += qml quick -# Avoid going to debug/release subdirectory -# so that our application will see the -# import path for the Charts module. +# Ensure that the application will see the import path for the Charts module: +# * On Windows, do not build into a debug/release subdirectory. +# * On OS X, add the plugin files into the bundle. win32: DESTDIR = ./ +osx { + charts.files = $$OUT_PWD/Charts + charts.path = Contents/PlugIns + QMAKE_BUNDLE_DATA += charts +} SOURCES += main.cpp RESOURCES += app.qrc diff --git a/examples/qml/tutorials/extending-qml/chapter6-plugins/main.cpp b/examples/qml/tutorials/extending-qml/chapter6-plugins/main.cpp index b20ae35f92..d165513861 100644 --- a/examples/qml/tutorials/extending-qml/chapter6-plugins/main.cpp +++ b/examples/qml/tutorials/extending-qml/chapter6-plugins/main.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. +** Copyright (C) 2016 The Qt Company Ltd. ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the documentation of the Qt Toolkit. @@ -37,17 +37,21 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -//![0] #include #include +#include int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); +//![0] QQuickView view; +#ifdef Q_OS_OSX + view.engine()->addImportPath(app.applicationDirPath() + "/../PlugIns"); +#endif +//![0] view.setResizeMode(QQuickView::SizeRootObjectToView); view.setSource(QUrl("qrc:///app.qml")); view.show(); return app.exec(); } -//![0] -- cgit v1.2.3