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.

Pick-to: 6.1
Change-Id: Ieff9330501f5a07c4bbe1e851a3ef211f8bf2d24
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
bb10
Volker Hilsheimer 2021-05-06 11:16:46 +02:00
parent e3b2b12a91
commit 718d1f88d7
1 changed files with 2 additions and 2 deletions

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;
@ -1472,7 +1472,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.