summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichele Calgaro <[email protected]>2019-05-23 13:12:27 +0900
committerSlávek Banko <[email protected]>2021-12-30 00:01:56 +0100
commit3823c75b929667be742871103295ed225fb570f8 (patch)
tree00bd7cce769bf42838687eda575bb5c918805c96
parentdc6b2e3d45b166c8aaa9946bfdda23fdc2a7b22b (diff)
downloadtqt3-3823c75b929667be742871103295ed225fb570f8.tar.gz
tqt3-3823c75b929667be742871103295ed225fb570f8.zip
Added utility functions tqDebug/tqWarning/tqFatal based on TQString parameter.
Signed-off-by: Michele Calgaro <[email protected]> (cherry picked from commit d63a113c5c0f9d43d71fc6486244b4382459a07a)
-rw-r--r--src/tools/ntqglobal.h11
-rw-r--r--src/tools/qglobal.cpp122
2 files changed, 85 insertions, 48 deletions
diff --git a/src/tools/ntqglobal.h b/src/tools/ntqglobal.h
index bc67fcae4..9b0dbed20 100644
--- a/src/tools/ntqglobal.h
+++ b/src/tools/ntqglobal.h
@@ -754,7 +754,7 @@ typedef TQ_UINT64 TQ_ULLONG; // unsigned long long
//
class TQDataStream;
-
+class TQString;
//
// Feature subsetting
@@ -975,19 +975,22 @@ Q_EXPORT int qWinVersion();
#endif
-Q_EXPORT void tqDebug( const char *, ... ) // print debug message
+Q_EXPORT void tqDebug( const TQString& ); // print debug message
+Q_EXPORT void tqDebug( const char *, ... ) // print debug message
#if defined(Q_CC_GNU) && !defined(__INSURE__)
__attribute__ ((format (printf, 1, 2)))
#endif
;
-Q_EXPORT void tqWarning( const char *, ... ) // print warning message
+Q_EXPORT void tqWarning( const TQString& ); // print warning message
+Q_EXPORT void tqWarning( const char *, ... ) // print warning message
#if defined(Q_CC_GNU) && !defined(__INSURE__)
__attribute__ ((format (printf, 1, 2)))
#endif
;
-Q_EXPORT void tqFatal( const char *, ... ) // print fatal message and exit
+Q_EXPORT void tqFatal( const TQString& ); // print fatal message and exit
+Q_EXPORT void tqFatal( const char *, ... ) // print fatal message and exit
#if defined(Q_CC_GNU)
__attribute__ ((format (printf, 1, 2)))
#endif
diff --git a/src/tools/qglobal.cpp b/src/tools/qglobal.cpp
index a541e7aad..5c9663df5 100644
--- a/src/tools/qglobal.cpp
+++ b/src/tools/qglobal.cpp
@@ -465,21 +465,27 @@ static void mac_default_handler( const char *msg )
#endif
-void tqDebug( const char *msg, ... )
+void handle_buffer(const char *buf, TQtMsgType msgType)
{
- 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 );
+ if ( handler ) {
+ (*handler)( msgType, buf );
+ } else if (msgType == TQtFatalMsg) {
+#if defined(Q_CC_MWERKS)
+ mac_default_handler(buf);
#else
- vsprintf( &buf[len], msg, ap );
+ 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
- va_end( ap );
- if ( handler ) {
- (*handler)( TQtDebugMsg, buf );
} else {
#if defined(Q_CC_MWERKS)
mac_default_handler(buf);
@@ -519,10 +525,24 @@ void debug( const char *msg, ... )
}
}
-void tqWarning( const char *msg, ... )
+void tqDebug( const TQString &msg )
{
char buf[QT_BUFFER_LENGTH];
- strcpy( buf, TQDateTime::currentDateTime().toString("[yyyy/MM/dd hh:mm:ss.zzz] ").ascii() );
+ strcpy( buf, TQDateTime::currentDateTime().toString("[yyyy/MM/dd hh:mm:ss.zzz] ").local8Bit() );
+ int len = strlen(buf);
+ strncpy( &buf[len], msg.local8Bit(), QT_BUFFER_LENGTH - len - 1 );
+ len += msg.length();
+ if (len >= QT_BUFFER_LENGTH) {
+ len = QT_BUFFER_LENGTH - 1;
+ }
+ buf[len] = '\0';
+ handle_buffer(buf, TQtDebugMsg);
+}
+
+void tqDebug( const char *msg, ... )
+{
+ char buf[QT_BUFFER_LENGTH];
+ strcpy( buf, TQDateTime::currentDateTime().toString("[yyyy/MM/dd hh:mm:ss.zzz] ").local8Bit() );
int len = strlen(buf);
va_list ap;
va_start( ap, msg ); // use variable arg list
@@ -559,24 +579,57 @@ void warning( const char *msg, ... )
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() );
+ handle_buffer(buf, TQtDebugMsg);
+}
+
+void tqWarning( const TQString &msg )
+{
+ char buf[QT_BUFFER_LENGTH];
+ strcpy( buf, TQDateTime::currentDateTime().toString("[yyyy/MM/dd hh:mm:ss.zzz] ").local8Bit() );
+ int len = strlen(buf);
+ strncpy( &buf[len], msg.local8Bit(), QT_BUFFER_LENGTH - len - 1 );
+ len += msg.length();
+ if (len >= QT_BUFFER_LENGTH) {
+ len = QT_BUFFER_LENGTH - 1;
+ }
+ buf[len] = '\0';
+ handle_buffer(buf, TQtWarningMsg);
+}
+
+void tqWarning( const char *msg, ... )
+{
+ char buf[QT_BUFFER_LENGTH];
+ strcpy( buf, TQDateTime::currentDateTime().toString("[yyyy/MM/dd hh:mm:ss.zzz] ").local8Bit() );
+ 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
- fprintf( stderr, "%s\n", buf ); // add newline
+ vsprintf( &buf[len], msg, ap );
#endif
+ va_end( ap );
+ handle_buffer(buf, TQtWarningMsg);
+}
+
+void tqFatal( const TQString &msg )
+{
+ char buf[QT_BUFFER_LENGTH];
+ strcpy( buf, TQDateTime::currentDateTime().toString("[yyyy/MM/dd hh:mm:ss.zzz] ").local8Bit() );
+ int len = strlen(buf);
+ strncpy( &buf[len], msg.local8Bit(), QT_BUFFER_LENGTH - len - 1 );
+ len += msg.length();
+ if (len >= QT_BUFFER_LENGTH) {
+ len = QT_BUFFER_LENGTH - 1;
}
+ buf[len] = '\0';
+ handle_buffer(buf, TQtFatalMsg);
}
void tqFatal( const char *msg, ... )
{
char buf[QT_BUFFER_LENGTH];
- strcpy( buf, TQDateTime::currentDateTime().toString("[yyyy/MM/dd hh:mm:ss.zzz] ").ascii() );
+ strcpy( buf, TQDateTime::currentDateTime().toString("[yyyy/MM/dd hh:mm:ss.zzz] ").local8Bit() );
int len = strlen(buf);
va_list ap;
va_start( ap, msg ); // use variable arg list
@@ -621,26 +674,7 @@ void fatal( const char *msg, ... )
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
- }
+ handle_buffer(buf, TQtFatalMsg);
}
/*!