Improved tool extraction code in InitializationThread. Also implemented better exception handling.
This commit is contained in:
parent
3065569f00
commit
414b261c0d
@ -3290,24 +3290,24 @@
|
||||
<context>
|
||||
<name>QApplication</name>
|
||||
<message>
|
||||
<location filename="../../src/Global.cpp" line="916"/>
|
||||
<location filename="../../src/Global.cpp" line="935"/>
|
||||
<source>Executable '%1' doesn't support Windows compatibility mode.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/Global.cpp" line="1170"/>
|
||||
<location filename="../../src/Global.cpp" line="1188"/>
|
||||
<source>Executable '%1' requires Qt v%2, but found Qt v%3.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/Global.cpp" line="1175"/>
|
||||
<location filename="../../src/Global.cpp" line="1193"/>
|
||||
<source>Executable '%1' was built for Qt '%2', but found Qt '%3'.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/Global.cpp" line="1188"/>
|
||||
<location filename="../../src/Global.cpp" line="1215"/>
|
||||
<source>Executable '%1' requires Windows 2000 or later.</source>
|
||||
<location filename="../../src/Global.cpp" line="1207"/>
|
||||
<location filename="../../src/Global.cpp" line="1234"/>
|
||||
<source>Executable '%1' requires Windows XP or later.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
|
@ -2586,14 +2586,14 @@
|
||||
<source>Executable '%1' requires Qt v%2, but found Qt v%3.</source>
|
||||
<translation>Programm '%1' benötigt Qt v%2, aber Qt v%3 wurde gefunden.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Executable '%1' requires Windows 2000 or later.</source>
|
||||
<translation>Programm '%1' benötigt Windows 2000 oder neuer.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Executable '%1' was built for Qt '%2', but found Qt '%3'.</source>
|
||||
<translation>Programm '%1' wurde für Qt '%2' erzeugt, aber Qt '%3' gefunden.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Executable '%1' requires Windows XP or later.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>ShellIntegration</name>
|
||||
|
@ -2585,14 +2585,14 @@
|
||||
<source>Executable '%1' requires Qt v%2, but found Qt v%3.</source>
|
||||
<translation>El ejecutable '%1'requiere Qt v%2, pero se ha encontrado v%3.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Executable '%1' requires Windows 2000 or later.</source>
|
||||
<translation>El ejecutable '%1'requiere Windows 2000 o superior.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Executable '%1' was built for Qt '%2', but found Qt '%3'.</source>
|
||||
<translation>El ejecutable '%1'fue creado con Qt '%2', pero se ha encontrado Qt '%3'.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Executable '%1' requires Windows XP or later.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>ShellIntegration</name>
|
||||
|
@ -2596,14 +2596,14 @@ Ouvrir le dossier récursivement...</translation>
|
||||
<source>Executable '%1' requires Qt v%2, but found Qt v%3.</source>
|
||||
<translation>L'éxécutable %1 nécessite Qt v%2, mais Qt v%3 trouvé.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Executable '%1' requires Windows 2000 or later.</source>
|
||||
<translation>L'exécutable '%1' nécessite Windows 2000 ou supérieur.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Executable '%1' was built for Qt '%2', but found Qt '%3'.</source>
|
||||
<translation>L'exécutable '%1' a été construit pour Qt '%2', mais a trouvé Qt '%3'.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Executable '%1' requires Windows XP or later.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>ShellIntegration</name>
|
||||
|
@ -2587,11 +2587,11 @@
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Executable '%1' requires Windows 2000 or later.</source>
|
||||
<source>Executable '%1' was built for Qt '%2', but found Qt '%3'.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Executable '%1' was built for Qt '%2', but found Qt '%3'.</source>
|
||||
<source>Executable '%1' requires Windows XP or later.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
|
@ -2568,14 +2568,14 @@
|
||||
<source>Executable '%1' requires Qt v%2, but found Qt v%3.</source>
|
||||
<translation type="unfinished">'%1'의 실행은 Qt v%2가 요구됩니다. 하지만 Qt v%3이 발견되었습니다.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Executable '%1' requires Windows 2000 or later.</source>
|
||||
<translation type="unfinished">'%1'의 실행은 윈도우 2000 또는 상위 버전이 필요합니다.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Executable '%1' was built for Qt '%2', but found Qt '%3'.</source>
|
||||
<translation type="unfinished">'%1'의 실행은 Qt '%2'용으로 제작되었습니다. 하지만 Qt v%3이 발견되었습니다.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Executable '%1' requires Windows XP or later.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>ShellIntegration</name>
|
||||
|
@ -3327,25 +3327,25 @@
|
||||
<context>
|
||||
<name>QApplication</name>
|
||||
<message>
|
||||
<location filename="../../src/Global.cpp" line="916"/>
|
||||
<location filename="../../src/Global.cpp" line="935"/>
|
||||
<source>Executable '%1' doesn't support Windows compatibility mode.</source>
|
||||
<translation type="unfinished">Plik wykonywalny '%1' nie działa w trybie kompatybilności z Windows.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/Global.cpp" line="1170"/>
|
||||
<location filename="../../src/Global.cpp" line="1188"/>
|
||||
<source>Executable '%1' requires Qt v%2, but found Qt v%3.</source>
|
||||
<translation type="unfinished">Plik wykonywalny '%1' wymaga Qt v%2, znaleziono jednak Qt v%3.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/Global.cpp" line="1175"/>
|
||||
<location filename="../../src/Global.cpp" line="1193"/>
|
||||
<source>Executable '%1' was built for Qt '%2', but found Qt '%3'.</source>
|
||||
<translation type="unfinished">Plik wykonywalny "%1" został skompilowany dla Qt "%2", znaleziono "%3".</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/Global.cpp" line="1188"/>
|
||||
<location filename="../../src/Global.cpp" line="1215"/>
|
||||
<source>Executable '%1' requires Windows 2000 or later.</source>
|
||||
<translation type="unfinished">Plik wykonywalny '%1' wymaga do uruchomienia Windows 2000 lub nowszego.</translation>
|
||||
<location filename="../../src/Global.cpp" line="1207"/>
|
||||
<location filename="../../src/Global.cpp" line="1234"/>
|
||||
<source>Executable '%1' requires Windows XP or later.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
|
@ -2610,14 +2610,14 @@
|
||||
<source>Executable '%1' requires Qt v%2, but found Qt v%3.</source>
|
||||
<translation type="unfinished">Исполняемому файлу '%1' требуется версия Qt v%2, но найдена версия v%3.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Executable '%1' requires Windows 2000 or later.</source>
|
||||
<translation type="unfinished">Исполняемому файлу '%1'требуется Windows 2000 или новее.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Executable '%1' was built for Qt '%2', but found Qt '%3'.</source>
|
||||
<translation type="unfinished">Исполняемый файл '%1' был собран для Qt '%2', но найдена версия Qt '%3'.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Executable '%1' requires Windows XP or later.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>ShellIntegration</name>
|
||||
|
@ -3310,25 +3310,25 @@
|
||||
<context>
|
||||
<name>QApplication</name>
|
||||
<message>
|
||||
<location filename="../../src/Global.cpp" line="916"/>
|
||||
<location filename="../../src/Global.cpp" line="935"/>
|
||||
<source>Executable '%1' doesn't support Windows compatibility mode.</source>
|
||||
<translation>EXE-filen '%1' stöder inte Windows kompatibilitetsläge.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/Global.cpp" line="1170"/>
|
||||
<location filename="../../src/Global.cpp" line="1188"/>
|
||||
<source>Executable '%1' requires Qt v%2, but found Qt v%3.</source>
|
||||
<translation>EXE-filen '%1' kräver Qt v%2, du har Qt v%3.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/Global.cpp" line="1175"/>
|
||||
<location filename="../../src/Global.cpp" line="1193"/>
|
||||
<source>Executable '%1' was built for Qt '%2', but found Qt '%3'.</source>
|
||||
<translation>EXE-filen '%1' är byggd för Qt '%2', du har Qt '%3'.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../../src/Global.cpp" line="1188"/>
|
||||
<location filename="../../src/Global.cpp" line="1215"/>
|
||||
<source>Executable '%1' requires Windows 2000 or later.</source>
|
||||
<translation>EXE-filen '%1' kräver Windows 2000 eller senare.</translation>
|
||||
<location filename="../../src/Global.cpp" line="1207"/>
|
||||
<location filename="../../src/Global.cpp" line="1234"/>
|
||||
<source>Executable '%1' requires Windows XP or later.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
|
@ -2567,14 +2567,14 @@
|
||||
<source>Executable '%1' requires Qt v%2, but found Qt v%3.</source>
|
||||
<translation>可執行文件 '%1' 需要 Qt v%2, 但發現 Qt v%3.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Executable '%1' requires Windows 2000 or later.</source>
|
||||
<translation>可執行文件 '%1' 需要 Windows 2000 或更高版本.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Executable '%1' was built for Qt '%2', but found Qt '%3'.</source>
|
||||
<translation>可執行文件 '%1'為Qt '%2',但發現Qt'%3'.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Executable '%1' requires Windows XP or later.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>ShellIntegration</name>
|
||||
|
@ -2604,14 +2604,14 @@
|
||||
<source>Executable '%1' requires Qt v%2, but found Qt v%3.</source>
|
||||
<translation>Додаток '%1' вимагає для роботи Qt v%2, але знайдено Qt v%3.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Executable '%1' requires Windows 2000 or later.</source>
|
||||
<translation>Додаток '%1' вимагає для роботи Windows 2000 або пізніші версії ОС.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Executable '%1' was built for Qt '%2', but found Qt '%3'.</source>
|
||||
<translation>Додаток '%1' був створений для Qt '%2', але знайдено Qt '%3'.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Executable '%1' requires Windows XP or later.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>ShellIntegration</name>
|
||||
|
@ -2567,14 +2567,14 @@
|
||||
<source>Executable '%1' requires Qt v%2, but found Qt v%3.</source>
|
||||
<translation>可执行文件 '%1' 需要 Qt v%2, 但发现 Qt v%3。</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Executable '%1' requires Windows 2000 or later.</source>
|
||||
<translation>可执行文件 '%1' 需要 Windows 2000 或更高版本。</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Executable '%1' was built for Qt '%2', but found Qt '%3'.</source>
|
||||
<translation>可执行文件 '%1'由Qt '%2'创建,但发现Qt'%3'。</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Executable '%1' requires Windows XP or later.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>ShellIntegration</name>
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -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
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -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"
|
||||
|
10
src/Global.h
10
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)
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include <stdio.h>
|
||||
#include <io.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdexcept>
|
||||
|
||||
//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<const char*>(resource.data()), resource.size()) != resource.size())
|
||||
if(outFile.write(reinterpret_cast<const char*>(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!");
|
||||
}
|
||||
}
|
||||
|
@ -23,10 +23,12 @@
|
||||
|
||||
#include <QString>
|
||||
|
||||
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);
|
||||
|
||||
|
12
src/Main.cpp
12
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!");
|
||||
}
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include <QRunnable>
|
||||
#include <QThreadPool>
|
||||
#include <QMutex>
|
||||
#include <QQueue>
|
||||
|
||||
/* 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<QString, QString> mapChecksum;
|
||||
QMap<QString, unsigned int> mapVersion;
|
||||
QMap<QString, unsigned int> mapCpuType;
|
||||
QMap<QString, QString> mapVersTag;
|
||||
QQueue<QString> queueToolName;
|
||||
QQueue<QString> queueChecksum;
|
||||
QQueue<QString> queueVersInfo;
|
||||
QQueue<unsigned int> queueVersions;
|
||||
QQueue<unsigned int> 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<QFileInfo> 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())
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user