diff options
-rw-r--r-- | src/corelib/plugin/qpluginloader.cpp | 17 | ||||
-rw-r--r-- | src/corelib/plugin/qpluginloader.h | 2 |
2 files changed, 19 insertions, 0 deletions
diff --git a/src/corelib/plugin/qpluginloader.cpp b/src/corelib/plugin/qpluginloader.cpp index f198f108da..a33c4e2996 100644 --- a/src/corelib/plugin/qpluginloader.cpp +++ b/src/corelib/plugin/qpluginloader.cpp @@ -173,6 +173,23 @@ QObject *QPluginLoader::instance() } /*! + Returns the meta data for this plugin. The meta data is data specified + in a json format using the Q_PLUGIN_METADATA() macro when compiling + the plugin. + + The meta data can be queried in a fast and inexpensive way without + actually loading the plugin. This makes it possible to e.g. store + capabilities of the plugin in there, and make the decision whether to + load the plugin dependent on this meta data. + */ +QJsonObject QPluginLoader::metaData() const +{ + if (!d) + return QJsonObject(); + return d->metaData; +} + +/*! Loads the plugin and returns true if the plugin was loaded successfully; otherwise returns false. Since instance() always calls this function before resolving any symbols it is not diff --git a/src/corelib/plugin/qpluginloader.h b/src/corelib/plugin/qpluginloader.h index 0e62d3660b..99b44fd559 100644 --- a/src/corelib/plugin/qpluginloader.h +++ b/src/corelib/plugin/qpluginloader.h @@ -56,6 +56,7 @@ QT_BEGIN_HEADER QT_BEGIN_NAMESPACE class QLibraryPrivate; +class QJsonObject; class Q_CORE_EXPORT QPluginLoader : public QObject { @@ -68,6 +69,7 @@ public: ~QPluginLoader(); QObject *instance(); + QJsonObject metaData() const; static QObjectList staticInstances(); |