1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +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:
abv
2016-04-14 15:41:59 +03:00
committed by bugmaster
parent a0bb29e79e
commit 4680293609
4 changed files with 12 additions and 68 deletions

View File

@@ -344,14 +344,9 @@ void OSD_Environment :: Reset () {
} // end OSD_Environment :: Reset
void OSD_Environment :: Perror () {
if ( ErrorPrefix () )
( *ErrorStream () ) << TEXT( '\'' ) << myName.ToCString () << TEXT( "' - " );
myError.Perror ();
void OSD_Environment :: Perror ()
{
myError.Perror ();
} // end OSD_Environment :: Perror
Standard_Integer OSD_Environment :: Error () const {

View File

@@ -457,9 +457,6 @@ typedef struct _error_table {
} ERROR_TABLE;
static int fPrefix = 1;
static ostream* errorStream = &cerr;
static ERROR_TABLE commErrorTable [] = {
{ ERROR_INVALID_FUNCTION, ERR_INVAL },
@@ -573,14 +570,9 @@ OSD_Error :: OSD_Error () :
void OSD_Error :: Perror () {
if (errorStream == NULL)
return;
Standard_Character buff[ 32 ];
Standard_CString ptr;
if ( fPrefix ) {
lstrcpy ( buff, "Error ( " );
switch ( myCode ) {
@@ -653,12 +645,9 @@ void OSD_Error :: Perror () {
lstrcat ( buff, ptr );
lstrcat ( buff, " )" );
( *errorStream ) << buff;
std::cerr << buff;
} // end if ( fPrefix . . . )
TCollection_ExtendedString aMessageW(myMessage);
( *errorStream ) << L": " << (const wchar_t*)aMessageW.ToExtString () << endl << flush;
std::cerr << myMessage.ToCString() << std::endl << std::flush;
} // end OSD_Error :: Perror
@@ -741,42 +730,11 @@ Standard_Boolean OSD_Error :: Failed () const {
} // end OSD_Error :: Failed
void OSD_Error :: Reset () {
myErrno = ERROR_SUCCESS;
if (errorStream != NULL)
{
( *errorStream ).clear ();
( *errorStream ).seekp ( 0 );
( *errorStream ).clear ();
}
void OSD_Error :: Reset ()
{
myErrno = ERROR_SUCCESS;
} // 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 ) {
int i;

View File

@@ -29,10 +29,4 @@
# endif
# 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