Details
-
Bug
-
Resolution: Invalid
-
P3: Somewhat important
-
None
-
5.5.0
-
None
-
Linux (Qt5.5.0 on Debian/Wheezy) and Mac OSX 10.10.5 / iOS (7 and 8) with XCode 6.4 . For OSX builds only I still use Qt5.4.1, iOS is with 5.5.0.
Description
I have an application I'm building on Linux, OSX and iOS. I use a QQmlExtension in the application. On Linux and OSX I use a dynamic .so/.dylib plugin and it works great. Obviously on iOS I have to use static. I was surprised to discover I have to manually call
qobject_cast<QQmlExtensionPlugin*>(qt_static_plugin_ExamplePlugin().instance())->registerTypes("ExamplePlugin");
, otherwise it's never called and I get a
qrc:/qml/main.qml:3:1: module "ExamplePlugin" version 1.0 is not installed
when my QML attempts to import my plugin. But with the explicit invocation of registerTypes, all works as well as it does with the dynamic style.
There's a minimal reproducing example at https://bitbucket.org/timday/qt-example-plugin/ ; the default branch is static on iOS only, dynamic on the others. But there's also an all-static branch which confirms static plugins used on OSX and Linux (Win and Android untried) exhibit the same behaviour (I did wonder if it was some iOS-specific quirk due to xcode or something; I can't actually imagine preferring to use static plugins on platforms where dynamic ones are usable though).
I don't really know enough about what's going on behind the scenes with plugins to know if the need for a manual call is surprising. But I was certainly surprised to find I needed it; surely the
Q_IMPORT_PLUGIN(ExamplePlugin)
should be enough? Maybe there's some other misconfiguration in my .pro files or macro usage or something though.
Note that I am using a qmldir with a classname in it on static builds (here).
This may have something to do with QTBUG-28357, or at least that's what gave me the code snippet for calling a plugin's registerTypes directly.