SALOME Forum bug: sub-mesh removal leads to an Exception in a re-opened study.

Now UnRegister(), corresponding to the Register() called by AttributeIOR,
is invoked by an object publisher i.e. by SMESH_Gen_i::publish() but not by GUI
because GUI is unable to track publication of all objects created by the Engine:
for example groups can be created while mesh.Compute() is called.
This commit is contained in:
eap 2013-07-22 14:27:40 +00:00
parent e74e528833
commit 91084ee58a
10 changed files with 18 additions and 152 deletions

View File

@ -361,11 +361,6 @@
SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() ); SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
anEntryList.append( aMeshSO->GetID().c_str() ); anEntryList.append( aMeshSO->GetID().c_str() );
// obj has been published in study. Its refcount has been incremented.
// It is safe to decrement its refcount
// so that it will be destroyed when the entry in study will be removed
aMeshes[i]->UnRegister();
} }
else { else {
isEmpty = true; isEmpty = true;
@ -1790,7 +1785,7 @@
aSO = aRefSObject; // Delete main Object instead of reference aSO = aRefSObject; // Delete main Object instead of reference
listSO.push_back( aSO ); listSO.push_back( aSO );
std::list< _PTR(SObject) >::iterator itSO = listSO.begin(); std::list< _PTR(SObject) >::iterator itSO = --listSO.end();
for ( ; itSO != listSO.end(); ++itSO ) { for ( ; itSO != listSO.end(); ++itSO ) {
_PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO ); _PTR(ChildIterator) it = aStudy->NewChildIterator( *itSO );
for (it->InitEx(false); it->More(); it->Next()) for (it->InitEx(false); it->More(); it->Next())
@ -1835,24 +1830,9 @@
if ( !SO ) continue; if ( !SO ) continue;
std::string anEntry = SO->GetID(); std::string anEntry = SO->GetID();
/** Erase graphical object **/ /** Erase graphical object and remove all its data **/
if(SO->FindAttribute(anAttr, "AttributeIOR")) { if(SO->FindAttribute(anAttr, "AttributeIOR")) {
SMESH::RemoveVisualObjectWithActors( anEntry.c_str(), true); SMESH::RemoveVisualObjectWithActors( anEntry.c_str(), true);
// ViewManagerList aViewMenegers = anApp->viewManagers();
// ViewManagerList::const_iterator it = aViewMenegers.begin();
// for( ; it != aViewMenegers.end(); it++) {
// SUIT_ViewManager* vm = *it;
// int nbSf = vm ? vm->getViewsCount() : 0;
// if(vm) {
// QVector<SUIT_ViewWindow*> aViews = vm->getViews();
// for(int i = 0; i < nbSf; i++){
// SUIT_ViewWindow *sf = aViews[i];
// if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.c_str())){
// SMESH::RemoveActor(sf,anActor);
// }
// }
// }
// }
} }
/** Remove an object from data structures **/ /** Remove an object from data structures **/
SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO )); SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( SO ));
@ -2529,10 +2509,10 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
if (vtkwnd) { if (vtkwnd) {
SALOME_ListIteratorOfListIO It( to_process ); SALOME_ListIteratorOfListIO It( to_process );
for ( ; It.More(); It.Next()) { for ( ; It.More(); It.Next()) {
MESSAGE("---"); MESSAGE("---");
Handle(SALOME_InteractiveObject) IOS = It.Value(); Handle(SALOME_InteractiveObject) IOS = It.Value();
if (IOS->hasEntry()) { if (IOS->hasEntry()) {
MESSAGE("---"); MESSAGE("---");
if (!SMESH::UpdateView(anAction, IOS->getEntry())) { if (!SMESH::UpdateView(anAction, IOS->getEntry())) {
SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged(); SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
break; // PAL16774 (Crash after display of many groups) break; // PAL16774 (Crash after display of many groups)
@ -2548,7 +2528,7 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
// PAL13338 + PAL15161 --> // PAL13338 + PAL15161 -->
if ( ( theCommandID==301 || theCommandID==302 ) && !checkLock(aStudy)) { if ( ( theCommandID==301 || theCommandID==302 ) && !checkLock(aStudy)) {
MESSAGE("anAction = SMESH::eDisplayOnly"); MESSAGE("anAction = SMESH::eDisplayOnly");
SMESH::UpdateView(); SMESH::UpdateView();
SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged(); SMESHGUI::GetSMESHGUI()->EmitSignalVisibilityChanged();
} }

View File

@ -65,10 +65,6 @@
#define SPACING 6 #define SPACING 6
#define MARGIN 11 #define MARGIN 11
//To disable automatic genericobj management, the following line should be commented.
//Otherwise, it should be uncommented. Refer to KERNEL_SRC/src/SALOMEDSImpl/SALOMEDSImpl_AttributeIOR.cxx
#define WITHGENERICOBJ
//================================================================================= //=================================================================================
// name : SMESHGUI_BuildCompoundDlg // name : SMESHGUI_BuildCompoundDlg
// Purpose : // Purpose :
@ -347,12 +343,6 @@ bool SMESHGUI_BuildCompoundDlg::ClickOnApply()
SMESHGUI::Modified(); SMESHGUI::Modified();
// obj has been published in study. Its refcount has been incremented.
// It is safe to decrement its refcount
// so that it will be destroyed when the entry in study will be removed
if (!CORBA::is_nil(aCompoundMesh))
aCompoundMesh->UnRegister();
return true; return true;
} }
return false; return false;

View File

@ -98,10 +98,6 @@ namespace
#define SPACING 6 #define SPACING 6
#define MARGIN 11 #define MARGIN 11
//To disable automatic genericobj management, the following line should be commented.
//Otherwise, it should be uncommented. Refer to KERNEL_SRC/src/SALOMEDSImpl/SALOMEDSImpl_AttributeIOR.cxx
#define WITHGENERICOBJ
//================================================================================ //================================================================================
/*! /*!
@ -338,13 +334,8 @@ bool SMESHGUI_CopyMeshDlg::ClickOnApply()
if( !newMesh->_is_nil() ) if( !newMesh->_is_nil() )
if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( newMesh ) ) if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( newMesh ) )
anEntryList.append( aSObject->GetID().c_str() ); anEntryList.append( aSObject->GetID().c_str() );
#ifdef WITHGENERICOBJ }
// obj has been published in study. Its refcount has been incremented. catch (...) {
// It is safe to decrement its refcount
// so that it will be destroyed when the entry in study will be removed
newMesh->UnRegister();
#endif
} catch (...) {
} }
mySMESHGUI->updateObjBrowser(true); mySMESHGUI->updateObjBrowser(true);

View File

@ -88,7 +88,7 @@ void SMESHGUI_GenericHypothesisCreator::create( SMESH::SMESH_Hypothesis_ptr init
create( false, theHypName, parent, obj, slot ); create( false, theHypName, parent, obj, slot );
} }
void SMESHGUI_GenericHypothesisCreator::create( bool isAlgo, void SMESHGUI_GenericHypothesisCreator::create( bool isAlgo,
const QString& theHypName, const QString& theHypName,
QWidget* theParent, QObject* obj, const QString& slot ) QWidget* theParent, QObject* obj, const QString& slot )
{ {
@ -100,27 +100,22 @@ void SMESHGUI_GenericHypothesisCreator::create( bool isAlgo,
if (isAlgo) { if (isAlgo) {
SMESH::SMESH_Hypothesis_var anAlgo = SMESH::SMESH_Hypothesis_var anAlgo =
SMESH::CreateHypothesis( hypType(), theHypName, isAlgo ); SMESH::CreateHypothesis( hypType(), theHypName, isAlgo );
if (!CORBA::is_nil(anAlgo)) anAlgo.out(); // avoid unused variable warning
anAlgo->UnRegister();
} }
else { else {
SMESH::SMESH_Hypothesis_var aHypothesis = SMESH::SMESH_Hypothesis_var aHypothesis =
SMESH::CreateHypothesis( hypType(), theHypName, false ); SMESH::CreateHypothesis( hypType(), theHypName, false );
editHypothesis( aHypothesis.in(), theHypName, theParent, obj, slot ); editHypothesis( aHypothesis.in(), theHypName, theParent, obj, slot );
if (!CORBA::is_nil(aHypothesis))
aHypothesis->UnRegister();
} }
} }
void SMESHGUI_GenericHypothesisCreator::edit( SMESH::SMESH_Hypothesis_ptr theHypothesis, void SMESHGUI_GenericHypothesisCreator::edit( SMESH::SMESH_Hypothesis_ptr theHypothesis,
const QString& theHypName, const QString& theHypName,
QWidget* theParent, QObject* obj, const QString& slot ) QWidget* theParent, QObject* obj, const QString& slot )
{ {
if( CORBA::is_nil( theHypothesis ) ) if( CORBA::is_nil( theHypothesis ) )
return; return;
MESSAGE("Edition of hypothesis");
myIsCreate = false; myIsCreate = false;
editHypothesis( theHypothesis, theHypName, theParent, obj, slot ); editHypothesis( theHypothesis, theHypName, theParent, obj, slot );

View File

@ -466,14 +466,6 @@ bool SMESHGUI_Make2DFrom3DOp::compute2DMesh( QStringList& theEntryList )
if ( !newMesh->_is_nil() ) { if ( !newMesh->_is_nil() ) {
if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( newMesh ) ) if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( newMesh ) )
theEntryList.append( aSObject->GetID().c_str() ); theEntryList.append( aSObject->GetID().c_str() );
#ifdef WITHGENERICOBJ
newMesh->UnRegister();
#endif
}
if ( !newGrp->_is_nil() ) {
#ifdef WITHGENERICOBJ
newGrp->UnRegister();
#endif
} }
ok = true; ok = true;

View File

@ -75,10 +75,6 @@
#include <SALOMEconfig.h> #include <SALOMEconfig.h>
#include CORBA_CLIENT_HEADER(SMESH_Gen) #include CORBA_CLIENT_HEADER(SMESH_Gen)
//To disable automatic genericobj management, the following line should be commented.
//Otherwise, it should be uncommented. Refer to KERNEL_SRC/src/SALOMEDSImpl/SALOMEDSImpl_AttributeIOR.cxx
#define WITHGENERICOBJ
//================================================================================ //================================================================================
/*! /*!
* \brief Constructor * \brief Constructor
@ -1103,14 +1099,10 @@ void SMESHGUI_MeshOp::createHypothesis(const int theDim,
// Call hypothesis creation server method (without GUI) // Call hypothesis creation server method (without GUI)
SMESH::SMESH_Hypothesis_var aHyp = SMESH::SMESH_Hypothesis_var aHyp =
SMESH::CreateHypothesis(theTypeName, aHypName, false); SMESH::CreateHypothesis(theTypeName, aHypName, false);
#ifdef WITHGENERICOBJ aHyp.out();
if (!CORBA::is_nil(aHyp)) }
aHyp->UnRegister(); else {
#endif
} else {
// Get hypotheses creator client (GUI) // Get hypotheses creator client (GUI)
// BUG 0020378
//SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(theTypeName);
SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(theTypeName); SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(theTypeName);
// Create hypothesis // Create hypothesis
@ -1179,10 +1171,7 @@ void SMESHGUI_MeshOp::createHypothesis(const int theDim,
else { else {
SMESH::SMESH_Hypothesis_var aHyp = SMESH::SMESH_Hypothesis_var aHyp =
SMESH::CreateHypothesis(theTypeName, aHypName, false); SMESH::CreateHypothesis(theTypeName, aHypName, false);
#ifdef WITHGENERICOBJ aHyp.out();
if (!CORBA::is_nil(aHyp))
aHyp->UnRegister();
#endif
} }
} }
@ -1653,13 +1642,6 @@ bool SMESHGUI_MeshOp::createMesh( QString& theMess, QStringList& theEntryList )
if ( !anAlgoVar->_is_nil() ) if ( !anAlgoVar->_is_nil() )
SMESH::AddHypothesisOnMesh( aMeshVar, anAlgoVar ); SMESH::AddHypothesisOnMesh( aMeshVar, anAlgoVar );
} }
#ifdef WITHGENERICOBJ
// obj has been published in study. Its refcount has been incremented.
// It is safe to decrement its refcount
// so that it will be destroyed when the entry in study will be removed
if (aMeshSO)
aMeshVar->UnRegister();
#endif
} }
return true; return true;
} }
@ -1918,32 +1900,25 @@ SMESH::SMESH_Hypothesis_var SMESHGUI_MeshOp::getAlgo( const int theDim )
if (aHypData) if (aHypData)
{ {
QString aClientLibName = aHypData->ClientLibName; QString aClientLibName = aHypData->ClientLibName;
if (aClientLibName == "") if ( aClientLibName.isEmpty() )
{ {
// Call hypothesis creation server method (without GUI) // Call hypothesis creation server method (without GUI)
SMESH::SMESH_Hypothesis_var aHyp = SMESH::SMESH_Hypothesis_var aHyp =
SMESH::CreateHypothesis(aHypName, aHypName, true); SMESH::CreateHypothesis(aHypName, aHypName, true);
#ifdef WITHGENERICOBJ aHyp.out();
if (!CORBA::is_nil(aHyp))
aHyp->UnRegister();
#endif
} }
else else
{ {
// Get hypotheses creator client (GUI) // Get hypotheses creator client (GUI)
// BUG 0020378
SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypName); SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypName);
// Create algorithm // Create algorithm
if (aCreator) if (aCreator)
aCreator->create(true, aHypName, myDlg, 0, QString::null ); aCreator->create( true, aHypName, myDlg, 0, QString::null );
else { else {
SMESH::SMESH_Hypothesis_var aHyp = SMESH::SMESH_Hypothesis_var aHyp =
SMESH::CreateHypothesis(aHypName, aHypName, true); SMESH::CreateHypothesis(aHypName, aHypName, true);
#ifdef WITHGENERICOBJ aHyp.out();
if (!CORBA::is_nil(aHyp))
aHyp->UnRegister();
#endif
} }
} }
QStringList tmpList; QStringList tmpList;

View File

@ -85,9 +85,6 @@ enum { MOVE_ELEMS_BUTTON = 0, COPY_ELEMS_BUTTON, MAKE_MESH_BUTTON }; //!< action
#define SPACING 8 #define SPACING 8
#define MARGIN 11 #define MARGIN 11
//To disable automatic genericobj management, the following line should be commented.
//Otherwise, it should be uncommented. Refer to KERNEL_SRC/src/SALOMEDSImpl/SALOMEDSImpl_AttributeIOR.cxx
#define WITHGENERICOBJ
//================================================================================= //=================================================================================
// class : SMESHGUI_RotationDlg() // class : SMESHGUI_RotationDlg()
@ -494,12 +491,6 @@ bool SMESHGUI_RotationDlg::ClickOnApply()
if (!mesh->_is_nil()) { if (!mesh->_is_nil()) {
if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( mesh ) ) if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( mesh ) )
anEntryList.append( aSObject->GetID().c_str() ); anEntryList.append( aSObject->GetID().c_str() );
#ifdef WITHGENERICOBJ
// obj has been published in study. Its refcount has been incremented.
// It is safe to decrement its refcount
// so that it will be destroyed when the entry in study will be removed
mesh->UnRegister();
#endif
} }
} }
} }
@ -511,12 +502,6 @@ bool SMESHGUI_RotationDlg::ClickOnApply()
if (!mesh->_is_nil()) { if (!mesh->_is_nil()) {
if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( mesh ) ) if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( mesh ) )
anEntryList.append( aSObject->GetID().c_str() ); anEntryList.append( aSObject->GetID().c_str() );
#ifdef WITHGENERICOBJ
// obj has been published in study. Its refcount has been incremented.
// It is safe to decrement its refcount
// so that it will be destroyed when the entry in study will be removed
mesh->UnRegister();
#endif
} }
} }
break; break;

View File

@ -100,10 +100,6 @@ private:
#define SPACING 6 #define SPACING 6
#define MARGIN 11 #define MARGIN 11
//To disable automatic genericobj management, the following line should be commented.
//Otherwise, it should be uncommented. Refer to KERNEL_SRC/src/SALOMEDSImpl/SALOMEDSImpl_AttributeIOR.cxx
#define WITHGENERICOBJ
//================================================================================= //=================================================================================
// class : SMESHGUI_ScaleDlg() // class : SMESHGUI_ScaleDlg()
// purpose : // purpose :
@ -536,12 +532,6 @@ bool SMESHGUI_ScaleDlg::ClickOnApply()
aName.toLatin1().data()); aName.toLatin1().data());
if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( mesh ) ) if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( mesh ) )
anEntryList.append( aSObject->GetID().c_str() ); anEntryList.append( aSObject->GetID().c_str() );
#ifdef WITHGENERICOBJ
// obj has been published in study. Its refcount has been incremented.
// It is safe to decrement its refcount
// so that it will be destroyed when the entry in study will be removed
mesh->UnRegister();
#endif
} }
} }
else { else {
@ -551,12 +541,6 @@ bool SMESHGUI_ScaleDlg::ClickOnApply()
LineEditNewMesh->text().toLatin1().data()); LineEditNewMesh->text().toLatin1().data());
if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( mesh ) ) if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( mesh ) )
anEntryList.append( aSObject->GetID().c_str() ); anEntryList.append( aSObject->GetID().c_str() );
#ifdef WITHGENERICOBJ
// obj has been published in study. Its refcount has been incremented.
// It is safe to decrement its refcount
// so that it will be destroyed when the entry in study will be removed
mesh->UnRegister();
#endif
} }
break; break;
} }

View File

@ -85,10 +85,6 @@ enum { MOVE_ELEMS_BUTTON = 0, COPY_ELEMS_BUTTON, MAKE_MESH_BUTTON }; //!< action
#define SPACING 6 #define SPACING 6
#define MARGIN 11 #define MARGIN 11
//To disable automatic genericobj management, the following line should be commented.
//Otherwise, it should be uncommented. Refer to KERNEL_SRC/src/SALOMEDSImpl/SALOMEDSImpl_AttributeIOR.cxx
#define WITHGENERICOBJ
//================================================================================= //=================================================================================
// class : SMESHGUI_SymmetryDlg() // class : SMESHGUI_SymmetryDlg()
// purpose : // purpose :
@ -556,12 +552,6 @@ bool SMESHGUI_SymmetryDlg::ClickOnApply()
aName.toLatin1().data()); aName.toLatin1().data());
if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( mesh ) ) if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( mesh ) )
anEntryList.append( aSObject->GetID().c_str() ); anEntryList.append( aSObject->GetID().c_str() );
#ifdef WITHGENERICOBJ
// obj has been published in study. Its refcount has been incremented.
// It is safe to decrement its refcount
// so that it will be destroyed when the entry in study will be removed
mesh->UnRegister();
#endif
} }
else { else {
SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[0]->GetMeshEditor(); SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[0]->GetMeshEditor();
@ -570,12 +560,6 @@ bool SMESHGUI_SymmetryDlg::ClickOnApply()
LineEditNewMesh->text().toLatin1().data()); LineEditNewMesh->text().toLatin1().data());
if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( mesh ) ) if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( mesh ) )
anEntryList.append( aSObject->GetID().c_str() ); anEntryList.append( aSObject->GetID().c_str() );
#ifdef WITHGENERICOBJ
// obj has been published in study. Its refcount has been incremented.
// It is safe to decrement its refcount
// so that it will be destroyed when the entry in study will be removed
mesh->UnRegister();
#endif
} }
} }
break; break;

View File

@ -559,11 +559,6 @@ bool SMESHGUI_TranslationDlg::ClickOnApply()
aName.toLatin1().data()); aName.toLatin1().data());
if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( mesh ) ) if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( mesh ) )
anEntryList.append( aSObject->GetID().c_str() ); anEntryList.append( aSObject->GetID().c_str() );
// obj has been published in study. Its refcount has been incremented.
// It is safe to decrement its refcount
// so that it will be destroyed when the entry in study will be removed
mesh->UnRegister();
} }
} }
else { else {
@ -573,11 +568,6 @@ bool SMESHGUI_TranslationDlg::ClickOnApply()
LineEditNewMesh->text().toLatin1().data()); LineEditNewMesh->text().toLatin1().data());
if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( mesh ) ) if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( mesh ) )
anEntryList.append( aSObject->GetID().c_str() ); anEntryList.append( aSObject->GetID().c_str() );
// obj has been published in study. Its refcount has been incremented.
// It is safe to decrement its refcount
// so that it will be destroyed when the entry in study will be removed
mesh->UnRegister();
} }
break; break;
} }