Fix memory leaks

This commit is contained in:
vsr 2009-09-21 13:24:01 +00:00
parent 56ca7cc409
commit c20be9052a
8 changed files with 61 additions and 59 deletions

View File

@ -194,14 +194,14 @@ void GroupGUI_GroupDlg::Init()
mainFrame()->ResultName->setText( GEOMBase::GetName( myGroup ) ); mainFrame()->ResultName->setText( GEOMBase::GetName( myGroup ) );
GEOM::GEOM_IGroupOperations_var anOp = GEOM::GEOM_IGroupOperations::_narrow( getOperation() ); GEOM::GEOM_IGroupOperations_var anOper = GEOM::GEOM_IGroupOperations::_narrow( getOperation() );
myMainObj = anOp->GetMainShape( myGroup ); myMainObj = anOper->GetMainShape( myGroup );
if ( !CORBA::is_nil( myMainObj ) ) if ( !CORBA::is_nil( myMainObj ) )
myMainName->setText( GEOMBase::GetName( myMainObj ) ); myMainName->setText( GEOMBase::GetName( myMainObj ) );
setShapeType( (TopAbs_ShapeEnum)anOp->GetType( myGroup ) ); setShapeType( (TopAbs_ShapeEnum)anOper->GetType( myGroup ) );
GEOM::ListOfLong_var aCurrList = anOp->GetObjects( myGroup ); GEOM::ListOfLong_var aCurrList = anOper->GetObjects( myGroup );
for ( int i = 0, n = aCurrList->length(); i < n; i++ ) for ( int i = 0, n = aCurrList->length(); i < n; i++ )
myIdList->addItem( new QListWidgetItem( QString( "%1" ).arg( aCurrList[i] ) ) ); myIdList->addItem( new QListWidgetItem( QString( "%1" ).arg( aCurrList[i] ) ) );
@ -1052,25 +1052,25 @@ bool GroupGUI_GroupDlg::execute( ObjectList& objects )
{ {
setInPlaceObj( GEOM::GEOM_Object::_nil() ); setInPlaceObj( GEOM::GEOM_Object::_nil() );
GEOM::GEOM_IGroupOperations_var anOp = GEOM::GEOM_IGroupOperations::_narrow(getOperation()); GEOM::GEOM_IGroupOperations_var anOper = GEOM::GEOM_IGroupOperations::_narrow(getOperation());
GEOM::GEOM_Object_var aGroup; GEOM::GEOM_Object_var aGroup;
if (myMode == CreateGroup) if (myMode == CreateGroup)
aGroup = anOp->CreateGroup(myMainObj, getShapeType()); aGroup = anOper->CreateGroup(myMainObj, getShapeType());
else if (myMode == EditGroup) else if (myMode == EditGroup)
aGroup = myGroup; aGroup = myGroup;
if (CORBA::is_nil(aGroup) || (myMode == CreateGroup && !anOp->IsDone())) if (CORBA::is_nil(aGroup) || (myMode == CreateGroup && !anOper->IsDone()))
return false; return false;
GEOM::ListOfLong_var aCurrList = anOp->GetObjects(aGroup); GEOM::ListOfLong_var aCurrList = anOper->GetObjects(aGroup);
if (!anOp->IsDone()) if (!anOper->IsDone())
return false; return false;
if (aCurrList->length() > 0) if (aCurrList->length() > 0)
{ {
anOp->DifferenceIDs(aGroup, aCurrList); anOper->DifferenceIDs(aGroup, aCurrList);
if (!anOp->IsDone()) if (!anOper->IsDone())
return false; return false;
} }
@ -1082,8 +1082,8 @@ bool GroupGUI_GroupDlg::execute( ObjectList& objects )
for (ii = 0; ii < nn; ii++) { for (ii = 0; ii < nn; ii++) {
aNewList[ii] = myIdList->item(ii)->text().toInt(); aNewList[ii] = myIdList->item(ii)->text().toInt();
} }
anOp->UnionIDs(aGroup, aNewList); anOper->UnionIDs(aGroup, aNewList);
if (!anOp->IsDone()) if (!anOper->IsDone())
return false; return false;
} }
@ -1115,8 +1115,8 @@ GEOM::GEOM_Object_ptr GroupGUI_GroupDlg::getFather( GEOM::GEOM_Object_ptr theObj
{ {
GEOM::GEOM_Object_var aFatherObj; GEOM::GEOM_Object_var aFatherObj;
if ( theObj->GetType() == GEOM_GROUP ) { if ( theObj->GetType() == GEOM_GROUP ) {
GEOM::GEOM_IGroupOperations_var anOp = GEOM::GEOM_IGroupOperations::_narrow( getOperation() ); GEOM::GEOM_IGroupOperations_var anOper = GEOM::GEOM_IGroupOperations::_narrow( getOperation() );
aFatherObj = anOp->GetMainShape( theObj ); aFatherObj = anOper->GetMainShape( theObj );
} }
return aFatherObj._retn(); return aFatherObj._retn();
} }

View File

@ -448,11 +448,13 @@ bool PrimitiveGUI_BoxDlg::execute (ObjectList& objects)
GEOM::GEOM_Object_var anObj; GEOM::GEOM_Object_var anObj;
GEOM::GEOM_I3DPrimOperations_var anOper = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation());
switch (getConstructorId()) { switch (getConstructorId()) {
case 0: case 0:
{ {
if (!CORBA::is_nil(myPoint1) && !CORBA::is_nil(myPoint2)) { if (!CORBA::is_nil(myPoint1) && !CORBA::is_nil(myPoint2)) {
anObj = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation())->MakeBoxTwoPnt(myPoint1, myPoint2); anObj = anOper->MakeBoxTwoPnt(myPoint1, myPoint2);
res = true; res = true;
} }
} }
@ -463,14 +465,14 @@ bool PrimitiveGUI_BoxDlg::execute (ObjectList& objects)
double y = GroupDimensions->SpinBox_DY->value(); double y = GroupDimensions->SpinBox_DY->value();
double z = GroupDimensions->SpinBox_DZ->value(); double z = GroupDimensions->SpinBox_DZ->value();
anObj = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation())->MakeBoxDXDYDZ(x, y, z); anObj = anOper->MakeBoxDXDYDZ(x, y, z);
if (!anObj->_is_nil() && !IsPreview()) if (!anObj->_is_nil() && !IsPreview())
{ {
QStringList aParameters; QStringList aParameters;
aParameters << GroupDimensions->SpinBox_DX->text(); aParameters << GroupDimensions->SpinBox_DX->text();
aParameters << GroupDimensions->SpinBox_DY->text(); aParameters << GroupDimensions->SpinBox_DY->text();
aParameters << GroupDimensions->SpinBox_DZ->text(); aParameters << GroupDimensions->SpinBox_DZ->text();
anObj->SetParameters(GeometryGUI::JoinObjectParameters(aParameters)); anObj->SetParameters(aParameters.join(":").toLatin1().constData());
} }
res = true; res = true;
} }

