OSDN Git Service

Improved tool extraction code in InitializationThread. Also implemented better except...
authorLoRd_MuldeR <mulder2@gmx.de>
Fri, 18 Oct 2013 18:49:22 +0000 (20:49 +0200)
committerLoRd_MuldeR <mulder2@gmx.de>
Fri, 18 Oct 2013 18:49:22 +0000 (20:49 +0200)
29 files changed:
etc/Translation/Blank.ts
etc/Translation/LameXP_DE.ts
etc/Translation/LameXP_ES.ts
etc/Translation/LameXP_FR.ts
etc/Translation/LameXP_IT.ts
etc/Translation/LameXP_KR.ts
etc/Translation/LameXP_PL.ts
etc/Translation/LameXP_RU.ts
etc/Translation/LameXP_SV.ts
etc/Translation/LameXP_TW.ts
etc/Translation/LameXP_UK.ts
etc/Translation/LameXP_ZH.ts
res/localization/LameXP_DE.qm
res/localization/LameXP_ES.qm
res/localization/LameXP_FR.qm
res/localization/LameXP_KR.qm
res/localization/LameXP_PL.qm
res/localization/LameXP_RU.qm
res/localization/LameXP_SV.qm
res/localization/LameXP_TW.qm
res/localization/LameXP_UK.qm
res/localization/LameXP_ZH.qm
src/Config.h
src/Dialog_MainWindow.cpp
src/Global.h
src/LockedFile.cpp
src/LockedFile.h
src/Main.cpp
src/Thread_Initialization.cpp

index c353c45..784bec7 100644 (file)
 <context>
     <name>QApplication</name>
     <message>
-        <location filename="../../src/Global.cpp" line="916"/>
+        <location filename="../../src/Global.cpp" line="935"/>
         <source>Executable &apos;%1&apos; doesn&apos;t support Windows compatibility mode.</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../../src/Global.cpp" line="1170"/>
+        <location filename="../../src/Global.cpp" line="1188"/>
         <source>Executable &apos;%1&apos; requires Qt v%2, but found Qt v%3.</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../../src/Global.cpp" line="1175"/>
+        <location filename="../../src/Global.cpp" line="1193"/>
         <source>Executable &apos;%1&apos; was built for Qt &apos;%2&apos;, but found Qt &apos;%3&apos;.</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../../src/Global.cpp" line="1188"/>
-        <location filename="../../src/Global.cpp" line="1215"/>
-        <source>Executable &apos;%1&apos; requires Windows 2000 or later.</source>
+        <location filename="../../src/Global.cpp" line="1207"/>
+        <location filename="../../src/Global.cpp" line="1234"/>
+        <source>Executable &apos;%1&apos; requires Windows XP or later.</source>
         <translation type="unfinished"></translation>
     </message>
 </context>
index 13a623c..b0536c8 100644 (file)
         <translation>Programm &apos;%1&apos; benötigt Qt v%2, aber Qt v%3 wurde gefunden.</translation>
     </message>
     <message>
-        <source>Executable &apos;%1&apos; requires Windows 2000 or later.</source>
-        <translation>Programm &apos;%1&apos; benötigt Windows 2000 oder neuer.</translation>
-    </message>
-    <message>
         <source>Executable &apos;%1&apos; was built for Qt &apos;%2&apos;, but found Qt &apos;%3&apos;.</source>
         <translation>Programm &apos;%1&apos; wurde für Qt &apos;%2&apos; erzeugt, aber Qt &apos;%3&apos; gefunden.</translation>
     </message>
+    <message>
+        <source>Executable &apos;%1&apos; requires Windows XP or later.</source>
+        <translation type="unfinished"></translation>
+    </message>
 </context>
 <context>
     <name>ShellIntegration</name>
index 6e5a6f9..4dba261 100644 (file)
         <translation>El ejecutable &apos;%1&apos;requiere Qt v%2, pero se ha encontrado v%3.</translation>
     </message>
     <message>
-        <source>Executable &apos;%1&apos; requires Windows 2000 or later.</source>
-        <translation>El ejecutable &apos;%1&apos;requiere Windows 2000 o superior.</translation>
-    </message>
-    <message>
         <source>Executable &apos;%1&apos; was built for Qt &apos;%2&apos;, but found Qt &apos;%3&apos;.</source>
         <translation>El ejecutable &apos;%1&apos;fue creado con Qt &apos;%2&apos;, pero se ha encontrado Qt &apos;%3&apos;.</translation>
     </message>
