From 24de79c3a5694af1d02437a7dccd1624d9a039ca Mon Sep 17 00:00:00 2001 From: gka Date: Fri, 14 Dec 2012 16:17:11 +0400 Subject: [PATCH] 0023523: In session DRAW it is impossible to close document having name already once closed document. Added destructor for TDocStd_Document which performs destruction of document in logical order in order to avoid exception when Undo and Redo fields are destructed after THF_Data field. Added removing name of closed document from tcl variables in the DRAW in order to avoid exception during use the same name for new document. Modification to avoid compilation error class ViewerTest Minor correction in test caf basic G3 --- src/CDM/CDM_Document.cdl | 5 +++-- src/DDocStd/DDocStd_ApplicationCommands.cxx | 3 +++ src/TDocStd/TDocStd_Document.cdl | 6 +++--- src/TDocStd/TDocStd_Document.cxx | 15 +++++++++++---- src/ViewerTest/ViewerTest.cdl | 5 +++-- src/ViewerTest/ViewerTest.cxx | 8 +++++--- tests/bugs/caf/bug23489 | 2 +- tests/caf/basic/G3 | 2 +- tests/caf/bugs/B6 | 1 + tests/caf/named_shape/E1 | 2 +- tests/caf/named_shape/E2 | 2 +- tests/caf/named_shape/E3 | 2 +- tests/caf/named_shape/E4 | 2 +- tests/caf/named_shape/E5 | 2 +- tests/caf/named_shape/E6 | 2 +- tests/caf/named_shape/E7 | 2 +- tests/caf/named_shape/E8 | 2 +- tests/caf/named_shape/E9 | 2 +- tests/caf/named_shape/F1 | 2 +- tests/caf/named_shape/F2 | 2 +- tests/caf/named_shape/F3 | 2 +- tests/caf/named_shape/F4 | 2 +- tests/caf/named_shape/F5 | 2 +- tests/caf/named_shape/F6 | 2 +- tests/caf/named_shape/F7 | 2 +- 25 files changed, 47 insertions(+), 32 deletions(-) diff --git a/src/CDM/CDM_Document.cdl b/src/CDM/CDM_Document.cdl index 221a5adf28..3cc2eeb44d 100755 --- a/src/CDM/CDM_Document.cdl +++ b/src/CDM/CDM_Document.cdl @@ -68,9 +68,10 @@ is Initialize; - Destroy(me: mutable) is protected; - ---C++: alias ~ ---Category: virtual methods + Destroy(me: mutable) is virtual protected; + ---C++: alias ~ + Update(me: mutable; aToDocument: Document from CDM; aReferenceIdentifier: Integer from Standard; aModifContext: Address from Standard) ---Purpose: The Update method will be called once for each diff --git a/src/DDocStd/DDocStd_ApplicationCommands.cxx b/src/DDocStd/DDocStd_ApplicationCommands.cxx index dacd083e4a..593fde7e11 100755 --- a/src/DDocStd/DDocStd_ApplicationCommands.cxx +++ b/src/DDocStd/DDocStd_ApplicationCommands.cxx @@ -297,8 +297,11 @@ static Standard_Integer DDocStd_Close (Draw_Interpretor& di, Handle(TDocStd_Application) A; if (!DDocStd::Find(A)) return 1; A->Close(D); + Handle(Draw_Drawable3D) DD = Draw::Get(a[1],Standard_False); dout.RemoveDrawable (DD); + Handle(Draw_Drawable3D) aDNull; + Draw::Set(a[1], aDNull); return 0; } di << "DDocStd_Close : Error" << "\n"; diff --git a/src/TDocStd/TDocStd_Document.cdl b/src/TDocStd/TDocStd_Document.cdl index b10bdce10a..938f67cd2a 100755 --- a/src/TDocStd/TDocStd_Document.cdl +++ b/src/TDocStd/TDocStd_Document.cdl @@ -49,9 +49,9 @@ uses Data from TDF, is - --Destroy (me : mutable); - ---Purpose: Will Abort any execution, and commit the Undo transaction - -----C++: alias ~ + Destroy (me : mutable) is redefined protected; + ---Purpose: Will Abort any execution, clear fields + ---C++: alias ~ Get (myclass; L : Label from TDF) ---Purpose: returns the document which contains . raises an diff --git a/src/TDocStd/TDocStd_Document.cxx b/src/TDocStd/TDocStd_Document.cxx index df85eaf30a..2c141623c1 100755 --- a/src/TDocStd/TDocStd_Document.cxx +++ b/src/TDocStd/TDocStd_Document.cxx @@ -74,10 +74,17 @@ Handle(TDocStd_Document) TDocStd_Document::Get (const TDF_Label& acces) //function : Destroy //purpose : //======================================================================= -// void TDocStd_Document::Destroy() -// { -// myUndoTransaction.Commit(); // no needs to store the Undo -// } +void TDocStd_Document::Destroy() +{ + SetModificationMode(Standard_False); + myData->Root().ForgetAllAttributes(Standard_True); + myUndoTransaction.Abort(); + if(!myUndoFILO.IsEmpty()) + myUndoFILO.Clear(); + ClearUndos(); + myData.Nullify(); + +} //======================================================================= diff --git a/src/ViewerTest/ViewerTest.cdl b/src/ViewerTest/ViewerTest.cdl index 8ee7d9f4af..e254c54dd1 100755 --- a/src/ViewerTest/ViewerTest.cdl +++ b/src/ViewerTest/ViewerTest.cdl @@ -135,7 +135,7 @@ is GetCollectorFromContext returns Viewer from V3d; GetAISContext returns InteractiveContext from AIS; - + ---C++: return const & GetNISContext returns InteractiveContext from NIS; ---C++: return & @@ -144,7 +144,8 @@ is SetNISContext (aContext: InteractiveContext from NIS); CurrentView returns View from V3d; - + ---C++: return const & + CurrentView (aViou:View from V3d); Clear ; diff --git a/src/ViewerTest/ViewerTest.cxx b/src/ViewerTest/ViewerTest.cxx index f3146c65b8..0efa670d68 100755 --- a/src/ViewerTest/ViewerTest.cxx +++ b/src/ViewerTest/ViewerTest.cxx @@ -334,17 +334,19 @@ static void VwrTst_InitEventMgr(const Handle(NIS_View)& aView, theEventMgrs.Prepend(new ViewerTest_EventManager(aView, Ctx)); } -static Handle(V3d_View)& a3DView(){ +static Handle(V3d_View)& a3DView() +{ static Handle(V3d_View) Viou; return Viou; } + Standard_EXPORT Handle(AIS_InteractiveContext)& TheAISContext(){ static Handle(AIS_InteractiveContext) aContext; return aContext; } -Handle(V3d_View) ViewerTest::CurrentView() +const Handle(V3d_View)& ViewerTest::CurrentView() { return a3DView(); } @@ -363,7 +365,7 @@ Standard_EXPORT const Handle(NIS_InteractiveContext)& TheNISContext() return aContext; } -Handle(AIS_InteractiveContext) ViewerTest::GetAISContext() +const Handle(AIS_InteractiveContext)& ViewerTest::GetAISContext() { return TheAISContext(); } diff --git a/tests/bugs/caf/bug23489 b/tests/bugs/caf/bug23489 index 6e72af0af7..4ca3a4da99 100755 --- a/tests/bugs/caf/bug23489 +++ b/tests/bugs/caf/bug23489 @@ -21,7 +21,7 @@ for {set i 1} {$i < 10} {incr i} { # close document Close D - unset D + # unload shape (replace by small one) vertex a 0 0 0 diff --git a/tests/caf/basic/G3 b/tests/caf/basic/G3 index b00ffce2ca..b7b9866d46 100755 --- a/tests/caf/basic/G3 +++ b/tests/caf/basic/G3 @@ -39,7 +39,7 @@ set aFile ${imagedir}/caf001-G3.std file delete ${aFile} SaveAs D ${aFile} if { ![file exists ${aFile}] } { - puts "There is not ${aFile} file; SaveAs command: Error" + puts "There is no file ${aFile}; SaveAs command: Error" return } #catch {exec chmod 777 ${aFile}} diff --git a/tests/caf/bugs/B6 b/tests/caf/bugs/B6 index 5843509a21..e5fd63756e 100755 --- a/tests/caf/bugs/B6 +++ b/tests/caf/bugs/B6 @@ -64,6 +64,7 @@ if { ${IsDone} != 0 } { puts "Get a value of TPrsStd_AISPresentation attribute from restoring document: Error" puts "OCC1228: ERROR (case 2)" } else { + Close DDoc puts "There is the box in the viewer" puts "OCC1228: OK" } diff --git a/tests/caf/named_shape/E1 b/tests/caf/named_shape/E1 index d7f0810570..c36b93e0f5 100644 --- a/tests/caf/named_shape/E1 +++ b/tests/caf/named_shape/E1 @@ -18,7 +18,7 @@ #pload FULL erase Close D -unset D + NewDocument D MDTV-Standard isos 12 #1 - create box using more flexible set of commands diff --git a/tests/caf/named_shape/E2 b/tests/caf/named_shape/E2 index 568e0bc377..30691cd6e0 100644 --- a/tests/caf/named_shape/E2 +++ b/tests/caf/named_shape/E2 @@ -18,7 +18,7 @@ #pload FULL erase Close D -unset D + NewDocument D MDTV-Standard #Drivers' nick-names: diff --git a/tests/caf/named_shape/E3 b/tests/caf/named_shape/E3 index eebcb62f70..c752b15efc 100644 --- a/tests/caf/named_shape/E3 +++ b/tests/caf/named_shape/E3 @@ -17,7 +17,7 @@ #pload FULL erase Close D -unset D + NewDocument D MDTV-Standard AddDriver D Box Cyl Sph Attach XAttach PTxyz PTALine PRLine PMirr Cut Fuse Prism FulRevol SecRevol Fillet diff --git a/tests/caf/named_shape/E4 b/tests/caf/named_shape/E4 index 167957ccc8..ee82d1a9cc 100644 --- a/tests/caf/named_shape/E4 +++ b/tests/caf/named_shape/E4 @@ -17,7 +17,7 @@ erase Close D -unset D + NewDocument D MDTV-Standard AddDriver D Box Cyl Sph Attach XAttach PTxyz PTALine PRLine PMirr Cut Fuse Prism FulRevol SecRevol Fillet diff --git a/tests/caf/named_shape/E5 b/tests/caf/named_shape/E5 index 7ac47bb5ef..62b506a7ca 100644 --- a/tests/caf/named_shape/E5 +++ b/tests/caf/named_shape/E5 @@ -17,7 +17,7 @@ erase Close D -unset D + NewDocument D MDTV-Standard AddDriver D Box Cyl Sph Attach XAttach PTxyz PTALine PRLine PMirr Cut Fuse Prism FulRevol SecRevol Fillet diff --git a/tests/caf/named_shape/E6 b/tests/caf/named_shape/E6 index c1eac67270..ec81f8981e 100644 --- a/tests/caf/named_shape/E6 +++ b/tests/caf/named_shape/E6 @@ -21,7 +21,7 @@ erase Close D -unset D + NewDocument D MDTV-Standard #1 - create Box using short-cut diff --git a/tests/caf/named_shape/E7 b/tests/caf/named_shape/E7 index 7eb3d56091..7a0e2ac99f 100644 --- a/tests/caf/named_shape/E7 +++ b/tests/caf/named_shape/E7 @@ -21,7 +21,7 @@ #pload FULL erase Close D -unset D + NewDocument D MDTV-Standard #Drivers' nick-names: diff --git a/tests/caf/named_shape/E8 b/tests/caf/named_shape/E8 index a88dea045a..a8d6864fe2 100644 --- a/tests/caf/named_shape/E8 +++ b/tests/caf/named_shape/E8 @@ -19,7 +19,7 @@ #pload FULL erase Close D -unset D + NewDocument D MDTV-Standard #Drivers' nick-names: diff --git a/tests/caf/named_shape/E9 b/tests/caf/named_shape/E9 index c1b9e5f0ae..1223e9d578 100644 --- a/tests/caf/named_shape/E9 +++ b/tests/caf/named_shape/E9 @@ -18,7 +18,7 @@ #pload FULL erase Close D -unset D + NewDocument D MDTV-Standard isos 12 diff --git a/tests/caf/named_shape/F1 b/tests/caf/named_shape/F1 index f7ae3533df..aced514bb1 100644 --- a/tests/caf/named_shape/F1 +++ b/tests/caf/named_shape/F1 @@ -22,7 +22,7 @@ #pload FULL erase Close D -unset D + NewDocument D MDTV-Standard AddDriver D Box Cyl Sph Attach XAttach PTxyz PTALine PRLine PMirr Cut Fuse Prism FulRevol SecRevol Fillet diff --git a/tests/caf/named_shape/F2 b/tests/caf/named_shape/F2 index b71c86520e..d38957ad4d 100644 --- a/tests/caf/named_shape/F2 +++ b/tests/caf/named_shape/F2 @@ -19,7 +19,7 @@ #pload FULL erase Close D -unset D + NewDocument D MDTV-Standard isos 12 #1 - create Box using short-cut diff --git a/tests/caf/named_shape/F3 b/tests/caf/named_shape/F3 index b0f2f30f12..74733f9783 100644 --- a/tests/caf/named_shape/F3 +++ b/tests/caf/named_shape/F3 @@ -25,7 +25,7 @@ #pload FULL erase Close D -unset D + NewDocument D MDTV-Standard isos 12 #1 - create Box using short-cut diff --git a/tests/caf/named_shape/F4 b/tests/caf/named_shape/F4 index c3c7e88e16..8f39e59b87 100644 --- a/tests/caf/named_shape/F4 +++ b/tests/caf/named_shape/F4 @@ -17,7 +17,7 @@ #pload FULL erase Close D -unset D + NewDocument D MDTV-Standard #Drivers' nick-names: diff --git a/tests/caf/named_shape/F5 b/tests/caf/named_shape/F5 index 49b9a161c5..347a550c8c 100644 --- a/tests/caf/named_shape/F5 +++ b/tests/caf/named_shape/F5 @@ -20,7 +20,7 @@ #pload FULL erase Close D -unset D + NewDocument D MDTV-Standard isos 12 diff --git a/tests/caf/named_shape/F6 b/tests/caf/named_shape/F6 index c51d62fe87..d906bb6f7c 100755 --- a/tests/caf/named_shape/F6 +++ b/tests/caf/named_shape/F6 @@ -22,7 +22,7 @@ #pload FULL erase Close D -unset D + NewDocument D MDTV-Standard isos 12 diff --git a/tests/caf/named_shape/F7 b/tests/caf/named_shape/F7 index 5949f8d2b2..cbbb723389 100644 --- a/tests/caf/named_shape/F7 +++ b/tests/caf/named_shape/F7 @@ -21,7 +21,7 @@ #pload FULL erase Close D -unset D + NewDocument D MDTV-Standard isos 12