Commit 04fda7d0 authored by Ulf Hermann's avatar Ulf Hermann

QmlProfiler: Avoid unrestricted unions

It seems we cannot use them, yet.

Change-Id: Ie5b0fd7daffbdc46992fc040448058dbde4b7209
Reviewed-by: default avatarChristian Kandeler <christian.kandeler@theqtcompany.com>
parent 53335c2f
...@@ -91,7 +91,7 @@ public: ...@@ -91,7 +91,7 @@ public:
{ {
if (this != &other) { if (this != &other) {
if (m_dataType == StringData) if (m_dataType == StringData)
m_stringData.~QString(); delete m_stringData;
m_startTime = other.m_startTime; m_startTime = other.m_startTime;
m_duration = other.m_duration; m_duration = other.m_duration;
...@@ -105,7 +105,7 @@ public: ...@@ -105,7 +105,7 @@ public:
~QmlEventData() ~QmlEventData()
{ {
if (m_dataType == StringData) if (m_dataType == StringData)
m_stringData.~QString(); delete m_stringData;
} }
qint64 startTime() const { return m_startTime; } qint64 startTime() const { return m_startTime; }
...@@ -121,7 +121,7 @@ public: ...@@ -121,7 +121,7 @@ public:
void setNumericData(int i, qint64 data) void setNumericData(int i, qint64 data)
{ {
if (m_dataType == StringData) if (m_dataType == StringData)
m_stringData.~QString(); delete m_stringData;
m_dataType = NumericData; m_dataType = NumericData;
m_numericData[i] = data; m_numericData[i] = data;
...@@ -131,7 +131,7 @@ public: ...@@ -131,7 +131,7 @@ public:
{ {
switch (m_dataType) { switch (m_dataType) {
case NumericData: return QString(); case NumericData: return QString();
case StringData: return m_stringData; case StringData: return *m_stringData;
default: return QString::fromUtf8(m_characterData, m_characterDataLength); default: return QString::fromUtf8(m_characterData, m_characterDataLength);
} }
} }
...@@ -139,7 +139,7 @@ public: ...@@ -139,7 +139,7 @@ public:
void setStringData(const QString &data) void setStringData(const QString &data)
{ {
if (m_dataType == StringData) if (m_dataType == StringData)
m_stringData.~QString(); delete m_stringData;
assignStringData(data); assignStringData(data);
} }
...@@ -153,7 +153,7 @@ public: ...@@ -153,7 +153,7 @@ public:
qint64 m_duration; qint64 m_duration;
union { union {
qint64 m_numericData[5]; qint64 m_numericData[5];
QString m_stringData; QString *m_stringData;
char m_characterData[5 * sizeof(qint64) + 3]; char m_characterData[5 * sizeof(qint64) + 3];
}; };
...@@ -167,7 +167,7 @@ public: ...@@ -167,7 +167,7 @@ public:
{ {
switch (m_dataType) { switch (m_dataType) {
case StringData: case StringData:
new (&m_stringData) QString(other.m_stringData); m_stringData = new QString(*other.m_stringData);
break; break;
case NumericData: case NumericData:
for (int i = 0; i < 5; ++i) for (int i = 0; i < 5; ++i)
...@@ -187,7 +187,7 @@ public: ...@@ -187,7 +187,7 @@ public:
memcpy(m_characterData, cdata.constData(), m_characterDataLength); memcpy(m_characterData, cdata.constData(), m_characterDataLength);
} else { } else {
m_dataType = StringData; m_dataType = StringData;
new (&m_stringData) QString(data); m_stringData = new QString(data);
} }
} }
}; };
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment