Fixed mistakes in CStatusMessage copy assignment operator

This commit is contained in:
Mat Sutcliffe
2020-04-14 20:39:29 +01:00
parent 114b36e611
commit 20c6bef800
2 changed files with 4 additions and 6 deletions

View File

@@ -102,21 +102,19 @@ namespace BlackMisc
CStatusMessage &CStatusMessage::operator =(const CStatusMessage &other)
{
// locks because of mutable members
if (this == &other) { return *this; }
static_cast<CMessageBase &>(*this) = other;
static_cast<ITimestampBased &>(*this) = other;
static_cast<IOrderable &>(*this) = other;
// locks because of mutable member
QReadLocker readLock(&other.m_lock);
const auto handledBy = other.m_handledByObjects;
const qint64 ts = other.m_timestampMSecsSinceEpoch;
const int order = other.m_order;
readLock.unlock(); // avoid deadlock
QWriteLocker writeLock(&m_lock);
m_handledByObjects = handledBy;
m_timestampMSecsSinceEpoch = ts;
m_order = order;
return *this;
}

View File

@@ -518,7 +518,7 @@ namespace BlackMisc
CStatusMessage(const CLogCategoryList &categories, StatusSeverity severity, QStringView message, bool validation);
mutable QVector<quintptr> m_handledByObjects;
mutable QReadWriteLock m_lock; //!< lock (because of mutable members)
mutable QReadWriteLock m_lock; //!< lock (because of mutable member)
//! \fixme KB 2019-01 order and timestamp "disabled" for Ref T184 token bucket. Would it be better to enable those and use a special comparison function for that (e.g. "equalMessageAndSeverity")?
BLACK_METACLASS(