Details
-
Bug
-
Resolution: Invalid
-
P2: Important
-
None
-
5.14.1
-
None
Description
According to the docs: "
QImageIOPlugin
Creates and returns a QImageIOHandler subclass, with device and format set. The format must come from the values listed in the "Keys" entry in the plugin metadata, or be empty. If it is empty, the data in device must have been recognized by the capabilities() method (with a likewise empty format)."
The way I interpret this is that you should be able to create an image plugin with no key, but have capabilities queried to find supported formats.
However, in
// QMultiMap<int, QString> QFactoryLoader::keyMap() const { QMultiMap<int, QString> result; const QList<QJsonObject> metaDataList = metaData(); for (int i = 0; i < metaDataList.size(); ++i) { const QJsonObject metaData = metaDataList.at(i).value(QLatin1String("MetaData")).toObject(); const QJsonArray keys = metaData.value(QLatin1String("Keys")).toArray(); const int keyCount = keys.size(); for (int k = 0; k < keyCount; ++k) result.insert(i, keys.at(k).toString()); } return result; }
If there are no keys for a plugin image format, the format is not added to the key map. The key map is used to check on each format to call capabilities. Since there are no keys, capabilities is not called and the plugin is not listed as a supported format.
// static void appendImagePluginFormats(QFactoryLoader *loader, QImageIOPlugin::Capability cap, QList<QByteArray> *result) { typedef QMultiMap<int, QString> PluginKeyMap; typedef PluginKeyMap::const_iterator PluginKeyMapConstIterator; const PluginKeyMap keyMap = loader->keyMap(); const PluginKeyMapConstIterator cend = keyMap.constEnd(); int i = -1; QImageIOPlugin *plugin = 0; result->reserve(result->size() + keyMap.size()); for (PluginKeyMapConstIterator it = keyMap.constBegin(); it != cend; ++it) { if (it.key() != i) { i = it.key(); plugin = qobject_cast<QImageIOPlugin *>(loader->instance(i)); } const QByteArray key = it.value().toLatin1(); if (plugin && (plugin->capabilities(0, key) & cap) != 0) result->append(key); } }
The end result is that an image plugin that has no listed keys is loaded, but the format is not added to the list of supported formats when QImageReader::supportedImageFormats() is called.