CTF: Fix plugin cleanup
Handle cleanup of the CTF plugin correctly. The cleanup causes recursive trace event so the plugin needs to handle this. Change-Id: Id6f4c6efe95e51332a8be97fecdf7886ba173e43 Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io> Reviewed-by: Hatem ElKharashy <hatem.elkharashy@qt.io> (cherry picked from commit b652d9753bb474b3bc6c881dcb4b40a5a01ddcff) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
93b15be524
commit
c290537cd5
@ -42,6 +42,12 @@ QCtfLib *QCtfLibImpl::instance()
|
|||||||
return s_instance;
|
return s_instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QCtfLibImpl::cleanup()
|
||||||
|
{
|
||||||
|
if (s_instance)
|
||||||
|
delete s_instance;
|
||||||
|
}
|
||||||
|
|
||||||
QCtfLibImpl::QCtfLibImpl()
|
QCtfLibImpl::QCtfLibImpl()
|
||||||
{
|
{
|
||||||
QString location = QString::fromUtf8(qgetenv("QTRACE_LOCATION"));
|
QString location = QString::fromUtf8(qgetenv("QTRACE_LOCATION"));
|
||||||
|
@ -80,6 +80,7 @@ public:
|
|||||||
int eventId();
|
int eventId();
|
||||||
|
|
||||||
static QCtfLib *instance();
|
static QCtfLib *instance();
|
||||||
|
static void cleanup();
|
||||||
private:
|
private:
|
||||||
static QCtfLibImpl *s_instance;
|
static QCtfLibImpl *s_instance;
|
||||||
QHash<QString, QCtfTracePointPrivate *> m_eventPrivs;
|
QHash<QString, QCtfTracePointPrivate *> m_eventPrivs;
|
||||||
|
@ -19,24 +19,38 @@ public:
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
~QCtfTracePlugin() = default;
|
~QCtfTracePlugin()
|
||||||
|
{
|
||||||
|
m_cleanup = true;
|
||||||
|
QCtfLibImpl::cleanup();
|
||||||
|
}
|
||||||
|
|
||||||
bool tracepointEnabled(const QCtfTracePointEvent &point) override
|
bool tracepointEnabled(const QCtfTracePointEvent &point) override
|
||||||
{
|
{
|
||||||
|
if (m_cleanup)
|
||||||
|
return false;
|
||||||
return QCtfLibImpl::instance()->tracepointEnabled(point);
|
return QCtfLibImpl::instance()->tracepointEnabled(point);
|
||||||
}
|
}
|
||||||
void doTracepoint(const QCtfTracePointEvent &point, const QByteArray &arr) override
|
void doTracepoint(const QCtfTracePointEvent &point, const QByteArray &arr) override
|
||||||
{
|
{
|
||||||
|
if (m_cleanup)
|
||||||
|
return;
|
||||||
QCtfLibImpl::instance()->doTracepoint(point, arr);
|
QCtfLibImpl::instance()->doTracepoint(point, arr);
|
||||||
}
|
}
|
||||||
bool sessionEnabled() override
|
bool sessionEnabled() override
|
||||||
{
|
{
|
||||||
|
if (m_cleanup)
|
||||||
|
return false;
|
||||||
return QCtfLibImpl::instance()->sessionEnabled();
|
return QCtfLibImpl::instance()->sessionEnabled();
|
||||||
}
|
}
|
||||||
QCtfTracePointPrivate *initializeTracepoint(const QCtfTracePointEvent &point) override
|
QCtfTracePointPrivate *initializeTracepoint(const QCtfTracePointEvent &point) override
|
||||||
{
|
{
|
||||||
|
if (m_cleanup)
|
||||||
|
return nullptr;
|
||||||
return QCtfLibImpl::instance()->initializeTracepoint(point);
|
return QCtfLibImpl::instance()->initializeTracepoint(point);
|
||||||
}
|
}
|
||||||
|
private:
|
||||||
|
bool m_cleanup = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
#include "qctfplugin.moc"
|
#include "qctfplugin.moc"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user