OSDN Git Service

Set text codec to UTF-8, so qDebug/qWarning/qFatal don't destroy Unicode strings...
authorlordmulder <mulder2@gmx.de>
Thu, 29 Sep 2011 18:06:09 +0000 (20:06 +0200)
committerlordmulder <mulder2@gmx.de>
Thu, 29 Sep 2011 18:06:09 +0000 (20:06 +0200)
etc/Translation/Blank.ts
src/Config.h
src/Dialog_MainWindow.cpp
src/Global.cpp
src/Global.h
src/Thread_DiskObserver.cpp
src/Thread_FileAnalyzer.cpp
src/Thread_Initialization.cpp

index 20a6969..f71e1e0 100644 (file)
 <context>
     <name>QApplication</name>
     <message>
-        <location filename="../../src/Global.cpp" line="683"/>
+        <location filename="../../src/Global.cpp" line="671"/>
         <source>Executable &apos;%1&apos; doesn&apos;t support Windows compatibility mode.</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../../src/Global.cpp" line="770"/>
+        <location filename="../../src/Global.cpp" line="758"/>
         <source>Executable &apos;%1&apos; requires Qt v%2, but found Qt v%3.</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../../src/Global.cpp" line="779"/>
+        <location filename="../../src/Global.cpp" line="767"/>
         <source>Executable &apos;%1&apos; requires Windows 2000 or later.</source>
         <translation type="unfinished"></translation>
     </message>
index 63726dd..bd0b5ad 100644 (file)
@@ -30,7 +30,7 @@
 #define VER_LAMEXP_MINOR_LO                                    3
 #define VER_LAMEXP_TYPE                                                Beta
 #define VER_LAMEXP_PATCH                                       2
-#define VER_LAMEXP_BUILD                                       700
+#define VER_LAMEXP_BUILD                                       702
 
 ///////////////////////////////////////////////////////////////////////////////
 // Tools versions
index 2a7336b..2cb2f36 100644 (file)
@@ -745,13 +745,13 @@ void MainWindow::dropEvent(QDropEvent *event)
                }
                if(file.isFile())
                {
-                       qDebug64("Dropped File: %1", file.canonicalFilePath());
+                       qDebug("Dropped File: %s", file.canonicalFilePath().toUtf8().constData());
                        droppedFiles << file.canonicalFilePath();
                        continue;
                }
                if(file.isDir())
                {
-                       qDebug64("Dropped Folder: %1", file.canonicalFilePath());
+                       qDebug("Dropped Folder: %s", file.canonicalFilePath().toUtf8().constData());
                        QList<QFileInfo> list = QDir(file.canonicalFilePath()).entryInfoList(QDir::Files | QDir::NoSymLinks);
                        if(list.count() > 0)
                        {
@@ -765,7 +765,7 @@ void MainWindow::dropEvent(QDropEvent *event)
                                list = QDir(file.canonicalFilePath()).entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot | QDir::NoSymLinks);
                                for(int j = 0; j < list.count(); j++)
                                {
-                                       qDebug64("Descending to Folder: %1", list.at(j).canonicalFilePath());
+                                       qDebug("Descending to Folder: %s", list.at(j).canonicalFilePath().toUtf8().constData());
                                        urls.prepend(QUrl::fromLocalFile(list.at(j).canonicalFilePath()));
                                }
                        }
