Commit c44bf3a0 authored by Pavel Pokutnev's avatar Pavel Pokutnev Committed by Dave DeMarle
Browse files

Fix for MFC compatibility issue with bad_alloc

To be able to catch allocation failures, when VTK is running in the context of other framework (e.g. MFC), we should use (...) in the catch handler instead of std::bad_alloc. If hosting framework implements its own operator new, it's possible that it will throw own defined exception and not the standard std::bad_alloc! In the case of MFC this is CMemoryException, so it would not be handled correctly and crash.

BUG ID 0013018: http://vtk.org/Bug/view.php?id=13018

Change-Id: Ic47b1666116a4299d85e9b86a5d1b13a72822a94
parent 8b3d93bf
......@@ -2846,11 +2846,17 @@ void vtkFixedPointVolumeRayCastMapper::ComputeGradients( vtkVolume *vol )
// first, attempt contiguous memory. If this fails, then go
// for non-contiguous
// NOTE: To be able to catch allocation failures, when VTK is running in the
// context of other framework (e.g. MFC), we should use (...) in the
// catch handler instead of std::bad_alloc. If hosting framework implements
// its own operator new, it's possible that it will throw own defined exception
// and not the standard std::bad_alloc! In the case of MFC this is CMemoryException,
// so it would not be handled correctly and crash.
try
{
this->ContiguousGradientNormal = new unsigned short [numSlices * sliceSize];
}
catch(std::bad_alloc &)
catch(...)
{
this->ContiguousGradientNormal = NULL;
}
......@@ -2858,7 +2864,7 @@ void vtkFixedPointVolumeRayCastMapper::ComputeGradients( vtkVolume *vol )
{
this->ContiguousGradientMagnitude = new unsigned char [numSlices * sliceSize];
}
catch(std::bad_alloc &)
catch(...)
{
this->ContiguousGradientMagnitude = NULL;
}
......
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