diff --git a/etc/Translation/Blank.ts b/etc/Translation/Blank.ts
index c353c453..784bec78 100644
--- a/etc/Translation/Blank.ts
+++ b/etc/Translation/Blank.ts
@@ -3290,24 +3290,24 @@
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 2000 or later.
+
+
+ Executable '%1' requires Windows XP or later.
diff --git a/etc/Translation/LameXP_DE.ts b/etc/Translation/LameXP_DE.ts
index 13a623ca..b0536c8d 100644
--- a/etc/Translation/LameXP_DE.ts
+++ b/etc/Translation/LameXP_DE.ts
@@ -2586,14 +2586,14 @@
Executable '%1' requires Qt v%2, but found Qt v%3.
Programm '%1' benötigt Qt v%2, aber Qt v%3 wurde gefunden.
-
- Executable '%1' requires Windows 2000 or later.
- Programm '%1' benötigt Windows 2000 oder neuer.
-
Executable '%1' was built for Qt '%2', but found Qt '%3'.
Programm '%1' wurde für Qt '%2' erzeugt, aber Qt '%3' gefunden.
+
+ Executable '%1' requires Windows XP or later.
+
+
ShellIntegration
diff --git a/etc/Translation/LameXP_ES.ts b/etc/Translation/LameXP_ES.ts
index 6e5a6f9c..4dba2614 100644
--- a/etc/Translation/LameXP_ES.ts
+++ b/etc/Translation/LameXP_ES.ts
@@ -2585,14 +2585,14 @@
Executable '%1' requires Qt v%2, but found Qt v%3.
El ejecutable '%1'requiere Qt v%2, pero se ha encontrado v%3.
-
- Executable '%1' requires Windows 2000 or later.
- El ejecutable '%1'requiere Windows 2000 o superior.
-
Executable '%1' was built for Qt '%2', but found Qt '%3'.
El ejecutable '%1'fue creado con Qt '%2', pero se ha encontrado Qt '%3'.
+
+ Executable '%1' requires Windows XP or later.
+
+
ShellIntegration
diff --git a/etc/Translation/LameXP_FR.ts b/etc/Translation/LameXP_FR.ts
index b2523fc2..26fa1b13 100644
--- a/etc/Translation/LameXP_FR.ts
+++ b/etc/Translation/LameXP_FR.ts
@@ -2596,14 +2596,14 @@ Ouvrir le dossier récursivement...
Executable '%1' requires Qt v%2, but found Qt v%3.
L'éxécutable %1 nécessite Qt v%2, mais Qt v%3 trouvé.
-
- Executable '%1' requires Windows 2000 or later.
- L'exécutable '%1' nécessite Windows 2000 ou supérieur.
-
Executable '%1' was built for Qt '%2', but found Qt '%3'.
L'exécutable '%1' a été construit pour Qt '%2', mais a trouvé Qt '%3'.
+
+ Executable '%1' requires Windows XP or later.
+
+
ShellIntegration
diff --git a/etc/Translation/LameXP_IT.ts b/etc/Translation/LameXP_IT.ts
index 97e85ca9..b1476db2 100644
--- a/etc/Translation/LameXP_IT.ts
+++ b/etc/Translation/LameXP_IT.ts
@@ -2587,11 +2587,11 @@
- Executable '%1' requires Windows 2000 or later.
+ Executable '%1' was built for Qt '%2', but found Qt '%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_KR.ts b/etc/Translation/LameXP_KR.ts
index 6b442d59..bbf1d5af 100644
--- a/etc/Translation/LameXP_KR.ts
+++ b/etc/Translation/LameXP_KR.ts
@@ -2568,14 +2568,14 @@
Executable '%1' requires Qt v%2, but found Qt v%3.
'%1'의 실행은 Qt v%2가 요구됩니다. 하지만 Qt v%3이 발견되었습니다.
-
- Executable '%1' requires Windows 2000 or later.
- '%1'의 실행은 윈도우 2000 또는 상위 버전이 필요합니다.
-
Executable '%1' was built for Qt '%2', but found Qt '%3'.
'%1'의 실행은 Qt '%2'용으로 제작되었습니다. 하지만 Qt v%3이 발견되었습니다.
+
+ Executable '%1' requires Windows XP or later.
+
+
ShellIntegration
diff --git a/etc/Translation/LameXP_PL.ts b/etc/Translation/LameXP_PL.ts
index 0b93eb51..3c7156ba 100644
--- a/etc/Translation/LameXP_PL.ts
+++ b/etc/Translation/LameXP_PL.ts
@@ -3327,25 +3327,25 @@
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 2000 or later.
- Plik wykonywalny '%1' wymaga do uruchomienia Windows 2000 lub nowszego.
+
+
+ Executable '%1' requires Windows XP or later.
+
diff --git a/etc/Translation/LameXP_RU.ts b/etc/Translation/LameXP_RU.ts
index 8dab2bc4..99f7058f 100644
--- a/etc/Translation/LameXP_RU.ts
+++ b/etc/Translation/LameXP_RU.ts
@@ -2610,14 +2610,14 @@
Executable '%1' requires Qt v%2, but found Qt v%3.
Исполняемому файлу '%1' требуется версия Qt v%2, но найдена версия v%3.
-
- Executable '%1' requires Windows 2000 or later.
- Исполняемому файлу '%1'требуется Windows 2000 или новее.
-
Executable '%1' was built for Qt '%2', but found Qt '%3'.
Исполняемый файл '%1' был собран для Qt '%2', но найдена версия Qt '%3'.
+
+ Executable '%1' requires Windows XP or later.
+
+
ShellIntegration
diff --git a/etc/Translation/LameXP_SV.ts b/etc/Translation/LameXP_SV.ts
index f0b58993..c93276de 100644
--- a/etc/Translation/LameXP_SV.ts
+++ b/etc/Translation/LameXP_SV.ts
@@ -3310,25 +3310,25 @@
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 2000 or later.
- EXE-filen '%1' kräver Windows 2000 eller senare.
+
+
+ Executable '%1' requires Windows XP or later.
+
diff --git a/etc/Translation/LameXP_TW.ts b/etc/Translation/LameXP_TW.ts
index 9873cfdc..fd59f825 100644
--- a/etc/Translation/LameXP_TW.ts
+++ b/etc/Translation/LameXP_TW.ts
@@ -2567,14 +2567,14 @@
Executable '%1' requires Qt v%2, but found Qt v%3.
可執行文件 '%1' 需要 Qt v%2, 但發現 Qt v%3.
-
- Executable '%1' requires Windows 2000 or later.
- 可執行文件 '%1' 需要 Windows 2000 或更高版本.
-
Executable '%1' was built for Qt '%2', but found Qt '%3'.
可執行文件 '%1'為Qt '%2',但發現Qt'%3'.
+
+ Executable '%1' requires Windows XP or later.
+
+
ShellIntegration
diff --git a/etc/Translation/LameXP_UK.ts b/etc/Translation/LameXP_UK.ts
index cfacc0e5..f1c5badf 100644
--- a/etc/Translation/LameXP_UK.ts
+++ b/etc/Translation/LameXP_UK.ts
@@ -2604,14 +2604,14 @@
Executable '%1' requires Qt v%2, but found Qt v%3.
Додаток '%1' вимагає для роботи Qt v%2, але знайдено Qt v%3.
-
- Executable '%1' requires Windows 2000 or later.
- Додаток '%1' вимагає для роботи Windows 2000 або пізніші версії ОС.
-
Executable '%1' was built for Qt '%2', but found Qt '%3'.
Додаток '%1' був створений для Qt '%2', але знайдено Qt '%3'.
+
+ Executable '%1' requires Windows XP or later.
+
+
ShellIntegration
diff --git a/etc/Translation/LameXP_ZH.ts b/etc/Translation/LameXP_ZH.ts
index 25b23c66..3783a5ed 100644
--- a/etc/Translation/LameXP_ZH.ts
+++ b/etc/Translation/LameXP_ZH.ts
@@ -2567,14 +2567,14 @@
Executable '%1' requires Qt v%2, but found Qt v%3.
可执行文件 '%1' 需要 Qt v%2, 但发现 Qt v%3。
-
- Executable '%1' requires Windows 2000 or later.
- 可执行文件 '%1' 需要 Windows 2000 或更高版本。
-
Executable '%1' was built for Qt '%2', but found Qt '%3'.
可执行文件 '%1'由Qt '%2'创建,但发现Qt'%3'。
+
+ Executable '%1' requires Windows XP or later.
+
+
ShellIntegration
diff --git a/res/localization/LameXP_DE.qm b/res/localization/LameXP_DE.qm
index 1b7eaf1c..b82fdbe8 100644
Binary files a/res/localization/LameXP_DE.qm and b/res/localization/LameXP_DE.qm differ
diff --git a/res/localization/LameXP_ES.qm b/res/localization/LameXP_ES.qm
index f18e5764..4efe025f 100644
Binary files a/res/localization/LameXP_ES.qm and b/res/localization/LameXP_ES.qm differ
diff --git a/res/localization/LameXP_FR.qm b/res/localization/LameXP_FR.qm
index b8e0c815..60cad153 100644
Binary files a/res/localization/LameXP_FR.qm and b/res/localization/LameXP_FR.qm differ
diff --git a/res/localization/LameXP_KR.qm b/res/localization/LameXP_KR.qm
index f40acd03..ba4d72e9 100644
Binary files a/res/localization/LameXP_KR.qm and b/res/localization/LameXP_KR.qm differ
diff --git a/res/localization/LameXP_PL.qm b/res/localization/LameXP_PL.qm
index 988bedda..56fc710e 100644
Binary files a/res/localization/LameXP_PL.qm and b/res/localization/LameXP_PL.qm differ
diff --git a/res/localization/LameXP_RU.qm b/res/localization/LameXP_RU.qm
index 1bdbc462..bc11ca25 100644
Binary files a/res/localization/LameXP_RU.qm and b/res/localization/LameXP_RU.qm differ
diff --git a/res/localization/LameXP_SV.qm b/res/localization/LameXP_SV.qm
index ec3046a2..af747bef 100644
Binary files a/res/localization/LameXP_SV.qm and b/res/localization/LameXP_SV.qm differ
diff --git a/res/localization/LameXP_TW.qm b/res/localization/LameXP_TW.qm
index f585e250..496f8b13 100644
Binary files a/res/localization/LameXP_TW.qm and b/res/localization/LameXP_TW.qm differ
diff --git a/res/localization/LameXP_UK.qm b/res/localization/LameXP_UK.qm
index 1cf18251..96408eef 100644
Binary files a/res/localization/LameXP_UK.qm and b/res/localization/LameXP_UK.qm differ
diff --git a/res/localization/LameXP_ZH.qm b/res/localization/LameXP_ZH.qm
index d2db0d36..6ba1650b 100644
Binary files a/res/localization/LameXP_ZH.qm and b/res/localization/LameXP_ZH.qm differ
diff --git a/src/Config.h b/src/Config.h
index 4d234a5a..097c248b 100644
--- a/src/Config.h
+++ b/src/Config.h
@@ -33,8 +33,8 @@
#define VER_LAMEXP_MINOR_HI 0
#define VER_LAMEXP_MINOR_LO 9
#define VER_LAMEXP_TYPE Alpha
-#define VER_LAMEXP_PATCH 2
-#define VER_LAMEXP_BUILD 1394
+#define VER_LAMEXP_PATCH 3
+#define VER_LAMEXP_BUILD 1398
#define VER_LAMEXP_CONFG 1348
///////////////////////////////////////////////////////////////////////////////
diff --git a/src/Dialog_MainWindow.cpp b/src/Dialog_MainWindow.cpp
index f058ffe9..9a353203 100644
--- a/src/Dialog_MainWindow.cpp
+++ b/src/Dialog_MainWindow.cpp
@@ -35,7 +35,6 @@
#include "Dialog_CueImport.h"
#include "Dialog_LogView.h"
#include "Thread_FileAnalyzer.h"
-#include "Thread_FileAnalyzer_ST.h"
#include "Thread_MessageHandler.h"
#include "Model_MetaInfo.h"
#include "Model_Settings.h"
diff --git a/src/Global.h b/src/Global.h
index a1d45259..ae866f42 100644
--- a/src/Global.h
+++ b/src/Global.h
@@ -250,3 +250,13 @@ while(0)
#error We should not enabled SSE or SSE2 in release builds!
#endif
#endif
+
+//Helper macro for throwing exceptions
+#define THROW(MESSAGE) throw std::runtime_error((MESSAGE))
+#define THROW_FMT(FORMAT, ...) do \
+{ \
+ char error_msg[512]; \
+ _snprintf_s(error_msg, 512, _TRUNCATE, (FORMAT), __VA_ARGS__); \
+ throw std::runtime_error(error_msg); \
+} \
+while(0)
diff --git a/src/LockedFile.cpp b/src/LockedFile.cpp
index 588f07bc..09f6b5c9 100644
--- a/src/LockedFile.cpp
+++ b/src/LockedFile.cpp
@@ -32,6 +32,7 @@
#include
#include
#include
+#include
//Windows includes
#define NOMINMAX
@@ -40,13 +41,6 @@
///////////////////////////////////////////////////////////////////////////////
-#define THROW(STR) \
-{ \
- char error_msg[512]; \
- strcpy_s(error_msg, 512, STR); \
- throw error_msg; \
-}
-
// WARNING: Passing file descriptors into Qt does NOT work with dynamically linked CRT!
#ifdef QT_NODLL
static const bool g_useFileDescr = 1;
@@ -91,15 +85,14 @@ static QByteArray fileHash(QFile &file)
///////////////////////////////////////////////////////////////////////////////
-LockedFile::LockedFile(const QString &resourcePath, const QString &outPath, const QByteArray &expectedHash)
+LockedFile::LockedFile(QResource *const resource, const QString &outPath, const QByteArray &expectedHash)
{
m_fileHandle = NULL;
- QResource resource(resourcePath);
//Make sure the resource is valid
- if(!resource.isValid())
+ if(!(resource->isValid() && resource->data()))
{
- THROW(QString("Resource '%1' is invalid!").arg(QFileInfo(resourcePath).absoluteFilePath().replace(QRegExp("^:/"), QString())).toUtf8().constData());
+ THROW_FMT("The resource at %p is invalid!", resource);
}
QFile outFile(outPath);
@@ -116,16 +109,16 @@ LockedFile::LockedFile(const QString &resourcePath, const QString &outPath, cons
//Write data to file
if(outFile.isOpen() && outFile.isWritable())
{
- if(outFile.write(reinterpret_cast(resource.data()), resource.size()) != resource.size())
+ if(outFile.write(reinterpret_cast(resource->data()), resource->size()) != resource->size())
{
QFile::remove(QFileInfo(outFile).canonicalFilePath());
- THROW(QString("File '%1' could not be written!").arg(QFileInfo(outFile).fileName()).toUtf8().constData());
+ THROW_FMT("File '%s' could not be written!", QFileInfo(outFile).fileName().toUtf8().constData());
}
outFile.close();
}
else
{
- THROW(QString("File '%1' could not be created!").arg(QFileInfo(outFile).fileName()).toUtf8().constData());
+ THROW_FMT("File '%s' could not be created!", QFileInfo(outFile).fileName().toUtf8().constData());
}
//Now lock the file!
@@ -141,9 +134,7 @@ LockedFile::LockedFile(const QString &resourcePath, const QString &outPath, cons
if((m_fileHandle == NULL) || (m_fileHandle == INVALID_HANDLE_VALUE))
{
QFile::remove(QFileInfo(outFile).canonicalFilePath());
- char error_msg[512];
- strcpy_s(error_msg, 512, QString("File '%1' could not be locked!").arg(QFileInfo(outFile).fileName()).toLatin1().constData());
- throw error_msg;
+ THROW_FMT("File '%s' could not be locked!", QFileInfo(outFile).fileName().toUtf8().constData());
}
//Open file for reading
@@ -172,7 +163,7 @@ LockedFile::LockedFile(const QString &resourcePath, const QString &outPath, cons
else
{
QFile::remove(m_filePath);
- THROW(QString("File '%1' could not be read!").arg(QFileInfo(outFile).fileName()).toLatin1().constData());
+ THROW_FMT("File '%s' could not be read!", QFileInfo(outFile).fileName().toUtf8().constData());
}
//Compare hashes
@@ -181,7 +172,7 @@ LockedFile::LockedFile(const QString &resourcePath, const QString &outPath, cons
qWarning("\nFile checksum error:\n A = %s\n B = %s\n", expectedHash.constData(), hash.constData());
LAMEXP_CLOSE(m_fileHandle);
QFile::remove(m_filePath);
- THROW(QString("File '%1' is corruputed, take care!").arg(QFileInfo(resourcePath).absoluteFilePath().replace(QRegExp("^:/"), QString())).toLatin1().constData());
+ THROW_FMT("File '%s' is corruputed, take care!", QFileInfo(outFile).fileName().toUtf8().constData());
}
}
@@ -194,9 +185,7 @@ LockedFile::LockedFile(const QString &filePath)
//Make sure the file exists, before we try to lock it
if(!existingFile.exists())
{
- char error_msg[256];
- strcpy_s(error_msg, 256, QString("File '%1' does not exist!").arg(existingFile.fileName()).toLatin1().constData());
- throw error_msg;
+ THROW_FMT("File '%s' does not exist!", existingFile.fileName().toUtf8().constData());
}
//Remember file path
@@ -214,7 +203,7 @@ LockedFile::LockedFile(const QString &filePath)
//Locked successfully?
if((m_fileHandle == NULL) || (m_fileHandle == INVALID_HANDLE_VALUE))
{
- THROW(QString("File '%1' could not be locked!").arg(existingFile.fileName()).toLatin1().constData());
+ THROW_FMT("File '%s' could not be locked!", existingFile.fileName().toUtf8().constData());
}
}
@@ -232,6 +221,6 @@ void LockedFile::selfTest()
{
if(!QKeccakHash::selfTest())
{
- qFatal("QKeccakHash self-test has failed!");
+ THROW("QKeccakHash self-test has failed!");
}
}
diff --git a/src/LockedFile.h b/src/LockedFile.h
index 60b224e1..4485bd88 100644
--- a/src/LockedFile.h
+++ b/src/LockedFile.h
@@ -23,10 +23,12 @@
#include
+class QResource;
+
class LockedFile
{
public:
- LockedFile(const QString &resourcePath, const QString &outPath, const QByteArray &expectedHash = QByteArray());
+ LockedFile(QResource *const resource, const QString &outPath, const QByteArray &expectedHash = QByteArray());
LockedFile(const QString &filePath);
~LockedFile(void);
diff --git a/src/Main.cpp b/src/Main.cpp
index bbbd9a1b..435bdd6f 100644
--- a/src/Main.cpp
+++ b/src/Main.cpp
@@ -243,17 +243,21 @@ static int _main(int argc, char* argv[])
iResult = lamexp_main(argc, argv);
lamexp_finalization();
}
+ catch(const std::runtime_error &error)
+ {
+ fflush(stdout); fflush(stderr);
+ fprintf(stderr, "\nGURU MEDITATION !!!\n\nException error:\n%s\n", error);
+ lamexp_fatal_exit(L"Unhandeled C++ exception error, application will exit!");
+ }
catch(char *error)
{
- fflush(stdout);
- fflush(stderr);
+ fflush(stdout); fflush(stderr);
fprintf(stderr, "\nGURU MEDITATION !!!\n\nException error message: %s\n", error);
lamexp_fatal_exit(L"Unhandeled C++ exception error, application will exit!");
}
catch(int error)
{
- fflush(stdout);
- fflush(stderr);
+ fflush(stdout); fflush(stderr);
fprintf(stderr, "\nGURU MEDITATION !!!\n\nException error code: 0x%X\n", error);
lamexp_fatal_exit(L"Unhandeled C++ exception error, application will exit!");
}
diff --git a/src/Thread_Initialization.cpp b/src/Thread_Initialization.cpp
index 01e7c5e9..b0b052ce 100644
--- a/src/Thread_Initialization.cpp
+++ b/src/Thread_Initialization.cpp
@@ -35,6 +35,7 @@
#include
#include
#include
+#include
/* helper macros */
#define PRINT_CPU_TYPE(X) case X: qDebug("Selected CPU is: " #X)
@@ -50,18 +51,23 @@ static const size_t BUFF_SIZE = 512;
class ExtractorTask : public QRunnable
{
public:
- ExtractorTask(const QDir &appDir, const QString &toolName, const QString &toolShortName, const QByteArray &toolHash, const unsigned int toolVersion, const QString &toolTag)
+ ExtractorTask(QResource *const toolResource, const QDir &appDir, const QString &toolName, const QByteArray &toolHash, const unsigned int toolVersion, const QString &toolTag)
:
m_appDir(appDir),
m_toolName(toolName),
- m_toolShortName(toolShortName),
m_toolHash(toolHash),
m_toolVersion(toolVersion),
- m_toolTag(toolTag)
+ m_toolTag(toolTag),
+ m_toolResource(toolResource)
{
/* Nothing to do */
}
+ ~ExtractorTask(void)
+ {
+ delete m_toolResource;
+ }
+
static void clearFlags(void)
{
QMutexLocker lock(&s_mutex);
@@ -91,16 +97,27 @@ protected:
{
if(!getExcept()) doExtract();
}
- catch(char *errorMsg)
+ catch(const std::runtime_error &e)
{
QMutexLocker lock(&s_mutex);
if(!s_bExcept)
{
s_bExcept = true;
- strncpy_s(s_errMsg, BUFF_SIZE, errorMsg, _TRUNCATE);
- lock.unlock();
- qWarning("ExtractorTask error:\n%s", errorMsg);
+ strncpy_s(s_errMsg, BUFF_SIZE, e.what(), _TRUNCATE);
}
+ lock.unlock();
+ qWarning("ExtractorTask exception error:\n%s\n\n", e.what());
+ }
+ catch(...)
+ {
+ QMutexLocker lock(&s_mutex);
+ if(!s_bExcept)
+ {
+ s_bExcept = true;
+ strncpy_s(s_errMsg, BUFF_SIZE, "Unknown exception error!", _TRUNCATE);
+ }
+ lock.unlock();
+ qWarning("ExtractorTask encountered an unknown exception!");
}
}
@@ -109,28 +126,31 @@ protected:
LockedFile *lockedFile = NULL;
unsigned int version = m_toolVersion;
- QFileInfo customTool(QString("%1/tools/%2/%3").arg(m_appDir.canonicalPath(), QString::number(lamexp_version_build()), m_toolShortName));
+ QFileInfo toolFileInfo(m_toolName);
+ const QString toolShortName = QString("%1.%2").arg(toolFileInfo.baseName().toLower(), toolFileInfo.suffix().toLower());
+
+ QFileInfo customTool(QString("%1/tools/%2/%3").arg(m_appDir.canonicalPath(), QString::number(lamexp_version_build()), toolShortName));
if(customTool.exists() && customTool.isFile())
{
- qDebug("Setting up file: %s <- %s", m_toolShortName.toLatin1().constData(), m_appDir.relativeFilePath(customTool.canonicalFilePath()).toLatin1().constData());
+ qDebug("Setting up file: %s <- %s", toolShortName.toLatin1().constData(), m_appDir.relativeFilePath(customTool.canonicalFilePath()).toLatin1().constData());
lockedFile = new LockedFile(customTool.canonicalFilePath()); version = UINT_MAX; s_bCustom = true;
}
else
{
- qDebug("Extracting file: %s -> %s", m_toolName.toLatin1().constData(), m_toolShortName.toLatin1().constData());
- lockedFile = new LockedFile(QString(":/tools/%1").arg(m_toolName), QString("%1/lxp_%2").arg(lamexp_temp_folder2(), m_toolShortName), m_toolHash);
+ qDebug("Extracting file: %s -> %s", m_toolName.toLatin1().constData(), toolShortName.toLatin1().constData());
+ lockedFile = new LockedFile(m_toolResource, QString("%1/lxp_%2").arg(lamexp_temp_folder2(), toolShortName), m_toolHash);
}
if(lockedFile)
{
- lamexp_register_tool(m_toolShortName, lockedFile, version, &m_toolTag);
+ lamexp_register_tool(toolShortName, lockedFile, version, &m_toolTag);
}
}
private:
+ QResource *const m_toolResource;
const QDir m_appDir;
const QString m_toolName;
- const QString m_toolShortName;
const QByteArray m_toolHash;
const unsigned int m_toolVersion;
const QString m_toolTag;
@@ -142,9 +162,9 @@ private:
};
QMutex ExtractorTask::s_mutex;
+char ExtractorTask::s_errMsg[BUFF_SIZE] = {'\0'};
volatile bool ExtractorTask::s_bExcept = false;
volatile bool ExtractorTask::s_bCustom = false;
-char ExtractorTask::s_errMsg[BUFF_SIZE] = {'\0'};
////////////////////////////////////////////////////////////
// Constructor
@@ -203,10 +223,11 @@ void InitializationThread::run()
}
//Allocate maps
- QMap mapChecksum;
- QMap mapVersion;
- QMap mapCpuType;
- QMap mapVersTag;
+ QQueue queueToolName;
+ QQueue queueChecksum;
+ QQueue queueVersInfo;
+ QQueue queueVersions;
+ QQueue queueCpuTypes;
//Init properties
for(int i = 0; true; i++)
@@ -217,11 +238,11 @@ void InitializationThread::run()
}
else if(g_lamexp_tools[i].pcName && g_lamexp_tools[i].pcHash && g_lamexp_tools[i].uiVersion)
{
- const QString currentTool = QString::fromLatin1(g_lamexp_tools[i].pcName);
- mapChecksum.insert(currentTool, QString::fromLatin1(g_lamexp_tools[i].pcHash));
- mapCpuType.insert(currentTool, g_lamexp_tools[i].uiCpuType);
- mapVersion.insert(currentTool, g_lamexp_tools[i].uiVersion);
- mapVersTag.insert(currentTool, g_lamexp_tools[i].pcVersTag);
+ queueToolName.enqueue(QString::fromLatin1(g_lamexp_tools[i].pcName));
+ queueChecksum.enqueue(QString::fromLatin1(g_lamexp_tools[i].pcHash));
+ queueVersInfo.enqueue(QString::fromLatin1(g_lamexp_tools[i].pcVersTag));
+ queueCpuTypes.enqueue(g_lamexp_tools[i].uiCpuType);
+ queueVersions.enqueue(g_lamexp_tools[i].uiVersion);
}
else
{
@@ -229,8 +250,6 @@ void InitializationThread::run()
}
}
- QDir toolsDir(":/tools/");
- QList toolsList = toolsDir.entryInfoList(QStringList("*.*"), QDir::Files, QDir::Name);
QDir appDir = QDir(QCoreApplication::applicationDirPath()).canonicalPath();
QThreadPool *pool = new QThreadPool();
@@ -246,34 +265,42 @@ void InitializationThread::run()
const long long timeExtractStart = lamexp_perfcounter_value();
//Extract all files
- while(!toolsList.isEmpty())
+ while(!(queueToolName.isEmpty() || queueChecksum.isEmpty() || queueVersInfo.isEmpty() || queueCpuTypes.isEmpty() || queueVersions.isEmpty()))
{
- try
+ const QString toolName = queueToolName.dequeue();
+ const QString checksum = queueChecksum.dequeue();
+ const QString versInfo = queueVersInfo.dequeue();
+ const unsigned int cpuType = queueCpuTypes.dequeue();
+ const unsigned int version = queueVersions.dequeue();
+
+ const QByteArray toolHash(checksum.toLatin1());
+ if(toolHash.size() != 96)
{
- QFileInfo currentTool = toolsList.takeFirst();
- QString toolName = currentTool.fileName().toLower();
- QString toolShortName = QString("%1.%2").arg(currentTool.baseName().toLower(), currentTool.suffix().toLower());
-
- QByteArray toolHash = mapChecksum.take(toolName).toLatin1();
- unsigned int toolCpuType = mapCpuType.take(toolName);
- unsigned int toolVersion = mapVersion.take(toolName);
- QString toolVersTag = mapVersTag.take(toolName);
-
- if(toolHash.size() != 96)
- {
- throw "The required checksum is missing, take care!";
- }
-
- if(toolCpuType & cpuSupport)
- {
- pool->start(new ExtractorTask(appDir, toolName, toolShortName, toolHash, toolVersion, toolVersTag));
- }
- }
- catch(char *errorMsg)
- {
- qFatal("At least one of the required tools could not be initialized:\n%s", errorMsg);
+ qFatal("The checksum for \"%s\" has an invalid size!", toolName.toUtf8().constData());
return;
}
+
+ QResource *resource = new QResource(QString(":/tools/%1").arg(toolName));
+ if(!(resource->isValid() && resource->data()))
+ {
+ LAMEXP_DELETE(resource);
+ qFatal("The resource for \"%s\" could not be found!", toolName.toUtf8().constData());
+ return;
+ }
+
+ if(cpuType & cpuSupport)
+ {
+ pool->start(new ExtractorTask(resource, appDir, toolName, toolHash, version, versInfo));
+ continue;
+ }
+
+ LAMEXP_DELETE(resource);
+ }
+
+ //Sanity Check
+ if(!(queueToolName.isEmpty() && queueChecksum.isEmpty() && queueVersInfo.isEmpty() && queueCpuTypes.isEmpty() && queueVersions.isEmpty()))
+ {
+ qFatal("Checksum queues *not* empty fater verification completed. Take care!");
}
//Wait for extrator threads to finish
@@ -295,20 +322,8 @@ void InitializationThread::run()
return;
}
- //Make sure all files were extracted
- if(!mapChecksum.isEmpty())
- {
- qFatal("At least one required tool could not be found:\n%s", toolsDir.filePath(mapChecksum.keys().first()).toLatin1().constData());
- return;
- }
-
qDebug("All extracted.\n");
- //Clean-up
- mapChecksum.clear();
- mapVersion.clear();
- mapCpuType.clear();
-
//Using any custom tools?
if(ExtractorTask::getCustom())
{