From: eap Date: Mon, 10 Aug 2020 14:16:36 +0000 (+0300) Subject: Fix memory leaks in SMESHGUI_Displayer::canBeDisplayed() X-Git-Tag: V9_6_0a1~13 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=6c91402a6fe67b9c815fe64b9aee625dd21d0ef1;p=modules%2Fsmesh.git Fix memory leaks in SMESHGUI_Displayer::canBeDisplayed() --- diff --git a/src/SMESHGUI/SMESHGUI_Displayer.cxx b/src/SMESHGUI/SMESHGUI_Displayer.cxx index bfd048dc8..adeb2d736 100644 --- a/src/SMESHGUI/SMESHGUI_Displayer.cxx +++ b/src/SMESHGUI/SMESHGUI_Displayer.cxx @@ -89,7 +89,8 @@ SalomeApp_Study* SMESHGUI_Displayer::study() const return dynamic_cast( myApp->activeStudy() ); } -bool SMESHGUI_Displayer::canBeDisplayed( const QString& entry, const QString& viewer_type ) const { +bool SMESHGUI_Displayer::canBeDisplayed( const QString& entry, const QString& viewer_type ) const +{ bool res = false; if(viewer_type != SVTK_Viewer::Type()) return res; @@ -97,25 +98,18 @@ bool SMESHGUI_Displayer::canBeDisplayed( const QString& entry, const QString& vi _PTR(SObject) obj = SMESH::getStudy()->FindObjectID( (const char*)entry.toUtf8() ); CORBA::Object_var anObj = SMESH::SObjectToObject( obj ); - /* - if( !CORBA::is_nil( anObj ) ) { + if ( !CORBA::is_nil( anObj ) ) + { SMESH::SMESH_Mesh_var mesh = SMESH::SMESH_Mesh::_narrow( anObj ); - if ( ! mesh->_is_nil() ) - res = (mesh->NbNodes() > 0); - - SMESH::SMESH_subMesh_var aSubMeshObj = SMESH::SMESH_subMesh::_narrow( anObj ); - if ( !aSubMeshObj->_is_nil() ) - res = (aSubMeshObj->GetNumberOfNodes(true) > 0); - - SMESH::SMESH_GroupBase_var aGroupObj = SMESH::SMESH_GroupBase::_narrow( anObj ); - if ( !aGroupObj->_is_nil() ) - res = !aGroupObj->IsEmpty(); - }*/ - if( !CORBA::is_nil( anObj ) ) { - if(!SMESH::SMESH_Mesh::_narrow( anObj )->_is_nil() || - !SMESH::SMESH_subMesh::_narrow( anObj )->_is_nil() || - !SMESH::SMESH_GroupBase::_narrow( anObj )->_is_nil()) - res = true; + if ( ! ( res = !mesh->_is_nil() )) + { + SMESH::SMESH_subMesh_var aSubMeshObj = SMESH::SMESH_subMesh::_narrow( anObj ); + if ( ! ( res = !aSubMeshObj->_is_nil() )) + { + SMESH::SMESH_GroupBase_var aGroupObj = SMESH::SMESH_GroupBase::_narrow( anObj ); + res = !aGroupObj->_is_nil(); + } + } } return res; }