From: Hwankyu Jhun Date: Fri, 14 Jun 2024 00:35:00 +0000 (+0900) Subject: Fix copy constructor X-Git-Tag: accepted/tizen/unified/20240614.085200~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F49%2F312749%2F1;p=platform%2Fcore%2Fbase%2Fbundle.git Fix copy constructor For the wrong code written in anticipation of the order of the bundle, the elements are taken out of the list and the values are copied. This patc is for backward compatibility. Change-Id: I77eb340fcac5e0b4e7fbe8946cf4bdadfc44e576 Signed-off-by: Hwankyu Jhun --- diff --git a/src/bundle/bundle-internal.cc b/src/bundle/bundle-internal.cc index 68ccd8e..0470413 100644 --- a/src/bundle/bundle-internal.cc +++ b/src/bundle/bundle-internal.cc @@ -53,10 +53,9 @@ Bundle::Bundle(int argc, char** argv) { } Bundle::Bundle(const Bundle& b) { - for (const auto& [key, val] : b.map_) { - const KeyInfo& info = *val; - auto new_val = std::make_shared(info); - map_[key] = new_val; + for (const auto& info : b.list_) { + auto new_val = std::make_shared(*info); + map_[info->GetKey()] = new_val; list_.push_back(std::move(new_val)); } } @@ -65,10 +64,9 @@ Bundle& Bundle::operator = (const Bundle& b) { if (this != &b) { map_.clear(); list_.clear(); - for (const auto& [key, val] : b.map_) { - const KeyInfo& info = *val; - auto new_val = std::make_shared(info); - map_[key] = new_val; + for (const auto& info : b.list_) { + auto new_val = std::make_shared(*info); + map_[info->GetKey()] = new_val; list_.push_back(std::move(new_val)); } }