QFactoryLoader: add assert and explicitly cast to int

Other parts of the code are expecting int.

Pick-to: 6.6 6.5
Change-Id: Iea73412c874adb2e6589e9b11607f313e1747d19
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Ahmad Samir 2023-06-04 15:54:09 +03:00
parent 5ea0256b07
commit 60f34fc9e3

View File

@ -356,6 +356,8 @@ QFactoryLoader::MetaDataList QFactoryLoader::metaData() const
continue;
metaData.append(std::move(parsed));
}
Q_ASSERT(metaData.size() <= std::numeric_limits<int>::max());
return metaData;
}
@ -400,7 +402,7 @@ QMultiMap<int, QString> QFactoryLoader::keyMap() const
{
QMultiMap<int, QString> result;
const QList<QPluginParsedMetaData> metaDataList = metaData();
for (int i = 0; i < metaDataList.size(); ++i) {
for (int i = 0; i < int(metaDataList.size()); ++i) {
const QCborMap metaData = metaDataList.at(i).value(QtPluginMetaDataKeys::MetaData).toMap();
const QCborArray keys = metaData.value("Keys"_L1).toArray();
for (QCborValueConstRef key : keys)
@ -412,7 +414,7 @@ QMultiMap<int, QString> QFactoryLoader::keyMap() const
int QFactoryLoader::indexOf(const QString &needle) const
{
const QList<QPluginParsedMetaData> metaDataList = metaData();
for (int i = 0; i < metaDataList.size(); ++i) {
for (int i = 0; i < int(metaDataList.size()); ++i) {
const QCborMap metaData = metaDataList.at(i).value(QtPluginMetaDataKeys::MetaData).toMap();
const QCborArray keys = metaData.value("Keys"_L1).toArray();
for (QCborValueConstRef key : keys) {