mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-16 10:08:36 +03:00
0028310: Visualization - crash on iteration through detected interactive objects
AIS_InteractiveContext::Remove (anIObj, ...) removes object from sequence of detected owners. Therefore further iteration on detected will not require updating this list with ::MoveTo(). Additional modification includes incrementing properly the iterator of CurrentDetectedObject and resets iterator of Highlighted detected objects, because nothing is really highlighted after that.
This commit is contained in:
parent
c5ec75471a
commit
f2a88e54e8
@ -2418,13 +2418,31 @@ void AIS_InteractiveContext::ClearGlobal (const Handle(AIS_InteractiveObject)& t
|
|||||||
|
|
||||||
// Object removes from Detected sequence
|
// Object removes from Detected sequence
|
||||||
Standard_DISABLE_DEPRECATION_WARNINGS
|
Standard_DISABLE_DEPRECATION_WARNINGS
|
||||||
for (Standard_Integer aDetIter = myDetectedSeq.Lower(); aDetIter <= myDetectedSeq.Upper(); ++aDetIter)
|
for (Standard_Integer aDetIter = myDetectedSeq.Lower(); aDetIter <= myDetectedSeq.Upper();)
|
||||||
{
|
{
|
||||||
Handle(AIS_InteractiveObject) anObj = DetectedCurrentObject();
|
Handle(SelectMgr_EntityOwner) aPicked = myMainSel->Picked (myDetectedSeq (aDetIter));
|
||||||
|
Handle(AIS_InteractiveObject) anObj;
|
||||||
|
if (!aPicked.IsNull())
|
||||||
|
{
|
||||||
|
anObj = Handle(AIS_InteractiveObject)::DownCast (aPicked->Selectable());
|
||||||
|
}
|
||||||
|
|
||||||
if (!anObj.IsNull()
|
if (!anObj.IsNull()
|
||||||
&& anObj != theIObj)
|
&& anObj == theIObj)
|
||||||
{
|
{
|
||||||
myDetectedSeq.Remove (aDetIter);
|
myDetectedSeq.Remove (aDetIter);
|
||||||
|
if (myCurDetected == aDetIter)
|
||||||
|
{
|
||||||
|
myCurDetected = Min (myDetectedSeq.Upper(), aDetIter);
|
||||||
|
}
|
||||||
|
if (myCurHighlighted == aDetIter)
|
||||||
|
{
|
||||||
|
myCurHighlighted = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
aDetIter++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Standard_ENABLE_DEPRECATION_WARNINGS
|
Standard_ENABLE_DEPRECATION_WARNINGS
|
||||||
@ -2448,6 +2466,7 @@ void AIS_InteractiveContext::ClearGlobal (const Handle(AIS_InteractiveObject)& t
|
|||||||
{
|
{
|
||||||
clearDynamicHighlight();
|
clearDynamicHighlight();
|
||||||
myLastinMain.Nullify();
|
myLastinMain.Nullify();
|
||||||
|
myLastPicked.Nullify();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5358,6 +5358,41 @@ static Standard_Integer OCC27893 (Draw_Interpretor& /*theDI*/, Standard_Integer
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//========================================================================
|
||||||
|
//function : OCC28310
|
||||||
|
//purpose : Tests validness of iterator in AIS_InteractiveContext after
|
||||||
|
// an removing object from it
|
||||||
|
//========================================================================
|
||||||
|
static Standard_Integer OCC28310 (Draw_Interpretor& /*theDI*/, Standard_Integer /*theArgc*/, const char** theArgv)
|
||||||
|
{
|
||||||
|
const Handle(AIS_InteractiveContext)& aCtx = ViewerTest::GetAISContext();
|
||||||
|
if (aCtx.IsNull())
|
||||||
|
{
|
||||||
|
std::cout << "No interactive context. Use 'vinit' command before " << theArgv[0] << "\n";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
TopoDS_Shape aBox = BRepPrimAPI_MakeBox (10.0, 10.0, 10.0).Shape();
|
||||||
|
Handle(AIS_InteractiveObject) aBoxObj = new AIS_Shape (aBox);
|
||||||
|
aCtx->Display (aBoxObj, AIS_Shaded, 0, Standard_False);
|
||||||
|
ViewerTest::CurrentView()->FitAll();
|
||||||
|
aCtx->MoveTo (200, 200, ViewerTest::CurrentView());
|
||||||
|
aCtx->Select();
|
||||||
|
|
||||||
|
aCtx->Remove (aBoxObj, Standard_True);
|
||||||
|
// nullify the object explicitly to simulate situation in project,
|
||||||
|
// when ::Remove is called from another method and the object is destroyed
|
||||||
|
// before ::DetectedInteractive is called
|
||||||
|
aBoxObj.Nullify();
|
||||||
|
|
||||||
|
for (aCtx->InitDetected(); aCtx->MoreDetected(); aCtx->NextDetected())
|
||||||
|
{
|
||||||
|
Handle(AIS_InteractiveObject) anObj = aCtx->DetectedInteractive();
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
//========================================================================
|
//========================================================================
|
||||||
//function : Commands_19
|
//function : Commands_19
|
||||||
//purpose :
|
//purpose :
|
||||||
@ -5494,5 +5529,8 @@ void QABugs::Commands_19(Draw_Interpretor& theCommands) {
|
|||||||
theCommands.Add ("OCC27893",
|
theCommands.Add ("OCC27893",
|
||||||
"OCC27893: Creates a box and selects it via AIS_InteractiveContext API",
|
"OCC27893: Creates a box and selects it via AIS_InteractiveContext API",
|
||||||
__FILE__, OCC27893, group);
|
__FILE__, OCC27893, group);
|
||||||
|
theCommands.Add("OCC28310",
|
||||||
|
"OCC28310: Tests validness of iterator in AIS_InteractiveContext after an removing object from it",
|
||||||
|
__FILE__, OCC28310, group);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
14
tests/bugs/vis/bug28310
Normal file
14
tests/bugs/vis/bug28310
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
puts "==========="
|
||||||
|
puts "OCC28310"
|
||||||
|
puts "==========="
|
||||||
|
puts ""
|
||||||
|
##########################################################################
|
||||||
|
# Visualization - crash on iteration through detected interactive objects
|
||||||
|
##########################################################################
|
||||||
|
|
||||||
|
pload VISUALIZATION QAcommands
|
||||||
|
|
||||||
|
vinit View1
|
||||||
|
|
||||||
|
# Sequence of C++ commands crashes the application
|
||||||
|
OCC28310
|
Loading…
x
Reference in New Issue
Block a user