diff options
author | Antti Määttä <[email protected]> | 2023-05-24 15:20:49 +0300 |
---|---|---|
committer | Antti Määttä <[email protected]> | 2023-08-08 17:03:28 +0300 |
commit | 7f5d2262c13061f5caf7a162ae46d1e08ec8914d (patch) | |
tree | c817e8f09179c1d64dc692798abc7b18fe179927 | |
parent | 62312e667441aea32ebaf70f1304d3fb0381f48f (diff) |
CTF: Remove channel from channel list when it is destroyed
Prevents using the channel after it was destroyed.
Change-Id: I5d65fcde0d451dd8ce2c56f403e0bd1f41510382
Reviewed-by: Janne Koskinen <[email protected]>
-rw-r--r-- | src/plugins/tracing/qctflib.cpp | 7 | ||||
-rw-r--r-- | src/plugins/tracing/qctflib_p.h | 1 |
2 files changed, 8 insertions, 0 deletions
diff --git a/src/plugins/tracing/qctflib.cpp b/src/plugins/tracing/qctflib.cpp index 0ad639a9cee..86d39afaa9b 100644 --- a/src/plugins/tracing/qctflib.cpp +++ b/src/plugins/tracing/qctflib.cpp @@ -257,6 +257,7 @@ void QCtfLibImpl::writeCtfPacket(QCtfLibImpl::Channel &ch) QCtfLibImpl::Channel::~Channel() { impl->writeCtfPacket(*this); + impl->removeChannel(this); } QCtfLibImpl::~QCtfLibImpl() @@ -266,6 +267,12 @@ QCtfLibImpl::~QCtfLibImpl() qDeleteAll(m_eventPrivs); } +void QCtfLibImpl::removeChannel(Channel *ch) +{ + const QMutexLocker lock(&m_mutex); + m_channels.removeOne(ch); +} + bool QCtfLibImpl::tracepointEnabled(const QCtfTracePointEvent &point) { if (m_sessionChanged) { diff --git a/src/plugins/tracing/qctflib_p.h b/src/plugins/tracing/qctflib_p.h index ef70fcdd9ac..297d38ee509 100644 --- a/src/plugins/tracing/qctflib_p.h +++ b/src/plugins/tracing/qctflib_p.h @@ -89,6 +89,7 @@ public: private: static QCtfLibImpl *s_instance; QHash<QString, QCtfTracePointPrivate *> m_eventPrivs; + void removeChannel(Channel *ch); void updateMetadata(const QCtfTracePointEvent &point); void writeMetadata(const QString &metadata, bool overwrite = false); void clearLocation(); |