Fix memory leaks

This commit is contained in:
vsr 2009-09-21 12:42:56 +00:00
parent ba2aa33a1e
commit ee26d6488a
11 changed files with 48 additions and 46 deletions

View 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()));

View 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();
}
}

View 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() );

View 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() );

View 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();
}
}

View 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;

View 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();
}
}

View 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();
}
}

View 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());

View 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();
}
}

View 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 ) )