From 5fdfaa5aec351182f603c1b4eebeb9b8d79d29dd Mon Sep 17 00:00:00 2001 From: Xiao YiFang Date: Thu, 2 Jun 2022 20:38:55 +0800 Subject: [PATCH] remove uselesscode the gdDebug gdWarning method, set the QTextCodec, does not seem to take effect --- gddebug.cc | 49 +++++++++---------------------------------------- 1 file changed, 9 insertions(+), 40 deletions(-) diff --git a/gddebug.cc b/gddebug.cc index 9fce9dd3..59958bc0 100644 --- a/gddebug.cc +++ b/gddebug.cc @@ -4,61 +4,30 @@ #include #include "gddebug.hh" #include -#if(QT_VERSION >= QT_VERSION_CHECK(6,0,0)) +#if( QT_VERSION >= QT_VERSION_CHECK( 6, 0, 0 ) ) #include #else #include #endif QFile * logFilePtr; -static QTextCodec * utf8Codec; -void gdWarning(const char *msg, ...) +void gdWarning( const char * msg, ... ) { -va_list ap; -va_start(ap, msg); -QTextCodec *localeCodec = 0; - - if( logFilePtr && logFilePtr->isOpen() ) - { - if( utf8Codec == 0 ) - utf8Codec = QTextCodec::codecForName( "UTF8" ); - - localeCodec = QTextCodec::codecForLocale(); - QTextCodec::setCodecForLocale( utf8Codec ); - } + va_list ap; + va_start( ap, msg ); qWarning() << QString().vasprintf( msg, ap ); - if( logFilePtr && logFilePtr->isOpen() ) - { - QTextCodec::setCodecForLocale( localeCodec ); - } - - va_end(ap); + va_end( ap ); } -void gdDebug(const char *msg, ...) +void gdDebug( const char * msg, ... ) { -va_list ap; -va_start(ap, msg); -// QTextCodec *localeCodec = 0; - - // if( logFilePtr && logFilePtr->isOpen() ) - // { - // if( utf8Codec == 0 ) - // utf8Codec = QTextCodec::codecForName( "UTF8" ); - - // localeCodec = QTextCodec::codecForLocale(); - // QTextCodec::setCodecForLocale( utf8Codec ); - // } + va_list ap; + va_start( ap, msg ); qDebug().noquote() << QString().vasprintf( msg, ap ); - // if( logFilePtr && logFilePtr->isOpen() ) - // { - // QTextCodec::setCodecForLocale( localeCodec ); - // } - - va_end(ap); + va_end( ap ); }