From: vsr Date: Fri, 8 Apr 2011 07:19:54 +0000 (+0000) Subject: Fix SIGSEGV X-Git-Tag: V6_3_0a1~11 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=b72e9263a6932f2e531717bf0747e906fa025c5f;p=modules%2Fgeom.git Fix SIGSEGV Fix problem with preview --- diff --git a/src/RepairGUI/RepairGUI_GlueDlg.cxx b/src/RepairGUI/RepairGUI_GlueDlg.cxx index d79190e23..a7ca9028f 100644 --- a/src/RepairGUI/RepairGUI_GlueDlg.cxx +++ b/src/RepairGUI/RepairGUI_GlueDlg.cxx @@ -431,15 +431,16 @@ bool RepairGUI_GlueDlg::execute( ObjectList& objects ) { if ( IsPreview() ) { // if this method is used for displaying preview then we must detect glue faces only - ObjectList::iterator anIter; - for ( anIter = myTmpObjs.begin(); anIter != myTmpObjs.end(); ++anIter ) - objects.push_back( GEOM::GEOM_Object::_duplicate( *anIter ) ); - return myTmpObjs.size() ? true : false; + for ( int i = 0; i < myTmpObjs.count(); i++ ) { + myTmpObjs[i].get()->Register(); // increment counter, since calling function will call UnRegister() + objects.push_back( myTmpObjs[i].copy() ); + } + return !myTmpObjs.isEmpty(); } // IsPreview // Make glue face by list. // Iterate through myTmpObjs and verifies where each object is currently selected or not. - QMap selected; + QSet selected; // Get names of selected objects LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); @@ -448,24 +449,22 @@ bool RepairGUI_GlueDlg::execute( ObjectList& objects ) SALOME_ListIteratorOfListIO it (aSelList); 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 // 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 GEOM::ListOfGO_var aListForGlue = new GEOM::ListOfGO(); - aListForGlue->length( toGlue.size() ); - ObjectList::iterator anIter3 = toGlue.begin(); - for ( int i = 0; anIter3 != toGlue.end(); ++anIter3, ++i ) - aListForGlue[ i ] = *anIter3; - GEOM::GEOM_Object_var anObj = anOper->MakeGlueFacesByList( myObject, myTolEdt2->value(), aListForGlue, true ); + aListForGlue->length( myTmpObjs.count() ); + int added = 0; + for ( int i = 0; i < myTmpObjs.count(); i++ ) { + CORBA::String_var tmpior = myGeomGUI->getApp()->orb()->object_to_string(myTmpObjs[i].get()); + 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(); @@ -652,13 +651,13 @@ void RepairGUI_GlueDlg::onDetect() globalSelection( GEOM_ALLSHAPES ); 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++ ) - myTmpObjs.push_back(GEOM::GEOM_Object::_duplicate(aList[i])); + myTmpObjs << GEOM::GeomObjPtr( aList[i].in() ); - if ( myTmpObjs.size() > 0 ) { - msg = tr( "FACES_FOR_GLUING_ARE_DETECTED" ).arg( myTmpObjs.size() ); + if ( !myTmpObjs.isEmpty() ) { + msg = tr( "FACES_FOR_GLUING_ARE_DETECTED" ).arg( myTmpObjs.count() ); mySubShapesChk->setChecked( true ); } else { @@ -698,7 +697,7 @@ void RepairGUI_GlueDlg::activateSelection() if ( !mySubShapesChk->isChecked() ) globalSelection( GEOM_ALLSHAPES ); 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() ), this, SLOT( SelectionIntoArgument() ) ) ; globalSelection( GEOM_PREVIEW ); @@ -727,11 +726,9 @@ void RepairGUI_GlueDlg::updateButtonState() SALOME_ListIO aSelList; aSelMgr->selectedObjects(aSelList); - bool wasSelected = false; SALOME_ListIteratorOfListIO it (aSelList); - if (it.More() > 0) - wasSelected = true; - bool wasDetected = myTmpObjs.size() ? true : false; + bool wasSelected = it.More() > 0; + bool wasDetected = !myTmpObjs.isEmpty(); buttonOk()->setEnabled( hasMainObj && wasDetected && wasSelected ); buttonApply()->setEnabled( hasMainObj && wasDetected && wasSelected ); mySubShapesChk->setEnabled( hasMainObj && wasDetected ); @@ -747,10 +744,6 @@ void RepairGUI_GlueDlg::updateButtonState() //================================================================================= void RepairGUI_GlueDlg::clearTemporary() { - ObjectList::iterator anIter; - for ( anIter = myTmpObjs.begin(); anIter != myTmpObjs.end(); ++anIter ) - getGeomEngine()->RemoveObject(*anIter); - myTmpObjs.clear(); } diff --git a/src/RepairGUI/RepairGUI_GlueDlg.h b/src/RepairGUI/RepairGUI_GlueDlg.h index c8e06bc9d..e6e58107c 100644 --- a/src/RepairGUI/RepairGUI_GlueDlg.h +++ b/src/RepairGUI/RepairGUI_GlueDlg.h @@ -29,6 +29,8 @@ #include +#include + class DlgRef_1SelExt; class SalomeApp_DoubleSpinBox; class QPushButton; @@ -70,7 +72,7 @@ private: private: GEOM::GEOM_Object_var myObject; - ObjectList myTmpObjs; + QList myTmpObjs; DlgRef_1SelExt* GroupPoints; DlgRef_1SelExt* GroupPoints2;