+    <message>
+        <source>Executable &apos;%1&apos; requires Windows XP or later.</source>
+        <translation type="unfinished"></translation>
+    </message>
 </context>
 <context>
     <name>ShellIntegration</name>
index b2523fc..26fa1b1 100644 (file)
@@ -2597,13 +2597,13 @@ Ouvrir le dossier récursivement...</translation>
         <translation>L&apos;éxécutable %1 nécessite Qt v%2, mais Qt v%3 trouvé.</translation>
     </message>
     <message>
-        <source>Executable &apos;%1&apos; requires Windows 2000 or later.</source>
-        <translation>L&apos;exécutable &apos;%1&apos; nécessite Windows 2000 ou supérieur.</translation>
-    </message>
-    <message>
         <source>Executable &apos;%1&apos; was built for Qt &apos;%2&apos;, but found Qt &apos;%3&apos;.</source>
         <translation>L&apos;exécutable &apos;%1&apos; a été construit pour Qt &apos;%2&apos;, mais a trouvé Qt &apos;%3&apos;.</translation>
     </message>
+    <message>
+        <source>Executable &apos;%1&apos; requires Windows XP or later.</source>
+        <translation type="unfinished"></translation>
+    </message>
 </context>
 <context>
     <name>ShellIntegration</name>
index 97e85ca..b1476db 100644 (file)
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <source>Executable &apos;%1&apos; requires Windows 2000 or later.</source>
+        <source>Executable &apos;%1&apos; was built for Qt &apos;%2&apos;, but found Qt &apos;%3&apos;.</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <source>Executable &apos;%1&apos; was built for Qt &apos;%2&apos;, but found Qt &apos;%3&apos;.</source>
+        <source>Executable &apos;%1&apos; requires Windows XP or later.</source>
         <translation type="unfinished"></translation>
     </message>
 </context>
index 6b442d5..bbf1d5a 100644 (file)
         <translation type="unfinished">&apos;%1&apos;의 실행은 Qt v%2가 요구됩니다. 하지만 Qt v%3이 발견되었습니다.</translation>
     </message>
     <message>
-        <source>Executable &apos;%1&apos; requires Windows 2000 or later.</source>
-        <translation type="unfinished">&apos;%1&apos;의 실행은 윈도우 2000 또는 상위 버전이 필요합니다.</translation>
-    </message>
-    <message>
         <source>Executable &apos;%1&apos; was built for Qt &apos;%2&apos;, but found Qt &apos;%3&apos;.</source>
         <translation type="unfinished">&apos;%1&apos;의 실행은 Qt &apos;%2&apos;용으로 제작되었습니다. 하지만 Qt v%3이 발견되었습니다.</translation>
     </message>
+    <message>
+        <source>Executable &apos;%1&apos; requires Windows XP or later.</source>
+        <translation type="unfinished"></translation>
+    </message>
 </context>
 <context>
     <name>ShellIntegration</name>
index 0b93eb5..3c7156b 100644 (file)
 <context>
     <name>QApplication</name>
     <message>
-        <location filename="../../src/Global.cpp" line="916"/>
+        <location filename="../../src/Global.cpp" line="935"/>
         <source>Executable &apos;%1&apos; doesn&apos;t support Windows compatibility mode.</source>
         <translation type="unfinished">Plik wykonywalny &apos;%1&apos; 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 &apos;%1&apos; requires Qt v%2, but found Qt v%3.</source>
         <translation type="unfinished">Plik wykonywalny &apos;%1&apos; 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 &apos;%1&apos; was built for Qt &apos;%2&apos;, but found Qt &apos;%3&apos;.</source>
         <translation type="unfinished">Plik wykonywalny &quot;%1&quot; został skompilowany dla Qt &quot;%2&quot;, znaleziono &quot;%3&quot;.</translation>
     </message>
     <message>
-        <location filename="../../src/Global.cpp" line="1188"/>
-        <location filename="../../src/Global.cpp" line="1215"/>
-        <source>Executable &apos;%1&apos; requires Windows 2000 or later.</source>
-        <translation type="unfinished">Plik wykonywalny &apos;%1&apos; wymaga do uruchomienia Windows 2000 lub nowszego.</translation>
+        <location filename="../../src/Global.cpp" line="1207"/>
+        <location filename="../../src/Global.cpp" line="1234"/>
+        <source>Executable &apos;%1&apos; requires Windows XP or later.</source>
+        <translation type="unfinished"></translation>
     </message>
 </context>
 <context>
