Ticket #10178 (closed: fixed)
Geometry::Object copy constructor and assignment operator don't copy handlers correctly
Reported by: | Martyn Gigg | Owned by: | Martyn Gigg |
---|---|---|---|
Priority: | critical | Milestone: | Release 3.3 |
Component: | Framework | Keywords: | |
Cc: | Blocked By: | ||
Blocking: | #10169 | Tester: |
Description
There is also no unit test for this behaviour. This snippet of code will fail with the current HEAD
void testCopyConstructorGivesObjectWithSameAttributes() { Object_sptr original = ComponentCreationHelper::createSphere(1.0, V3D(), "sphere"); int objType(-1); double radius(-1.0), height(-1.0); std::vector<V3D> pts; original->GetObjectGeom(objType, pts, radius, height); TS_ASSERT_EQUALS(2, objType); TS_ASSERT(boost::dynamic_pointer_cast<GluGeometryHandler>(original->getGeometryHandler())); Object copy(*original); // The copy should be a primitive object with a GluGeometryHandler objType = -1; copy.GetObjectGeom(objType, pts, radius, height); TS_ASSERT_EQUALS(2, objType); TS_ASSERT(boost::dynamic_pointer_cast<GluGeometryHandler>(copy.getGeometryHandler())); } void testAssignmentOperatorGivesObjectWithSameAttributes() { Object_sptr original = ComponentCreationHelper::createSphere(1.0, V3D(), "sphere"); int objType(-1); double radius(-1.0), height(-1.0); std::vector<V3D> pts; original->GetObjectGeom(objType, pts, radius, height); TS_ASSERT_EQUALS(2, objType); TS_ASSERT(boost::dynamic_pointer_cast<GluGeometryHandler>(original->getGeometryHandler())); Object lhs; // initialize lhs = *original; // assign // The copy should be a primitive object with a GluGeometryHandler objType = -1; lhs.GetObjectGeom(objType, pts, radius, height); TS_ASSERT_EQUALS(2, objType); TS_ASSERT(boost::dynamic_pointer_cast<GluGeometryHandler>(lhs.getGeometryHandler())); }
Change History
comment:2 Changed 6 years ago by Martyn Gigg
- Status changed from assigned to inprogress
Implement a virtual clone method for geometry handlers
This provides a simple mechanism for copying the objects when their type is not available. Refs #10178
Changeset: 60afab6869e81aa37f30742c5b1b1d860125c0bd
comment:3 Changed 6 years ago by Martyn Gigg
Use handler::clone method in Object copy and assignment.
The new object now retains the same handler properties as the original. Refs #10178
Changeset: d1085a4b203ad20bf76509abccddc3112328a547
comment:4 Changed 6 years ago by Martyn Gigg
Implement unit tests for Object copy and assignment.
Refs #10178
Changeset: bfc044956b8abfc1e9278cd0c1dfb32814e4e0b3
comment:5 Changed 6 years ago by Martyn Gigg
Branch: bugfix/10178_geometry_object_copy_and_assign
Tester: This will have to be code reviewed really as the code is not accessible from anywhere but the unit tests. Check they are passing and look sensible.
comment:6 Changed 6 years ago by Martyn Gigg
- Status changed from inprogress to verify
- Resolution set to fixed
comment:7 Changed 6 years ago by Roman Tolchenov
- Status changed from verify to closed
Merge remote-tracking branch 'origin/bugfix/10178_geometry_object_copy_and_assign'
Full changeset: 0e765f8eb69a9a17dfdd93826c0cfead651aa7e6