From cb2b770a88a94fe1b30cccb30123e548c0652fda Mon Sep 17 00:00:00 2001 From: LoRd_MuldeR Date: Fri, 17 Aug 2012 23:47:01 +0200 Subject: [PATCH] Made lamexp_arguments() thread-safe, just to be sure. --- doc/Changelog.html | 1 + src/Config.h | 2 +- src/Global.cpp | 23 +++++++++++++++-------- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/doc/Changelog.html b/doc/Changelog.html index e390e223..e4070d5d 100644 --- a/doc/Changelog.html +++ b/doc/Changelog.html @@ -24,6 +24,7 @@ a:visited { color: #0000EE; }
  • Updated MediaInfo to v0.7.59 (2012-08-08), compiled with ICL 12.1.7 and MSVC 10.0
  • Updated optional add-ins for QAAC encoder and FHG AAC encoder (see FAQ doc for details)
  • Updated DCA Enc to v2 (2012-04-19), compiled with ICL 12.1.7 and MSVC 10.0 +
  • Updated language files (big thank-you to all contributors !!!)
  • Implemented multi-threading in file analyzer for faster file import (about 2.5x to 6.0x faster!)
  • Implemented multi-threading in initialization code for faster application startup
  • Fixed a potential crash (stack overflow) when adding a huge number of files diff --git a/src/Config.h b/src/Config.h index 2080712d..efb58ac2 100644 --- a/src/Config.h +++ b/src/Config.h @@ -30,7 +30,7 @@ #define VER_LAMEXP_MINOR_LO 5 #define VER_LAMEXP_TYPE Beta #define VER_LAMEXP_PATCH 4 -#define VER_LAMEXP_BUILD 1086 +#define VER_LAMEXP_BUILD 1087 /////////////////////////////////////////////////////////////////////////////// // Tool versions (minimum expected versions!) diff --git a/src/Global.cpp b/src/Global.cpp index 6819fe2a..9ad35a5e 100644 --- a/src/Global.cpp +++ b/src/Global.cpp @@ -232,7 +232,6 @@ static struct { QVariant instance; QReadWriteLock lock; - } g_lamexp_currentTranslator; @@ -279,7 +278,12 @@ static const DWORD g_main_thread_id = GetCurrentThreadId(); static FILE *g_lamexp_log_file = NULL; //CLI Arguments -static QStringList *g_lamexp_argv = NULL; +static struct +{ + QStringList list; + QReadWriteLock lock; +} +g_lamexp_argv; /////////////////////////////////////////////////////////////////////////////// // GLOBAL FUNCTIONS @@ -1130,7 +1134,7 @@ bool lamexp_init_qt(int argc, char* argv[]) DWORD osVersionNo = lamexp_get_os_version(); if(LAMEXP_EQL_OS_VER(osVersionNo, 6, 2)) { - qDebug("Running on Windows 8 (still experimental!)\n"); + qDebug("Running on Windows 8 or Windows Server 2012\n"); lamexp_check_compatibility_mode(NULL, executableName); } else @@ -1735,9 +1739,12 @@ bool lamexp_install_translator_from_file(const QString &qmFile) const QStringList &lamexp_arguments(void) { - if(!g_lamexp_argv) + QReadLocker readLock(&g_lamexp_argv.lock); + + if(g_lamexp_argv.list.isEmpty()) { - g_lamexp_argv = new QStringList(); + readLock.unlock(); + QWriteLocker writeLock(&g_lamexp_argv.lock); int nArgs = 0; LPWSTR *szArglist = CommandLineToArgvW(GetCommandLineW(), &nArgs); @@ -1746,7 +1753,7 @@ const QStringList &lamexp_arguments(void) { for(int i = 0; i < nArgs; i++) { - *g_lamexp_argv << WCHAR2QSTR(szArglist[i]); + g_lamexp_argv.list << WCHAR2QSTR(szArglist[i]); } LocalFree(szArglist); } @@ -1756,7 +1763,7 @@ const QStringList &lamexp_arguments(void) } } - return *g_lamexp_argv; + return g_lamexp_argv.list; } /* @@ -2222,7 +2229,7 @@ void lamexp_finalization(void) } //Free CLI Arguments - LAMEXP_DELETE(g_lamexp_argv); + g_lamexp_argv.list.clear(); } /*