View File

@ -470,32 +470,32 @@ bool PrimitiveGUI_ConeDlg::execute (ObjectList& objects)
GEOM::GEOM_Object_var anObj; GEOM::GEOM_Object_var anObj;
GEOM::GEOM_I3DPrimOperations_var anOper = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation());
switch (getConstructorId()) { switch (getConstructorId()) {
case 0: case 0:
if (!CORBA::is_nil(myPoint) && !CORBA::is_nil(myDir)) { if (!CORBA::is_nil(myPoint) && !CORBA::is_nil(myDir)) {
anObj = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation())-> anObj = anOper->MakeConePntVecR1R2H(myPoint, myDir, getRadius1(), getRadius2(), getHeight());
MakeConePntVecR1R2H(myPoint, myDir, getRadius1(), getRadius2(), getHeight());
if (!anObj->_is_nil() && !IsPreview()) if (!anObj->_is_nil() && !IsPreview())
{ {
QStringList aParameters; QStringList aParameters;
aParameters << GroupPoints->SpinBox_DX->text(); aParameters << GroupPoints->SpinBox_DX->text();
aParameters << GroupPoints->SpinBox_DY->text(); aParameters << GroupPoints->SpinBox_DY->text();
aParameters << GroupPoints->SpinBox_DZ->text(); aParameters << GroupPoints->SpinBox_DZ->text();
anObj->SetParameters(GeometryGUI::JoinObjectParameters(aParameters)); anObj->SetParameters(aParameters.join(":").toLatin1().constData());
} }
res = true; res = true;
} }
break; break;
case 1: case 1:
anObj = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation())-> anObj = anOper->MakeConeR1R2H(getRadius1(), getRadius2(), getHeight());
MakeConeR1R2H(getRadius1(), getRadius2(), getHeight());
if (!anObj->_is_nil() && !IsPreview()) if (!anObj->_is_nil() && !IsPreview())
{ {
QStringList aParameters; QStringList aParameters;
aParameters << GroupDimensions->SpinBox_DX->text(); aParameters << GroupDimensions->SpinBox_DX->text();
aParameters << GroupDimensions->SpinBox_DY->text(); aParameters << GroupDimensions->SpinBox_DY->text();
aParameters << GroupDimensions->SpinBox_DZ->text(); aParameters << GroupDimensions->SpinBox_DZ->text();
anObj->SetParameters(GeometryGUI::JoinObjectParameters(aParameters)); anObj->SetParameters(aParameters.join(":").toLatin1().constData());
} }
res = true; res = true;
break; break;

