From 779adc8fa5c4c44afca872293be805d4963981dd Mon Sep 17 00:00:00 2001 From: gdd Date: Fri, 10 Aug 2012 14:01:12 +0000 Subject: [PATCH] Fix crash during preview --- src/SMESH_I/SMESH_MeshEditor_i.cxx | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/SMESH_I/SMESH_MeshEditor_i.cxx b/src/SMESH_I/SMESH_MeshEditor_i.cxx index 026eed079..4ff0529dd 100644 --- a/src/SMESH_I/SMESH_MeshEditor_i.cxx +++ b/src/SMESH_I/SMESH_MeshEditor_i.cxx @@ -464,21 +464,25 @@ SMESH::MeshPreviewStruct* SMESH_MeshEditor_i::GetPreviewData() typedef map TNodesMap; TNodesMap nodesMap; - TPreviewMesh * aPreviewMesh = dynamic_cast< TPreviewMesh* >( myEditor.GetMesh() ); - SMDSAbs_ElementType previewType = aPreviewMesh->myPreviewType; - SMESHDS_Mesh* aMeshDS = myEditor.GetMeshDS(); int nbEdges = aMeshDS->NbEdges(); int nbFaces = aMeshDS->NbFaces(); int nbVolum = aMeshDS->NbVolumes(); - switch ( previewType ) { - case SMDSAbs_Edge : nbFaces = nbVolum = 0; break; - case SMDSAbs_Face : nbEdges = nbVolum = 0; break; - case SMDSAbs_Volume: nbEdges = nbFaces = 0; break; - default:; - } myPreviewData = new SMESH::MeshPreviewStruct(); myPreviewData->nodesXYZ.length(aMeshDS->NbNodes()); + + TPreviewMesh * aPreviewMesh = dynamic_cast< TPreviewMesh* >( myEditor.GetMesh() ); + SMDSAbs_ElementType previewType = SMDSAbs_All; + if (aPreviewMesh) { + previewType = aPreviewMesh->myPreviewType; + switch ( previewType ) { + case SMDSAbs_Edge : nbFaces = nbVolum = 0; break; + case SMDSAbs_Face : nbEdges = nbVolum = 0; break; + case SMDSAbs_Volume: nbEdges = nbFaces = 0; break; + default:; + } + } + myPreviewData->elementTypes.length(nbEdges + nbFaces + nbVolum); int i = 0, j = 0; SMDS_ElemIteratorPtr itMeshElems = aMeshDS->elementsIterator(); -- 2.39.2