Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-47827

registerTypes not automatically invoked on static linked QQmlExtension plugins

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3: Somewhat important
    • Resolution: Invalid
    • Affects Version/s: 5.5.0
    • Fix Version/s: None
    • Labels:
      None
    • Environment:
      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.

        Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

            Assignee:
            laknoll Lars Knoll
            Reporter:
            timday Tim Day
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Gerrit Reviews

                There are no open Gerrit changes