From 9bd822ca69b9b7e72ae32c9ba37d0179f7620db8 Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Sat, 27 Apr 2019 16:47:53 +0900 Subject: Reintroduced debug, warning and fatal functions since this are part of R14.0.x API. Signed-off-by: Michele Calgaro --- src/tools/qglobal.cpp | 89 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) diff --git a/src/tools/qglobal.cpp b/src/tools/qglobal.cpp index ea09c3d5a..a541e7aad 100644 --- a/src/tools/qglobal.cpp +++ b/src/tools/qglobal.cpp @@ -492,6 +492,33 @@ void tqDebug( const char *msg, ... ) } } +void debug( const char *msg, ... ) +{ + char buf[QT_BUFFER_LENGTH]; + strcpy( buf, TQDateTime::currentDateTime().toString("[yyyy/MM/dd hh:mm:ss.zzz] ").ascii() ); + int len = strlen(buf); + va_list ap; + va_start( ap, msg ); // use variable arg list +#if defined(QT_VSNPRINTF) + QT_VSNPRINTF( &buf[len], QT_BUFFER_LENGTH, msg, ap ); +#else + vsprintf( &buf[len], msg, ap ); +#endif + va_end( ap ); + if ( handler ) { + (*handler)( TQtDebugMsg, buf ); + } else { +#if defined(Q_CC_MWERKS) + mac_default_handler(buf); +#elif defined(Q_OS_TEMP) + TQString fstr( buf ); + OutputDebugString( (fstr + "\n").ucs2() ); +#else + fprintf( stderr, "%s\n", buf ); // add newline +#endif + } +} + void tqWarning( const char *msg, ... ) { char buf[QT_BUFFER_LENGTH]; @@ -519,6 +546,33 @@ void tqWarning( const char *msg, ... ) } } +void warning( const char *msg, ... ) +{ + char buf[QT_BUFFER_LENGTH]; + strcpy( buf, TQDateTime::currentDateTime().toString("[yyyy/MM/dd hh:mm:ss.zzz] ").ascii() ); + int len = strlen(buf); + va_list ap; + va_start( ap, msg ); // use variable arg list +#if defined(QT_VSNPRINTF) + QT_VSNPRINTF( &buf[len], QT_BUFFER_LENGTH, msg, ap ); +#else + vsprintf( &buf[len], msg, ap ); +#endif + va_end( ap ); + if ( handler ) { + (*handler)( TQtWarningMsg, buf ); + } else { +#if defined(Q_CC_MWERKS) + mac_default_handler(buf); +#elif defined(Q_OS_TEMP) + TQString fstr( buf ); + OutputDebugString( (fstr + "\n").ucs2() ); +#else + fprintf( stderr, "%s\n", buf ); // add newline +#endif + } +} + void tqFatal( const char *msg, ... ) { char buf[QT_BUFFER_LENGTH]; @@ -554,6 +608,41 @@ void tqFatal( const char *msg, ... ) } } +void fatal( const char *msg, ... ) +{ + char buf[QT_BUFFER_LENGTH]; + strcpy( buf, TQDateTime::currentDateTime().toString("[yyyy/MM/dd hh:mm:ss.zzz] ").ascii() ); + int len = strlen(buf); + va_list ap; + va_start( ap, msg ); // use variable arg list +#if defined(QT_VSNPRINTF) + QT_VSNPRINTF( &buf[len], QT_BUFFER_LENGTH, msg, ap ); +#else + vsprintf( &buf[len], msg, ap ); +#endif + va_end( ap ); + if ( handler ) { + (*handler)( TQtFatalMsg, buf ); + } else { +#if defined(Q_CC_MWERKS) + mac_default_handler(buf); +#else + fprintf( stderr, "%s\n", buf ); // add newline +#endif +#if defined(Q_OS_UNIX) && defined(QT_DEBUG) + abort(); // trap; generates core dump +#elif defined(Q_OS_TEMP) && defined(QT_DEBUG) + TQString fstr; + fstr.sprintf( "%s:%s %s %s\n", __FILE__, __LINE__, TQT_VERSION_STR, buf ); + OutputDebugString( fstr.ucs2() ); +#elif defined(_CRT_ERROR) && defined(_DEBUG) + _CrtDbgReport( _CRT_ERROR, __FILE__, __LINE__, TQT_VERSION_STR, buf ); +#else + exit( 1 ); // goodbye cruel world +#endif + } +} + /*! \relates TQApplication -- cgit v1.2.1