index 8dab2bc..99f7058 100644 (file)
         <translation type="unfinished">Исполняемому файлу  &apos;%1&apos; требуется версия Qt  v%2, но найдена версия  v%3.</translation>
     </message>
     <message>
-        <source>Executable &apos;%1&apos; requires Windows 2000 or later.</source>
-        <translation type="unfinished">Исполняемому файлу  &apos;%1&apos;требуется Windows 2000 или новее.</translation>
-    </message>
-    <message>
         <source>Executable &apos;%1&apos; was built for Qt &apos;%2&apos;, but found Qt &apos;%3&apos;.</source>
         <translation type="unfinished">Исполняемый файл  &apos;%1&apos; был собран для Qt &apos;%2&apos;, но найдена версия Qt &apos;%3&apos;.</translation>
     </message>
+    <message>
+        <source>Executable &apos;%1&apos; requires Windows XP or later.</source>
+        <translation type="unfinished"></translation>
+    </message>
 </context>
 <context>
     <name>ShellIntegration</name>
index f0b5899..c93276d 100644 (file)
 <context>
     <name>QApplication</name>
     <message>
-        <location filename="../../src/Global.cpp" line="916"/>
+        <location filename="../../src/Global.cpp" line="935"/>
         <source>Executable &apos;%1&apos; doesn&apos;t support Windows compatibility mode.</source>
         <translation>EXE-filen &apos;%1&apos; 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 &apos;%1&apos; requires Qt v%2, but found Qt v%3.</source>
         <translation>EXE-filen &apos;%1&apos; 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 &apos;%1&apos; was built for Qt &apos;%2&apos;, but found Qt &apos;%3&apos;.</source>
         <translation>EXE-filen &apos;%1&apos; är byggd för Qt &apos;%2&apos;, du har Qt &apos;%3&apos;.</translation>
     </message>
     <message>
-        <location filename="../../src/Global.cpp" line="1188"/>
-        <location filename="../../src/Global.cpp" line="1215"/>
-        <source>Executable &apos;%1&apos; requires Windows 2000 or later.</source>
-        <translation>EXE-filen &apos;%1&apos; kräver Windows 2000 eller senare.</translation>
+        <location filename="../../src/Global.cpp" line="1207"/>
+        <location filename="../../src/Global.cpp" line="1234"/>
+        <source>Executable &apos;%1&apos; requires Windows XP or later.</source>
+        <translation type="unfinished"></translation>
     </message>
 </context>
 <context>
index 9873cfd..fd59f82 100644 (file)
         <translation>可執行文件 &apos;%1&apos; 需要 Qt v%2, 但發現 Qt v%3.</translation>
     </message>
     <message>
-        <source>Executable &apos;%1&apos; requires Windows 2000 or later.</source>
-        <translation>可執行文件 &apos;%1&apos; 需要 Windows 2000 或更高版本.</translation>
-    </message>
-    <message>
         <source>Executable &apos;%1&apos; was built for Qt &apos;%2&apos;, but found Qt &apos;%3&apos;.</source>
         <translation>可執行文件 &apos;%1&apos;為Qt &apos;%2&apos;,但發現Qt&apos;%3&apos;.</translation>
     </message>
+    <message>
+        <source>Executable &apos;%1&apos; requires Windows XP or later.</source>
+        <translation type="unfinished"></translation>
+    </message>
 </context>
 <context>
     <name>ShellIntegration</name>
index cfacc0e..f1c5bad 100644 (file)
         <translation>Додаток &apos;%1&apos; вимагає для роботи Qt v%2, але знайдено Qt v%3.</translation>
     </message>
     <message>
-        <source>Executable &apos;%1&apos; requires Windows 2000 or later.</source>
-        <translation>Додаток &apos;%1&apos; вимагає для роботи Windows 2000 або пізніші версії ОС.</translation>
-    </message>
-    <message>
         <source>Executable &apos;%1&apos; was built for Qt &apos;%2&apos;, but found Qt &apos;%3&apos;.</source>
         <translation>Додаток &apos;%1&apos; був створений для Qt &apos;%2&apos;, але знайдено Qt &apos;%3&apos;.</translation>
     </message>
+    <message>
+        <source>Executable &apos;%1&apos; requires Windows XP or later.</source>
+        <translation type="unfinished"></translation>
+    </message>
 </context>
 <context>
     <name>ShellIntegration</name>
