mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-16 10:08:36 +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:
parent
9f9490e1ae
commit
f41fd243b6
@ -1337,6 +1337,12 @@ static int VDispMode (Draw_Interpretor& , Standard_Integer argc, const char** ar
|
|||||||
? TypeOfDispOperation_UnsetDispMode
|
? TypeOfDispOperation_UnsetDispMode
|
||||||
: TypeOfDispOperation_SetDispMode;
|
: TypeOfDispOperation_SetDispMode;
|
||||||
Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext();
|
Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext();
|
||||||
|
if (aCtx.IsNull())
|
||||||
|
{
|
||||||
|
Message::SendFail ("Error: no active viewer");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
if (aType == TypeOfDispOperation_UnsetDispMode)
|
if (aType == TypeOfDispOperation_UnsetDispMode)
|
||||||
{
|
{
|
||||||
if (argc == 1)
|
if (argc == 1)
|
||||||
@ -1402,6 +1408,11 @@ static int VSubInt(Draw_Interpretor& di, Standard_Integer argc, const char** arg
|
|||||||
if(argc==1) return 1;
|
if(argc==1) return 1;
|
||||||
Standard_Integer On = Draw::Atoi(argv[1]);
|
Standard_Integer On = Draw::Atoi(argv[1]);
|
||||||
const Handle(AIS_InteractiveContext)& Ctx = ViewerTest::GetAISContext();
|
const Handle(AIS_InteractiveContext)& Ctx = ViewerTest::GetAISContext();
|
||||||
|
if (Ctx.IsNull())
|
||||||
|
{
|
||||||
|
Message::SendFail ("Error: no active viewer");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
if(argc==2)
|
if(argc==2)
|
||||||
{
|
{
|
||||||
@ -5634,6 +5645,12 @@ Standard_Boolean ViewerTest::PickShapes (const TopAbs_ShapeEnum theShapeType,
|
|||||||
|
|
||||||
// step 1: prepare the data
|
// step 1: prepare the data
|
||||||
Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext();
|
Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext();
|
||||||
|
if (aCtx.IsNull())
|
||||||
|
{
|
||||||
|
Message::SendFail ("Error: no active viewer");
|
||||||
|
return Standard_False;
|
||||||
|
}
|
||||||
|
|
||||||
aCtx->RemoveFilters();
|
aCtx->RemoveFilters();
|
||||||
AIS_ListOfInteractive aDispObjects;
|
AIS_ListOfInteractive aDispObjects;
|
||||||
aCtx->DisplayedObjects (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)
|
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
|
// Declaration de booleens
|
||||||
Standard_Boolean ThereIsName;
|
Standard_Boolean ThereIsName;
|
||||||
Standard_Boolean ThereIsCurrent;
|
Standard_Boolean ThereIsCurrent;
|
||||||
@ -854,6 +860,12 @@ static int VPlaneTrihedron (Draw_Interpretor& di, Standard_Integer argc, const c
|
|||||||
// Verification des arguments
|
// Verification des arguments
|
||||||
if ( argc!=2) {di<<argv[0]<<" error\n"; return 1;}
|
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)
|
if (TheAISContext()->NbSelected() != 1)
|
||||||
{
|
{
|
||||||
Message::SendFail ("Error: Wrong number of selected shapes.");
|
Message::SendFail ("Error: Wrong number of selected shapes.");
|
||||||
|
11
tests/bugs/demo/bug31877
Normal file
11
tests/bugs/demo/bug31877
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
puts "# ======================================================================"
|
||||||
|
puts "# 0031877: DRAW - some Visualization commands are not protected against uninitialized viewer"
|
||||||
|
puts "# ======================================================================"
|
||||||
|
|
||||||
|
puts "REQUIRED 31877 ALL: Error: no active viewer"
|
||||||
|
|
||||||
|
pload VISUALIZATION
|
||||||
|
catch {vsetdispmode 1}
|
||||||
|
catch {vpickshapes}
|
||||||
|
catch {vsize}
|
||||||
|
catch {vplanetri a}
|
Loading…
x
Reference in New Issue
Block a user