View File

@ -461,30 +461,30 @@ bool PrimitiveGUI_CylinderDlg::execute (ObjectList& objects)
GEOM::GEOM_Object_var anObj; GEOM::GEOM_Object_var anObj;
GEOM::GEOM_I3DPrimOperations_var anOper = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation());
switch (getConstructorId()) { switch (getConstructorId()) {
case 0: case 0:
if (!CORBA::is_nil(myPoint) && !CORBA::is_nil(myDir)) { if (!CORBA::is_nil(myPoint) && !CORBA::is_nil(myDir)) {
anObj = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation())-> anObj = anOper->MakeCylinderPntVecRH(myPoint, myDir, getRadius(), getHeight());
MakeCylinderPntVecRH(myPoint, myDir, getRadius(), getHeight());
if (!anObj->_is_nil() && !IsPreview()) if (!anObj->_is_nil() && !IsPreview())
{ {
QStringList aParameters; QStringList aParameters;
aParameters << GroupPoints->SpinBox_DX->text(); aParameters << GroupPoints->SpinBox_DX->text();
aParameters << GroupPoints->SpinBox_DY->text(); aParameters << GroupPoints->SpinBox_DY->text();
anObj->SetParameters(GeometryGUI::JoinObjectParameters(aParameters)); anObj->SetParameters(aParameters.join(":").toLatin1().constData());
} }
res = true; res = true;
} }
break; break;
case 1: case 1:
anObj = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation())-> anObj = anOper->MakeCylinderRH(getRadius(), getHeight());
MakeCylinderRH(getRadius(), getHeight());
if (!anObj->_is_nil() && !IsPreview()) if (!anObj->_is_nil() && !IsPreview())
{ {
QStringList aParameters; QStringList aParameters;
aParameters << GroupDimensions->SpinBox_DX->text(); aParameters << GroupDimensions->SpinBox_DX->text();
aParameters << GroupDimensions->SpinBox_DY->text(); aParameters << GroupDimensions->SpinBox_DY->text();
anObj->SetParameters(GeometryGUI::JoinObjectParameters(aParameters)); anObj->SetParameters(aParameters.join(":").toLatin1().constData());
} }
res = true; res = true;
break; break;

View File

