Set text codec to UTF-8, so qDebug/qWarning/qFatal don't destroy Unicode strings. Also remove qDebug64() and friends, as we don't need them any more.

This commit is contained in:
LoRd_MuldeR 2011-09-29 20:06:09 +02:00
parent 9f011cb572
commit 282528ea67
8 changed files with 35 additions and 44 deletions

View File

@ -2684,17 +2684,17 @@
<context> <context>
<name>QApplication</name> <name>QApplication</name>
<message> <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> <source>Executable &apos;%1&apos; doesn&apos;t support Windows compatibility mode.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<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> <source>Executable &apos;%1&apos; requires Qt v%2, but found Qt v%3.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<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> <source>Executable &apos;%1&apos; requires Windows 2000 or later.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>

View File

@ -30,7 +30,7 @@
#define VER_LAMEXP_MINOR_LO 3 #define VER_LAMEXP_MINOR_LO 3
#define VER_LAMEXP_TYPE Beta #define VER_LAMEXP_TYPE Beta
#define VER_LAMEXP_PATCH 2 #define VER_LAMEXP_PATCH 2
#define VER_LAMEXP_BUILD 700 #define VER_LAMEXP_BUILD 702
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// Tools versions // Tools versions

View File

@ -745,13 +745,13 @@ void MainWindow::dropEvent(QDropEvent *event)
} }
if(file.isFile()) if(file.isFile())
{ {
qDebug64("Dropped File: %1", file.canonicalFilePath()); qDebug("Dropped File: %s", file.canonicalFilePath().toUtf8().constData());
droppedFiles << file.canonicalFilePath(); droppedFiles << file.canonicalFilePath();
continue; continue;
} }
if(file.isDir()) 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); QList<QFileInfo> list = QDir(file.canonicalFilePath()).entryInfoList(QDir::Files | QDir::NoSymLinks);
if(list.count() > 0) if(list.count() > 0)
{ {
@ -765,7 +765,7 @@ void MainWindow::dropEvent(QDropEvent *event)
list = QDir(file.canonicalFilePath()).entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot | QDir::NoSymLinks); list = QDir(file.canonicalFilePath()).entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot | QDir::NoSymLinks);
for(int j = 0; j < list.count(); j++) 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())); urls.prepend(QUrl::fromLocalFile(list.at(j).canonicalFilePath()));
} }
} }

View File

@ -368,17 +368,14 @@ static void lamexp_console_color(FILE* file, WORD attributes)
void lamexp_message_handler(QtMsgType type, const char *msg) void lamexp_message_handler(QtMsgType type, const char *msg)
{ {
static const char *GURU_MEDITATION = "\n\nGURU MEDITATION !!!\n\n"; static const char *GURU_MEDITATION = "\n\nGURU MEDITATION !!!\n\n";
const char *text = msg;
const char *buffer = NULL;
QMutexLocker lock(&g_lamexp_message_mutex); QMutexLocker lock(&g_lamexp_message_mutex);
if((strlen(msg) > 8) && (_strnicmp(msg, "@BASE64@", 8) == 0)) //if((strlen(msg) > 8) && (_strnicmp(msg, "@BASE64@", 8) == 0))
{ //{
buffer = _strdup(QByteArray::fromBase64(msg + 8).constData()); // buffer = _strdup(QByteArray::fromBase64(msg + 8).constData());
if(buffer) text = buffer; // if(buffer) text = buffer;
} //}
if(g_lamexp_console_attached) if(g_lamexp_console_attached)
{ {
@ -393,17 +390,17 @@ void lamexp_message_handler(QtMsgType type, const char *msg)
fflush(stderr); fflush(stderr);
lamexp_console_color(stderr, FOREGROUND_RED | FOREGROUND_INTENSITY); lamexp_console_color(stderr, FOREGROUND_RED | FOREGROUND_INTENSITY);
fprintf(stderr, GURU_MEDITATION); fprintf(stderr, GURU_MEDITATION);
fprintf(stderr, "%s\n", text); fprintf(stderr, "%s\n", msg);
fflush(stderr); fflush(stderr);
break; break;
case QtWarningMsg: case QtWarningMsg:
lamexp_console_color(stderr, FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY); lamexp_console_color(stderr, FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY);
fprintf(stderr, "%s\n", text); fprintf(stderr, "%s\n", msg);
fflush(stderr); fflush(stderr);
break; break;
default: default:
lamexp_console_color(stderr, FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY); lamexp_console_color(stderr, FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY);
fprintf(stderr, "%s\n", text); fprintf(stderr, "%s\n", msg);
fflush(stderr); fflush(stderr);
break; break;
} }
@ -413,42 +410,33 @@ void lamexp_message_handler(QtMsgType type, const char *msg)
} }
else else
{ {
char temp[1024] = {'\0'}; QString temp("[LameXP][%1] %2");
switch(type) switch(type)
{ {
case QtCriticalMsg: case QtCriticalMsg:
case QtFatalMsg: case QtFatalMsg:
_snprintf_s(temp, 1024, _TRUNCATE, "[LameXP][C] %s", text); temp = temp.arg("C", QString::fromUtf8(msg));
break; break;
case QtWarningMsg: case QtWarningMsg:
_snprintf_s(temp, 1024, _TRUNCATE, "[LameXP][C] %s", text); temp = temp.arg("W", QString::fromUtf8(msg));
break; break;
default: default:
_snprintf_s(temp, 1024, _TRUNCATE, "[LameXP][C] %s", text); temp = temp.arg("I", QString::fromUtf8(msg));
break; break;
} }
char *ptr = strchr(temp, '\n'); temp.replace("\n", "\t").append("\n");
while(ptr != NULL) OutputDebugStringA(temp.toLatin1().constData());
{
*ptr = '\t';
ptr = strchr(temp, '\n');
}
strncat_s(temp, 1024, "\n", _TRUNCATE);
OutputDebugStringA(temp);
} }
if(type == QtCriticalMsg || type == QtFatalMsg) if(type == QtCriticalMsg || type == QtFatalMsg)
{ {
lock.unlock(); 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!"); FatalAppExit(0, L"The application has encountered a critical error and will exit now!");
TerminateProcess(GetCurrentProcess(), -1); 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->setOrganizationDomain("mulder.at.gg");
application->setWindowIcon((date.month() == 12 && date.day() >= 24 && date.day() <= 26) ? QIcon(":/MainIcon2.png") : QIcon(":/MainIcon.png")); 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 //Load plugins from application directory
QCoreApplication::setLibraryPaths(QStringList() << QApplication::applicationDirPath()); QCoreApplication::setLibraryPaths(QStringList() << QApplication::applicationDirPath());
qDebug("Library Path:\n%s\n", QApplication::libraryPaths().first().toUtf8().constData()); qDebug("Library Path:\n%s\n", QApplication::libraryPaths().first().toUtf8().constData());

View 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)) #define LAMEXP_COMPILER_WARNING(TXT) __pragma(message(__FILE__ "(" LAMEXP_MAKE_STRING(__LINE__) ") : warning: " TXT))
//Output Qt debug message (Unicode-safe versions) //Output Qt debug message (Unicode-safe versions)
#define qDebug64(FORMAT, ...) qDebug("@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 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 qFatal64(FORMAT, ...) qFatal("@BASE64@%s", QString(FORMAT).arg(__VA_ARGS__).toUtf8().toBase64().constData());
//Check for debug build //Check for debug build
#if defined(_DEBUG) && defined(QT_DEBUG) && !defined(NDEBUG) && !defined(QT_NO_DEBUG) #if defined(_DEBUG) && defined(QT_DEBUG) && !defined(NDEBUG) && !defined(QT_NO_DEBUG)

