From d068bb8b4634a97ffbf89dffc204371409245e27 Mon Sep 17 00:00:00 2001 From: vsr Date: Mon, 21 Sep 2009 12:54:44 +0000 Subject: [PATCH] Fix memory leaks --- .../TransformationGUI_MirrorDlg.cxx | 20 +++++-------- .../TransformationGUI_MultiRotationDlg.cxx | 10 +++---- .../TransformationGUI_MultiTranslationDlg.cxx | 13 +++++---- .../TransformationGUI_OffsetDlg.cxx | 6 ++-- .../TransformationGUI_PositionDlg.cxx | 22 ++++++-------- .../TransformationGUI_RotationDlg.cxx | 18 +++++------- .../TransformationGUI_ScaleDlg.cxx | 20 ++++++------- .../TransformationGUI_TranslationDlg.cxx | 29 ++++++++----------- 8 files changed, 62 insertions(+), 76 deletions(-) diff --git a/src/TransformationGUI/TransformationGUI_MirrorDlg.cxx b/src/TransformationGUI/TransformationGUI_MirrorDlg.cxx index 772755da5..2e4b06310 100644 --- a/src/TransformationGUI/TransformationGUI_MirrorDlg.cxx +++ b/src/TransformationGUI/TransformationGUI_MirrorDlg.cxx @@ -411,21 +411,21 @@ bool TransformationGUI_MirrorDlg::execute (ObjectList& objects) GEOM::GEOM_Object_var anObj; + GEOM::GEOM_ITransformOperations_var anOper = GEOM::GEOM_ITransformOperations::_narrow(getOperation()); + switch (getConstructorId()) { case 0: { if (toCreateCopy) { for (int i = 0; i < myObjects.length(); i++) { - anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())-> - MirrorPointCopy(myObjects[i], myArgument); + anObj = anOper->MirrorPointCopy(myObjects[i], myArgument); if (!anObj->_is_nil()) objects.push_back(anObj._retn()); } } else { for (int i = 0; i < myObjects.length(); i++) { - anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())-> - MirrorPoint(myObjects[i], myArgument); + anObj = anOper->MirrorPoint(myObjects[i], myArgument); if (!anObj->_is_nil()) objects.push_back(anObj._retn()); } @@ -437,16 +437,14 @@ bool TransformationGUI_MirrorDlg::execute (ObjectList& objects) { if (toCreateCopy) { for (int i = 0; i < myObjects.length(); i++) { - anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())-> - MirrorAxisCopy(myObjects[i], myArgument); + anObj = anOper->MirrorAxisCopy(myObjects[i], myArgument); if (!anObj->_is_nil()) objects.push_back(anObj._retn()); } } else { for (int i = 0; i < myObjects.length(); i++) { - anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())-> - MirrorAxis(myObjects[i], myArgument); + anObj = anOper->MirrorAxis(myObjects[i], myArgument); if (!anObj->_is_nil()) objects.push_back(anObj._retn()); } @@ -458,16 +456,14 @@ bool TransformationGUI_MirrorDlg::execute (ObjectList& objects) { if (toCreateCopy) { for (int i = 0; i < myObjects.length(); i++) { - anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())-> - MirrorPlaneCopy(myObjects[i], myArgument); + anObj = anOper->MirrorPlaneCopy(myObjects[i], myArgument); if (!anObj->_is_nil()) objects.push_back(anObj._retn()); } } else { for (int i = 0; i < myObjects.length(); i++) { - anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())-> - MirrorPlane(myObjects[i], myArgument); + anObj = anOper->MirrorPlane(myObjects[i], myArgument); if (!anObj->_is_nil()) objects.push_back(anObj._retn()); } diff --git a/src/TransformationGUI/TransformationGUI_MultiRotationDlg.cxx b/src/TransformationGUI/TransformationGUI_MultiRotationDlg.cxx index 72648767a..9f4ae0478 100644 --- a/src/TransformationGUI/TransformationGUI_MultiRotationDlg.cxx +++ b/src/TransformationGUI/TransformationGUI_MultiRotationDlg.cxx @@ -565,11 +565,12 @@ bool TransformationGUI_MultiRotationDlg::execute (ObjectList& objects) GEOM::GEOM_Object_var anObj; QStringList aParameters; + GEOM::GEOM_ITransformOperations_var anOper = GEOM::GEOM_ITransformOperations::_narrow(getOperation()); + switch (getConstructorId()) { case 0: if (!CORBA::is_nil(myBase) && !CORBA::is_nil(myVector)) { - anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())-> - MultiRotate1D(myBase, myVector, myNbTimes1); + anObj = anOper->MultiRotate1D(myBase, myVector, myNbTimes1); if(!IsPreview()) aParameters<SpinBox_DX->text(); res = true; @@ -577,8 +578,7 @@ bool TransformationGUI_MultiRotationDlg::execute (ObjectList& objects) break; case 1: if (!CORBA::is_nil(myBase) && !CORBA::is_nil(myVector)) { - anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())-> - MultiRotate2D(myBase, myVector, myAng, myNbTimes1, myStep, myNbTimes2); + anObj = anOper->MultiRotate2D(myBase, myVector, myAng, myNbTimes1, myStep, myNbTimes2); if(!IsPreview()) { aParameters<SpinBox_DX1->text(); aParameters<SpinBox_DY1->text(); @@ -592,7 +592,7 @@ bool TransformationGUI_MultiRotationDlg::execute (ObjectList& objects) if (!anObj->_is_nil()) { if(!IsPreview()) - anObj->SetParameters(GeometryGUI::JoinObjectParameters(aParameters)); + anObj->SetParameters(aParameters.join(":").toLatin1().constData()); objects.push_back(anObj._retn()); } diff --git a/src/TransformationGUI/TransformationGUI_MultiTranslationDlg.cxx b/src/TransformationGUI/TransformationGUI_MultiTranslationDlg.cxx index 9d6bc29ef..0e992818c 100644 --- a/src/TransformationGUI/TransformationGUI_MultiTranslationDlg.cxx +++ b/src/TransformationGUI/TransformationGUI_MultiTranslationDlg.cxx @@ -670,11 +670,12 @@ bool TransformationGUI_MultiTranslationDlg::execute (ObjectList& objects) QStringList aParameters; + GEOM::GEOM_ITransformOperations_var anOper = GEOM::GEOM_ITransformOperations::_narrow(getOperation()); + switch (getConstructorId()) { case 0: if (!CORBA::is_nil(myBase) && !CORBA::is_nil(myVectorU)) { - anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())-> - MultiTranslate1D(myBase, myVectorU, myStepU, myNbTimesU); + anObj = anOper->MultiTranslate1D(myBase, myVectorU, myStepU, myNbTimesU); if(!IsPreview()) { aParameters<SpinBox_DX->text(); aParameters<SpinBox_DY->text(); @@ -685,9 +686,9 @@ bool TransformationGUI_MultiTranslationDlg::execute (ObjectList& objects) case 1: if (!CORBA::is_nil(myBase) && !CORBA::is_nil(myVectorU) && !CORBA::is_nil(myVectorV)) { - anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())-> - MultiTranslate2D(myBase, myVectorU, myStepU, myNbTimesU, - myVectorV, myStepV, myNbTimesV); + anObj = anOper->MultiTranslate2D(myBase, + myVectorU, myStepU, myNbTimesU, + myVectorV, myStepV, myNbTimesV); if(!IsPreview()) { aParameters<SpinBox_DX1->text(); aParameters<SpinBox_DY1->text(); @@ -701,7 +702,7 @@ bool TransformationGUI_MultiTranslationDlg::execute (ObjectList& objects) if (!anObj->_is_nil()) { if(!IsPreview()) - anObj->SetParameters(GeometryGUI::JoinObjectParameters(aParameters)); + anObj->SetParameters(aParameters.join(":").toLatin1().constData()); objects.push_back(anObj._retn()); } diff --git a/src/TransformationGUI/TransformationGUI_OffsetDlg.cxx b/src/TransformationGUI/TransformationGUI_OffsetDlg.cxx index df5a0dd1e..e3bacd73e 100644 --- a/src/TransformationGUI/TransformationGUI_OffsetDlg.cxx +++ b/src/TransformationGUI/TransformationGUI_OffsetDlg.cxx @@ -292,10 +292,12 @@ bool TransformationGUI_OffsetDlg::execute( ObjectList& objects ) GEOM::GEOM_Object_var anObj; + GEOM::GEOM_ITransformOperations_var anOper = GEOM::GEOM_ITransformOperations::_narrow(getOperation()); + if ( GroupPoints->CheckButton1->isChecked() || IsPreview() ) { for ( int i = 0; i < myObjects.length(); i++ ) { - anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->OffsetShapeCopy( myObjects[i], GetOffset() ); + anObj = anOper->OffsetShapeCopy( myObjects[i], GetOffset() ); if ( !anObj->_is_nil() ) { if(!IsPreview()) { anObj->SetParameters(GroupPoints->SpinBox_DX->text().toLatin1().constData()); @@ -306,7 +308,7 @@ bool TransformationGUI_OffsetDlg::execute( ObjectList& objects ) } else { for ( int i = 0; i < myObjects.length(); i++ ) { - anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->OffsetShape( myObjects[i], GetOffset() ); + anObj = anOper->OffsetShape( myObjects[i], GetOffset() ); if ( !anObj->_is_nil() ) objects.push_back( anObj._retn() ); } diff --git a/src/TransformationGUI/TransformationGUI_PositionDlg.cxx b/src/TransformationGUI/TransformationGUI_PositionDlg.cxx index e6cd6c213..6a04c1b98 100644 --- a/src/TransformationGUI/TransformationGUI_PositionDlg.cxx +++ b/src/TransformationGUI/TransformationGUI_PositionDlg.cxx @@ -607,16 +607,15 @@ bool TransformationGUI_PositionDlg::execute (ObjectList& objects) bool toCreateCopy = IsPreview() || Group1->CheckButton1->isChecked(); GEOM::GEOM_Object_var anObj; + GEOM::GEOM_ITransformOperations_var anOper = GEOM::GEOM_ITransformOperations::_narrow(getOperation()); + switch (getConstructorId()) { case 0: { for (int i = 0; i < myObjects.length(); i++) { - if (toCreateCopy) - anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())-> - PositionShapeCopy(myObjects[i], myObjects[i], myEndLCS); - else - anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())-> - PositionShape(myObjects[i], myObjects[i], myEndLCS); + anObj = toCreateCopy ? + anOper->PositionShapeCopy(myObjects[i], myObjects[i], myEndLCS) : + anOper->PositionShape(myObjects[i], myObjects[i], myEndLCS); if (!anObj->_is_nil()) objects.push_back(anObj._retn()); @@ -628,11 +627,9 @@ bool TransformationGUI_PositionDlg::execute (ObjectList& objects) { for (int i = 0; i < myObjects.length(); i++) { if (toCreateCopy) - anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())-> - PositionShapeCopy(myObjects[i], myStartLCS, myEndLCS); - else - anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())-> - PositionShape(myObjects[i], myStartLCS, myEndLCS); + anObj = toCreateCopy ? + anOper->PositionShapeCopy(myObjects[i], myStartLCS, myEndLCS) : + anOper->PositionShape(myObjects[i], myStartLCS, myEndLCS); if (!anObj->_is_nil()) objects.push_back(anObj._retn()); } @@ -644,8 +641,7 @@ bool TransformationGUI_PositionDlg::execute (ObjectList& objects) double aDistance = Group1->SpinBox_DX->value(); bool toReverse = Group1->CheckButton3->isChecked(); for (int i = 0; i < myObjects.length(); i++) { - anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())-> - PositionAlongPath(myObjects[i], myPath, aDistance, toCreateCopy, toReverse); + anObj = anOper->PositionAlongPath(myObjects[i], myPath, aDistance, toCreateCopy, toReverse); if (!anObj->_is_nil()) objects.push_back(anObj._retn()); } diff --git a/src/TransformationGUI/TransformationGUI_RotationDlg.cxx b/src/TransformationGUI/TransformationGUI_RotationDlg.cxx index 7171cb4ae..5e68057be 100644 --- a/src/TransformationGUI/TransformationGUI_RotationDlg.cxx +++ b/src/TransformationGUI/TransformationGUI_RotationDlg.cxx @@ -537,6 +537,8 @@ bool TransformationGUI_RotationDlg::execute (ObjectList& objects) GEOM::GEOM_Object_var anObj; + GEOM::GEOM_ITransformOperations_var anOper = GEOM::GEOM_ITransformOperations::_narrow(getOperation()); + switch (getConstructorId()) { case 0: { @@ -545,11 +547,10 @@ bool TransformationGUI_RotationDlg::execute (ObjectList& objects) if (toCreateCopy) { for (int i = 0; i < myObjects.length(); i++) { myCurrObject = myObjects[i]; - anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())-> - RotateCopy(myObjects[i], myAxis, GetAngle() * PI180); + anObj = anOper->RotateCopy(myObjects[i], myAxis, GetAngle() * PI180); if (!anObj->_is_nil()) { if(!IsPreview()) { - anObj->SetParameters(GeometryGUI::JoinObjectParameters(aParameters)); + anObj->SetParameters(aParameters.join(":").toLatin1().constData()); } objects.push_back(anObj._retn()); } @@ -558,11 +559,10 @@ bool TransformationGUI_RotationDlg::execute (ObjectList& objects) else { for (int i = 0; i < myObjects.length(); i++) { myCurrObject = myObjects[i]; - anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())-> - Rotate(myObjects[i], myAxis, GetAngle() * PI180); + anObj = anOper->Rotate(myObjects[i], myAxis, GetAngle() * PI180); if (!anObj->_is_nil()) { if(!IsPreview()) { - anObj->SetParameters(GeometryGUI::JoinObjectParameters(aParameters)); + anObj->SetParameters(aParameters.join(":").toLatin1().constData()); updateAttributes(anObj, aParameters); } objects.push_back(anObj._retn()); @@ -577,8 +577,7 @@ bool TransformationGUI_RotationDlg::execute (ObjectList& objects) if (toCreateCopy) { for (int i = 0; i < myObjects.length(); i++) { myCurrObject = myObjects[i]; - anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())-> - RotateThreePointsCopy(myObjects[i], myCentPoint, myPoint1, myPoint2); + anObj = anOper->RotateThreePointsCopy(myObjects[i], myCentPoint, myPoint1, myPoint2); if (!anObj->_is_nil()) objects.push_back(anObj._retn()); } @@ -586,8 +585,7 @@ bool TransformationGUI_RotationDlg::execute (ObjectList& objects) else { for (int i = 0; i < myObjects.length(); i++) { myCurrObject = myObjects[i]; - anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())-> - RotateThreePoints(myObjects[i], myCentPoint, myPoint1, myPoint2); + anObj = anOper->RotateThreePoints(myObjects[i], myCentPoint, myPoint1, myPoint2); if (!anObj->_is_nil()) objects.push_back(anObj._retn()); } diff --git a/src/TransformationGUI/TransformationGUI_ScaleDlg.cxx b/src/TransformationGUI/TransformationGUI_ScaleDlg.cxx index 32daa0cb5..3384b1816 100644 --- a/src/TransformationGUI/TransformationGUI_ScaleDlg.cxx +++ b/src/TransformationGUI/TransformationGUI_ScaleDlg.cxx @@ -488,6 +488,8 @@ bool TransformationGUI_ScaleDlg::execute (ObjectList& objects) GEOM::GEOM_Object_var anObj; + GEOM::GEOM_ITransformOperations_var anOper = GEOM::GEOM_ITransformOperations::_narrow(getOperation()); + switch (getConstructorId()) { case 0: @@ -496,8 +498,7 @@ bool TransformationGUI_ScaleDlg::execute (ObjectList& objects) { for (int i = 0; i < myObjects.length(); i++) { - anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())-> - ScaleShapeCopy(myObjects[i], myPoint, SpinBox_FX->value()); + anObj = anOper->ScaleShapeCopy(myObjects[i], myPoint, SpinBox_FX->value()); if (!anObj->_is_nil()) { if(!IsPreview()) anObj->SetParameters(SpinBox_FX->text().toLatin1().constData()); @@ -509,8 +510,7 @@ bool TransformationGUI_ScaleDlg::execute (ObjectList& objects) { for (int i = 0; i < myObjects.length(); i++) { - anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())-> - ScaleShape(myObjects[i], myPoint, SpinBox_FX->value()); + anObj = anOper->ScaleShape(myObjects[i], myPoint, SpinBox_FX->value()); if (!anObj->_is_nil()) objects.push_back(anObj._retn()); } @@ -523,16 +523,15 @@ bool TransformationGUI_ScaleDlg::execute (ObjectList& objects) { for (int i = 0; i < myObjects.length(); i++) { - anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())-> - ScaleShapeAlongAxesCopy(myObjects[i], myPoint, SpinBox_FX->value(), - SpinBox_FY->value(), SpinBox_FZ->value()); + anObj = anOper->ScaleShapeAlongAxesCopy(myObjects[i], myPoint, SpinBox_FX->value(), + SpinBox_FY->value(), SpinBox_FZ->value()); if (!anObj->_is_nil()) if(!IsPreview()) { QStringList aParameters; aParameters<text(); aParameters<text(); aParameters<text(); - anObj->SetParameters(GeometryGUI::JoinObjectParameters(aParameters)); + anObj->SetParameters(aParameters.join(":").toLatin1().constData()); } objects.push_back(anObj._retn()); } @@ -541,9 +540,8 @@ bool TransformationGUI_ScaleDlg::execute (ObjectList& objects) { for (int i = 0; i < myObjects.length(); i++) { - anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())-> - ScaleShapeAlongAxes(myObjects[i], myPoint, SpinBox_FX->value(), - SpinBox_FY->value(), SpinBox_FZ->value()); + anObj = anOper->ScaleShapeAlongAxes(myObjects[i], myPoint, SpinBox_FX->value(), + SpinBox_FY->value(), SpinBox_FZ->value()); if (!anObj->_is_nil()) objects.push_back(anObj._retn()); } diff --git a/src/TransformationGUI/TransformationGUI_TranslationDlg.cxx b/src/TransformationGUI/TransformationGUI_TranslationDlg.cxx index 40dde336c..b498d5a68 100644 --- a/src/TransformationGUI/TransformationGUI_TranslationDlg.cxx +++ b/src/TransformationGUI/TransformationGUI_TranslationDlg.cxx @@ -554,6 +554,8 @@ bool TransformationGUI_TranslationDlg::execute (ObjectList& objects) GEOM::GEOM_Object_var anObj; + GEOM::GEOM_ITransformOperations_var anOper = GEOM::GEOM_ITransformOperations::_narrow(getOperation()); + switch (getConstructorId()) { case 0: { @@ -569,11 +571,10 @@ bool TransformationGUI_TranslationDlg::execute (ObjectList& objects) if (toCreateCopy) { for (int i = 0; i < myObjects.length(); i++) { myCurrObject = myObjects[i]; - anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())-> - TranslateDXDYDZCopy(myObjects[i], dx, dy, dz); + anObj = anOper->TranslateDXDYDZCopy(myObjects[i], dx, dy, dz); if (!anObj->_is_nil()) { if(!IsPreview()) - anObj->SetParameters(GeometryGUI::JoinObjectParameters(aParameters)); + anObj->SetParameters(aParameters.join(":").toLatin1().constData()); objects.push_back(anObj._retn()); } } @@ -581,11 +582,10 @@ bool TransformationGUI_TranslationDlg::execute (ObjectList& objects) else { for (int i = 0; i < myObjects.length(); i++) { myCurrObject = myObjects[i]; - anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())-> - TranslateDXDYDZ(myObjects[i], dx, dy, dz); + anObj = anOper->TranslateDXDYDZ(myObjects[i], dx, dy, dz); if (!anObj->_is_nil()) { if(!IsPreview()) { - anObj->SetParameters(GeometryGUI::JoinObjectParameters(aParameters)); + anObj->SetParameters(aParameters.join(":").toLatin1().constData()); updateAttributes(anObj, aParameters); } objects.push_back(anObj._retn()); @@ -600,8 +600,7 @@ bool TransformationGUI_TranslationDlg::execute (ObjectList& objects) if (toCreateCopy) { for (int i = 0; i < myObjects.length(); i++) { myCurrObject = myObjects[i]; - anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())-> - TranslateTwoPointsCopy(myObjects[i], myPoint1, myPoint2); + anObj = anOper->TranslateTwoPointsCopy(myObjects[i], myPoint1, myPoint2); if (!anObj->_is_nil()) objects.push_back(anObj._retn()); } @@ -609,8 +608,7 @@ bool TransformationGUI_TranslationDlg::execute (ObjectList& objects) else { for (int i = 0; i < myObjects.length(); i++) { myCurrObject = myObjects[i]; - anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())-> - TranslateTwoPoints(myObjects[i], myPoint1, myPoint2); + anObj = anOper->TranslateTwoPoints(myObjects[i], myPoint1, myPoint2); if (!anObj->_is_nil()) objects.push_back(anObj._retn()); } @@ -627,11 +625,10 @@ bool TransformationGUI_TranslationDlg::execute (ObjectList& objects) double aDistance = GroupPoints->SpinBox3->value(); for (int i = 0; i < myObjects.length(); i++) { myCurrObject = myObjects[i]; - anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())-> - TranslateVectorDistance(myObjects[i], myVector, aDistance, toCreateCopy); + anObj = anOper->TranslateVectorDistance(myObjects[i], myVector, aDistance, toCreateCopy); if (!anObj->_is_nil()) { if(!IsPreview()) { - anObj->SetParameters(GeometryGUI::JoinObjectParameters(aParameters)); + anObj->SetParameters(aParameters.join(":").toLatin1().constData()); if (!toCreateCopy) updateAttributes(anObj, aParameters); } @@ -643,8 +640,7 @@ bool TransformationGUI_TranslationDlg::execute (ObjectList& objects) if (toCreateCopy) { for (int i = 0; i < myObjects.length(); i++) { myCurrObject = myObjects[i]; - anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())-> - TranslateVectorCopy(myObjects[i], myVector); + anObj = anOper->TranslateVectorCopy(myObjects[i], myVector); if (!anObj->_is_nil()) objects.push_back(anObj._retn()); } @@ -652,8 +648,7 @@ bool TransformationGUI_TranslationDlg::execute (ObjectList& objects) else { for (int i = 0; i < myObjects.length(); i++) { myCurrObject = myObjects[i]; - anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())-> - TranslateVector(myObjects[i], myVector); + anObj = anOper->TranslateVector(myObjects[i], myVector); if (!anObj->_is_nil()) objects.push_back(anObj._retn()); } -- 2.39.2