QmlProfiler: Avoid memcpy for non-POD object

Replace with assignments/memcpy for members.

Detected by GCC8.

Change-Id: I9866ea0215cf5d43b55ed10d21e4efa371315365
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
This commit is contained in:
Orgad Shaneh
2018-05-08 19:36:12 +03:00
committed by Orgad Shaneh
parent 52e0b47c3f
commit ef528e1801

View File

@@ -68,8 +68,9 @@ struct QmlEvent : public Timeline::TraceEvent {
} }
QmlEvent(QmlEvent &&other) QmlEvent(QmlEvent &&other)
: TraceEvent(other), m_dataType(other.m_dataType), m_dataLength(other.m_dataLength)
{ {
memcpy(this, &other, sizeof(QmlEvent)); memcpy(&m_data, &other.m_data, sizeof(m_data));
other.m_dataType = Inline8Bit; // prevent dtor from deleting the pointer other.m_dataType = Inline8Bit; // prevent dtor from deleting the pointer
} }
@@ -88,7 +89,10 @@ struct QmlEvent : public Timeline::TraceEvent {
QmlEvent &operator=(QmlEvent &&other) QmlEvent &operator=(QmlEvent &&other)
{ {
if (this != &other) { if (this != &other) {
memcpy(this, &other, sizeof(QmlEvent)); TraceEvent::operator=(other);
m_dataType = other.m_dataType;
m_dataLength = other.m_dataLength;
memcpy(&m_data, &other.m_data, sizeof(m_data));
other.m_dataType = Inline8Bit; other.m_dataType = Inline8Bit;
} }
return *this; return *this;