[Development] Q_EXPORT_PLUGIN_2 breaks source compat

lars.knoll at nokia.com lars.knoll at nokia.com
Mon Jun 11 09:23:58 CEST 2012


On 6/10/12 9:45 PM, "ext Thiago Macieira" <thiago.macieira at intel.com>
wrote:

>On domingo, 10 de junho de 2012 20.44.05, David Faure wrote:
>> Is it really desired to break source compat so much, after making the
>> promise of "almost no porting required"? Porting to a different plugin
>> framework doesn't sound trivial. Well, maybe it is, who knows -- there
>>is
>> no entry in dist/changes-5.0.0 about this!
>
>It's necessary if we want to skip the loading of the old-style plugins.
>There's no way to get the metadata from them besides loading.
>
>This change was intentional.

Yes, it was unfortunately needed. This had also been discussed with
various people before the feature freeze.

The old style plugins require loading to get the keys() data, something
that's unacceptable in terms of performance. Porting is actually not very
difficult. It's simply about:

* add Q_PLUGIN_METADATA macro to your plugin object:

class MyPlugin : public QFooPlugin
{
	Q_PLUGIN_METADATA(IID "org.qt-project.foo" FILE
"myplugindescription.json")
}

* Add a myplugindescription.json file next to myplugin.h containing:

{ "Keys": [ "keyA", "KeyB", Š ] }

The json data will get compiled into the plugin into a special ELF
section, that we can find fast at runtime without having to dlopen the
plugin.

* remove the Q_EXPORT_PLUGIN macro


The json file btw allows us to extend the meta data for plugins longer
term, as you can pretty much store anything in the json file.

I am e.g. thinking of changing the json format for image plugins to
something better than what we have now, containing the list of supported
mime types, and some feature description (can it load scaled, can it save,
etc.). Combine that with qmimedatabase, and we can significantly simplify
our image loading code as well as avoid having to load plugins that can't
handle the image for 99% of the cases.

But you're right that I still need to update the docs. I'll make sure they
are up to date for the beta.

Cheers,
Lars






More information about the Development mailing list