mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-10 18:51:21 +03:00
0027385: assertion in static initializer in a Windows GUI application
Useless global pointer to cerr is removed from OSD_Error, along with methods supporting its customization (Windows-only). Global accessors to environment variables are replaced by locals in UnitsAPI.cxx.
This commit is contained in:
parent
a0bb29e79e
commit
4680293609
@ -344,14 +344,9 @@ void OSD_Environment :: Reset () {
|
|||||||
|
|
||||||
} // end OSD_Environment :: Reset
|
} // end OSD_Environment :: Reset
|
||||||
|
|
||||||
void OSD_Environment :: Perror () {
|
void OSD_Environment :: Perror ()
|
||||||
|
{
|
||||||
if ( ErrorPrefix () )
|
myError.Perror ();
|
||||||
|
|
||||||
( *ErrorStream () ) << TEXT( '\'' ) << myName.ToCString () << TEXT( "' - " );
|
|
||||||
|
|
||||||
myError.Perror ();
|
|
||||||
|
|
||||||
} // end OSD_Environment :: Perror
|
} // end OSD_Environment :: Perror
|
||||||
|
|
||||||
Standard_Integer OSD_Environment :: Error () const {
|
Standard_Integer OSD_Environment :: Error () const {
|
||||||
|
@ -457,9 +457,6 @@ typedef struct _error_table {
|
|||||||
|
|
||||||
} ERROR_TABLE;
|
} ERROR_TABLE;
|
||||||
|
|
||||||
static int fPrefix = 1;
|
|
||||||
static ostream* errorStream = &cerr;
|
|
||||||
|
|
||||||
static ERROR_TABLE commErrorTable [] = {
|
static ERROR_TABLE commErrorTable [] = {
|
||||||
|
|
||||||
{ ERROR_INVALID_FUNCTION, ERR_INVAL },
|
{ ERROR_INVALID_FUNCTION, ERR_INVAL },
|
||||||
@ -573,14 +570,9 @@ OSD_Error :: OSD_Error () :
|
|||||||
|
|
||||||
void OSD_Error :: Perror () {
|
void OSD_Error :: Perror () {
|
||||||
|
|
||||||
if (errorStream == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
Standard_Character buff[ 32 ];
|
Standard_Character buff[ 32 ];
|
||||||
Standard_CString ptr;
|
Standard_CString ptr;
|
||||||
|
|
||||||
if ( fPrefix ) {
|
|
||||||
|
|
||||||
lstrcpy ( buff, "Error ( " );
|
lstrcpy ( buff, "Error ( " );
|
||||||
|
|
||||||
switch ( myCode ) {
|
switch ( myCode ) {
|
||||||
@ -653,12 +645,9 @@ void OSD_Error :: Perror () {
|
|||||||
|
|
||||||
lstrcat ( buff, ptr );
|
lstrcat ( buff, ptr );
|
||||||
lstrcat ( buff, " )" );
|
lstrcat ( buff, " )" );
|
||||||
( *errorStream ) << buff;
|
std::cerr << buff;
|
||||||
|
|
||||||
} // end if ( fPrefix . . . )
|
std::cerr << myMessage.ToCString() << std::endl << std::flush;
|
||||||
|
|
||||||
TCollection_ExtendedString aMessageW(myMessage);
|
|
||||||
( *errorStream ) << L": " << (const wchar_t*)aMessageW.ToExtString () << endl << flush;
|
|
||||||
|
|
||||||
} // end OSD_Error :: Perror
|
} // end OSD_Error :: Perror
|
||||||
|
|
||||||
@ -741,42 +730,11 @@ Standard_Boolean OSD_Error :: Failed () const {
|
|||||||
|
|
||||||
} // end OSD_Error :: Failed
|
} // end OSD_Error :: Failed
|
||||||
|
|
||||||
void OSD_Error :: Reset () {
|
void OSD_Error :: Reset ()
|
||||||
|
{
|
||||||
myErrno = ERROR_SUCCESS;
|
myErrno = ERROR_SUCCESS;
|
||||||
if (errorStream != NULL)
|
|
||||||
{
|
|
||||||
( *errorStream ).clear ();
|
|
||||||
( *errorStream ).seekp ( 0 );
|
|
||||||
( *errorStream ).clear ();
|
|
||||||
}
|
|
||||||
|
|
||||||
} // end OSD_Error :: Reset
|
} // end OSD_Error :: Reset
|
||||||
|
|
||||||
void SetErrorStream ( ostream* errStream ) {
|
|
||||||
|
|
||||||
errorStream = errStream;
|
|
||||||
|
|
||||||
} // end SetErrorStream
|
|
||||||
|
|
||||||
void EnablePrefix ( int fEnable ) {
|
|
||||||
|
|
||||||
fPrefix = fEnable;
|
|
||||||
|
|
||||||
} // end EnablePrefix
|
|
||||||
|
|
||||||
int ErrorPrefix ( void ) {
|
|
||||||
|
|
||||||
return fPrefix;
|
|
||||||
|
|
||||||
} // end ErrorPrefix
|
|
||||||
|
|
||||||
ostream* ErrorStream ( void ) {
|
|
||||||
|
|
||||||
return errorStream;
|
|
||||||
|
|
||||||
} // end ErrorStream
|
|
||||||
|
|
||||||
static Standard_Integer _get_comm_error ( DWORD dwCode ) {
|
static Standard_Integer _get_comm_error ( DWORD dwCode ) {
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
|
@ -29,10 +29,4 @@
|
|||||||
# endif
|
# endif
|
||||||
# endif // OSDAPI
|
# endif // OSDAPI
|
||||||
|
|
||||||
void OSDAPI SetErrorStream ( ostream* );
|
|
||||||
//ostream* OSDAPI ErrorStream ( void );
|
|
||||||
ostream OSDAPI *ErrorStream ( void ); // for VisualAge
|
|
||||||
void OSDAPI EnablePrefix ( int );
|
|
||||||
int OSDAPI ErrorPrefix ( void );
|
|
||||||
|
|
||||||
#endif // __OSD_WNT_HXX
|
#endif // __OSD_WNT_HXX
|
||||||
|
@ -29,13 +29,6 @@ static Units_UnitsSystem LocalSystemUnits,SILocalSystemUnits,MDTVLocalSystemUnit
|
|||||||
static TCollection_AsciiString rstring;
|
static TCollection_AsciiString rstring;
|
||||||
static UnitsAPI_SystemUnits localSystem = UnitsAPI_SI;
|
static UnitsAPI_SystemUnits localSystem = UnitsAPI_SI;
|
||||||
static UnitsAPI_SystemUnits currentSystem = UnitsAPI_DEFAULT;
|
static UnitsAPI_SystemUnits currentSystem = UnitsAPI_DEFAULT;
|
||||||
static OSD_Environment env1("CSF_UnitsLexicon");
|
|
||||||
static OSD_Environment env2("CSF_UnitsDefinition");
|
|
||||||
#ifdef _WIN32
|
|
||||||
static OSD_Environment env3("CSF_CurrentUnits");
|
|
||||||
static OSD_Environment env4("CSF_MDTVCurrentUnits");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : CheckLoading
|
//function : CheckLoading
|
||||||
@ -45,6 +38,7 @@ static OSD_Environment env4("CSF_MDTVCurrentUnits");
|
|||||||
void UnitsAPI::CheckLoading (const UnitsAPI_SystemUnits aSystemUnits)
|
void UnitsAPI::CheckLoading (const UnitsAPI_SystemUnits aSystemUnits)
|
||||||
{
|
{
|
||||||
if( currentSystem != aSystemUnits || CurrentUnits.IsNull()) {
|
if( currentSystem != aSystemUnits || CurrentUnits.IsNull()) {
|
||||||
|
OSD_Environment env1("CSF_UnitsLexicon");
|
||||||
TCollection_AsciiString slexiconfile(env1.Value());
|
TCollection_AsciiString slexiconfile(env1.Value());
|
||||||
if( slexiconfile.Length() > 0 )
|
if( slexiconfile.Length() > 0 )
|
||||||
Units::LexiconFile(slexiconfile.ToCString());
|
Units::LexiconFile(slexiconfile.ToCString());
|
||||||
@ -59,6 +53,7 @@ void UnitsAPI::CheckLoading (const UnitsAPI_SystemUnits aSystemUnits)
|
|||||||
Standard_NoSuchObject::Raise("environment variable CSF_UnitsLexicon undefined");
|
Standard_NoSuchObject::Raise("environment variable CSF_UnitsLexicon undefined");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
OSD_Environment env2("CSF_UnitsDefinition");
|
||||||
TCollection_AsciiString sunitsfile(env2.Value());
|
TCollection_AsciiString sunitsfile(env2.Value());
|
||||||
if( sunitsfile.Length() > 0 )
|
if( sunitsfile.Length() > 0 )
|
||||||
Units::UnitsFile(sunitsfile.ToCString());
|
Units::UnitsFile(sunitsfile.ToCString());
|
||||||
@ -80,6 +75,7 @@ void UnitsAPI::CheckLoading (const UnitsAPI_SystemUnits aSystemUnits)
|
|||||||
currentSystem = UnitsAPI_SI;
|
currentSystem = UnitsAPI_SI;
|
||||||
if( SICurrentUnits.IsNull() ) {
|
if( SICurrentUnits.IsNull() ) {
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
OSD_Environment env3("CSF_CurrentUnits");
|
||||||
TCollection_AsciiString csfcurrent (env3.Value());
|
TCollection_AsciiString csfcurrent (env3.Value());
|
||||||
if( csfcurrent.Length() > 0 )
|
if( csfcurrent.Length() > 0 )
|
||||||
SICurrentUnits = new Resource_Manager(csfcurrent.ToCString());
|
SICurrentUnits = new Resource_Manager(csfcurrent.ToCString());
|
||||||
@ -96,6 +92,7 @@ void UnitsAPI::CheckLoading (const UnitsAPI_SystemUnits aSystemUnits)
|
|||||||
currentSystem = UnitsAPI_MDTV;
|
currentSystem = UnitsAPI_MDTV;
|
||||||
if( MDTVCurrentUnits.IsNull() ) {
|
if( MDTVCurrentUnits.IsNull() ) {
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
OSD_Environment env4("CSF_MDTVCurrentUnits");
|
||||||
TCollection_AsciiString csfmdtvcurrent (env4.Value());
|
TCollection_AsciiString csfmdtvcurrent (env4.Value());
|
||||||
if( csfmdtvcurrent.Length() > 0 )
|
if( csfmdtvcurrent.Length() > 0 )
|
||||||
MDTVCurrentUnits = new Resource_Manager(csfmdtvcurrent.ToCString());
|
MDTVCurrentUnits = new Resource_Manager(csfmdtvcurrent.ToCString());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user