QmlProfiler: Fix some number conversion issues

Qt containers have int as size type, while std containers have size_t.
We can use auto and decltype to deal with this. Also, memcpy and malloc
expect size_t, not int.

Change-Id: Id2942d14978c8a15f72967962d551ddb20905471
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
Ulf Hermann
2018-03-27 17:37:24 +02:00
parent e0ba6f91ce
commit 32c54dfdac

View File

@@ -240,7 +240,7 @@ private:
void assignData(const QmlEvent &other) void assignData(const QmlEvent &other)
{ {
if (m_dataType & External) { if (m_dataType & External) {
int length = m_dataLength * (other.m_dataType / 8); size_t length = m_dataLength * (other.m_dataType / 8);
m_data.external = malloc(length); m_data.external = malloc(length);
memcpy(m_data.external, other.m_data.external, length); memcpy(m_data.external, other.m_data.external, length);
} else { } else {
@@ -278,8 +278,9 @@ private:
void assignNumbers(const Container &numbers) void assignNumbers(const Container &numbers)
{ {
Number *data; Number *data;
m_dataLength = squeezable<size_t, quint16>(numbers.size()) ? const auto size = numbers.size();
static_cast<quint16>(numbers.size()) : std::numeric_limits<quint16>::max(); m_dataLength = squeezable<decltype(size), quint16>(size) ?
static_cast<quint16>(size) : std::numeric_limits<quint16>::max();
if (m_dataLength > sizeof(m_data) / sizeof(Number)) { if (m_dataLength > sizeof(m_data) / sizeof(Number)) {
if (squeeze<Container, Number>(numbers)) if (squeeze<Container, Number>(numbers))
return; return;