From ba2aa33a1e0c3daad79f130a20bae22942fd0239 Mon Sep 17 00:00:00 2001 From: vsr Date: Mon, 21 Sep 2009 12:21:38 +0000 Subject: [PATCH] Fix memory leaks --- src/BlocksGUI/BlocksGUI_BlockDlg.cxx | 8 ++++---- src/BlocksGUI/BlocksGUI_ExplodeDlg.cxx | 23 ++++++++++++----------- src/BlocksGUI/BlocksGUI_PropagateDlg.cxx | 3 ++- src/BlocksGUI/BlocksGUI_QuadFaceDlg.cxx | 11 +++++------ src/BlocksGUI/BlocksGUI_TrsfDlg.cxx | 24 ++++++++++++------------ src/BooleanGUI/BooleanGUI_Dialog.cxx | 4 ++-- 6 files changed, 37 insertions(+), 36 deletions(-) diff --git a/src/BlocksGUI/BlocksGUI_BlockDlg.cxx b/src/BlocksGUI/BlocksGUI_BlockDlg.cxx index 5ebb5f4ce..715bc222c 100644 --- a/src/BlocksGUI/BlocksGUI_BlockDlg.cxx +++ b/src/BlocksGUI/BlocksGUI_BlockDlg.cxx @@ -477,11 +477,12 @@ bool BlocksGUI_BlockDlg::execute (ObjectList& objects) GEOM::GEOM_Object_var anObj; + GEOM::GEOM_IBlocksOperations_var anOper = GEOM::GEOM_IBlocksOperations::_narrow(getOperation()); + switch (getConstructorId()) { case 0: if (!CORBA::is_nil(myFace1) && !CORBA::is_nil(myFace2)) { - anObj = GEOM::GEOM_IBlocksOperations::_narrow(getOperation())-> - MakeHexa2Faces(myFace1, myFace2); + anObj = anOper->MakeHexa2Faces(myFace1, myFace2); res = true; } break; @@ -489,8 +490,7 @@ bool BlocksGUI_BlockDlg::execute (ObjectList& objects) if (!CORBA::is_nil(myFace1) && !CORBA::is_nil(myFace2) && !CORBA::is_nil(myFace3) && !CORBA::is_nil(myFace4) && !CORBA::is_nil(myFace5) && !CORBA::is_nil(myFace6)) { - anObj = GEOM::GEOM_IBlocksOperations::_narrow(getOperation())-> - MakeHexa(myFace1, myFace2, myFace3, myFace4, myFace5, myFace6); + anObj = anOper->MakeHexa(myFace1, myFace2, myFace3, myFace4, myFace5, myFace6); res = true; } break; diff --git a/src/BlocksGUI/BlocksGUI_ExplodeDlg.cxx b/src/BlocksGUI/BlocksGUI_ExplodeDlg.cxx index 8dcbdbbeb..6db2e767a 100644 --- a/src/BlocksGUI/BlocksGUI_ExplodeDlg.cxx +++ b/src/BlocksGUI/BlocksGUI_ExplodeDlg.cxx @@ -332,11 +332,11 @@ void BlocksGUI_ExplodeDlg::updateButtonState() myGrp1->TextBrowser1->setText( "" ); } else { - bool isOnlyBlocks = GEOM::GEOM_IBlocksOperations::_narrow - ( getOperation() )->IsCompoundOfBlocks( myObject, - myGrp1->SpinBox1->value(), - myGrp1->SpinBox2->value(), - myNbBlocks ); + GEOM::GEOM_IBlocksOperations_var anOper = GEOM::GEOM_IBlocksOperations::_narrow(getOperation()); + bool isOnlyBlocks = anOper->IsCompoundOfBlocks( myObject, + myGrp1->SpinBox1->value(), + myGrp1->SpinBox2->value(), + myNbBlocks ); if ( isOnlyBlocks ) myGrp1->TextBrowser1->setText( tr( "GEOM_NB_BLOCKS_NO_OTHERS" ).arg( myNbBlocks ) ); else @@ -401,12 +401,13 @@ bool BlocksGUI_ExplodeDlg::execute( ObjectList& objects ) { GEOM::ListOfGO_var aList; + GEOM::GEOM_IBlocksOperations_var anOper = GEOM::GEOM_IBlocksOperations::_narrow(getOperation()); + switch ( getConstructorId() ) { case 0: - aList = GEOM::GEOM_IBlocksOperations::_narrow( getOperation() )->ExplodeCompoundOfBlocks - ( myObject, - myGrp1->SpinBox1->value(), - myGrp1->SpinBox2->value() ); + aList = anOper->ExplodeCompoundOfBlocks( myObject, + myGrp1->SpinBox1->value(), + myGrp1->SpinBox2->value() ); break; } @@ -452,7 +453,7 @@ bool BlocksGUI_ExplodeDlg::execute( ObjectList& objects ) if ( selected.contains( QString( objStr.in() ) ) ) { if ( !IsPreview() ) - (*anIter)->SetParameters(GeometryGUI::JoinObjectParameters(aParameters)); + (*anIter)->SetParameters(aParameters.join(":").toLatin1().constData()); objects.push_back( *anIter ); } else @@ -472,7 +473,7 @@ bool BlocksGUI_ExplodeDlg::execute( ObjectList& objects ) { GEOM::GEOM_Object_var anObj = GEOM::GEOM_Object::_duplicate( aList[i] ); if ( !IsPreview() ) - anObj->SetParameters(GeometryGUI::JoinObjectParameters(aParameters)); + anObj->SetParameters(aParameters.join(":").toLatin1().constData()); objects.push_back( anObj._retn() ); } } diff --git a/src/BlocksGUI/BlocksGUI_PropagateDlg.cxx b/src/BlocksGUI/BlocksGUI_PropagateDlg.cxx index 07801d8a1..83989caa9 100644 --- a/src/BlocksGUI/BlocksGUI_PropagateDlg.cxx +++ b/src/BlocksGUI/BlocksGUI_PropagateDlg.cxx @@ -239,7 +239,8 @@ bool BlocksGUI_PropagateDlg::isValid( QString& ) //================================================================================= bool BlocksGUI_PropagateDlg::execute( ObjectList& objects ) { - GEOM::ListOfGO_var aList = GEOM::GEOM_IBlocksOperations::_narrow( getOperation() )->Propagate( myObject ); + GEOM::GEOM_IBlocksOperations_var anOper = GEOM::GEOM_IBlocksOperations::_narrow(getOperation()); + GEOM::ListOfGO_var aList = anOper->Propagate( myObject ); mainFrame()->ResultName->setText( "" ); if ( !aList->length() ) diff --git a/src/BlocksGUI/BlocksGUI_QuadFaceDlg.cxx b/src/BlocksGUI/BlocksGUI_QuadFaceDlg.cxx index 930af1c45..fd32bbbd8 100644 --- a/src/BlocksGUI/BlocksGUI_QuadFaceDlg.cxx +++ b/src/BlocksGUI/BlocksGUI_QuadFaceDlg.cxx @@ -532,20 +532,19 @@ bool BlocksGUI_QuadFaceDlg::execute (ObjectList& objects) GEOM::GEOM_Object_var anObj; + GEOM::GEOM_IBlocksOperations_var anOper = GEOM::GEOM_IBlocksOperations::_narrow(getOperation()); + switch (getConstructorId()) { case 0: - anObj = GEOM::GEOM_IBlocksOperations::_narrow(getOperation())-> - MakeQuad4Vertices(myShape1, myShape2, myShape3, myShape4); + anObj = anOper->MakeQuad4Vertices(myShape1, myShape2, myShape3, myShape4); res = true; break; case 1: - anObj = GEOM::GEOM_IBlocksOperations::_narrow(getOperation())-> - MakeQuad2Edges(myShape1, myShape2); + anObj = anOper->MakeQuad2Edges(myShape1, myShape2); res = true; break; case 2: - anObj = GEOM::GEOM_IBlocksOperations::_narrow(getOperation())-> - MakeQuad(myShape1, myShape2, myShape3, myShape4); + anObj = anOper->MakeQuad(myShape1, myShape2, myShape3, myShape4); res = true; break; default: diff --git a/src/BlocksGUI/BlocksGUI_TrsfDlg.cxx b/src/BlocksGUI/BlocksGUI_TrsfDlg.cxx index 9508f69e9..b5d681c4e 100644 --- a/src/BlocksGUI/BlocksGUI_TrsfDlg.cxx +++ b/src/BlocksGUI/BlocksGUI_TrsfDlg.cxx @@ -576,28 +576,28 @@ bool BlocksGUI_TrsfDlg::execute (ObjectList& objects) GEOM::GEOM_Object_var anObj; + GEOM::GEOM_IBlocksOperations_var anOper = GEOM::GEOM_IBlocksOperations::_narrow(getOperation()); + switch (getConstructorId()) { case 0: - anObj = GEOM::GEOM_IBlocksOperations::_narrow(getOperation())-> - MakeMultiTransformation1D(myShape, - myFaces[Face1], myFaces[Face2], - mySpinBox[SpinBox1]->value()); + anObj = anOper->MakeMultiTransformation1D(myShape, + myFaces[Face1], myFaces[Face2], + mySpinBox[SpinBox1]->value()); if (!anObj->_is_nil() && !IsPreview()) { QStringList aParameters; aParameters << "" << ""; aParameters << mySpinBox[SpinBox1]->text(); - anObj->SetParameters(GeometryGUI::JoinObjectParameters(aParameters)); + anObj->SetParameters(aParameters.join(":").toLatin1().constData()); } res = true; break; case 1: - anObj = GEOM::GEOM_IBlocksOperations::_narrow(getOperation())-> - MakeMultiTransformation2D (myShape, - myFaces[Face1U], myFaces[Face2U], - mySpinBox[SpinBox2U]->value(), - myFaces[Face1V], myFaces[Face2V], - mySpinBox[SpinBox2V]->value()); + anObj = anOper->MakeMultiTransformation2D (myShape, + myFaces[Face1U], myFaces[Face2U], + mySpinBox[SpinBox2U]->value(), + myFaces[Face1V], myFaces[Face2V], + mySpinBox[SpinBox2V]->value()); if (!anObj->_is_nil() && !IsPreview()) { QStringList aParameters; @@ -605,7 +605,7 @@ bool BlocksGUI_TrsfDlg::execute (ObjectList& objects) aParameters << mySpinBox[SpinBox2U]->text(); aParameters << "" << ""; aParameters << mySpinBox[SpinBox2V]->text(); - anObj->SetParameters(GeometryGUI::JoinObjectParameters(aParameters)); + anObj->SetParameters(aParameters.join(":").toLatin1().constData()); } res = true; break; diff --git a/src/BooleanGUI/BooleanGUI_Dialog.cxx b/src/BooleanGUI/BooleanGUI_Dialog.cxx index 7b1e3df5a..6f4ca138b 100644 --- a/src/BooleanGUI/BooleanGUI_Dialog.cxx +++ b/src/BooleanGUI/BooleanGUI_Dialog.cxx @@ -329,8 +329,8 @@ bool BooleanGUI_Dialog::execute (ObjectList& objects) { GEOM::GEOM_Object_var anObj; - anObj = GEOM::GEOM_IBooleanOperations::_narrow(getOperation())-> - MakeBoolean(myObject1, myObject2, myOperation); + GEOM::GEOM_IBooleanOperations_var anOper = GEOM::GEOM_IBooleanOperations::_narrow(getOperation()); + anObj = anOper->MakeBoolean(myObject1, myObject2, myOperation); if (!anObj->_is_nil()) objects.push_back(anObj._retn()); -- 2.39.2