Fix SIGSEGV

Fix problem with preview
This commit is contained in:
vsr 2011-04-08 07:19:54 +00:00
parent 346dbd8b2f
commit b72e9263a6
2 changed files with 26 additions and 31 deletions

View File

@ -431,15 +431,16 @@ bool RepairGUI_GlueDlg::execute( ObjectList& objects )
{ {
if ( IsPreview() ) { if ( IsPreview() ) {
// if this method is used for displaying preview then we must detect glue faces only // if this method is used for displaying preview then we must detect glue faces only
ObjectList::iterator anIter; for ( int i = 0; i < myTmpObjs.count(); i++ ) {
for ( anIter = myTmpObjs.begin(); anIter != myTmpObjs.end(); ++anIter ) myTmpObjs[i].get()->Register(); // increment counter, since calling function will call UnRegister()
objects.push_back( GEOM::GEOM_Object::_duplicate( *anIter ) ); objects.push_back( myTmpObjs[i].copy() );
return myTmpObjs.size() ? true : false; }
return !myTmpObjs.isEmpty();
} // IsPreview } // IsPreview
// Make glue face by list. // Make glue face by list.
// Iterate through myTmpObjs and verifies where each object is currently selected or not. // Iterate through myTmpObjs and verifies where each object is currently selected or not.
QMap<QString, char> selected; QSet<QString> selected;
// Get names of selected objects // Get names of selected objects
LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
@ -448,24 +449,22 @@ bool RepairGUI_GlueDlg::execute( ObjectList& objects )
SALOME_ListIteratorOfListIO it (aSelList); SALOME_ListIteratorOfListIO it (aSelList);
for (; it.More(); it.Next()) for (; it.More(); it.Next())
selected.insert(it.Value()->getName(), 0); selected.insert(it.Value()->getName());
// Iterate through result and select objects with names from selection // Iterate through result and select objects with names from selection
// ObjectList toRemoveFromEnggine; // ObjectList toRemoveFromEnggine;
ObjectList toGlue;
ObjectList::iterator anIter;
for ( anIter = myTmpObjs.begin(); anIter != myTmpObjs.end(); ++anIter ) {
if ( selected.contains( myGeomGUI->getApp()->orb()->object_to_string(*anIter) ) )
toGlue.push_back( *anIter );
}
// make glue faces // make glue faces
GEOM::ListOfGO_var aListForGlue = new GEOM::ListOfGO(); GEOM::ListOfGO_var aListForGlue = new GEOM::ListOfGO();
aListForGlue->length( toGlue.size() ); aListForGlue->length( myTmpObjs.count() );
ObjectList::iterator anIter3 = toGlue.begin(); int added = 0;
for ( int i = 0; anIter3 != toGlue.end(); ++anIter3, ++i ) for ( int i = 0; i < myTmpObjs.count(); i++ ) {
aListForGlue[ i ] = *anIter3; CORBA::String_var tmpior = myGeomGUI->getApp()->orb()->object_to_string(myTmpObjs[i].get());
GEOM::GEOM_Object_var anObj = anOper->MakeGlueFacesByList( myObject, myTolEdt2->value(), aListForGlue, true ); if ( selected.contains( tmpior.in() ) )
aListForGlue[ added++ ] = myTmpObjs[i].copy();
}
GEOM::GEOM_Object_var anObj = anOper->MakeGlueFacesByList( myObject, myTolEdt2->value(), aListForGlue.in(), true );
aResult = !anObj->_is_nil(); aResult = !anObj->_is_nil();
@ -652,13 +651,13 @@ void RepairGUI_GlueDlg::onDetect()
globalSelection( GEOM_ALLSHAPES ); globalSelection( GEOM_ALLSHAPES );
GEOM::GEOM_IShapesOperations_var anOper = GEOM::GEOM_IShapesOperations::_narrow( getOperation() ); GEOM::GEOM_IShapesOperations_var anOper = GEOM::GEOM_IShapesOperations::_narrow( getOperation() );
GEOM::ListOfGO_var aList = anOper->GetGlueFaces( myObject, myTolEdt2->value() ); GEOM::ListOfGO_var aList = anOper->GetGlueFaces( myObject.in(), myTolEdt2->value() );
for ( int i = 0, n = aList->length(); i < n; i++ ) for ( int i = 0, n = aList->length(); i < n; i++ )
myTmpObjs.push_back(GEOM::GEOM_Object::_duplicate(aList[i])); myTmpObjs << GEOM::GeomObjPtr( aList[i].in() );
if ( myTmpObjs.size() > 0 ) { if ( !myTmpObjs.isEmpty() ) {
msg = tr( "FACES_FOR_GLUING_ARE_DETECTED" ).arg( myTmpObjs.size() ); msg = tr( "FACES_FOR_GLUING_ARE_DETECTED" ).arg( myTmpObjs.count() );
mySubShapesChk->setChecked( true ); mySubShapesChk->setChecked( true );
} }
else { else {
@ -698,7 +697,7 @@ void RepairGUI_GlueDlg::activateSelection()
if ( !mySubShapesChk->isChecked() ) if ( !mySubShapesChk->isChecked() )
globalSelection( GEOM_ALLSHAPES ); globalSelection( GEOM_ALLSHAPES );
else { else {
displayPreview( true, false, false, 2/*line width*/, 1/*display mode*/, Quantity_NOC_RED ); displayPreview( true, true, false, false, 2/*line width*/, 1/*display mode*/, Quantity_NOC_RED );
disconnect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ), disconnect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
this, SLOT( SelectionIntoArgument() ) ) ; this, SLOT( SelectionIntoArgument() ) ) ;
globalSelection( GEOM_PREVIEW ); globalSelection( GEOM_PREVIEW );
@ -727,11 +726,9 @@ void RepairGUI_GlueDlg::updateButtonState()
SALOME_ListIO aSelList; SALOME_ListIO aSelList;
aSelMgr->selectedObjects(aSelList); aSelMgr->selectedObjects(aSelList);
bool wasSelected = false;
SALOME_ListIteratorOfListIO it (aSelList); SALOME_ListIteratorOfListIO it (aSelList);
if (it.More() > 0) bool wasSelected = it.More() > 0;
wasSelected = true; bool wasDetected = !myTmpObjs.isEmpty();
bool wasDetected = myTmpObjs.size() ? true : false;
buttonOk()->setEnabled( hasMainObj && wasDetected && wasSelected ); buttonOk()->setEnabled( hasMainObj && wasDetected && wasSelected );
buttonApply()->setEnabled( hasMainObj && wasDetected && wasSelected ); buttonApply()->setEnabled( hasMainObj && wasDetected && wasSelected );
mySubShapesChk->setEnabled( hasMainObj && wasDetected ); mySubShapesChk->setEnabled( hasMainObj && wasDetected );
@ -747,10 +744,6 @@ void RepairGUI_GlueDlg::updateButtonState()
//================================================================================= //=================================================================================
void RepairGUI_GlueDlg::clearTemporary() void RepairGUI_GlueDlg::clearTemporary()
{ {
ObjectList::iterator anIter;
for ( anIter = myTmpObjs.begin(); anIter != myTmpObjs.end(); ++anIter )
getGeomEngine()->RemoveObject(*anIter);
myTmpObjs.clear(); myTmpObjs.clear();
} }

View File

@ -29,6 +29,8 @@
#include <GEOMBase_Skeleton.h> #include <GEOMBase_Skeleton.h>
#include <QList>
class DlgRef_1SelExt; class DlgRef_1SelExt;
class SalomeApp_DoubleSpinBox; class SalomeApp_DoubleSpinBox;
class QPushButton; class QPushButton;
@ -70,7 +72,7 @@ private:
private: private:
GEOM::GEOM_Object_var myObject; GEOM::GEOM_Object_var myObject;
ObjectList myTmpObjs; QList<GEOM::GeomObjPtr> myTmpObjs;
DlgRef_1SelExt* GroupPoints; DlgRef_1SelExt* GroupPoints;
DlgRef_1SelExt* GroupPoints2; DlgRef_1SelExt* GroupPoints2;