mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-16 10:08:36 +03:00
0024164: Optimization of OCAF document closing
OCAF document closing redesign. added 2 test scripts. removed commented method. added missed Draw commands.
This commit is contained in:
parent
830d849f94
commit
1c9cffdb4b
@ -98,6 +98,7 @@
|
|||||||
#include <TDataStd_ListIteratorOfListOfByte.hxx>
|
#include <TDataStd_ListIteratorOfListOfByte.hxx>
|
||||||
#include <TColStd_ListIteratorOfListOfInteger.hxx>
|
#include <TColStd_ListIteratorOfListOfInteger.hxx>
|
||||||
#include <TColStd_ListIteratorOfListOfReal.hxx>
|
#include <TColStd_ListIteratorOfListOfReal.hxx>
|
||||||
|
#include <TDataStd_ReferenceArray.hxx>
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : DDataStd_SetInteger
|
//function : DDataStd_SetInteger
|
||||||
@ -2595,6 +2596,67 @@ static Standard_Integer DDataStd_GetNDRealArray (Draw_Interpretor& di,
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : SetRefArray (DF, entry , From, To, elmt1, elmt2, ...
|
||||||
|
//=======================================================================
|
||||||
|
static Standard_Integer DDataStd_SetRefArray (Draw_Interpretor& di,
|
||||||
|
Standard_Integer,
|
||||||
|
const char** arg)
|
||||||
|
{
|
||||||
|
|
||||||
|
Handle(TDF_Data) DF;
|
||||||
|
if (!DDF::GetDF(arg[1],DF)) return 1;
|
||||||
|
TDF_Label label;
|
||||||
|
DDF::AddLabel(DF, arg[2], label);
|
||||||
|
|
||||||
|
Standard_Integer From = Draw::Atoi(arg[3]), To = Draw::Atoi( arg[4] ), j;
|
||||||
|
di << "RefArray with bounds from = " << From << " to = " << To << "\n";
|
||||||
|
|
||||||
|
Handle(TDataStd_ReferenceArray) A = TDataStd_ReferenceArray::Set(label, From, To);
|
||||||
|
|
||||||
|
j = 5;
|
||||||
|
for(Standard_Integer i = From; i<=To; i++) {
|
||||||
|
TDF_Label aRefLabel;
|
||||||
|
DDF::AddLabel(DF, arg[j], aRefLabel);
|
||||||
|
A->SetValue(i, aRefLabel);
|
||||||
|
j++;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
//=======================================================================
|
||||||
|
//function : GetRefArray (DF, entry )
|
||||||
|
//=======================================================================
|
||||||
|
static Standard_Integer DDataStd_GetRefArray (Draw_Interpretor& di,
|
||||||
|
Standard_Integer,
|
||||||
|
const char** arg)
|
||||||
|
{
|
||||||
|
|
||||||
|
Handle(TDF_Data) DF;
|
||||||
|
if (!DDF::GetDF(arg[1],DF)) return 1;
|
||||||
|
TDF_Label label;
|
||||||
|
if( !DDF::FindLabel(DF, arg[2], label) ) {
|
||||||
|
di << "No label for entry" << "\n";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
Handle(TDataStd_ReferenceArray) A;
|
||||||
|
if ( !label.FindAttribute(TDataStd_ReferenceArray::GetID(), A) ) {
|
||||||
|
di << "There is no TDataStd_ReferenceArray under label" << "\n";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(Standard_Integer i = A->Lower(); i<=A->Upper(); i++){
|
||||||
|
const TDF_Label& aLabel = A->Value(i);
|
||||||
|
TCollection_AsciiString entry;
|
||||||
|
TDF_Tool::Entry(aLabel, entry);
|
||||||
|
di << entry.ToCString();
|
||||||
|
if(i<A->Upper())
|
||||||
|
di<<" ";
|
||||||
|
}
|
||||||
|
di<<"\n";
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : BasicCommands
|
//function : BasicCommands
|
||||||
//purpose :
|
//purpose :
|
||||||
@ -2636,6 +2698,10 @@ void DDataStd::BasicCommands (Draw_Interpretor& theCommands)
|
|||||||
"SetExtStringArray (DF, entry, isDelta, From, To, elmt1, elmt2, ... )",
|
"SetExtStringArray (DF, entry, isDelta, From, To, elmt1, elmt2, ... )",
|
||||||
__FILE__, DDataStd_SetExtStringArray, g);
|
__FILE__, DDataStd_SetExtStringArray, g);
|
||||||
|
|
||||||
|
theCommands.Add ("SetRefArray",
|
||||||
|
"SetRefArray (DF, entry, From, To, lab1, lab2,.. )",
|
||||||
|
__FILE__, DDataStd_SetRefArray, g);
|
||||||
|
|
||||||
theCommands.Add ("SetIntPackedMap",
|
theCommands.Add ("SetIntPackedMap",
|
||||||
"SetIntPackedMap (DF, entry, isDelta, key1, key2, ... )",
|
"SetIntPackedMap (DF, entry, isDelta, key1, key2, ... )",
|
||||||
__FILE__, DDataStd_SetIntPackedMap, g);
|
__FILE__, DDataStd_SetIntPackedMap, g);
|
||||||
@ -2703,6 +2769,10 @@ void DDataStd::BasicCommands (Draw_Interpretor& theCommands)
|
|||||||
"GetExtStringArray (DF, entry )",
|
"GetExtStringArray (DF, entry )",
|
||||||
__FILE__, DDataStd_GetExtStringArray, g);
|
__FILE__, DDataStd_GetExtStringArray, g);
|
||||||
|
|
||||||
|
theCommands.Add ("GetRefArray",
|
||||||
|
"GetRefArray (DF, entry )",
|
||||||
|
__FILE__, DDataStd_GetRefArray, g);
|
||||||
|
|
||||||
theCommands.Add ("GetIntPackedMap",
|
theCommands.Add ("GetIntPackedMap",
|
||||||
"GetIntPackedMap (DF, entry )",
|
"GetIntPackedMap (DF, entry )",
|
||||||
__FILE__, DDataStd_GetIntPackedMap, g);
|
__FILE__, DDataStd_GetIntPackedMap, g);
|
||||||
|
@ -163,6 +163,7 @@ void TDocStd_Application::Close(const Handle(TDocStd_Document)& aDoc)
|
|||||||
Handle(TDocStd_Document) emptyDoc;
|
Handle(TDocStd_Document) emptyDoc;
|
||||||
Owner->SetDocument(emptyDoc);
|
Owner->SetDocument(emptyDoc);
|
||||||
}
|
}
|
||||||
|
aDoc->BeforeClose();
|
||||||
CDF_Application::Close(aDoc);
|
CDF_Application::Close(aDoc);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -49,7 +49,7 @@ uses Data from TDF,
|
|||||||
|
|
||||||
is
|
is
|
||||||
|
|
||||||
Destroy (me : mutable) is redefined protected;
|
-- Destroy (me : mutable) is redefined protected;
|
||||||
---Purpose: Will Abort any execution, clear fields
|
---Purpose: Will Abort any execution, clear fields
|
||||||
---C++: alias ~
|
---C++: alias ~
|
||||||
|
|
||||||
@ -320,6 +320,9 @@ is
|
|||||||
---Purpose: returns True if changes allowed only inside transactions
|
---Purpose: returns True if changes allowed only inside transactions
|
||||||
---C++: inline
|
---C++: inline
|
||||||
|
|
||||||
|
BeforeClose(me : mutable) is virtual;
|
||||||
|
---Purpose: Prepares document for closing
|
||||||
|
|
||||||
fields
|
fields
|
||||||
|
|
||||||
---Purpose: storage format
|
---Purpose: storage format
|
||||||
|
@ -70,23 +70,6 @@ Handle(TDocStd_Document) TDocStd_Document::Get (const TDF_Label& acces)
|
|||||||
return TDocStd_Owner::GetDocument(acces.Data());
|
return TDocStd_Owner::GetDocument(acces.Data());
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
|
||||||
//function : Destroy
|
|
||||||
//purpose :
|
|
||||||
//=======================================================================
|
|
||||||
void TDocStd_Document::Destroy()
|
|
||||||
{
|
|
||||||
SetModificationMode(Standard_False);
|
|
||||||
myData->Root().ForgetAllAttributes(Standard_True);
|
|
||||||
myUndoTransaction.Abort();
|
|
||||||
if(!myUndoFILO.IsEmpty())
|
|
||||||
myUndoFILO.Clear();
|
|
||||||
ClearUndos();
|
|
||||||
myData.Nullify();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : TDocStd_Document
|
//function : TDocStd_Document
|
||||||
//purpose :
|
//purpose :
|
||||||
@ -911,3 +894,15 @@ void TDocStd_Document::RemoveFirstUndo() {
|
|||||||
myUndos.RemoveFirst();
|
myUndos.RemoveFirst();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : BeforeClose
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
void TDocStd_Document::BeforeClose()
|
||||||
|
{
|
||||||
|
SetModificationMode(Standard_False);
|
||||||
|
AbortTransaction();
|
||||||
|
if(myIsNestedTransactionMode)
|
||||||
|
myUndoFILO.Clear();
|
||||||
|
ClearUndos();
|
||||||
|
}
|
||||||
|
52
tests/bugs/caf/bug24164_1
Normal file
52
tests/bugs/caf/bug24164_1
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
pload DCAF
|
||||||
|
|
||||||
|
if { [info exists imagedir] == 0 } {
|
||||||
|
set imagedir .
|
||||||
|
}
|
||||||
|
set BugNumber OCC24164
|
||||||
|
|
||||||
|
#1 open new document
|
||||||
|
NewDocument D MDTV-Standard
|
||||||
|
UndoLimit D 10 0 0
|
||||||
|
InitLogBook D
|
||||||
|
AddDriver D Box
|
||||||
|
|
||||||
|
#2 build box
|
||||||
|
NewCommand D
|
||||||
|
set B2 [AddObject D]
|
||||||
|
set F2 [AddFunction D $B2 Box]
|
||||||
|
BoxDX D $B2 190
|
||||||
|
BoxDY D $B2 290
|
||||||
|
BoxDZ D $B2 390
|
||||||
|
ComputeFun D $F2
|
||||||
|
GetShape D $F2:2 Box2
|
||||||
|
NewCommand D
|
||||||
|
|
||||||
|
#3 save shape in the document
|
||||||
|
SaveAs D ${imagedir}/testDoc1.std
|
||||||
|
|
||||||
|
#4 close document
|
||||||
|
set catch_status 0
|
||||||
|
if { [catch {Close D} catch_result] } {
|
||||||
|
set catch_status 1
|
||||||
|
}
|
||||||
|
if { ${catch_status} != 0 } {
|
||||||
|
puts "Faulty ${BugNumber}"
|
||||||
|
} else {
|
||||||
|
puts "OK ${BugNumber}"
|
||||||
|
}
|
||||||
|
|
||||||
|
#5 reopen just saved document with the same name
|
||||||
|
Open ${imagedir}/testDoc1.std D
|
||||||
|
set catch_status 0
|
||||||
|
|
||||||
|
#6 close the document
|
||||||
|
if { [catch {Close D} catch_result] } {
|
||||||
|
set catch_status 1
|
||||||
|
}
|
||||||
|
|
||||||
|
if { ${catch_status} != 0 } {
|
||||||
|
puts "Faulty ${BugNumber}"
|
||||||
|
} else {
|
||||||
|
puts "OK ${BugNumber}"
|
||||||
|
}
|
69
tests/bugs/caf/bug24164_2
Normal file
69
tests/bugs/caf/bug24164_2
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
pload DCAF
|
||||||
|
|
||||||
|
set BugNumber OCC24164
|
||||||
|
if { [info exists imagedir] == 0 } {
|
||||||
|
set imagedir .
|
||||||
|
}
|
||||||
|
|
||||||
|
#1 open new document
|
||||||
|
NewDocument D MDTV-Standard
|
||||||
|
UndoLimit D 10 0 0
|
||||||
|
|
||||||
|
#2 define set of labels
|
||||||
|
NewCommand D
|
||||||
|
set Lab1 [Label D 0:1:1]
|
||||||
|
set Lab2 [Label D 0:1:2]
|
||||||
|
set Lab3 [Label D 0:1:3]
|
||||||
|
set Lab4 [Label D 0:1:4]
|
||||||
|
set Lab5 [Label D 0:1:5]
|
||||||
|
set Lab6 [Label D 0:1:6]
|
||||||
|
|
||||||
|
#3 set references
|
||||||
|
SetRefArray D $Lab1 1 2 $Lab2 $Lab1
|
||||||
|
SetRefArray D $Lab2 1 2 $Lab3 $Lab4
|
||||||
|
SetRefArray D $Lab3 1 1 $Lab1
|
||||||
|
|
||||||
|
#4 set additional references
|
||||||
|
NewCommand D
|
||||||
|
SetRefArray D $Lab4 1 2 $Lab5 $Lab1
|
||||||
|
SetRefArray D $Lab5 1 1 $Lab6
|
||||||
|
SetRefArray D $Lab6 1 2 $Lab3 $Lab4
|
||||||
|
|
||||||
|
NewCommand D
|
||||||
|
|
||||||
|
#5 check references
|
||||||
|
GetRefArray D $Lab1
|
||||||
|
GetRefArray D $Lab2
|
||||||
|
GetRefArray D $Lab3
|
||||||
|
GetRefArray D $Lab4
|
||||||
|
GetRefArray D $Lab5
|
||||||
|
GetRefArray D $Lab6
|
||||||
|
|
||||||
|
#6 save the document
|
||||||
|
SaveAs D ${imagedir}/testDoc2.std
|
||||||
|
|
||||||
|
#7 close the document
|
||||||
|
set catch_status 0
|
||||||
|
if { [catch {Close D} catch_result] } {
|
||||||
|
set catch_status 1
|
||||||
|
}
|
||||||
|
if { ${catch_status} != 0 } {
|
||||||
|
puts "Faulty ${BugNumber}"
|
||||||
|
} else {
|
||||||
|
puts "OK ${BugNumber}"
|
||||||
|
}
|
||||||
|
|
||||||
|
#8 reopen just saved document with the same name
|
||||||
|
Open ${imagedir}/testDoc2.std D
|
||||||
|
|
||||||
|
#9 close the document
|
||||||
|
if { [catch {Close D} catch_result] } {
|
||||||
|
set catch_status 1
|
||||||
|
}
|
||||||
|
|
||||||
|
if { ${catch_status} != 0 } {
|
||||||
|
puts "Faulty ${BugNumber}"
|
||||||
|
} else {
|
||||||
|
puts "OK ${BugNumber}"
|
||||||
|
}
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user