mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-19 13:40:49 +03:00
0031877: DRAW - some Visualization commands are not protected against uninitialized viewer
Added protections in DRAW commands against accessing Null context Added test bugs demo bug31877
This commit is contained in:
@@ -1337,6 +1337,12 @@ static int VDispMode (Draw_Interpretor& , Standard_Integer argc, const char** ar
|
||||
? TypeOfDispOperation_UnsetDispMode
|
||||
: TypeOfDispOperation_SetDispMode;
|
||||
Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext();
|
||||
if (aCtx.IsNull())
|
||||
{
|
||||
Message::SendFail ("Error: no active viewer");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (aType == TypeOfDispOperation_UnsetDispMode)
|
||||
{
|
||||
if (argc == 1)
|
||||
@@ -1402,6 +1408,11 @@ static int VSubInt(Draw_Interpretor& di, Standard_Integer argc, const char** arg
|
||||
if(argc==1) return 1;
|
||||
Standard_Integer On = Draw::Atoi(argv[1]);
|
||||
const Handle(AIS_InteractiveContext)& Ctx = ViewerTest::GetAISContext();
|
||||
if (Ctx.IsNull())
|
||||
{
|
||||
Message::SendFail ("Error: no active viewer");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(argc==2)
|
||||
{
|
||||
@@ -5634,6 +5645,12 @@ Standard_Boolean ViewerTest::PickShapes (const TopAbs_ShapeEnum theShapeType,
|
||||
|
||||
// step 1: prepare the data
|
||||
Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext();
|
||||
if (aCtx.IsNull())
|
||||
{
|
||||
Message::SendFail ("Error: no active viewer");
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
aCtx->RemoveFilters();
|
||||
AIS_ListOfInteractive aDispObjects;
|
||||
aCtx->DisplayedObjects (aDispObjects);
|
||||
|
@@ -701,6 +701,12 @@ static int VTrihedron (Draw_Interpretor& ,
|
||||
static int VSize (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
|
||||
|
||||
{
|
||||
if (TheAISContext().IsNull())
|
||||
{
|
||||
Message::SendFail ("Error: no active viewer");
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Declaration de booleens
|
||||
Standard_Boolean ThereIsName;
|
||||
Standard_Boolean ThereIsCurrent;
|
||||
@@ -854,6 +860,12 @@ static int VPlaneTrihedron (Draw_Interpretor& di, Standard_Integer argc, const c
|
||||
// Verification des arguments
|
||||
if ( argc!=2) {di<<argv[0]<<" error\n"; return 1;}
|
||||
|
||||
if (TheAISContext().IsNull())
|
||||
{
|
||||
Message::SendFail ("Error: no active viewer");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (TheAISContext()->NbSelected() != 1)
|
||||
{
|
||||
Message::SendFail ("Error: Wrong number of selected shapes.");
|
||||
|
Reference in New Issue
Block a user