forked from qt-creator/qt-creator
Tracing: Make sure we don't cast between different kinds of events
Add a classId to TraceEvent and TraceEventType and add is() and as() methods that check for it. Change-Id: I76fe1df624516b36db90d57d4788b17e0b690726 Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
@@ -39,24 +39,26 @@
|
||||
namespace QmlProfiler {
|
||||
|
||||
struct QmlEvent : public Timeline::TraceEvent {
|
||||
QmlEvent() : m_dataType(Inline8Bit), m_dataLength(0) {}
|
||||
static const qint32 staticClassId = 0x716d6c65; // 'qmle';
|
||||
|
||||
QmlEvent() : TraceEvent(staticClassId), m_dataType(Inline8Bit), m_dataLength(0) {}
|
||||
|
||||
template<typename Number>
|
||||
QmlEvent(qint64 timestamp, int typeIndex, std::initializer_list<Number> list)
|
||||
: TraceEvent(timestamp, typeIndex)
|
||||
: TraceEvent(staticClassId, timestamp, typeIndex)
|
||||
{
|
||||
assignNumbers<std::initializer_list<Number>, Number>(list);
|
||||
}
|
||||
|
||||
QmlEvent(qint64 timestamp, int typeIndex, const QString &data)
|
||||
: TraceEvent(timestamp, typeIndex)
|
||||
: TraceEvent(staticClassId, timestamp, typeIndex)
|
||||
{
|
||||
assignNumbers<QByteArray, qint8>(data.toUtf8());
|
||||
}
|
||||
|
||||
template<typename Number>
|
||||
QmlEvent(qint64 timestamp, int typeIndex, const QVector<Number> &data)
|
||||
: TraceEvent(timestamp, typeIndex)
|
||||
: TraceEvent(staticClassId, timestamp, typeIndex)
|
||||
{
|
||||
assignNumbers<QVector<Number>, Number>(data);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user