index 25b23c6..3783a5e 100644 (file)
         <translation>可执行文件 &apos;%1&apos; 需要 Qt v%2, 但发现 Qt v%3。</translation>
     </message>
     <message>
-        <source>Executable &apos;%1&apos; requires Windows 2000 or later.</source>
-        <translation>可执行文件 &apos;%1&apos; 需要 Windows 2000 或更高版本。</translation>
-    </message>
-    <message>
         <source>Executable &apos;%1&apos; was built for Qt &apos;%2&apos;, but found Qt &apos;%3&apos;.</source>
         <translation>可执行文件 &apos;%1&apos;由Qt &apos;%2&apos;创建,但发现Qt&apos;%3&apos;。</translation>
     </message>
+    <message>
+        <source>Executable &apos;%1&apos; requires Windows XP or later.</source>
+        <translation type="unfinished"></translation>
+    </message>
 </context>
 <context>
     <name>ShellIntegration</name>
index 1b7eaf1..b82fdbe 100644 (file)
Binary files a/res/localization/LameXP_DE.qm and b/res/localization/LameXP_DE.qm differ
index f18e576..4efe025 100644 (file)
Binary files a/res/localization/LameXP_ES.qm and b/res/localization/LameXP_ES.qm differ
index b8e0c81..60cad15 100644 (file)
Binary files a/res/localization/LameXP_FR.qm and b/res/localization/LameXP_FR.qm differ
index f40acd0..ba4d72e 100644 (file)
Binary files a/res/localization/LameXP_KR.qm and b/res/localization/LameXP_KR.qm differ
index 988bedd..56fc710 100644 (file)
Binary files a/res/localization/LameXP_PL.qm and b/res/localization/LameXP_PL.qm differ
index 1bdbc46..bc11ca2 100644 (file)
Binary files a/res/localization/LameXP_RU.qm and b/res/localization/LameXP_RU.qm differ
index ec3046a..af747be 100644 (file)
Binary files a/res/localization/LameXP_SV.qm and b/res/localization/LameXP_SV.qm differ
index f585e25..496f8b1 100644 (file)
Binary files a/res/localization/LameXP_TW.qm and b/res/localization/LameXP_TW.qm differ
index 1cf1825..96408ee 100644 (file)
Binary files a/res/localization/LameXP_UK.qm and b/res/localization/LameXP_UK.qm differ
index d2db0d3..6ba1650 100644 (file)
Binary files a/res/localization/LameXP_ZH.qm and b/res/localization/LameXP_ZH.qm differ
index 4d234a5..097c248 100644 (file)
@@ -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
 
 ///////////////////////////////////////////////////////////////////////////////
index f058ffe..9a35320 100644 (file)
@@ -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"
index a1d4525..ae866f4 100644 (file)
@@ -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)
index 588f07b..09f6b5c 100644 (file)
@@ -32,6 +32,7 @@
 #include <stdio.h>
 #include <io.h>
 #include <fcntl.h>
+#include <stdexcept>
 
 //Windows includes
 #define NOMINMAX
 
 ///////////////////////////////////////////////////////////////////////////////
 
-#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!");
        }
 }
index 60b224e..4485bd8 100644 (file)
 
 #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);
 
index bbbd9a1..435bdd6 100644 (file)
@@ -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!");
                }
index 01e7c5e..b0b052c 100644 (file)
@@ -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, 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, errorMsg, _TRUNCATE);
-                               lock.unlock();
-                               qWarning("ExtractorTask error:\n%s", errorMsg);
+                               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
-               {
-                       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!";
-                       }
+               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();
                        
-                       if(toolCpuType & cpuSupport)
-                       {
-                               pool->start(new ExtractorTask(appDir, toolName, toolShortName, toolHash, toolVersion, toolVersTag));
-                       }
+               const QByteArray toolHash(checksum.toLatin1());
+               if(toolHash.size() != 96)
+               {
+                       qFatal("The checksum for \"%s\" has an invalid size!", toolName.toUtf8().constData());
+                       return;
                }
-               catch(char *errorMsg)
+                       
+               QResource *resource = new QResource(QString(":/tools/%1").arg(toolName));
+               if(!(resource->isValid() && resource->data()))
                {
-                       qFatal("At least one of the required tools could not be initialized:\n%s", errorMsg);
+                       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())
        {