Skip to content

Commit 49dcf5f

Browse files
authored
Merge pull request #93 from scharlton2/91-input-causes-crash
Fixed additional unchecked m_StructuredGrid calls
2 parents 9bb476f + dad55bf commit 49dcf5f

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

mv/mvModelFeatures.cpp

+7-6
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ static char THIS_FILE[] = __FILE__;
3232
mvModelFeatures::mvModelFeatures()
3333
{
3434
m_DisplayMode = MV_DISPLAY_MODEL_FEATURES_AS_CELLS;
35-
m_StructuredGrid = 0;
36-
m_UnstructuredGrid = 0;
35+
m_StructuredGrid = nullptr;
36+
m_UnstructuredGrid = nullptr;
3737
m_ThresholdCells = vtkSmartPointer<vtkThreshold>::New();
3838
m_ThresholdCells->SetInputData(m_StructuredGrid);
3939
#if ((VTK_MAJOR_VERSION == 9) && (VTK_MINOR_VERSION < 1) || (VTK_MAJOR_VERSION < 9))
@@ -269,7 +269,7 @@ void mvModelFeatures::Build()
269269
m_UnstructuredGrid->SetPoints(m_GridPoints);
270270
m_NumberOfCells = m_Cells->GetNumberOfCells();
271271
}
272-
else
272+
else if (m_StructuredGrid)
273273
{
274274
m_StructuredGrid->SetDimensions(m_Dim[0], m_Dim[1], m_Dim[2]);
275275
m_StructuredGrid->SetPoints(m_GridPoints);
@@ -291,7 +291,7 @@ void mvModelFeatures::Build()
291291
{
292292
m_UnstructuredGrid->GetCellData()->SetScalars(scalars);
293293
}
294-
else
294+
else if (m_StructuredGrid)
295295
{
296296
m_StructuredGrid->GetCellData()->SetScalars(scalars);
297297
}
@@ -595,15 +595,15 @@ void mvModelFeatures::SetCellArrayForUnstructuredGrid(vtkUnsignedCharArray *cell
595595

596596
void mvModelFeatures::SetGridTypeToStructuredGrid()
597597
{
598-
m_UnstructuredGrid = 0;
598+
m_UnstructuredGrid = nullptr;
599599
m_StructuredGrid = vtkSmartPointer<vtkStructuredGrid>::New();
600600
m_ThresholdCells->SetInputData(m_StructuredGrid);
601601
m_ThresholdCells->Modified();
602602
}
603603

604604
void mvModelFeatures::SetGridTypeToUnstructuredGrid()
605605
{
606-
m_StructuredGrid = 0;
606+
m_StructuredGrid = nullptr;
607607
m_UnstructuredGrid = vtkSmartPointer<vtkUnstructuredGrid>::New();
608608
m_ThresholdCells->SetInputData(m_UnstructuredGrid);
609609
m_ThresholdCells->Modified();
@@ -616,6 +616,7 @@ void mvModelFeatures::Update()
616616
}
617617
else
618618
{
619+
assert(m_DisplayMode == MV_DISPLAY_MODEL_FEATURES_AS_CELLS);
619620
if (m_UnstructuredGrid)
620621
{
621622
m_UnstructuredGrid->SetCells(m_CellTypes, m_CellLocations, m_Cells);

0 commit comments

Comments
 (0)