View File

@ -73,8 +73,8 @@ void DiskObserverThread::observe(void)
freeSpace = lamexp_free_diskspace(m_path); freeSpace = lamexp_free_diskspace(m_path);
if(freeSpace < minimumSpace) 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)); 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 / 1048576)), true); 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)); minimumSpace = min(freeSpace, (minimumSpace >> 1));
} }
Sleep(1000); Sleep(1000);

View File

@ -84,7 +84,7 @@ void FileAnalyzer::run()
{ {
int fileType = fileTypeNormal; int fileType = fileTypeNormal;
QString currentFile = QDir::fromNativeSeparators(m_inputFiles.takeFirst()); QString currentFile = QDir::fromNativeSeparators(m_inputFiles.takeFirst());
qDebug64("Analyzing: %1", currentFile); qDebug("Analyzing: %s", currentFile.toUtf8().constData());
emit fileSelected(QFileInfo(currentFile).fileName()); emit fileSelected(QFileInfo(currentFile).fileName());
AudioFileModel file = analyzeFile(currentFile, &fileType); AudioFileModel file = analyzeFile(currentFile, &fileType);
@ -134,13 +134,13 @@ void FileAnalyzer::run()
} }
else else
{ {
qDebug64("Rejected Avisynth file: %1", file.filePath()); qDebug("Rejected Avisynth file: %s", file.filePath().toUtf8().constData());
m_filesRejected++; m_filesRejected++;
} }
} }
else else
{ {
qDebug64("Rejected file of unknown type: %1", file.filePath()); qDebug("Rejected file of unknown type: %s", file.filePath().toUtf8().constData());
m_filesRejected++; m_filesRejected++;
} }
continue; continue;
@ -513,7 +513,7 @@ bool FileAnalyzer::checkFile_CDDA(QFile &file)
void FileAnalyzer::retrieveCover(AudioFileModel &audioFile, const QString &filePath) void FileAnalyzer::retrieveCover(AudioFileModel &audioFile, const QString &filePath)
{ {
qDebug64("Retrieving cover from: %1", filePath); qDebug("Retrieving cover from: %s", filePath.toUtf8().constData());
QString extension; QString extension;
switch(m_currentCover) switch(m_currentCover)

View File

@ -299,7 +299,7 @@ void InitializationThread::initTranslations(void)
if(lamexp_translation_register(langId, qmFile, langName, systemId)) 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 else
{ {