From 1b44f73640fde3a290989b578cdfec8e89a406fa Mon Sep 17 00:00:00 2001 From: vsr Date: Thu, 17 Sep 2015 19:13:42 +0300 Subject: [PATCH] 0023164: Problem with Dump Study in case of an import - Fix problem caused by unhandled memory leaks --- src/BREPPlugin/BREPPlugin_GUI.cxx | 16 ++++++++++------ src/IGESPlugin/IGESPlugin_GUI.cxx | 16 ++++++++++------ src/STEPPlugin/STEPPlugin_GUI.cxx | 16 ++++++++++------ src/STLPlugin/STLPlugin_GUI.cxx | 16 ++++++++++------ src/VTKPlugin/VTKPlugin_GUI.cxx | 15 +++++++++------ src/XAOPlugin/XAOPlugin_ImportDlg.cxx | 5 +++++ 6 files changed, 54 insertions(+), 30 deletions(-) diff --git a/src/BREPPlugin/BREPPlugin_GUI.cxx b/src/BREPPlugin/BREPPlugin_GUI.cxx index 9da10a0d1..312919727 100644 --- a/src/BREPPlugin/BREPPlugin_GUI.cxx +++ b/src/BREPPlugin/BREPPlugin_GUI.cxx @@ -36,10 +36,13 @@ #include "GEOM_Operation.h" #include "GEOMBase.h" #include "GEOM_Displayer.h" +#include "GEOM_GenericObjPtr.h" #include #include CORBA_SERVER_HEADER(BREPPlugin) +typedef GEOM::GenericObjPtr BREPOpPtr; + //======================================================================= // function : BREPPlugin_GUI() // purpose : Constructor @@ -111,8 +114,8 @@ bool BREPPlugin_GUI::importBREP( SUIT_Desktop* parent ) SALOMEDS::Study_var dsStudy = GeometryGUI::ClientStudyToStudy( study->studyDS() ); GEOM::GEOM_IOperations_var op = GeometryGUI::GetGeomGen()->GetPluginOperations( dsStudy->StudyId(), "BREPPluginEngine" ); - GEOM::IBREPOperations_var brepOp = GEOM::IBREPOperations::_narrow( op ); - if ( CORBA::is_nil( brepOp ) ) return false; + BREPOpPtr brepOp = GEOM::IBREPOperations::_narrow( op ); + if ( brepOp.isNull() ) return false; QStringList fileNames = app->getOpenFileNames( SUIT_FileDlg::getLastVisitedPath().isEmpty() ? QDir::currentPath() : QString(""), tr( "BREP_FILES" ), @@ -126,7 +129,7 @@ bool BREPPlugin_GUI::importBREP( SUIT_Desktop* parent ) foreach( QString fileName, fileNames ) { SUIT_OverrideCursor wc; - GEOM_Operation transaction( app, brepOp.in() ); + GEOM_Operation transaction( app, brepOp.get() ); try { @@ -145,6 +148,7 @@ bool BREPPlugin_GUI::importBREP( SUIT_Desktop* parent ) entryList.append( so->GetID() ); transaction.commit(); GEOM_Displayer( study ).Display( main.in() ); + main->UnRegister(); } else { @@ -183,8 +187,8 @@ bool BREPPlugin_GUI::exportBREP( SUIT_Desktop* parent ) SALOMEDS::Study_var dsStudy = GeometryGUI::ClientStudyToStudy( study->studyDS() ); GEOM::GEOM_IOperations_var op = GeometryGUI::GetGeomGen()->GetPluginOperations( dsStudy->StudyId(), "BREPPluginEngine" ); - GEOM::IBREPOperations_var brepOp = GEOM::IBREPOperations::_narrow( op ); - if ( CORBA::is_nil( brepOp ) ) return false; + BREPOpPtr brepOp = GEOM::IBREPOperations::_narrow( op ); + if ( brepOp.isNull() ) return false; LightApp_SelectionMgr* sm = app->selectionMgr(); if ( !sm ) return false; @@ -212,7 +216,7 @@ bool BREPPlugin_GUI::exportBREP( SUIT_Desktop* parent ) SUIT_OverrideCursor wc; - GEOM_Operation transaction( app, brepOp.in() ); + GEOM_Operation transaction( app, brepOp.get() ); try { diff --git a/src/IGESPlugin/IGESPlugin_GUI.cxx b/src/IGESPlugin/IGESPlugin_GUI.cxx index da70682b7..f3dd0d0ac 100644 --- a/src/IGESPlugin/IGESPlugin_GUI.cxx +++ b/src/IGESPlugin/IGESPlugin_GUI.cxx @@ -37,10 +37,13 @@ #include "GEOM_Operation.h" #include "GEOMBase.h" #include "GEOM_Displayer.h" +#include "GEOM_GenericObjPtr.h" #include #include CORBA_SERVER_HEADER(IGESPlugin) +typedef GEOM::GenericObjPtr IGESOpPtr; + //======================================================================= // function : IGESPlugin_GUI() // purpose : Constructor @@ -109,8 +112,8 @@ bool IGESPlugin_GUI::importIGES( SUIT_Desktop* parent ) SALOMEDS::Study_var dsStudy = GeometryGUI::ClientStudyToStudy( study->studyDS() ); GEOM::GEOM_IOperations_var op = GeometryGUI::GetGeomGen()->GetPluginOperations( dsStudy->StudyId(), "IGESPluginEngine" ); - GEOM::IIGESOperations_var igesOp = GEOM::IIGESOperations::_narrow( op ); - if ( CORBA::is_nil( igesOp ) ) return false; + IGESOpPtr igesOp = GEOM::IIGESOperations::_narrow( op ); + if ( igesOp.isNull() ) return false; QStringList fileNames = app->getOpenFileNames( SUIT_FileDlg::getLastVisitedPath().isEmpty() ? QDir::currentPath() : QString(""), tr( "IGES_FILES" ), @@ -126,7 +129,7 @@ bool IGESPlugin_GUI::importIGES( SUIT_Desktop* parent ) { QString fileName = fileNames.at( i ); SUIT_OverrideCursor wc; - GEOM_Operation transaction( app, igesOp.in() ); + GEOM_Operation transaction( app, igesOp.get() ); bool ignoreUnits = false; try @@ -182,6 +185,7 @@ bool IGESPlugin_GUI::importIGES( SUIT_Desktop* parent ) entryList.append( so->GetID() ); transaction.commit(); GEOM_Displayer( study ).Display( main.in() ); + main->UnRegister(); } else { @@ -221,8 +225,8 @@ bool IGESPlugin_GUI::exportIGES( SUIT_Desktop* parent ) SALOMEDS::Study_var dsStudy = GeometryGUI::ClientStudyToStudy( study->studyDS() ); GEOM::GEOM_IOperations_var op = GeometryGUI::GetGeomGen()->GetPluginOperations( dsStudy->StudyId(), "IGESPluginEngine" ); - GEOM::IIGESOperations_var igesOp = GEOM::IIGESOperations::_narrow( op ); - if ( CORBA::is_nil( igesOp ) ) return false; + IGESOpPtr igesOp = GEOM::IIGESOperations::_narrow( op ); + if ( igesOp.isNull() ) return false; LightApp_SelectionMgr* sm = app->selectionMgr(); if ( !sm ) return false; @@ -251,7 +255,7 @@ bool IGESPlugin_GUI::exportIGES( SUIT_Desktop* parent ) SUIT_OverrideCursor wc; - GEOM_Operation transaction( app, igesOp.in() ); + GEOM_Operation transaction( app, igesOp.get() ); try { diff --git a/src/STEPPlugin/STEPPlugin_GUI.cxx b/src/STEPPlugin/STEPPlugin_GUI.cxx index 88686838e..c8f0300e3 100644 --- a/src/STEPPlugin/STEPPlugin_GUI.cxx +++ b/src/STEPPlugin/STEPPlugin_GUI.cxx @@ -36,10 +36,13 @@ #include "GEOM_Operation.h" #include "GEOMBase.h" #include "GEOM_Displayer.h" +#include "GEOM_GenericObjPtr.h" #include #include CORBA_SERVER_HEADER(STEPPlugin) +typedef GEOM::GenericObjPtr STEPOpPtr; + //======================================================================= // function : STEPPlugin_GUI() // purpose : Constructor @@ -111,8 +114,8 @@ bool STEPPlugin_GUI::importSTEP( SUIT_Desktop* parent ) SALOMEDS::Study_var dsStudy = GeometryGUI::ClientStudyToStudy( study->studyDS() ); GEOM::GEOM_IOperations_var op = GeometryGUI::GetGeomGen()->GetPluginOperations( dsStudy->StudyId(), "STEPPluginEngine" ); - GEOM::ISTEPOperations_var stepOp = GEOM::ISTEPOperations::_narrow( op ); - if ( CORBA::is_nil( stepOp ) ) return false; + STEPOpPtr stepOp = GEOM::ISTEPOperations::_narrow( op ); + if ( stepOp.isNull() ) return false; QStringList fileNames = app->getOpenFileNames( SUIT_FileDlg::getLastVisitedPath().isEmpty() ? QDir::currentPath() : QString(""), tr( "STEP_FILES" ), @@ -128,7 +131,7 @@ bool STEPPlugin_GUI::importSTEP( SUIT_Desktop* parent ) { QString fileName = fileNames.at( i ); SUIT_OverrideCursor wc; - GEOM_Operation transaction( app, stepOp.in() ); + GEOM_Operation transaction( app, stepOp.get() ); bool ignoreUnits = false; try @@ -189,6 +192,7 @@ bool STEPPlugin_GUI::importSTEP( SUIT_Desktop* parent ) } transaction.commit(); GEOM_Displayer( study ).Display( main.in() ); + main->UnRegister(); } else { @@ -228,8 +232,8 @@ bool STEPPlugin_GUI::exportSTEP( SUIT_Desktop* parent ) SALOMEDS::Study_var dsStudy = GeometryGUI::ClientStudyToStudy( study->studyDS() ); GEOM::GEOM_IOperations_var op = GeometryGUI::GetGeomGen()->GetPluginOperations( dsStudy->StudyId(), "STEPPluginEngine" ); - GEOM::ISTEPOperations_var stepOp = GEOM::ISTEPOperations::_narrow( op ); - if ( CORBA::is_nil( stepOp ) ) return false; + STEPOpPtr stepOp = GEOM::ISTEPOperations::_narrow( op ); + if ( stepOp.isNull() ) return false; LightApp_SelectionMgr* sm = app->selectionMgr(); if ( !sm ) return false; @@ -257,7 +261,7 @@ bool STEPPlugin_GUI::exportSTEP( SUIT_Desktop* parent ) SUIT_OverrideCursor wc; - GEOM_Operation transaction( app, stepOp.in() ); + GEOM_Operation transaction( app, stepOp.get() ); try { diff --git a/src/STLPlugin/STLPlugin_GUI.cxx b/src/STLPlugin/STLPlugin_GUI.cxx index 27311769a..d868adb97 100644 --- a/src/STLPlugin/STLPlugin_GUI.cxx +++ b/src/STLPlugin/STLPlugin_GUI.cxx @@ -37,10 +37,13 @@ #include "GEOM_Operation.h" #include "GEOMBase.h" #include "GEOM_Displayer.h" +#include "GEOM_GenericObjPtr.h" #include #include CORBA_SERVER_HEADER(STLPlugin) +typedef GEOM::GenericObjPtr STLOpPtr; + //======================================================================= // function : STLPlugin_GUI() // purpose : Constructor @@ -109,8 +112,8 @@ bool STLPlugin_GUI::importSTL( SUIT_Desktop* parent ) SALOMEDS::Study_var dsStudy = GeometryGUI::ClientStudyToStudy( study->studyDS() ); GEOM::GEOM_IOperations_var op = GeometryGUI::GetGeomGen()->GetPluginOperations( dsStudy->StudyId(), "STLPluginEngine" ); - GEOM::ISTLOperations_var stlOp = GEOM::ISTLOperations::_narrow( op ); - if ( CORBA::is_nil( stlOp ) ) return false; + STLOpPtr stlOp = GEOM::ISTLOperations::_narrow( op ); + if ( stlOp.isNull() ) return false; QStringList fileNames = app->getOpenFileNames( SUIT_FileDlg::getLastVisitedPath().isEmpty() ? QDir::currentPath() : QString(""), tr( "STL_FILES" ), @@ -124,7 +127,7 @@ bool STLPlugin_GUI::importSTL( SUIT_Desktop* parent ) foreach( QString fileName, fileNames ) { SUIT_OverrideCursor wc; - GEOM_Operation transaction( app, stlOp.in() ); + GEOM_Operation transaction( app, stlOp.get() ); try { @@ -143,6 +146,7 @@ bool STLPlugin_GUI::importSTL( SUIT_Desktop* parent ) entryList.append( so->GetID() ); transaction.commit(); GEOM_Displayer( study ).Display( main.in() ); + main->UnRegister(); } else { @@ -181,8 +185,8 @@ bool STLPlugin_GUI::exportSTL( SUIT_Desktop* parent ) SALOMEDS::Study_var dsStudy = GeometryGUI::ClientStudyToStudy( study->studyDS() ); GEOM::GEOM_IOperations_var op = GeometryGUI::GetGeomGen()->GetPluginOperations( dsStudy->StudyId(), "STLPluginEngine" ); - GEOM::ISTLOperations_var stlOp = GEOM::ISTLOperations::_narrow( op ); - if ( CORBA::is_nil( stlOp ) ) return false; + STLOpPtr stlOp = GEOM::ISTLOperations::_narrow( op ); + if ( stlOp.isNull() ) return false; LightApp_SelectionMgr* sm = app->selectionMgr(); if ( !sm ) return false; @@ -215,7 +219,7 @@ bool STLPlugin_GUI::exportSTL( SUIT_Desktop* parent ) SUIT_OverrideCursor wc; - GEOM_Operation transaction( app, stlOp.in() ); + GEOM_Operation transaction( app, stlOp.get() ); try { diff --git a/src/VTKPlugin/VTKPlugin_GUI.cxx b/src/VTKPlugin/VTKPlugin_GUI.cxx index ada1e297c..fbf7dfdc6 100644 --- a/src/VTKPlugin/VTKPlugin_GUI.cxx +++ b/src/VTKPlugin/VTKPlugin_GUI.cxx @@ -35,10 +35,13 @@ #include "GEOM_Operation.h" #include "GEOMBase.h" #include "GEOM_Displayer.h" +#include "GEOM_GenericObjPtr.h" #include #include CORBA_SERVER_HEADER(VTKPlugin) +typedef GEOM::GenericObjPtr VTKOpPtr; + //======================================================================= // function : VTKPlugin_GUI() // purpose : Constructor @@ -102,8 +105,8 @@ bool VTKPlugin_GUI::exportVTK( SUIT_Desktop* parent ) SALOMEDS::Study_var dsStudy = GeometryGUI::ClientStudyToStudy( study->studyDS() ); GEOM::GEOM_IOperations_var op = GeometryGUI::GetGeomGen()->GetPluginOperations( dsStudy->StudyId(), "VTKPluginEngine" ); - GEOM::IVTKOperations_var stlOp = GEOM::IVTKOperations::_narrow( op ); - if ( CORBA::is_nil( stlOp ) ) return false; + VTKOpPtr vtkOp = GEOM::IVTKOperations::_narrow( op ); + if ( vtkOp.isNull() ) return false; LightApp_SelectionMgr* sm = app->selectionMgr(); if ( !sm ) return false; @@ -132,16 +135,16 @@ bool VTKPlugin_GUI::exportVTK( SUIT_Desktop* parent ) SUIT_OverrideCursor wc; - GEOM_Operation transaction( app, stlOp.in() ); + GEOM_Operation transaction( app, vtkOp.get() ); try { app->putInfo( tr( "GEOM_PRP_EXPORT" ).arg( fileName ) ); transaction.start(); - stlOp->ExportVTK( obj, fileName.toUtf8().constData(), deflection ); + vtkOp->ExportVTK( obj, fileName.toUtf8().constData(), deflection ); - if ( stlOp->IsDone() ) + if ( vtkOp->IsDone() ) { transaction.commit(); } @@ -150,7 +153,7 @@ bool VTKPlugin_GUI::exportVTK( SUIT_Desktop* parent ) transaction.abort(); SUIT_MessageBox::critical( parent, tr( "GEOM_ERROR" ), - tr( "GEOM_PRP_ABORT" ) + "\n" + tr( stlOp->GetErrorCode() ) ); + tr( "GEOM_PRP_ABORT" ) + "\n" + tr( vtkOp->GetErrorCode() ) ); return false; } } diff --git a/src/XAOPlugin/XAOPlugin_ImportDlg.cxx b/src/XAOPlugin/XAOPlugin_ImportDlg.cxx index 990386361..2d061210f 100644 --- a/src/XAOPlugin/XAOPlugin_ImportDlg.cxx +++ b/src/XAOPlugin/XAOPlugin_ImportDlg.cxx @@ -280,13 +280,16 @@ bool XAOPlugin_ImportDlg::execute() { QStringList anEntryList; anEntryList << addInStudy(m_mainShape, m_mainShape->GetName()); + m_mainShape->UnRegister(); for (int i = 0; i < subShapes->length(); i++) { addInStudy(subShapes[i].in(), subShapes[i]->GetName()); + subShapes[i]->UnRegister(); } for (int i = 0; i < groups->length(); i++) { addInStudy(groups[i].in(), groups[i]->GetName()); + groups[i]->UnRegister(); } for (int i = 0; i < fields->length(); i++) { @@ -316,6 +319,7 @@ QString XAOPlugin_ImportDlg::addFieldInStudy( GEOM::GEOM_Field_ptr theField, GEO SALOMEDS::SObject_var aSO = getGeomEngine()->AddInStudy(aStudyDS, theField, theField->GetName(), theFather); + theField->UnRegister(); QString anEntry; if ( !aSO->_is_nil() ) { @@ -331,6 +335,7 @@ QString XAOPlugin_ImportDlg::addFieldInStudy( GEOM::GEOM_Field_ptr theField, GEO QString stepName = (tr("XAOPLUGIN_STEP") + " %1 %2").arg( step->GetID() ).arg( step->GetStamp() ); SALOMEDS::SObject_wrap aSOField = getGeomEngine()->AddInStudy( aStudyDS, step, stepName.toLatin1().constData(), theField ); + step->UnRegister(); } aSO->UnRegister(); -- 2.39.2