From: vsr Date: Mon, 21 Sep 2009 12:42:56 +0000 (+0000) Subject: Fix memory leaks X-Git-Tag: V5_1_3rc1~21 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=ee26d6488a70a00d2e1d9e069d6cef86dc078e98;p=modules%2Fgeom.git Fix memory leaks --- diff --git a/src/MeasureGUI/MeasureGUI_AngleDlg.cxx b/src/MeasureGUI/MeasureGUI_AngleDlg.cxx index 6c6cff648..a0843985e 100644 --- a/src/MeasureGUI/MeasureGUI_AngleDlg.cxx +++ b/src/MeasureGUI/MeasureGUI_AngleDlg.cxx @@ -215,17 +215,18 @@ bool MeasureGUI_AngleDlg::getParameters (double& theAngle) { QString msg; if (isValid(msg)) { + GEOM::GEOM_IMeasureOperations_var anOper = GEOM::GEOM_IMeasureOperations::_narrow( getOperation() ); try { - theAngle = GEOM::GEOM_IMeasureOperations::_narrow(getOperation())->GetAngle(myObj, myObj2); + theAngle = anOper->GetAngle(myObj, myObj2); } catch(const SALOME::SALOME_Exception& e) { SalomeApp_Tools::QtCatchCorbaException(e); return false; } - bool isDone = getOperation()->IsDone(); + bool isDone = anOper->IsDone(); if (!isDone) { - CORBA::String_var aMsg = getOperation()->GetErrorCode(); + CORBA::String_var aMsg = anOper->GetErrorCode(); SUIT_MessageBox::warning(this, QObject::tr("WRN_WARNING"), QObject::tr(aMsg.in())); diff --git a/src/MeasureGUI/MeasureGUI_BndBoxDlg.cxx b/src/MeasureGUI/MeasureGUI_BndBoxDlg.cxx index a3d718caf..b80633b4d 100644 --- a/src/MeasureGUI/MeasureGUI_BndBoxDlg.cxx +++ b/src/MeasureGUI/MeasureGUI_BndBoxDlg.cxx @@ -162,6 +162,7 @@ bool MeasureGUI_BndBoxDlg::getParameters( double& theXmin, double& theXmax, if ( myObj->_is_nil() ) return false; else { + GEOM::GEOM_IMeasureOperations_var anOper = GEOM::GEOM_IMeasureOperations::_narrow( getOperation() ); try { Handle(Poly_Triangulation) Trtn = 0; @@ -198,8 +199,7 @@ bool MeasureGUI_BndBoxDlg::getParameters( double& theXmin, double& theXmax, } } - GEOM::GEOM_IMeasureOperations::_narrow( getOperation() )->GetBoundingBox( - myObj, theXmin, theXmax, theYmin, theYmax, theZmin, theZmax ); + anOper->GetBoundingBox( myObj, theXmin, theXmax, theYmin, theYmax, theZmin, theZmax ); if (!Trtn.IsNull()) { @@ -227,7 +227,7 @@ bool MeasureGUI_BndBoxDlg::getParameters( double& theXmin, double& theXmax, return false; } - return getOperation()->IsDone(); + return anOper->IsDone(); } } diff --git a/src/MeasureGUI/MeasureGUI_CenterMassDlg.cxx b/src/MeasureGUI/MeasureGUI_CenterMassDlg.cxx index fe3a2c06f..d09bf58ee 100644 --- a/src/MeasureGUI/MeasureGUI_CenterMassDlg.cxx +++ b/src/MeasureGUI/MeasureGUI_CenterMassDlg.cxx @@ -290,9 +290,9 @@ bool MeasureGUI_CenterMassDlg::getParameters( double& theX, double& theY, double return false; else { try { - GEOM::GEOM_Object_var anObj; - anObj = GEOM::GEOM_IMeasureOperations::_narrow( getOperation() )->GetCentreOfMass( myObj ); - if ( !getOperation()->IsDone() ) + GEOM::GEOM_IMeasureOperations_var anOper = GEOM::GEOM_IMeasureOperations::_narrow( getOperation() ); + GEOM::GEOM_Object_var anObj = anOper->GetCentreOfMass( myObj ); + if ( !anOper->IsDone() ) return false; TopoDS_Shape aShape; @@ -324,9 +324,8 @@ bool MeasureGUI_CenterMassDlg::getParameters( double& theX, double& theY, double //================================================================================= bool MeasureGUI_CenterMassDlg::execute( ObjectList& objects ) { - GEOM::GEOM_Object_var anObj; - - anObj = GEOM::GEOM_IMeasureOperations::_narrow( getOperation() )->GetCentreOfMass( myObj ); + GEOM::GEOM_IMeasureOperations_var anOper = GEOM::GEOM_IMeasureOperations::_narrow( getOperation() ); + GEOM::GEOM_Object_var anObj = anOper->GetCentreOfMass( myObj ); if ( !anObj->_is_nil() ) objects.push_back( anObj._retn() ); diff --git a/src/MeasureGUI/MeasureGUI_CheckCompoundOfBlocksDlg.cxx b/src/MeasureGUI/MeasureGUI_CheckCompoundOfBlocksDlg.cxx index 90c6adf71..11d0ab3e0 100644 --- a/src/MeasureGUI/MeasureGUI_CheckCompoundOfBlocksDlg.cxx +++ b/src/MeasureGUI/MeasureGUI_CheckCompoundOfBlocksDlg.cxx @@ -241,10 +241,10 @@ bool MeasureGUI_CheckCompoundOfBlocksDlg::getBCErrors( bool& theIsCompoundOfBloc if ( myObj->_is_nil() ) return false; else { + GEOM::GEOM_IBlocksOperations_var anOper = GEOM::GEOM_IBlocksOperations::_narrow( getOperation() ); try { GEOM::GEOM_IBlocksOperations::BCErrors_var aErrs; - theIsCompoundOfBlocks = - GEOM::GEOM_IBlocksOperations::_narrow( getOperation() )->CheckCompoundOfBlocks( myObj, aErrs ); + theIsCompoundOfBlocks = anOper->CheckCompoundOfBlocks( myObj, aErrs ); theErrors = aErrs; } catch ( const SALOME::SALOME_Exception& e ) { @@ -252,7 +252,7 @@ bool MeasureGUI_CheckCompoundOfBlocksDlg::getBCErrors( bool& theIsCompoundOfBloc return false; } - return getOperation()->IsDone(); + return anOper->IsDone(); } } @@ -472,9 +472,8 @@ bool MeasureGUI_CheckCompoundOfBlocksDlg::isValid( QString& ) //================================================================================= bool MeasureGUI_CheckCompoundOfBlocksDlg::execute( ObjectList& objects ) { - GEOM::GEOM_Object_var anObj; - - anObj = GEOM::GEOM_IBlocksOperations::_narrow( getOperation() )->CheckAndImprove( myObj ); + GEOM::GEOM_IBlocksOperations_var anOper = GEOM::GEOM_IBlocksOperations::_narrow( getOperation() ); + GEOM::GEOM_Object_var anObj = anOper->CheckAndImprove( myObj ); if ( !anObj->_is_nil() ) objects.push_back( anObj._retn() ); diff --git a/src/MeasureGUI/MeasureGUI_CheckShapeDlg.cxx b/src/MeasureGUI/MeasureGUI_CheckShapeDlg.cxx index 9fd3c2228..92e7e616c 100644 --- a/src/MeasureGUI/MeasureGUI_CheckShapeDlg.cxx +++ b/src/MeasureGUI/MeasureGUI_CheckShapeDlg.cxx @@ -110,15 +110,14 @@ bool MeasureGUI_CheckShapeDlg::getParameters ( bool& theIsValid, QString& theMsg if ( myObj->_is_nil() ) return false; else { + GEOM::GEOM_IMeasureOperations_var anOper = GEOM::GEOM_IMeasureOperations::_narrow( getOperation() ); try { char* aMsg; bool isCheckGeometry = myGrp->CheckBox1->isChecked(); - GEOM::GEOM_IMeasureOperations_ptr aMeasureOp = - GEOM::GEOM_IMeasureOperations::_narrow( getOperation() ); if ( isCheckGeometry ) - theIsValid = aMeasureOp->CheckShapeWithGeometry( myObj, aMsg ); + theIsValid = anOper->CheckShapeWithGeometry( myObj, aMsg ); else - theIsValid = aMeasureOp->CheckShape( myObj, aMsg ); + theIsValid = anOper->CheckShape( myObj, aMsg ); theMsg = aMsg; } catch( const SALOME::SALOME_Exception& e ) { @@ -126,7 +125,7 @@ bool MeasureGUI_CheckShapeDlg::getParameters ( bool& theIsValid, QString& theMsg return false; } - return getOperation()->IsDone(); + return anOper->IsDone(); } } diff --git a/src/MeasureGUI/MeasureGUI_DistanceDlg.cxx b/src/MeasureGUI/MeasureGUI_DistanceDlg.cxx index a684ce804..30613d7cd 100644 --- a/src/MeasureGUI/MeasureGUI_DistanceDlg.cxx +++ b/src/MeasureGUI/MeasureGUI_DistanceDlg.cxx @@ -207,10 +207,11 @@ bool MeasureGUI_DistanceDlg::getParameters (double& theDistance, { QString msg; if (isValid(msg)) { + GEOM::GEOM_IMeasureOperations_var anOper = GEOM::GEOM_IMeasureOperations::_narrow( getOperation() ); + try { double x1, y1, z1, x2, y2, z2; - theDistance = GEOM::GEOM_IMeasureOperations::_narrow(getOperation())-> - GetMinDistance(myObj, myObj2, x1, y1, z1, x2, y2, z2); + theDistance = anOper->GetMinDistance(myObj, myObj2, x1, y1, z1, x2, y2, z2); thePnt1.SetCoord(x1, y1, z1); thePnt2.SetCoord(x2, y2, z2); @@ -220,7 +221,7 @@ bool MeasureGUI_DistanceDlg::getParameters (double& theDistance, return false; } - return getOperation()->IsDone(); + return anOper->IsDone(); } return false; diff --git a/src/MeasureGUI/MeasureGUI_InertiaDlg.cxx b/src/MeasureGUI/MeasureGUI_InertiaDlg.cxx index 2ff5495be..228de1c52 100644 --- a/src/MeasureGUI/MeasureGUI_InertiaDlg.cxx +++ b/src/MeasureGUI/MeasureGUI_InertiaDlg.cxx @@ -169,13 +169,14 @@ bool MeasureGUI_InertiaDlg::getParameters( gp_Mat& I, if ( myObj->_is_nil() ) return false; else { + GEOM::GEOM_IMeasureOperations_var anOper = GEOM::GEOM_IMeasureOperations::_narrow( getOperation() ); try { double x, y, z; - GEOM::GEOM_IMeasureOperations::_narrow( getOperation() )->GetInertia( myObj, - I( 1, 1 ), I( 1, 2 ), I( 1, 3 ), - I( 2, 1 ), I( 2, 2 ), I( 2, 3 ), - I( 3, 1 ), I( 3, 2 ), I( 3, 3 ), - x, y, z ); + anOper->GetInertia( myObj, + I( 1, 1 ), I( 1, 2 ), I( 1, 3 ), + I( 2, 1 ), I( 2, 2 ), I( 2, 3 ), + I( 3, 1 ), I( 3, 2 ), I( 3, 3 ), + x, y, z ); theIXYZ.SetCoord( x, y, z ); } @@ -184,6 +185,6 @@ bool MeasureGUI_InertiaDlg::getParameters( gp_Mat& I, return false; } - return getOperation()->IsDone(); + return anOper->IsDone(); } } diff --git a/src/MeasureGUI/MeasureGUI_MaxToleranceDlg.cxx b/src/MeasureGUI/MeasureGUI_MaxToleranceDlg.cxx index 59630ab7d..1b740627b 100644 --- a/src/MeasureGUI/MeasureGUI_MaxToleranceDlg.cxx +++ b/src/MeasureGUI/MeasureGUI_MaxToleranceDlg.cxx @@ -156,16 +156,17 @@ bool MeasureGUI_MaxToleranceDlg::getParameters( double& theMinFaceToler, if ( myObj->_is_nil() ) return false; else { + GEOM::GEOM_IMeasureOperations_var anOper = GEOM::GEOM_IMeasureOperations::_narrow( getOperation() ); try { - GEOM::GEOM_IMeasureOperations::_narrow( getOperation() )->GetTolerance( myObj, - theMinFaceToler, theMaxFaceToler, theMinEdgeToler, - theMaxEdgeToler, theMinVertexToler, theMaxVertexToler ); + anOper->GetTolerance( myObj, + theMinFaceToler, theMaxFaceToler, theMinEdgeToler, + theMaxEdgeToler, theMinVertexToler, theMaxVertexToler ); } catch( const SALOME::SALOME_Exception& e ) { SalomeApp_Tools::QtCatchCorbaException( e ); return false; } - return getOperation()->IsDone(); + return anOper->IsDone(); } } diff --git a/src/MeasureGUI/MeasureGUI_NormaleDlg.cxx b/src/MeasureGUI/MeasureGUI_NormaleDlg.cxx index b5207d790..e5afac75b 100644 --- a/src/MeasureGUI/MeasureGUI_NormaleDlg.cxx +++ b/src/MeasureGUI/MeasureGUI_NormaleDlg.cxx @@ -354,8 +354,8 @@ bool MeasureGUI_NormaleDlg::isValid (QString&) //================================================================================= bool MeasureGUI_NormaleDlg::execute (ObjectList& objects) { - GEOM::GEOM_Object_var anObj = - GEOM::GEOM_IMeasureOperations::_narrow(getOperation())->GetNormal(myFace, myPoint); + GEOM::GEOM_IMeasureOperations_var anOper = GEOM::GEOM_IMeasureOperations::_narrow( getOperation() ); + GEOM::GEOM_Object_var anObj = anOper->GetNormal(myFace, myPoint); if (!anObj->_is_nil()) objects.push_back(anObj._retn()); diff --git a/src/MeasureGUI/MeasureGUI_PropertiesDlg.cxx b/src/MeasureGUI/MeasureGUI_PropertiesDlg.cxx index 7f45b5a80..b92298f4d 100644 --- a/src/MeasureGUI/MeasureGUI_PropertiesDlg.cxx +++ b/src/MeasureGUI/MeasureGUI_PropertiesDlg.cxx @@ -155,16 +155,16 @@ bool MeasureGUI_PropertiesDlg::getParameters( double& theLength, if ( myObj->_is_nil() ) return false; else { + GEOM::GEOM_IMeasureOperations_var anOper = GEOM::GEOM_IMeasureOperations::_narrow( getOperation() ); try { - GEOM::GEOM_IMeasureOperations::_narrow( getOperation() )->GetBasicProperties( - myObj, theLength, theArea, theVolume ); + anOper->GetBasicProperties( myObj, theLength, theArea, theVolume ); } catch( const SALOME::SALOME_Exception& e ) { SalomeApp_Tools::QtCatchCorbaException( e ); return false; } - return getOperation()->IsDone(); + return anOper->IsDone(); } } diff --git a/src/MeasureGUI/MeasureGUI_WhatisDlg.cxx b/src/MeasureGUI/MeasureGUI_WhatisDlg.cxx index 202b3faf3..64faf036b 100644 --- a/src/MeasureGUI/MeasureGUI_WhatisDlg.cxx +++ b/src/MeasureGUI/MeasureGUI_WhatisDlg.cxx @@ -208,9 +208,10 @@ bool MeasureGUI_WhatisDlg::getParameters( QString& theText ) if ( myObj->_is_nil() ) return false; + GEOM::GEOM_IMeasureOperations_var anOper = GEOM::GEOM_IMeasureOperations::_narrow( getOperation() ); try { - theText = GEOM::GEOM_IMeasureOperations::_narrow( getOperation() )->WhatIs( myObj ); + theText = anOper->WhatIs( myObj ); } catch( const SALOME::SALOME_Exception& e ) { @@ -218,7 +219,7 @@ bool MeasureGUI_WhatisDlg::getParameters( QString& theText ) return false; } - return getOperation()->IsDone(); + return anOper->IsDone(); } //================================================================================= @@ -237,18 +238,18 @@ QString MeasureGUI_WhatisDlg::getKindOfShape( QString& theParameters ) GEOM::ListOfLong_var anInts; GEOM::ListOfDouble_var aDbls; - GEOM::GEOM_IMeasureOperations_var anOp = GEOM::GEOM_IMeasureOperations::_narrow( getOperation() ); + GEOM::GEOM_IMeasureOperations_var anOper = GEOM::GEOM_IMeasureOperations::_narrow( getOperation() ); try { - aKind = anOp->KindOfShape( myObj, anInts, aDbls ); + aKind = anOper->KindOfShape( myObj, anInts, aDbls ); } catch( const SALOME::SALOME_Exception& e ) { SalomeApp_Tools::QtCatchCorbaException( e ); return aKindStr; } - if ( !anOp->IsDone() ) + if ( !anOper->IsDone() ) return aKindStr; #define PRINT_DOUBLE(val) QString(" %1").arg( DlgRef::PrintDoubleValue( val ) )