From b54886f2422778db4836da63eb467483aa4c9474 Mon Sep 17 00:00:00 2001 From: LoRd_MuldeR Date: Mon, 21 Oct 2013 15:00:55 +0200 Subject: [PATCH] Introduce QUTF8 macro and replace ".toUtf8().constData()" everywhere. --- etc/Translation/Blank.ts | 8 +++--- etc/Translation/LameXP_PL.ts | 8 +++--- etc/Translation/LameXP_SV.ts | 8 +++--- src/Config.h | 2 +- src/Dialog_LogView.cpp | 2 +- src/Dialog_MainWindow.cpp | 16 ++++++------ src/Dialog_Processing.cpp | 2 +- src/Dialog_SplashScreen.cpp | 4 +-- src/Global.h | 43 ++++++++++++++++---------------- src/LockedFile.cpp | 14 +++++------ src/Main.cpp | 3 ++- src/Model_AudioFile.cpp | 2 +- src/Model_CueSheet.cpp | 20 +++++++-------- src/Model_FileList.cpp | 2 +- src/Model_Settings.cpp | 10 ++++---- src/PlaylistImporter.cpp | 4 ++- src/Thread_CueSplitter.cpp | 14 +++++------ src/Thread_DiskObserver.cpp | 2 +- src/Thread_FileAnalyzer_Task.cpp | 16 ++++++------ src/Thread_Initialization.cpp | 22 ++++++++-------- src/Thread_MessageProducer.cpp | 6 ++--- 21 files changed, 106 insertions(+), 102 deletions(-) diff --git a/etc/Translation/Blank.ts b/etc/Translation/Blank.ts index 9c03919e..d83c047a 100644 --- a/etc/Translation/Blank.ts +++ b/etc/Translation/Blank.ts @@ -3290,22 +3290,22 @@ QApplication - + Executable '%1' doesn't support Windows compatibility mode. - + Executable '%1' requires Qt v%2, but found Qt v%3. - + Executable '%1' was built for Qt '%2', but found Qt '%3'. - + Executable '%1' requires Windows XP or later. diff --git a/etc/Translation/LameXP_PL.ts b/etc/Translation/LameXP_PL.ts index 163d3517..f97764a4 100644 --- a/etc/Translation/LameXP_PL.ts +++ b/etc/Translation/LameXP_PL.ts @@ -3327,22 +3327,22 @@ QApplication - + Executable '%1' doesn't support Windows compatibility mode. Plik wykonywalny '%1' nie działa w trybie kompatybilności z Windows. - + Executable '%1' requires Qt v%2, but found Qt v%3. Plik wykonywalny '%1' wymaga Qt v%2, znaleziono jednak Qt v%3. - + Executable '%1' was built for Qt '%2', but found Qt '%3'. Plik wykonywalny "%1" został skompilowany dla Qt "%2", znaleziono "%3". - + Executable '%1' requires Windows XP or later. diff --git a/etc/Translation/LameXP_SV.ts b/etc/Translation/LameXP_SV.ts index 5747317f..6a212040 100644 --- a/etc/Translation/LameXP_SV.ts +++ b/etc/Translation/LameXP_SV.ts @@ -3310,22 +3310,22 @@ QApplication - + Executable '%1' doesn't support Windows compatibility mode. EXE-filen '%1' stöder inte Windows kompatibilitetsläge. - + Executable '%1' requires Qt v%2, but found Qt v%3. EXE-filen '%1' kräver Qt v%2, du har Qt v%3. - + Executable '%1' was built for Qt '%2', but found Qt '%3'. EXE-filen '%1' är byggd för Qt '%2', du har Qt '%3'. - + Executable '%1' requires Windows XP or later. diff --git a/src/Config.h b/src/Config.h index e2c18079..c47a26bb 100644 --- a/src/Config.h +++ b/src/Config.h @@ -34,7 +34,7 @@ #define VER_LAMEXP_MINOR_LO 9 #define VER_LAMEXP_TYPE Alpha #define VER_LAMEXP_PATCH 3 -#define VER_LAMEXP_BUILD 1410 +#define VER_LAMEXP_BUILD 1413 #define VER_LAMEXP_CONFG 1348 /////////////////////////////////////////////////////////////////////////////// diff --git a/src/Dialog_LogView.cpp b/src/Dialog_LogView.cpp index c4f04b45..ae4bf25c 100644 --- a/src/Dialog_LogView.cpp +++ b/src/Dialog_LogView.cpp @@ -79,7 +79,7 @@ int LogViewDialog::exec(const QStringList &logData) void LogViewDialog::copyButtonClicked(void) { QMimeData *mime = new QMimeData(); - mime->setData("text/plain", ui->textEdit->toPlainText().toUtf8().constData()); + mime->setData("text/plain", QUTF8(ui->textEdit->toPlainText())); QApplication::clipboard()->setMimeData(mime); m_clipboardUsed = true; m_oldIcon->swap(ui->buttonCopy->icon()); diff --git a/src/Dialog_MainWindow.cpp b/src/Dialog_MainWindow.cpp index b53d05e4..5217829a 100644 --- a/src/Dialog_MainWindow.cpp +++ b/src/Dialog_MainWindow.cpp @@ -1050,13 +1050,13 @@ void MainWindow::dropEvent(QDropEvent *event) } if(file.isFile()) { - qDebug("Dropped File: %s", file.canonicalFilePath().toUtf8().constData()); + qDebug("Dropped File: %s", QUTF8(file.canonicalFilePath())); droppedFiles << file.canonicalFilePath(); continue; } if(file.isDir()) { - qDebug("Dropped Folder: %s", file.canonicalFilePath().toUtf8().constData()); + qDebug("Dropped Folder: %s", QUTF8(file.canonicalFilePath())); QList list = QDir(file.canonicalFilePath()).entryInfoList(QDir::Files | QDir::NoSymLinks); if(list.count() > 0) { @@ -1070,7 +1070,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++) { - qDebug("Descending to Folder: %s", list.at(j).canonicalFilePath().toUtf8().constData()); + qDebug("Descending to Folder: %s", QUTF8(list.at(j).canonicalFilePath())); urls.prepend(QUrl::fromLocalFile(list.at(j).canonicalFilePath())); } } @@ -1390,7 +1390,7 @@ void MainWindow::windowShown(void) if(!arguments[i].compare("--add", Qt::CaseInsensitive)) { QFileInfo currentFile(arguments[++i].trimmed()); - qDebug("Adding file from CLI: %s", currentFile.absoluteFilePath().toUtf8().constData()); + qDebug("Adding file from CLI: %s", QUTF8(currentFile.absoluteFilePath())); addedFiles.append(currentFile.absoluteFilePath()); } if(!addedFiles.isEmpty()) @@ -1405,13 +1405,13 @@ void MainWindow::windowShown(void) if(!arguments[i].compare("--add-folder", Qt::CaseInsensitive)) { QFileInfo currentFile(arguments[++i].trimmed()); - qDebug("Adding folder from CLI: %s", currentFile.absoluteFilePath().toUtf8().constData()); + qDebug("Adding folder from CLI: %s", QUTF8(currentFile.absoluteFilePath())); addFolder(currentFile.absoluteFilePath(), false, true); } if(!arguments[i].compare("--add-recursive", Qt::CaseInsensitive)) { QFileInfo currentFile(arguments[++i].trimmed()); - qDebug("Adding folder recursively from CLI: %s", currentFile.absoluteFilePath().toUtf8().constData()); + qDebug("Adding folder recursively from CLI: %s", QUTF8(currentFile.absoluteFilePath())); addFolder(currentFile.absoluteFilePath(), true, true); } } @@ -3988,13 +3988,13 @@ void MainWindow::addFileDelayed(const QString &filePath, bool tryASAP) { if(tryASAP && !m_delayedFileTimer->isActive()) { - qDebug("Received file: %s", filePath.toUtf8().constData()); + qDebug("Received file: %s", QUTF8(filePath)); m_delayedFileList->append(filePath); QTimer::singleShot(0, this, SLOT(handleDelayedFiles())); } m_delayedFileTimer->stop(); - qDebug("Received file: %s", filePath.toUtf8().constData()); + qDebug("Received file: %s", QUTF8(filePath)); m_delayedFileList->append(filePath); m_delayedFileTimer->start(5000); } diff --git a/src/Dialog_Processing.cpp b/src/Dialog_Processing.cpp index 69e32af9..09b4dfa1 100644 --- a/src/Dialog_Processing.cpp +++ b/src/Dialog_Processing.cpp @@ -1012,7 +1012,7 @@ void ProcessingDialog::writePlayList(void) playList.write("#EXTM3U\r\n"); while(!list.isEmpty()) { - playList.write(useUtf8 ? list.takeFirst().toUtf8().constData() : list.takeFirst().toLatin1().constData()); + playList.write(useUtf8 ?QUTF8(list.takeFirst()) : list.takeFirst().toLatin1().constData()); playList.write("\r\n"); } playList.close(); diff --git a/src/Dialog_SplashScreen.cpp b/src/Dialog_SplashScreen.cpp index 169478dd..16fdd1b3 100644 --- a/src/Dialog_SplashScreen.cpp +++ b/src/Dialog_SplashScreen.cpp @@ -147,11 +147,11 @@ void SplashScreen::showSplash(QThread *thread) //Loop while thread is still running while(THREAD_RUNNING(thread)) { - ASYNC_WAIT(loop, 500); - if((deadlockCounter++ > 360) && thread->isRunning()) + if((++deadlockCounter) > 60) { qFatal("Deadlock in initialization thread detected!"); } + ASYNC_WAIT(loop, 5000); } //Stop the timer diff --git a/src/Global.h b/src/Global.h index 78ecbc6c..90ccacce 100644 --- a/src/Global.h +++ b/src/Global.h @@ -227,9 +227,10 @@ unsigned long lamexp_dbg_private_bytes(void); #define LAMEXP_DELETE_ARRAY(PTR) do { if(PTR) { delete [] PTR; PTR = NULL; } } while(0) #define LAMEXP_SAFE_FREE(PTR) do { if(PTR) { free((void*) PTR); PTR = NULL; } } while(0) #define LAMEXP_CLOSE(HANDLE) do { if(HANDLE != NULL && HANDLE != INVALID_HANDLE_VALUE) { CloseHandle(HANDLE); HANDLE = NULL; } } while(0) -#define QWCHAR(STR) reinterpret_cast((STR).utf16()) -#define WCHAR2QSTR(STR) QString::fromUtf16(reinterpret_cast(STR)) -#define LAMEXP_BOOL2STR(X) (X ? "1" : "0") +#define QWCHAR(STR) (reinterpret_cast((STR).utf16())) +#define WCHAR2QSTR(STR) (QString::fromUtf16(reinterpret_cast((STR)))) +#define QUTF8(STR) ((STR).toUtf8().constData()) +#define LAMEXP_BOOL2STR(X) ((X) ? "1" : "0") #define LAMEXP_MAKE_STRING_EX(X) #X #define LAMEXP_MAKE_STRING(X) LAMEXP_MAKE_STRING_EX(X) #define LAMEXP_COMPILER_WARNING(TXT) __pragma(message(__FILE__ "(" LAMEXP_MAKE_STRING(__LINE__) ") : warning: " TXT)) @@ -246,26 +247,26 @@ unsigned long lamexp_dbg_private_bytes(void); //Memory check #if LAMEXP_DEBUG -#define LAMEXP_MEMORY_CHECK(FUNC, RETV, ...) do \ -{ \ - SIZE_T _privateBytesBefore = lamexp_dbg_private_bytes(); \ - RETV = FUNC(__VA_ARGS__); \ - SIZE_T _privateBytesLeak = (lamexp_dbg_private_bytes() - _privateBytesBefore) / 1024; \ - if(_privateBytesLeak > 0) { \ - char _buffer[128]; \ - _snprintf_s(_buffer, 128, _TRUNCATE, "Memory leak: Lost %u KiloBytes of PrivateUsage memory.\n", _privateBytesLeak); \ - OutputDebugStringA("----------\n"); \ - OutputDebugStringA(_buffer); \ - OutputDebugStringA("----------\n"); \ + #define LAMEXP_MEMORY_CHECK(FUNC, RETV, ...) do \ + { \ + SIZE_T _privateBytesBefore = lamexp_dbg_private_bytes(); \ + RETV = FUNC(__VA_ARGS__); \ + SIZE_T _privateBytesLeak = (lamexp_dbg_private_bytes() - _privateBytesBefore) / 1024; \ + if(_privateBytesLeak > 0) { \ + char _buffer[128]; \ + _snprintf_s(_buffer, 128, _TRUNCATE, "Memory leak: Lost %u KiloBytes of PrivateUsage memory.\n", _privateBytesLeak); \ + OutputDebugStringA("----------\n"); \ + OutputDebugStringA(_buffer); \ + OutputDebugStringA("----------\n"); \ + } \ } \ -} \ -while(0) + while(0) #else -#define LAMEXP_MEMORY_CHECK(FUNC, RETV, ...) do \ -{ \ - RETV = __noop(__VA_ARGS__); \ -} \ -while(0) + #define LAMEXP_MEMORY_CHECK(FUNC, RETV, ...) do \ + { \ + RETV = __noop(__VA_ARGS__); \ + } \ + while(0) #endif //Check for CPU-compatibility options diff --git a/src/LockedFile.cpp b/src/LockedFile.cpp index 394b94b3..aa1981d8 100644 --- a/src/LockedFile.cpp +++ b/src/LockedFile.cpp @@ -112,13 +112,13 @@ LockedFile::LockedFile(QResource *const resource, const QString &outPath, const if(outFile.write(reinterpret_cast(resource->data()), resource->size()) != resource->size()) { QFile::remove(QFileInfo(outFile).canonicalFilePath()); - THROW_FMT("File '%s' could not be written!", QFileInfo(outFile).fileName().toUtf8().constData()); + THROW_FMT("File '%s' could not be written!", QUTF8(QFileInfo(outFile).fileName())); } outFile.close(); } else { - THROW_FMT("File '%s' could not be created!", QFileInfo(outFile).fileName().toUtf8().constData()); + THROW_FMT("File '%s' could not be created!", QUTF8(QFileInfo(outFile).fileName())); } //Now lock the file! @@ -134,7 +134,7 @@ LockedFile::LockedFile(QResource *const resource, const QString &outPath, const if((m_fileHandle == NULL) || (m_fileHandle == INVALID_HANDLE_VALUE)) { QFile::remove(QFileInfo(outFile).canonicalFilePath()); - THROW_FMT("File '%s' could not be locked!", QFileInfo(outFile).fileName().toUtf8().constData()); + THROW_FMT("File '%s' could not be locked!", QUTF8(QFileInfo(outFile).fileName())); } //Open file for reading @@ -163,7 +163,7 @@ LockedFile::LockedFile(QResource *const resource, const QString &outPath, const else { QFile::remove(m_filePath); - THROW_FMT("File '%s' could not be read!", QFileInfo(outFile).fileName().toUtf8().constData()); + THROW_FMT("File '%s' could not be read!", QUTF8(QFileInfo(outFile).fileName())); } //Compare hashes @@ -172,7 +172,7 @@ LockedFile::LockedFile(QResource *const resource, const QString &outPath, const qWarning("\nFile checksum error:\n A = %s\n B = %s\n", expectedHash.constData(), hash.constData()); LAMEXP_CLOSE(m_fileHandle); QFile::remove(m_filePath); - THROW_FMT("File '%s' is corruputed, take care!", QFileInfo(outFile).fileName().toUtf8().constData()); + THROW_FMT("File '%s' is corruputed, take care!", QUTF8(QFileInfo(outFile).fileName())); } } @@ -185,7 +185,7 @@ LockedFile::LockedFile(const QString &filePath) //Make sure the file exists, before we try to lock it if(!existingFile.exists()) { - THROW_FMT("File '%s' does not exist!", existingFile.fileName().toUtf8().constData()); + THROW_FMT("File '%s' does not exist!", QUTF8(existingFile.fileName())); } //Remember file path @@ -203,7 +203,7 @@ LockedFile::LockedFile(const QString &filePath) //Locked successfully? if((m_fileHandle == NULL) || (m_fileHandle == INVALID_HANDLE_VALUE)) { - THROW_FMT("File '%s' could not be locked!", existingFile.fileName().toUtf8().constData()); + THROW_FMT("File '%s' could not be locked!", QUTF8(existingFile.fileName())); } } diff --git a/src/Main.cpp b/src/Main.cpp index 1d4a7f73..34042c29 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -88,7 +88,7 @@ static int lamexp_main(int argc, char* argv[]) qDebug("Command-Line Arguments:"); for(int i = 0; i < arguments.count(); i++) { - qDebug("argv[%d]=%s", i, arguments.at(i).toUtf8().constData()); + qDebug("argv[%d]=%s", i, QUTF8(arguments.at(i))); } qDebug(""); @@ -271,6 +271,7 @@ int main(int argc, char* argv[]) { __try { + SetErrorMode(GetErrorMode() | SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX); SetUnhandledExceptionFilter(lamexp_exception_handler); _set_invalid_parameter_handler(lamexp_invalid_param_handler); return _main(argc, argv); diff --git a/src/Model_AudioFile.cpp b/src/Model_AudioFile.cpp index 9680ccf1..68f9430d 100644 --- a/src/Model_AudioFile.cpp +++ b/src/Model_AudioFile.cpp @@ -34,7 +34,7 @@ const unsigned int AudioFileModel::BITDEPTH_IEEE_FLOAT32 = UINT_MAX-1; #define PRINT_S(VAR) do \ { \ - if((VAR).isEmpty()) qDebug(#VAR " = N/A"); else qDebug(#VAR " = \"%s\"", (VAR).toUtf8().constData()); \ + if((VAR).isEmpty()) qDebug(#VAR " = N/A"); else qDebug(#VAR " = \"%s\"", QUTF8((VAR))); \ } \ while(0) diff --git a/src/Model_CueSheet.cpp b/src/Model_CueSheet.cpp index 11f1056f..a8b932fe 100644 --- a/src/Model_CueSheet.cpp +++ b/src/Model_CueSheet.cpp @@ -523,7 +523,7 @@ int CueSheetModel::parseCueFile(QFile &cueFile, const QDir &baseDir, QCoreApplic /* --- FILE --- */ if(rxFile.indexIn(line) >= 0) { - qDebug("%03d File: <%s> <%s>", lines, rxFile.cap(1).toUtf8().constData(), rxFile.cap(2).toUtf8().constData()); + qDebug("%03d File: <%s> <%s>", lines, QUTF8(rxFile.cap(1)), QUTF8(rxFile.cap(2))); if(currentFile) { if(currentTrack) @@ -560,7 +560,7 @@ int CueSheetModel::parseCueFile(QFile &cueFile, const QDir &baseDir, QCoreApplic else { bUnsupportedTrack = true; - qWarning("%03d Skipping unsupported file of type '%s'.", lines, rxFile.cap(2).toUtf8().constData()); + qWarning("%03d Skipping unsupported file of type '%s'.", lines, QUTF8(rxFile.cap(2))); currentFile = NULL; } bPreamble = false; @@ -573,7 +573,7 @@ int CueSheetModel::parseCueFile(QFile &cueFile, const QDir &baseDir, QCoreApplic { if(currentFile) { - qDebug("%03d Track: <%s> <%s>", lines, rxTrack.cap(1).toUtf8().constData(), rxTrack.cap(2).toUtf8().constData()); + qDebug("%03d Track: <%s> <%s>", lines, QUTF8(rxTrack.cap(1)), QUTF8(rxTrack.cap(2))); if(currentTrack) { if(currentTrack->isValid()) @@ -593,7 +593,7 @@ int CueSheetModel::parseCueFile(QFile &cueFile, const QDir &baseDir, QCoreApplic else { bUnsupportedTrack = true; - qWarning("%03d Skipping unsupported track of type '%s'.", lines, rxTrack.cap(2).toUtf8().constData()); + qWarning("%03d Skipping unsupported track of type '%s'.", lines, QUTF8(rxTrack.cap(2))); currentTrack = NULL; } } @@ -610,7 +610,7 @@ int CueSheetModel::parseCueFile(QFile &cueFile, const QDir &baseDir, QCoreApplic { if(currentFile && currentTrack) { - qDebug("%03d Index: <%s> <%s>", lines, rxIndex.cap(1).toUtf8().constData(), rxIndex.cap(2).toUtf8().constData()); + qDebug("%03d Index: <%s> <%s>", lines, QUTF8(rxIndex.cap(1)), QUTF8(rxIndex.cap(2))); if(rxIndex.cap(1).toInt() == 1) { currentTrack->setStartIndex(parseTimeIndex(rxIndex.cap(2))); @@ -628,7 +628,7 @@ int CueSheetModel::parseCueFile(QFile &cueFile, const QDir &baseDir, QCoreApplic } else if(currentFile && currentTrack) { - qDebug("%03d Title: <%s>", lines, rxTitle.cap(1).toUtf8().constData()); + qDebug("%03d Title: <%s>", lines, QUTF8(rxTitle.cap(1))); currentTrack->metaInfo().setTitle(UNQUOTE(rxTitle.cap(1)).simplified()); } continue; @@ -643,7 +643,7 @@ int CueSheetModel::parseCueFile(QFile &cueFile, const QDir &baseDir, QCoreApplic } else if(currentFile && currentTrack) { - qDebug("%03d Title: <%s>", lines, rxPerformer.cap(1).toUtf8().constData()); + qDebug("%03d Title: <%s>", lines, QUTF8(rxPerformer.cap(1))); currentTrack->metaInfo().setArtist(UNQUOTE(rxPerformer.cap(1)).simplified()); } continue; @@ -666,7 +666,7 @@ int CueSheetModel::parseCueFile(QFile &cueFile, const QDir &baseDir, QCoreApplic } else if(currentFile && currentTrack) { - qDebug("%03d Genre: <%s>", lines, rxGenre.cap(1).toUtf8().constData()); + qDebug("%03d Genre: <%s>", lines, QUTF8(rxGenre.cap(1))); QString temp = UNQUOTE(rxGenre.cap(1).simplified()); for(int i = 0; g_lamexp_generes[i]; i++) { @@ -691,7 +691,7 @@ int CueSheetModel::parseCueFile(QFile &cueFile, const QDir &baseDir, QCoreApplic } else if(currentFile && currentTrack) { - qDebug("%03d Year: <%s>", lines, rxPerformer.cap(1).toUtf8().constData()); + qDebug("%03d Year: <%s>", lines, QUTF8(rxPerformer.cap(1))); bool ok = false; unsigned int temp = rxYear.cap(1).toUInt(&ok); if(ok) currentTrack->metaInfo().setYear(temp); @@ -831,7 +831,7 @@ double CueSheetModel::parseTimeIndex(const QString &index) } } - qWarning(" Bad time index: '%s'", index.toUtf8().constData()); + qWarning(" Bad time index: '%s'", QUTF8(index)); return std::numeric_limits::quiet_NaN(); } diff --git a/src/Model_FileList.cpp b/src/Model_FileList.cpp index 3a7905fe..f2ad11d3 100644 --- a/src/Model_FileList.cpp +++ b/src/Model_FileList.cpp @@ -494,7 +494,7 @@ int FileListModel::importFromCsv(QWidget *parent, const QString &inFile) } else { - qWarning("Unkonw field '%s' will be ignored!", header.at(j).toUtf8().constData()); + qWarning("Unkonw field '%s' will be ignored!", QUTF8(header.at(j))); ignore[j] = true; if(!checkArray(ignore, false, nCols)) diff --git a/src/Model_Settings.cpp b/src/Model_Settings.cpp index 6fc930d8..c12a6b4a 100644 --- a/src/Model_Settings.cpp +++ b/src/Model_Settings.cpp @@ -110,7 +110,7 @@ public: } else { - qWarning("Could not find '%s' in cache, but it has been marked as dirty!", (*iter).toUtf8().constData()); + qWarning("Could not find '%s' in cache, but it has been marked as dirty!", QUTF8(*iter)); } } m_configFile->sync(); @@ -322,7 +322,7 @@ SettingsModel::SettingsModel(void) continue; } } - qWarning("Deleting obsolete group from config: %s", current.toUtf8().constData()); + qWarning("Deleting obsolete group from config: %s", QUTF8(current)); REMOVE_GROUP(configFile, current); } @@ -463,9 +463,9 @@ QString SettingsModel::defaultLanguage(void) const //Detect system langauge QLocale systemLanguage= QLocale::system(); qDebug("[Locale]"); - qDebug("Language: %s (%d)", QLocale::languageToString(systemLanguage.language()).toUtf8().constData(), systemLanguage.language()); - qDebug("Country is: %s (%d)", QLocale::countryToString(systemLanguage.country()).toUtf8().constData(), systemLanguage.country()); - qDebug("Script is: %s (%d)\n", QLocale::scriptToString(systemLanguage.script()).toUtf8().constData(), systemLanguage.script()); + qDebug("Language: %s (%d)", QUTF8(QLocale::languageToString(systemLanguage.language())), systemLanguage.language()); + qDebug("Country is: %s (%d)", QUTF8(QLocale::countryToString(systemLanguage.country())), systemLanguage.country()); + qDebug("Script is: %s (%d)\n", QUTF8(QLocale::scriptToString(systemLanguage.script())), systemLanguage.script()); //Check if we can use the default translation if(systemLanguage.language() == QLocale::English /*|| systemLanguage.language() == QLocale::C*/) diff --git a/src/PlaylistImporter.cpp b/src/PlaylistImporter.cpp index f8bab664..e26de25e 100644 --- a/src/PlaylistImporter.cpp +++ b/src/PlaylistImporter.cpp @@ -21,6 +21,8 @@ #include "PlaylistImporter.h" +#include "Global.h" + #include #include #include @@ -167,7 +169,7 @@ bool PlaylistImporter::parsePlaylist_m3u(QFile &data, QStringList &fileList, con if(filename.exists() && filename.isFile()) { - qDebug("Found: \"%s\"", filePath[i].toUtf8().constData()); + qDebug("Found: \"%s\"", QUTF8(filePath[i])); if(isPlaylist(filename.canonicalFilePath()) == notPlaylist) { fileList << filename.canonicalFilePath(); diff --git a/src/Thread_CueSplitter.cpp b/src/Thread_CueSplitter.cpp index 3360f9e6..fb5e32ef 100644 --- a/src/Thread_CueSplitter.cpp +++ b/src/Thread_CueSplitter.cpp @@ -64,7 +64,7 @@ CueSplitter::CueSplitter(const QString &outputDir, const QString &baseName, CueS for(int i = 0; i < nInputFiles; i++) { m_inputFilesInfo.insert(inputFilesInfo[i].filePath(), inputFilesInfo[i]); - qDebug("File %02d: <%s>", i, inputFilesInfo[i].filePath().toUtf8().constData()); + qDebug("File %02d: <%s>", i, QUTF8(inputFilesInfo[i].filePath())); } qDebug("All input files added."); @@ -95,7 +95,7 @@ void CueSplitter::run() if(!QDir(m_outputDir).exists()) { - qWarning("Output directory \"%s\" does not exist!", m_outputDir.toUtf8().constData()); + qWarning("Output directory \"%s\" does not exist!", QUTF8(m_outputDir)); return; } @@ -243,12 +243,12 @@ void CueSplitter::handleUpdate(int progress) void CueSplitter::splitFile(const QString &output, const int trackNo, const QString &file, const double offset, const double length, const AudioFileModel_MetaInfo &metaInfo, const int baseProgress) { qDebug("[Track %02d]", trackNo); - qDebug("File: <%s>", file.toUtf8().constData()); + qDebug("File: <%s>", QUTF8(file)); qDebug("Offset: <%f> <%s>", offset, indexToString(offset).toLatin1().constData()); qDebug("Length: <%f> <%s>", length, indexToString(length).toLatin1().constData()); - qDebug("Artist: <%s>", metaInfo.artist().toUtf8().constData()); - qDebug("Title: <%s>", metaInfo.title().toUtf8().constData()); - qDebug("Album: <%s>", metaInfo.album().toUtf8().constData()); + qDebug("Artist: <%s>", QUTF8(metaInfo.artist())); + qDebug("Title: <%s>", QUTF8(metaInfo.title())); + qDebug("Album: <%s>", QUTF8(metaInfo.album())); int prevProgress = baseProgress; @@ -261,7 +261,7 @@ void CueSplitter::splitFile(const QString &output, const int trackNo, const QStr QString baseName = shortName(QFileInfo(output).fileName()); QString decompressedInput = m_decompressedFiles[file]; - qDebug("Input: <%s>", decompressedInput.toUtf8().constData()); + qDebug("Input: <%s>", QUTF8(decompressedInput)); AudioFileModel outFileInfo(output); outFileInfo.setMetaInfo(metaInfo); diff --git a/src/Thread_DiskObserver.cpp b/src/Thread_DiskObserver.cpp index 74af323a..e600e5b4 100644 --- a/src/Thread_DiskObserver.cpp +++ b/src/Thread_DiskObserver.cpp @@ -83,7 +83,7 @@ void DiskObserverThread::observe(void) { if(freeSpace < minimumSpace) { - 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()); + qWarning("Free diskspace on '%s' dropped below %s MB, only %s MB free!", QUTF8(m_path), QUTF8(QString::number(minimumSpace / 1048576ui64)), QUTF8(QString::number(freeSpace / 1048576ui64))); 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)), ProgressModel::SysMsg_Warning); minimumSpace = qMin(freeSpace, (minimumSpace >> 1)); } diff --git a/src/Thread_FileAnalyzer_Task.cpp b/src/Thread_FileAnalyzer_Task.cpp index bef209d5..65ceb4a9 100644 --- a/src/Thread_FileAnalyzer_Task.cpp +++ b/src/Thread_FileAnalyzer_Task.cpp @@ -96,7 +96,7 @@ void AnalyzeTask::run_ex(void) { int fileType = fileTypeNormal; QString currentFile = QDir::fromNativeSeparators(m_inputFile); - qDebug("Analyzing: %s", currentFile.toUtf8().constData()); + qDebug("Analyzing: %s", QUTF8(currentFile)); AudioFileModel file = analyzeFile(currentFile, &fileType); @@ -132,12 +132,12 @@ void AnalyzeTask::run_ex(void) } else { - qDebug("Rejected Avisynth file: %s", file.filePath().toUtf8().constData()); + qDebug("Rejected Avisynth file: %s", QUTF8(file.filePath())); } } else { - qDebug("Rejected file of unknown type: %s", file.filePath().toUtf8().constData()); + qDebug("Rejected file of unknown type: %s", QUTF8(file.filePath())); } } break; @@ -219,7 +219,7 @@ const AudioFileModel AnalyzeTask::analyzeFile(const QString &filePath, int *type QString line = QString::fromUtf8(process.readLine().constData()).simplified(); if(!line.isEmpty()) { - //qDebug("Line:%s", line.toUtf8().constData()); + //qDebug("Line:%s", QUTF8(line)); int index = line.indexOf('='); if(index > 0) @@ -278,7 +278,7 @@ const AudioFileModel AnalyzeTask::analyzeFile(const QString &filePath, int *type void AnalyzeTask::updateInfo(AudioFileModel &audioFile, bool *skipNext, unsigned int *id_val, cover_t *coverType, QByteArray *coverData, const QString &key, const QString &value) { - //qWarning("'%s' -> '%s'", key.toUtf8().constData(), value.toUtf8().constData()); + //qWarning("'%s' -> '%s'", QUTF8(key), QUTF8(value)); /*New Stream*/ if(IS_KEY("Gen_ID") || IS_KEY("Aud_ID")) @@ -393,7 +393,7 @@ void AnalyzeTask::updateInfo(AudioFileModel &audioFile, bool *skipNext, unsigned } else { - qWarning("Unknown key '%s' with value '%s' found!", key.toUtf8().constData(), value.toUtf8().constData()); + qWarning("Unknown key '%s' with value '%s' found!", QUTF8(key), QUTF8(value)); } return; } @@ -454,13 +454,13 @@ void AnalyzeTask::updateInfo(AudioFileModel &audioFile, bool *skipNext, unsigned } else { - qWarning("Unknown key '%s' with value '%s' found!", key.toUtf8().constData(), value.toUtf8().constData()); + qWarning("Unknown key '%s' with value '%s' found!", QUTF8(key), QUTF8(value)); } return; } /*Section not recognized*/ - qWarning("Unknown section: %s", key.toUtf8().constData()); + qWarning("Unknown section: %s", QUTF8(key)); } bool AnalyzeTask::checkFile_CDDA(QFile &file) diff --git a/src/Thread_Initialization.cpp b/src/Thread_Initialization.cpp index 859f7eb0..52198519 100644 --- a/src/Thread_Initialization.cpp +++ b/src/Thread_Initialization.cpp @@ -222,7 +222,7 @@ void InitializationThread::run() default: THROW("CPU support undefined!"); } - //Allocate maps + //Allocate queues QQueue queueToolName; QQueue queueChecksum; QQueue queueVersInfo; @@ -276,7 +276,7 @@ void InitializationThread::run() const QByteArray toolHash(checksum.toLatin1()); if(toolHash.size() != 96) { - qFatal("The checksum for \"%s\" has an invalid size!", toolName.toUtf8().constData()); + qFatal("The checksum for \"%s\" has an invalid size!", QUTF8(toolName)); return; } @@ -284,7 +284,7 @@ void InitializationThread::run() if(!(resource->isValid() && resource->data())) { LAMEXP_DELETE(resource); - qFatal("The resource for \"%s\" could not be found!", toolName.toUtf8().constData()); + qFatal("The resource for \"%s\" could not be found!", QUTF8(toolName)); return; } @@ -419,7 +419,7 @@ void InitializationThread::initTranslations(void) { if(lamexp_translation_register(langId, qmFile, langName, systemId, country)) { - qDebug("Registering translation: %s = %s (%u) [%u]", qmFile.toUtf8().constData(), langName.toUtf8().constData(), systemId, country); + qDebug("Registering translation: %s = %s (%u) [%u]", QUTF8(qmFile), QUTF8(langName), systemId, country); } else { @@ -450,7 +450,7 @@ void InitializationThread::initNeroAac(void) return; } - qDebug("Found Nero AAC encoder binary:\n%s\n", neroFileInfo[0].canonicalFilePath().toUtf8().constData()); + qDebug("Found Nero AAC encoder binary:\n%s\n", QUTF8(neroFileInfo[0].canonicalFilePath())); LockedFile *neroBin[3]; for(int i = 0; i < 3; i++) neroBin[i] = NULL; @@ -555,8 +555,8 @@ void InitializationThread::initFhgAac(void) return; } - qDebug("Found FhgAacEnc cli_exe:\n%s\n", fhgFileInfo[0].canonicalFilePath().toUtf8().constData()); - qDebug("Found FhgAacEnc enc_dll:\n%s\n", fhgFileInfo[1].canonicalFilePath().toUtf8().constData()); + qDebug("Found FhgAacEnc cli_exe:\n%s\n", QUTF8(fhgFileInfo[0].canonicalFilePath())); + qDebug("Found FhgAacEnc enc_dll:\n%s\n", QUTF8(fhgFileInfo[1].canonicalFilePath())); LockedFile *fhgBin[5]; for(int i = 0; i < 5; i++) fhgBin[i] = NULL; @@ -654,7 +654,7 @@ void InitializationThread::initQAac(void) return; } - qDebug("Found QAAC encoder:\n%s\n", qaacFileInfo[0].canonicalFilePath().toUtf8().constData()); + qDebug("Found QAAC encoder:\n%s\n", QUTF8(qaacFileInfo[0].canonicalFilePath())); LockedFile *qaacBin[2]; for(int i = 0; i < 2; i++) qaacBin[i] = NULL; @@ -800,17 +800,17 @@ void InitializationThread::selfTest(void) const QByteArray expectedHash = QByteArray(g_lamexp_tools[i].pcHash); if(g_lamexp_tools[i].uiCpuType & cpu[k]) { - qDebug("%02i -> %s", ++n, toolName.toUtf8().constData()); + qDebug("%02i -> %s", ++n, QUTF8(toolName)); QFile resource(QString(":/tools/%1").arg(toolName)); if(!resource.open(QIODevice::ReadOnly)) { - qFatal("The resource for \"%s\" could not be opened!", toolName.toUtf8().constData()); + qFatal("The resource for \"%s\" could not be opened!", QUTF8(toolName)); break; } QByteArray hash = LockedFile::fileHash(resource); if(hash.isNull() || _stricmp(hash.constData(), expectedHash.constData())) { - qFatal("Hash check for tool \"%s\" has failed!", toolName.toUtf8().constData()); + qFatal("Hash check for tool \"%s\" has failed!", QUTF8(toolName)); break; } resource.close(); diff --git a/src/Thread_MessageProducer.cpp b/src/Thread_MessageProducer.cpp index 3fa7f0f6..59394f1d 100644 --- a/src/Thread_MessageProducer.cpp +++ b/src/Thread_MessageProducer.cpp @@ -69,7 +69,7 @@ void MessageProducerThread::run() QFileInfo file = QFileInfo(arguments[++i]); if(file.exists() && file.isFile()) { - lamexp_ipc_send(1, file.canonicalFilePath().toUtf8().constData()); + lamexp_ipc_send(1, QUTF8(file.canonicalFilePath())); } bSentFiles = true; } @@ -78,7 +78,7 @@ void MessageProducerThread::run() QDir dir = QDir(arguments[++i]); if(dir.exists()) { - lamexp_ipc_send(2, dir.canonicalPath().toUtf8().constData()); + lamexp_ipc_send(2, QUTF8(dir.canonicalPath())); } bSentFiles = true; } @@ -87,7 +87,7 @@ void MessageProducerThread::run() QDir dir = QDir(arguments[++i]); if(dir.exists()) { - lamexp_ipc_send(3, dir.canonicalPath().toUtf8().constData()); + lamexp_ipc_send(3, QUTF8(dir.canonicalPath())); } bSentFiles = true; }