aboutsummaryrefslogtreecommitdiffstats
path: root/src/core/function/basic/SingletonStorage.cpp
diff options
context:
space:
mode:
authorsaturneric <[email protected]>2023-12-14 08:58:53 +0000
committersaturneric <[email protected]>2023-12-14 08:58:53 +0000
commit79783510863445b5068eef092a1f2650733a5b02 (patch)
treed8e6070b85467451c658ce4122c45a5a132e6d44 /src/core/function/basic/SingletonStorage.cpp
parentfix: slove a memory issue found by valgrind (diff)
downloadGpgFrontend-79783510863445b5068eef092a1f2650733a5b02.tar.gz
GpgFrontend-79783510863445b5068eef092a1f2650733a5b02.zip
fix: slove some memory issues
Diffstat (limited to 'src/core/function/basic/SingletonStorage.cpp')
-rw-r--r--src/core/function/basic/SingletonStorage.cpp17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/core/function/basic/SingletonStorage.cpp b/src/core/function/basic/SingletonStorage.cpp
index 211a51b3..4786ad93 100644
--- a/src/core/function/basic/SingletonStorage.cpp
+++ b/src/core/function/basic/SingletonStorage.cpp
@@ -71,7 +71,8 @@ class SingletonStorage::Impl {
auto SetObjectInChannel(int channel, ChannelObjectPtr p_obj)
-> GpgFrontend::ChannelObject* {
{
- SPDLOG_TRACE("set channel object in channel: {}, address: {}", channel,
+ SPDLOG_TRACE("set channel object, type: {} in channel: {}, address: {}",
+ typeid(p_obj.get()).name(), channel,
static_cast<void*>(p_obj.get()));
assert(p_obj != nullptr);
@@ -84,12 +85,14 @@ class SingletonStorage::Impl {
p_obj->SetChannel(channel);
auto* raw_obj = p_obj.get();
- SPDLOG_TRACE(
- "register channel object to instances map, "
- "channel: {}, address: {}",
- channel, static_cast<void*>(p_obj.get()));
- std::unique_lock<std::shared_mutex> lock(instances_mutex_);
- instances_map_.insert({channel, std::move(p_obj)});
+ {
+ SPDLOG_TRACE(
+ "register channel object to instances map, "
+ "channel: {}, address: {}",
+ channel, static_cast<void*>(p_obj.get()));
+ std::unique_lock<std::shared_mutex> lock(instances_mutex_);
+ instances_map_[channel] = std::move(p_obj);
+ }
SPDLOG_TRACE(
"set channel: {} success, current channel object address: {}",