diff options
| author | Thiago Macieira <thiago.macieira@intel.com> | 2018-06-26 22:46:49 -0700 |
|---|---|---|
| committer | Thiago Macieira <thiago.macieira@intel.com> | 2018-09-01 15:19:39 +0000 |
| commit | d9766ddc3d525cf08acec4c3483e61d86c9899a8 (patch) | |
| tree | 755b9c9181a24cbc1663714e888e2e3f4cd4db45 /src/corelib/plugin/qpluginloader.cpp | |
| parent | 7391662f80470549b9f9c182da43cf433efabdf7 (diff) | |
Plugins: store the metadata in CBOR instead of binary JSON
In preparation for Qt 6 deprecating the binary JSON format. Also reduces
the size of the metadata a little: for the xcb platform plugin, it went
down from 264 bytes to 138; for the jpeg image plugin, it went from 320
to 135.
I've had to change the signature so older versions of Qt won't try to
parse the CBOR data as Binary JSON. Unfortunately, before QJsonDocument
could get a chance to reject it, qJsonFromRawLibraryMetaData() needed to
allocate memory and that causes crashes with Qt < 5.11.2.
Change-Id: Ieb48f7c0dd0e4e0fb35efffd153bee34e16ce347
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/corelib/plugin/qpluginloader.cpp')
| -rw-r--r-- | src/corelib/plugin/qpluginloader.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/corelib/plugin/qpluginloader.cpp b/src/corelib/plugin/qpluginloader.cpp index 83cbcd2b44e..0f94bb6adf8 100644 --- a/src/corelib/plugin/qpluginloader.cpp +++ b/src/corelib/plugin/qpluginloader.cpp @@ -475,10 +475,19 @@ QVector<QStaticPlugin> QPluginLoader::staticPlugins() */ QJsonObject QStaticPlugin::metaData() const { +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // the data is already loaded, so this doesn't matter qsizetype rawMetaDataSize = INT_MAX; + const char *ptr = rawMetaData(); +#else + auto ptr = static_cast<const char *>(rawMetaData); +#endif - return qJsonFromRawLibraryMetaData(rawMetaData(), rawMetaDataSize).object(); + QString errMsg; + QJsonDocument doc = qJsonFromRawLibraryMetaData(ptr, rawMetaDataSize, &errMsg); + Q_ASSERT(doc.isObject()); + Q_ASSERT(errMsg.isEmpty()); + return doc.object(); } QT_END_NAMESPACE |
