mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-10 18:51:21 +03:00
0031711: Data Exchange - STEPCAFControl_Reader hangs on attached file in an infinite loop
Add check if .step external file is the same main file.
This commit is contained in:
parent
2fa0e902f0
commit
2547d97917
@ -46,6 +46,7 @@
|
|||||||
#include <StepBasic_SiUnit.hxx>
|
#include <StepBasic_SiUnit.hxx>
|
||||||
#include <StepBasic_SiUnitAndLengthUnit.hxx>
|
#include <StepBasic_SiUnitAndLengthUnit.hxx>
|
||||||
#include <StepBasic_Unit.hxx>
|
#include <StepBasic_Unit.hxx>
|
||||||
|
#include <StepBasic_DocumentFile.hxx>
|
||||||
#include <STEPCAFControl_Controller.hxx>
|
#include <STEPCAFControl_Controller.hxx>
|
||||||
#include <STEPCAFControl_DataMapIteratorOfDataMapOfShapePD.hxx>
|
#include <STEPCAFControl_DataMapIteratorOfDataMapOfShapePD.hxx>
|
||||||
#include <STEPCAFControl_DataMapOfPDExternFile.hxx>
|
#include <STEPCAFControl_DataMapOfPDExternFile.hxx>
|
||||||
@ -623,8 +624,10 @@ Standard_Boolean STEPCAFControl_Reader::Transfer (STEPControl_Reader &reader,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// get directory name of the main file
|
// get file name and directory name of the main file
|
||||||
OSD_Path mainfile(reader.WS()->LoadedFile());
|
OSD_Path mainfile(reader.WS()->LoadedFile());
|
||||||
|
TCollection_AsciiString aMainName;
|
||||||
|
aMainName = mainfile.Name() + mainfile.Extension();
|
||||||
mainfile.SetName("");
|
mainfile.SetName("");
|
||||||
mainfile.SetExtension("");
|
mainfile.SetExtension("");
|
||||||
TCollection_AsciiString dpath;
|
TCollection_AsciiString dpath;
|
||||||
@ -674,6 +677,13 @@ Standard_Boolean STEPCAFControl_Reader::Transfer (STEPControl_Reader &reader,
|
|||||||
TCollection_AsciiString fullname = OSD_Path::AbsolutePath(dpath, filename);
|
TCollection_AsciiString fullname = OSD_Path::AbsolutePath(dpath, filename);
|
||||||
if (fullname.Length() <= 0) fullname = filename;
|
if (fullname.Length() <= 0) fullname = filename;
|
||||||
|
|
||||||
|
// check for not the same file
|
||||||
|
TCollection_AsciiString aMainFullName = OSD_Path::AbsolutePath(dpath, aMainName);
|
||||||
|
if (TCollection_AsciiString::IsSameString(aMainFullName,fullname,Standard_False)) {
|
||||||
|
TP->AddWarning(ExtRefs.DocFile(i), "External reference file is the same main file");
|
||||||
|
continue; // not a valid extern ref
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
char fullname[1024];
|
char fullname[1024];
|
||||||
char *mainfile = reader.WS()->LoadedFile();
|
char *mainfile = reader.WS()->LoadedFile();
|
||||||
|
@ -468,6 +468,16 @@ Handle(StepBasic_ProductDefinition) STEPConstruct_ExternRefs::ProdDef (const Sta
|
|||||||
return Handle(StepBasic_ProductDefinition)::DownCast( myShapes(num) );
|
return Handle(StepBasic_ProductDefinition)::DownCast( myShapes(num) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : DocFile
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
Handle(StepBasic_DocumentFile) STEPConstruct_ExternRefs::DocFile(const Standard_Integer num) const
|
||||||
|
{
|
||||||
|
return Handle(StepBasic_DocumentFile)::DownCast(myDocFiles.Value(num));
|
||||||
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : Format
|
//function : Format
|
||||||
//purpose :
|
//purpose :
|
||||||
|
@ -82,6 +82,11 @@ public:
|
|||||||
//! is not associated to SDR in a proper way.
|
//! is not associated to SDR in a proper way.
|
||||||
Standard_EXPORT Handle(StepBasic_ProductDefinition) ProdDef (const Standard_Integer num) const;
|
Standard_EXPORT Handle(StepBasic_ProductDefinition) ProdDef (const Standard_Integer num) const;
|
||||||
|
|
||||||
|
//! Returns DocumentFile to which numth extern reference
|
||||||
|
//! is associated.
|
||||||
|
//! Returns Null if cannot be detected.
|
||||||
|
Standard_EXPORT Handle(StepBasic_DocumentFile) DocFile (const Standard_Integer num) const;
|
||||||
|
|
||||||
//! Returns format identification string for the extern document
|
//! Returns format identification string for the extern document
|
||||||
//! Returns Null handle if format is not defined
|
//! Returns Null handle if format is not defined
|
||||||
Standard_EXPORT Handle(TCollection_HAsciiString) Format (const Standard_Integer num) const;
|
Standard_EXPORT Handle(TCollection_HAsciiString) Format (const Standard_Integer num) const;
|
||||||
|
23
tests/bugs/step/bug31711
Normal file
23
tests/bugs/step/bug31711
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
puts "=========="
|
||||||
|
puts "0031711: Data Exchange - STEPCAFControl_Reader hangs on attached file in an infinite loop"
|
||||||
|
puts "=========="
|
||||||
|
puts ""
|
||||||
|
|
||||||
|
# to prevent loops limit to 2 minute
|
||||||
|
cpulimit 120
|
||||||
|
|
||||||
|
set path_first [locate_data_file bug31711.stp]
|
||||||
|
regsub -all {/} $path_first {\\} path_second
|
||||||
|
|
||||||
|
ReadStep D_First $path_first
|
||||||
|
|
||||||
|
XGetOneShape result D_First
|
||||||
|
checkshape result
|
||||||
|
checknbshapes result -solid 1 -shell 1 -face 3687 -wire 4020
|
||||||
|
|
||||||
|
if { [regexp -nocase "Windows" $tcl_platform(os)] != 0 } {
|
||||||
|
ReadStep D_Second $path_second
|
||||||
|
}
|
||||||
|
|
||||||
|
# return cpu limit
|
||||||
|
cpulimit 1000
|
Loading…
x
Reference in New Issue
Block a user