Silence MSVC warning about int/size_t mismatch

Warning was

qmetaobjectbuilder.cpp(1439): warning C4267: '+=': conversion from
'size_t' to 'int', possible loss of data

Instead of adding another cast in that line, fix the warning by making
the size variable a qsizetype, and remove the now unnecessary
static_cast to int.

Change-Id: Ieff9330501f5a07c4bbe1e851a3ef211f8bf2d24
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit 718d1f88d7089d6792eea4dcb56875734a09a742)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Volker Hilsheimer 2021-05-06 11:16:46 +02:00 committed by Qt Cherry-pick Bot
parent ca4d48595b
commit 25bd96eb80

View File

@ -1173,7 +1173,7 @@ static int buildMetaObject(QMetaObjectBuilderPrivate *d, char *buf,
{
Q_UNUSED(expectedSize); // Avoid warning in release mode
Q_UNUSED(buf);
int size = 0;
qsizetype size = 0;
int dataIndex;
int paramsIndex;
int enumIndex;
@ -1467,7 +1467,7 @@ static int buildMetaObject(QMetaObjectBuilderPrivate *d, char *buf,
}
}
// parameterMetaTypesIndex is equal to the total number of metatypes
size += static_cast<int>(sizeof(QMetaType) * parameterMetaTypesIndex);
size += sizeof(QMetaType) * parameterMetaTypesIndex;
}
// Align the final size and return it.