diff options
Diffstat (limited to 'comphelper')
-rw-r--r-- | comphelper/source/misc/traceevent.cxx | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/comphelper/source/misc/traceevent.cxx b/comphelper/source/misc/traceevent.cxx index fb07e1caa771..1296404ebd32 100644 --- a/comphelper/source/misc/traceevent.cxx +++ b/comphelper/source/misc/traceevent.cxx @@ -40,15 +40,16 @@ std::mutex g_aMutex; void TraceEvent::addRecording(const OUString& sObject) { - std::lock_guard aGuard(g_aMutex); + bool bEmitCallback; + { + std::lock_guard aGuard(g_aMutex); - g_aRecording.emplace_back(sObject); + g_aRecording.emplace_back(sObject); - if (s_nBufferSize > 0 && g_aRecording.size() >= s_nBufferSize) - { - if (s_pBufferFullCallback != nullptr) - (*s_pBufferFullCallback)(); + bEmitCallback = s_nBufferSize > 0 && g_aRecording.size() >= s_nBufferSize; } + if (bEmitCallback && s_pBufferFullCallback != nullptr) + (*s_pBufferFullCallback)(); } void TraceEvent::addInstantEvent(const char* sName, const std::map<OUString, OUString>& args) |