@ -572,30 +572,29 @@ bool PrimitiveGUI_DiskDlg::execute (ObjectList& objects)
GEOM::GEOM_Object_var anObj; GEOM::GEOM_Object_var anObj;
GEOM::GEOM_I3DPrimOperations_var anOper = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation());
switch (getConstructorId()) { switch (getConstructorId()) {
case 0: case 0:
anObj = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation())-> anObj = anOper->MakeDiskR(getRadius(), myOrientationType);
MakeDiskR(getRadius(), myOrientationType);
if (!anObj->_is_nil() && !IsPreview()) if (!anObj->_is_nil() && !IsPreview())
{ {
aParameters << GroupDimensions->SpinBox_DX->text(); aParameters << GroupDimensions->SpinBox_DX->text();
anObj->SetParameters(GeometryGUI::JoinObjectParameters(aParameters)); anObj->SetParameters(aParameters.join(":").toLatin1().constData());
} }
res = true; res = true;
break; break;
case 1: case 1:
anObj = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation())-> anObj = anOper->MakeDiskPntVecR(myPoint, myDir, getRadius());
MakeDiskPntVecR(myPoint, myDir, getRadius());
if (!anObj->_is_nil() && !IsPreview()) if (!anObj->_is_nil() && !IsPreview())
{ {
aParameters << GroupPntVecR->SpinBox_DX->text(); aParameters << GroupPntVecR->SpinBox_DX->text();
anObj->SetParameters(GeometryGUI::JoinObjectParameters(aParameters)); anObj->SetParameters(aParameters.join(":").toLatin1().constData());
} }
res = true; res = true;
break; break;
case 2: case 2:
anObj = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation())-> anObj = anOper->MakeDiskThreePnt(myPoint1, myPoint2, myPoint3);
MakeDiskThreePnt(myPoint1, myPoint2, myPoint3);
res = true; res = true;
break; break;
} }

View File

@ -492,31 +492,30 @@ bool PrimitiveGUI_FaceDlg::execute (ObjectList& objects)
bool res = false; bool res = false;
QStringList aParameters; QStringList aParameters;
GEOM::GEOM_Object_var anObj; GEOM::GEOM_Object_var anObj;
GEOM::GEOM_I3DPrimOperations_var anOper = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation());
switch (getConstructorId()) { switch (getConstructorId()) {
case 0: case 0:
anObj = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation())-> anObj = anOper->MakeFaceHW(GroupDimensions->SpinBox_DX->value(),
MakeFaceHW(GroupDimensions->SpinBox_DX->value(), GroupDimensions->SpinBox_DY->value(), myOrientationType);
GroupDimensions->SpinBox_DY->value(), myOrientationType);
if (!anObj->_is_nil() && !IsPreview()) if (!anObj->_is_nil() && !IsPreview())
{ {
aParameters << GroupDimensions->SpinBox_DX->text(); aParameters << GroupDimensions->SpinBox_DX->text();
aParameters << GroupDimensions->SpinBox_DY->text(); aParameters << GroupDimensions->SpinBox_DY->text();
anObj->SetParameters(GeometryGUI::JoinObjectParameters(aParameters)); anObj->SetParameters(aParameters.join(":").toLatin1().constData());
} }
res = true; res = true;
break; break;
case 1: case 1:
if (GroupType->RadioButton1->isChecked()) anObj = GroupType->RadioButton1->isChecked() ?
anObj = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation())-> anOper->MakeFaceObjHW(myEdge, GroupPlane->SpinBox_DX->value(), GroupPlane->SpinBox_DY->value()) :
MakeFaceObjHW(myEdge, GroupPlane->SpinBox_DX->value(), GroupPlane->SpinBox_DY->value()); anOper->MakeFaceObjHW(myFace, GroupPlane->SpinBox_DX->value(), GroupPlane->SpinBox_DY->value());
else if (GroupType->RadioButton2->isChecked())
anObj = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation())->
MakeFaceObjHW(myFace, GroupPlane->SpinBox_DX->value(), GroupPlane->SpinBox_DY->value());
if (!anObj->_is_nil() && !IsPreview()) if (!anObj->_is_nil() && !IsPreview())
{ {
aParameters << GroupPlane->SpinBox_DX->text(); aParameters << GroupPlane->SpinBox_DX->text();
aParameters << GroupPlane->SpinBox_DY->text(); aParameters << GroupPlane->SpinBox_DY->text();
anObj->SetParameters(GeometryGUI::JoinObjectParameters(aParameters)); anObj->SetParameters(aParameters.join(":").toLatin1().constData());
} }
res = true; res = true;
break; break;

View File

