Commit 50583161 authored by Julien Finet's avatar Julien Finet
Browse files

Fix crash in transforms when doing DeepCopy after Identity

parent ab1d17f2
......@@ -20,12 +20,15 @@
// forward declare test subroutines
int testUseOfInverse();
int testConcatenationIdentity();
int TestTransform(int,char *[])
{
int numErrors = 0;
numErrors += testUseOfInverse();
numErrors += testConcatenationIdentity();
return (numErrors > 0) ? 1 : 0;
}
......@@ -74,3 +77,24 @@ int testUseOfInverse()
}
return 0;
}
// This is a regression test for a bug where th following code produced
// a segfault. As long as this code does not produce a segfault,
// consider it to have passed the test.
int testConcatenationIdentity()
{
vtkSmartPointer<vtkTransform> trans1 =
vtkSmartPointer<vtkTransform>::New();
// Add 2 transforms
trans1->Scale(2., 2., 2.);
trans1->Scale(2., 2., 2.);
trans1->Identity();
vtkSmartPointer<vtkTransform> trans2 =
vtkSmartPointer<vtkTransform>::New();
trans2->Scale(2., 2., 2.);
trans1->DeepCopy(trans2);
return 0;
}
......@@ -654,10 +654,12 @@ void vtkTransformConcatenation::Identity()
if (tuple->ForwardTransform)
{
tuple->ForwardTransform->Delete();
tuple->ForwardTransform = nullptr;
}
if (tuple->InverseTransform)
{
tuple->InverseTransform->Delete();
tuple->InverseTransform = nullptr;
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment