[Interest] Getting at the metadata (or simply the file names) of currently loaded plugins

Thiago Macieira thiago.macieira at intel.com
Thu Dec 28 11:49:45 CET 2017


On quinta-feira, 28 de dezembro de 2017 08:08:30 -02 René J. V. Bertin wrote:
> Thiago Macieira wrote:
> > Remember: staticplugins are not plugins.
> 
> Actually, I couldn't remember that. The name suggested they might, but the
> documentation doesn't (at least what I read of it).
> 
> > They are regular, static
> > libraries whose only access point is via the plugin loader mechanism.
> 
> Which also explains why the built-in styles don't show up because they're in
> a shared library?

Those would also be staticplugins. If they are compiled into a library or the 
executable, as opposed to a dynamically-loaded module, they're staticplugins.

> > If you poke through the internals of QPluginLoader, you'll find it. See
> > the
> > QLibraryStore global static instance in qlibrary.cpp.
> 
> I started doing that, traced the metadata getter to a rawMetaData symbol
> which is a QtPluginMetaDataFunction which is a function pointer, and got
> lost there.

I think that QPluginLoader will leave the QLibraryPrivate in a IsAPlugin 
state, which means the QJsonObject metaData meber should be filled.

> I'll have a look at qlibrary.cpp and see if that gets me where I want though
> I guess that would oblige me to trawl the plugin directory myself to
> enumerate all plugins of potential interest.

Right, that's what QFactoryLoader does.

> I'm a bit surprised though that this is so difficult. Plugin metadata is a
> special case of QObject metadata, no? I can't find any methods to query that
> information (except via QPluginLoader for plugins), why is that?

No. It's a special section in the executable so that QLibrary can find it 
without loading the actual library. Then we read in the binary JSON that is 
stored there.

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center




More information about the Interest mailing list