aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Hughes <robert.hughes@arm.com>2022-01-26 09:30:57 +0000
committerRob Hughes <robert.hughes@arm.com>2022-01-26 11:58:31 +0000
commit524a99ccf69b4bf5c8188bc9e4d89f402c374cae (patch)
tree8ad4c288cfced86ae9cbf64f748d27e315800e20
parent881c2e1fd5e0afd3ec81ded7df66dcf66888ac7d (diff)
downloadarmnn-524a99ccf69b4bf5c8188bc9e4d89f402c374cae.tar.gz
IVGCVSW-6739 Fix logging bug where blank messages were being sent
The ScopedRecord class sends its message to its sinks in its destructor. The StartNewRecord() method was creating a local ScopedRecord variable, returning a (move-initialised) copy of this, and then destroying this local variable (as the variable goes out of scope at the end of the function). That destruction was causing an empty log message to be sent to the sinks, which was not intended. This patch fixes this by making the move constructor of ScopedRecord disable the moved-from object, so that it does not send its message upon destruction. Change-Id: I435d96074698575ed3445fed2597c115b83701fd Signed-off-by: Rob Hughes <robert.hughes@arm.com>
-rw-r--r--include/armnn/Logging.hpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/include/armnn/Logging.hpp b/include/armnn/Logging.hpp
index 9a60e07c63..d18072a22d 100644
--- a/include/armnn/Logging.hpp
+++ b/include/armnn/Logging.hpp
@@ -120,7 +120,15 @@ struct ScopedRecord
ScopedRecord& operator=(const ScopedRecord&) = delete;
ScopedRecord& operator=(ScopedRecord&&) = delete;
- ScopedRecord(ScopedRecord&& other) = default;
+ ScopedRecord(ScopedRecord&& other)
+ : m_LogSinks(other.m_LogSinks)
+ , m_Os(std::move(other.m_Os))
+ , m_Enabled(other.m_Enabled)
+ {
+ // Disable the moved-from ScopedRecord, to prevent it from sending its (now empty) message to
+ // its sinks.
+ other.m_Enabled = false;
+ }
template<typename Streamable>
ScopedRecord& operator<<(const Streamable& s)
@@ -161,8 +169,7 @@ public:
ScopedRecord StartNewRecord()
{
- ScopedRecord record(m_Sinks, Level, m_Enable);
- return record;
+ return ScopedRecord(m_Sinks, Level, m_Enable);
}
void RemoveAllSinks()