mirror of
https://github.com/pocoproject/poco.git
synced 2024-12-12 18:20:26 +01:00
fixed GH #1355: [JSON::Object] After copy-ctor, JSON::Object::_keys still points to keys in map of copied object
This commit is contained in:
parent
4232d0b497
commit
f9f4c54bc3
@ -303,6 +303,19 @@ inline std::size_t Object::size() const
|
||||
inline void Object::remove(const std::string& key)
|
||||
{
|
||||
_values.erase(key);
|
||||
if (_preserveInsOrder)
|
||||
{
|
||||
KeyPtrList::iterator it = _keys.begin();
|
||||
KeyPtrList::iterator end = _keys.end();
|
||||
for (; it != end; ++it)
|
||||
{
|
||||
if (key == **it)
|
||||
{
|
||||
_keys.erase(it);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -32,10 +32,19 @@ Object::Object(bool preserveInsertionOrder): _preserveInsOrder(preserveInsertion
|
||||
|
||||
|
||||
Object::Object(const Object& copy) : _values(copy._values),
|
||||
_keys(copy._keys),
|
||||
_preserveInsOrder(copy._preserveInsOrder),
|
||||
_pStruct(0)
|
||||
{
|
||||
if (_preserveInsOrder)
|
||||
{
|
||||
// need to update pointers in _keys to point to copied _values
|
||||
for (KeyPtrList::const_iterator it = copy._keys.begin(); it != copy._keys.end(); ++it)
|
||||
{
|
||||
ValueMap::const_iterator itv = _values.find(**it);
|
||||
poco_assert (itv != _values.end());
|
||||
_keys.push_back(&itv->first);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user