index 2274cc3..bcf0764 100644 (file)
@@ -368,17 +368,14 @@ static void lamexp_console_color(FILE* file, WORD attributes)
 void lamexp_message_handler(QtMsgType type, const char *msg)
 {
        static const char *GURU_MEDITATION = "\n\nGURU MEDITATION !!!\n\n";
-
-       const char *text = msg;
-       const char *buffer = NULL;
        
        QMutexLocker lock(&g_lamexp_message_mutex);
 
-       if((strlen(msg) > 8) && (_strnicmp(msg, "@BASE64@", 8) == 0))
-       {
-               buffer = _strdup(QByteArray::fromBase64(msg + 8).constData());
-               if(buffer) text = buffer;
-       }
+       //if((strlen(msg) > 8) && (_strnicmp(msg, "@BASE64@", 8) == 0))
+       //{
+       //      buffer = _strdup(QByteArray::fromBase64(msg + 8).constData());
+       //      if(buffer) text = buffer;
+       //}
 
        if(g_lamexp_console_attached)
        {
@@ -393,17 +390,17 @@ void lamexp_message_handler(QtMsgType type, const char *msg)
                        fflush(stderr);
                        lamexp_console_color(stderr, FOREGROUND_RED | FOREGROUND_INTENSITY);
                        fprintf(stderr, GURU_MEDITATION);
-                       fprintf(stderr, "%s\n", text);
+                       fprintf(stderr, "%s\n", msg);
                        fflush(stderr);
                        break;
                case QtWarningMsg:
                        lamexp_console_color(stderr, FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY);
-                       fprintf(stderr, "%s\n", text);
+                       fprintf(stderr, "%s\n", msg);
                        fflush(stderr);
                        break;
                default:
                        lamexp_console_color(stderr, FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY);
-                       fprintf(stderr, "%s\n", text);
+                       fprintf(stderr, "%s\n", msg);
                        fflush(stderr);
                        break;
                }
@@ -413,42 +410,33 @@ void lamexp_message_handler(QtMsgType type, const char *msg)
        }
        else
        {
-               char temp[1024] = {'\0'};
+               QString temp("[LameXP][%1] %2");
                
                switch(type)
                {
                case QtCriticalMsg:
                case QtFatalMsg:
-                       _snprintf_s(temp, 1024, _TRUNCATE, "[LameXP][C] %s", text);
+                       temp = temp.arg("C", QString::fromUtf8(msg));
                        break;
                case QtWarningMsg:
-                       _snprintf_s(temp, 1024, _TRUNCATE, "[LameXP][C] %s", text);
+                       temp = temp.arg("W", QString::fromUtf8(msg));
                        break;
                default:
-                       _snprintf_s(temp, 1024, _TRUNCATE, "[LameXP][C] %s", text);
+                       temp = temp.arg("I", QString::fromUtf8(msg));
                        break;
                }
 
-               char *ptr = strchr(temp, '\n');
-               while(ptr != NULL)
-               {
-                       *ptr = '\t';
-                       ptr = strchr(temp, '\n');
-               }
-               
-               strncat_s(temp, 1024, "\n", _TRUNCATE);
-               OutputDebugStringA(temp);
+               temp.replace("\n", "\t").append("\n");
+               OutputDebugStringA(temp.toLatin1().constData());
        }
 
        if(type == QtCriticalMsg || type == QtFatalMsg)
        {
                lock.unlock();
-               MessageBoxW(NULL, QWCHAR(QString::fromUtf8(text)), L"LameXP - GURU MEDITATION", MB_ICONERROR | MB_TOPMOST | MB_TASKMODAL);
+               MessageBoxW(NULL, QWCHAR(QString::fromUtf8(msg)), L"LameXP - GURU MEDITATION", MB_ICONERROR | MB_TOPMOST | MB_TASKMODAL);
                FatalAppExit(0, L"The application has encountered a critical error and will exit now!");
                TerminateProcess(GetCurrentProcess(), -1);
        }
