Salome HOME
Fix memory leaks
authorvsr <vsr@opencascade.com>
Mon, 21 Sep 2009 12:42:56 +0000 (12:42 +0000)
committervsr <vsr@opencascade.com>
Mon, 21 Sep 2009 12:42:56 +0000 (12:42 +0000)
src/MeasureGUI/MeasureGUI_AngleDlg.cxx
src/MeasureGUI/MeasureGUI_BndBoxDlg.cxx
src/MeasureGUI/MeasureGUI_CenterMassDlg.cxx
src/MeasureGUI/MeasureGUI_CheckCompoundOfBlocksDlg.cxx
src/MeasureGUI/MeasureGUI_CheckShapeDlg.cxx
src/MeasureGUI/MeasureGUI_DistanceDlg.cxx
src/MeasureGUI/MeasureGUI_InertiaDlg.cxx
src/MeasureGUI/MeasureGUI_MaxToleranceDlg.cxx
src/MeasureGUI/MeasureGUI_NormaleDlg.cxx
src/MeasureGUI/MeasureGUI_PropertiesDlg.cxx
src/MeasureGUI/MeasureGUI_WhatisDlg.cxx

index 6c6cff6482eae7a6ed1c0b55858107fa7df83039..a0843985e1d3901dab236d126d01c51a3e006ac6 100644 (file)
@@ -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()));
index a3d718caf04e012e06827f688769794c3a4ff916..b80633b4d62cf4b7ef97ce34cee56494283da0e9 100644 (file)
@@ -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();
   }
 }
 
index fe3a2c06fd0d3b0a973e4c92f6fe076d5b2d1f19..d09bf58ee3e693afdb7e59d757a562fb4552d5cf 100644 (file)
@@ -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() );
index 90c6adf71b23645e7d3bb11a70870df4a72615ed..11d0ab3e0f1772b64c24b39d3879c3cfa0095921 100644 (file)
@@ -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() );
index 9fd3c222843e10ade455649185ac54889334a3db..92e7e616c1b12a21d5ee28769135b0c0383fcba7 100644 (file)
@@ -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();
   }
 }
 
index a684ce804282220ef60c33962a5ad964273c1410..30613d7cd74ffdcf6c9579f715784e4dac0918b8 100644 (file)
@@ -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;
index 2ff5495be9fdc6db0c2dbb6b690a15adfb2e3b6e..228de1c5275f5602ce116724ad8cde3f473f5ea2 100644 (file)
@@ -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();
   }
 }
index 59630ab7dee82958c88d62266f22ac9125cfa59b..1b740627bb7f82e9c00aacf10e58ba727a67a5c9 100644 (file)
@@ -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();
   }
 }
index b5207d79085cad49da643ee102a14c75520f6407..e5afac75b6e6f9f0e85de2c21e89c3e0ec0b6dbd 100644 (file)
@@ -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());
index 7f45b5a802c1f2f629ccc0a3204a8cfa31320318..b92298f4dc6017ac75bf399d5e0eef7a5adc19fe 100644 (file)
@@ -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();
   }
 }
 
index 202b3faf31d69e43a1447a9e9a0f7d3ca0b7f39a..64faf036b3f8193b3f2f1751dcfb936b5377f91a 100644 (file)
@@ -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 ) )