Skip to content

Commit

Permalink
Correct operator= for UserData and Partitions
Browse files Browse the repository at this point in the history
  • Loading branch information
IkerLuengo committed Feb 10, 2020
1 parent de0f4e7 commit 8e87789
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
13 changes: 9 additions & 4 deletions include/fastrtps/qos/QosPolicies.h
Original file line number Diff line number Diff line change
Expand Up @@ -688,9 +688,13 @@ class UserDataQosPolicy : public Parameter_t, public QosPolicy, public ResourceL
UserDataQosPolicy& operator =(
const collection_type& b)
{
//If the object is size limited, already has max_size() allocated
//assign() will always stop copying when reaching max_size()
assign(b.begin(), b.end());
if (collection_ != b)
{
//If the object is size limited, already has max_size() allocated
//assign() will always stop copying when reaching max_size()
assign(b.begin(), b.end());
hasChanged = true;
}
return *this;
}

Expand Down Expand Up @@ -1119,7 +1123,8 @@ class PartitionQosPolicy : public Parameter_t, public QosPolicy
PartitionQosPolicy& operator =(
const PartitionQosPolicy& b)
{
length = b.length;
QosPolicy::operator=(b);
Parameter_t::operator=(b);
max_size_ = b.max_size_;
partitions_.reserve(max_size_ != 0 ?
b.partitions_.max_size :
Expand Down
6 changes: 5 additions & 1 deletion test/mock/rtps/QosPolicies/fastrtps/qos/QosPolicies.h
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,11 @@ class UserDataQosPolicy : public Parameter_t, public QosPolicy, public ResourceL
UserDataQosPolicy& operator =(
const collection_type& b)
{
assign(b.begin(), b.end());
if (collection_ != b)
{
assign(b.begin(), b.end());
hasChanged = true;
}
return *this;
}

Expand Down

0 comments on commit 8e87789

Please sign in to comment.