-
-       LAMEXP_SAFE_FREE(buffer);
 }
 
 /*
@@ -822,6 +810,9 @@ bool lamexp_init_qt(int argc, char* argv[])
        application->setOrganizationDomain("mulder.at.gg");
        application->setWindowIcon((date.month() == 12 && date.day() >= 24 && date.day() <= 26) ? QIcon(":/MainIcon2.png") : QIcon(":/MainIcon.png"));
        
+       //Set text Codec for locale
+       QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8"));
+
        //Load plugins from application directory
        QCoreApplication::setLibraryPaths(QStringList() << QApplication::applicationDirPath());
        qDebug("Library Path:\n%s\n", QApplication::libraryPaths().first().toUtf8().constData());
index e61b434..487dc46 100644 (file)
@@ -140,9 +140,9 @@ SIZE_T lamexp_dbg_private_bytes(void);
 #define LAMEXP_COMPILER_WARNING(TXT) __pragma(message(__FILE__ "(" LAMEXP_MAKE_STRING(__LINE__) ") : warning: " TXT))
 
 //Output Qt debug message (Unicode-safe versions)
-#define qDebug64(FORMAT, ...) qDebug("@BASE64@%s", QString(FORMAT).arg(__VA_ARGS__).toUtf8().toBase64().constData());
-#define qWarning64(FORMAT, ...) qWarning("@BASE64@%s", QString(FORMAT).arg(__VA_ARGS__).toUtf8().toBase64().constData());
-#define qFatal64(FORMAT, ...) qFatal("@BASE64@%s", QString(FORMAT).arg(__VA_ARGS__).toUtf8().toBase64().constData());
+//#define qDebug64(FORMAT, ...) qDebug("@BASE64@%s", QString(FORMAT).arg(__VA_ARGS__).toUtf8().toBase64().constData());
+//#define qWarning64(FORMAT, ...) qWarning("@BASE64@%s", QString(FORMAT).arg(__VA_ARGS__).toUtf8().toBase64().constData());
+//#define qFatal64(FORMAT, ...) qFatal("@BASE64@%s", QString(FORMAT).arg(__VA_ARGS__).toUtf8().toBase64().constData());
 
 //Check for debug build
 #if defined(_DEBUG) && defined(QT_DEBUG) && !defined(NDEBUG) && !defined(QT_NO_DEBUG)
index a58259d..564521b 100644 (file)
@@ -73,8 +73,8 @@ void DiskObserverThread::observe(void)
                freeSpace = lamexp_free_diskspace(m_path);
                if(freeSpace < minimumSpace)
                {
-                       qWarning64("Free diskspace on '%1' dropped below %2 MB, only %3 MB free!", m_path, QString::number(minimumSpace / 1048576), QString::number(freeSpace / 1048576));
-                       emit messageLogged(tr("Low diskspace on drive '%1' detected (only %2 MB are free), problems can occur!").arg(QDir::toNativeSeparators(m_path), QString::number(freeSpace / 1048576)), true);
+                       qWarning("Free diskspace on '%s' dropped below %s MB, only %s MB free!", m_path.toUtf8().constData(), QString::number(minimumSpace / 1048576ui64).toUtf8().constData(), QString::number(freeSpace / 1048576ui64).toUtf8().constData());
+                       emit messageLogged(tr("Low diskspace on drive '%1' detected (only %2 MB are free), problems can occur!").arg(QDir::toNativeSeparators(m_path), QString::number(freeSpace / 1048576ui64)), true);
                        minimumSpace = min(freeSpace, (minimumSpace >> 1));
                }
                Sleep(1000);
index 440cdf7..6b69ddc 100644 (file)
@@ -84,7 +84,7 @@ void FileAnalyzer::run()
        {
                int fileType = fileTypeNormal;
                QString currentFile = QDir::fromNativeSeparators(m_inputFiles.takeFirst());
-               qDebug64("Analyzing: %1", currentFile);
+               qDebug("Analyzing: %s", currentFile.toUtf8().constData());
                emit fileSelected(QFileInfo(currentFile).fileName());
                AudioFileModel file = analyzeFile(currentFile, &fileType);
                
@@ -134,13 +134,13 @@ void FileAnalyzer::run()
                                }
                                else
                                {
-                                       qDebug64("Rejected Avisynth file: %1", file.filePath());
+                                       qDebug("Rejected Avisynth file: %s", file.filePath().toUtf8().constData());
                                        m_filesRejected++;
                                }
                        }
                        else
                        {
-                               qDebug64("Rejected file of unknown type: %1", file.filePath());
+                               qDebug("Rejected file of unknown type: %s", file.filePath().toUtf8().constData());
                                m_filesRejected++;
                        }
                        continue;
@@ -513,7 +513,7 @@ bool FileAnalyzer::checkFile_CDDA(QFile &file)
 
 void FileAnalyzer::retrieveCover(AudioFileModel &audioFile, const QString &filePath)
 {
-       qDebug64("Retrieving cover from: %1", filePath);
+       qDebug("Retrieving cover from: %s", filePath.toUtf8().constData());
        QString extension;
 
        switch(m_currentCover)
index d691d1c..f6cac28 100644 (file)
@@ -299,7 +299,7 @@ void InitializationThread::initTranslations(void)
                
                if(lamexp_translation_register(langId, qmFile, langName, systemId))
                {
-                       qDebug64("Registering translation: %1 = %2 (%3)", qmFile, langName, QString::number(systemId));
+                       qDebug("Registering translation: %s = %s (%u)", qmFile.toUtf8().constData(), langName.toUtf8().constData(), systemId);
                }
                else
                {