diff --git a/src/Config.h b/src/Config.h index 8310ca5d..f8ba1b3c 100644 --- a/src/Config.h +++ b/src/Config.h @@ -30,7 +30,7 @@ #define VER_LAMEXP_MINOR_LO 5 #define VER_LAMEXP_TYPE Alpha #define VER_LAMEXP_PATCH 1 -#define VER_LAMEXP_BUILD 993 +#define VER_LAMEXP_BUILD 994 /////////////////////////////////////////////////////////////////////////////// // Tool versions (minimum expected versions!) diff --git a/src/Global.cpp b/src/Global.cpp index 1fc9b49a..5bd854fd 100644 --- a/src/Global.cpp +++ b/src/Global.cpp @@ -45,6 +45,9 @@ #include #include #include +#include +#include +#include //LameXP includes #include "Resource.h" @@ -198,6 +201,7 @@ static QString g_lamexp_temp_folder; //Tools static QMap g_lamexp_tool_registry; static QMap g_lamexp_tool_versions; +static QReadWriteLock g_lamexp_tool_lock; //Languages static struct @@ -1485,6 +1489,8 @@ bool lamexp_clean_folder(const QString &folderPath) */ void lamexp_register_tool(const QString &toolName, LockedFile *file, unsigned int version) { + QWriteLocker writeLock(&g_lamexp_tool_lock); + if(g_lamexp_tool_registry.contains(toolName.toLower())) { throw "lamexp_register_tool: Tool is already registered!"; @@ -1499,6 +1505,7 @@ void lamexp_register_tool(const QString &toolName, LockedFile *file, unsigned in */ bool lamexp_check_tool(const QString &toolName) { + QReadLocker readLock(&g_lamexp_tool_lock); return g_lamexp_tool_registry.contains(toolName.toLower()); } @@ -1507,6 +1514,8 @@ bool lamexp_check_tool(const QString &toolName) */ const QString lamexp_lookup_tool(const QString &toolName) { + QReadLocker readLock(&g_lamexp_tool_lock); + if(g_lamexp_tool_registry.contains(toolName.toLower())) { return g_lamexp_tool_registry.value(toolName.toLower())->filePath(); @@ -1522,6 +1531,8 @@ const QString lamexp_lookup_tool(const QString &toolName) */ unsigned int lamexp_tool_version(const QString &toolName) { + QReadLocker readLock(&g_lamexp_tool_lock); + if(g_lamexp_tool_versions.contains(toolName.toLower())) { return g_lamexp_tool_versions.value(toolName.toLower()); diff --git a/src/Thread_Initialization.cpp b/src/Thread_Initialization.cpp index 13c649a3..b4549b7b 100644 --- a/src/Thread_Initialization.cpp +++ b/src/Thread_Initialization.cpp @@ -36,7 +36,6 @@ #include #include #include -#include /* helper macros */ #define PRINT_CPU_TYPE(X) case X: qDebug("Selected CPU is: " #X) @@ -98,8 +97,11 @@ protected: catch(char *errorMsg) { qWarning("At least one of the required tools could not be initialized:\n%s", errorMsg); - QMutexLocker lock(&s_mutex); - if(!s_bAbort) { s_bAbort = true; strncpy_s(s_errMsg, 1024, errorMsg, _TRUNCATE); } + if(s_mutex.tryLock()) + { + if(!s_bAbort) { s_bAbort = true; strncpy_s(s_errMsg, 1024, errorMsg, _TRUNCATE); } + s_mutex.unlock(); + } } } @@ -250,7 +252,7 @@ void InitializationThread::run() return; } } - + //Wait for extrator threads to finish pool->waitForDone(); LAMEXP_DELETE(pool);