@ -396,16 +396,18 @@ bool PrimitiveGUI_SphereDlg::execute( ObjectList& objects )
GEOM::GEOM_Object_var anObj; GEOM::GEOM_Object_var anObj;
GEOM::GEOM_I3DPrimOperations_var anOper = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation());
switch ( getConstructorId() ) { switch ( getConstructorId() ) {
case 0 : case 0 :
{ {
if ( !CORBA::is_nil( myPoint ) ) { if ( !CORBA::is_nil( myPoint ) ) {
anObj = GEOM::GEOM_I3DPrimOperations::_narrow( getOperation() )->MakeSpherePntR( myPoint, getRadius() ); anObj = anOper->MakeSpherePntR( myPoint, getRadius() );
if (!anObj->_is_nil() && !IsPreview()) if (!anObj->_is_nil() && !IsPreview())
{ {
QStringList aParameters; QStringList aParameters;
aParameters << GroupPoints->SpinBox_DX->text(); aParameters << GroupPoints->SpinBox_DX->text();
anObj->SetParameters(GeometryGUI::JoinObjectParameters(aParameters)); anObj->SetParameters(aParameters.join(":").toLatin1().constData());
} }
res = true; res = true;
} }
@ -413,12 +415,12 @@ bool PrimitiveGUI_SphereDlg::execute( ObjectList& objects )
} }
case 1 : case 1 :
{ {
anObj = GEOM::GEOM_I3DPrimOperations::_narrow( getOperation() )->MakeSphereR( getRadius() ); anObj = anOper->MakeSphereR( getRadius() );
if (!anObj->_is_nil() && !IsPreview()) if (!anObj->_is_nil() && !IsPreview())
{ {
QStringList aParameters; QStringList aParameters;
aParameters << GroupDimensions->SpinBox_DX->text(); aParameters << GroupDimensions->SpinBox_DX->text();
anObj->SetParameters(GeometryGUI::JoinObjectParameters(aParameters)); anObj->SetParameters(aParameters.join(":").toLatin1().constData());
} }
res = true; res = true;
break; break;

View File

@ -457,30 +457,30 @@ bool PrimitiveGUI_TorusDlg::execute (ObjectList& objects)
GEOM::GEOM_Object_var anObj; GEOM::GEOM_Object_var anObj;
GEOM::GEOM_I3DPrimOperations_var anOper = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation());
switch (getConstructorId()) { switch (getConstructorId()) {
case 0: case 0:
if (!CORBA::is_nil(myPoint) && !CORBA::is_nil(myDir)) { if (!CORBA::is_nil(myPoint) && !CORBA::is_nil(myDir)) {
anObj = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation())-> anObj = anOper->MakeTorusPntVecRR(myPoint, myDir, getRadius1(), getRadius2());
MakeTorusPntVecRR(myPoint, myDir, getRadius1(), getRadius2());
if (!anObj->_is_nil() && !IsPreview()) if (!anObj->_is_nil() && !IsPreview())
{ {
QStringList aParameters; QStringList aParameters;
aParameters << GroupPoints->SpinBox_DX->text(); aParameters << GroupPoints->SpinBox_DX->text();
aParameters << GroupPoints->SpinBox_DY->text(); aParameters << GroupPoints->SpinBox_DY->text();
anObj->SetParameters(GeometryGUI::JoinObjectParameters(aParameters)); anObj->SetParameters(aParameters.join(":").toLatin1().constData());
} }
res = true; res = true;
} }
break; break;
case 1: case 1:
anObj = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation())-> anObj = anOper->MakeTorusRR(getRadius1(), getRadius2());
MakeTorusRR(getRadius1(), getRadius2());
if (!anObj->_is_nil() && !IsPreview()) if (!anObj->_is_nil() && !IsPreview())
{ {
QStringList aParameters; QStringList aParameters;
aParameters << GroupDimensions->SpinBox_DX->text(); aParameters << GroupDimensions->SpinBox_DX->text();
aParameters << GroupDimensions->SpinBox_DY->text(); aParameters << GroupDimensions->SpinBox_DY->text();
anObj->SetParameters(GeometryGUI::JoinObjectParameters(aParameters)); anObj->SetParameters(aParameters.join(":").toLatin1().constData());
} }
res = true; res = true;
break; break;