1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-04 13:13:25 +03:00

0026345: Shape Healer application crashes trying to run Shape Processing

Empty element, that was added to the Array, causes an exception while accessing myUserMap

LoadResourceManager is receives environment variable name, but stat is waiting for full path
This commit is contained in:
anv
2015-06-16 12:27:09 +03:00
committed by bugmaster
parent e9e644edf4
commit b6d779d9cd
3 changed files with 161 additions and 106 deletions

View File

@@ -67,28 +67,61 @@ Standard_Boolean ShapeProcess_Context::Init (const Standard_CString file,
//purpose :
//=======================================================================
Handle(Resource_Manager) ShapeProcess_Context::LoadResourceManager (const Standard_CString file)
Handle(Resource_Manager) ShapeProcess_Context::LoadResourceManager (const Standard_CString name)
{
// Optimisation of loading resource file: file is load only once
// and reloaded only if file date has changed
static Handle(Resource_Manager) sRC;
static Standard_Time mtime;
static TCollection_AsciiString name;
if ( ! sRC.IsNull() && ! name.IsEqual ( file ) ) sRC.Nullify();
if ( ! sRC.IsNull() ) {
struct stat buf;
if ( ! stat ( file, &buf ) && (Standard_Time)buf.st_mtime != mtime ) {
sRC.Nullify();
mtime = buf.st_mtime;
static Standard_Time sMtime, sUMtime;
static TCollection_AsciiString sName;
struct stat buf;
Standard_Time aMtime(0), aUMtime(0);
TCollection_AsciiString aPath,aUserPath;
Resource_Manager::GetResourcePath(aPath,name,Standard_False);
Resource_Manager::GetResourcePath(aUserPath,name,Standard_True);
if ( !aPath.IsEmpty() )
{
stat( aPath.ToCString(), &buf );
aMtime = (Standard_Time)buf.st_mtime;
}
if ( !aUserPath.IsEmpty() )
{
stat( aUserPath.ToCString(), &buf );
aUMtime = (Standard_Time)buf.st_mtime;
}
Standard_Boolean isFileModified = Standard_False;
if ( !sRC.IsNull() ) {
if ( sName.IsEqual ( name ) ) {
if ( sMtime != aMtime )
{
sMtime = aMtime;
isFileModified = Standard_True;
}
if ( sUMtime != aUMtime )
{
sUMtime = aUMtime;
isFileModified = Standard_True;
}
if (isFileModified)
sRC.Nullify();
}
else
sRC.Nullify();
}
if ( sRC.IsNull() ) {
#ifdef OCCT_DEBUG
cout << "Info: ShapeProcess_Context: Reload Resource_Manager: "
<< name.ToCString() << " -> " << file << endl;
<< sName.ToCString() << " -> " << name << endl;
#endif
sRC = new Resource_Manager ( file );
name = file;
sRC = new Resource_Manager ( name );
if (!isFileModified)
{
sName = name;
sMtime = aMtime;
sUMtime = aUMtime;
}
}
return sRC;
}
@@ -401,5 +434,4 @@ void ShapeProcess_Context::SetTraceLevel (const Standard_Integer tracelev)
Standard_Integer ShapeProcess_Context::TraceLevel () const
{
return myTraceLev;
}
}