Made lamexp_arguments() thread-safe, just to be sure.

This commit is contained in:
LoRd_MuldeR 2012-08-17 23:47:01 +02:00
parent 640828fb14
commit cb2b770a88
3 changed files with 17 additions and 9 deletions

View File

@ -24,6 +24,7 @@ a:visited { color: #0000EE; }
<li>Updated MediaInfo to v0.7.59 (2012-08-08), compiled with ICL 12.1.7 and MSVC 10.0 <li>Updated MediaInfo to v0.7.59 (2012-08-08), compiled with ICL 12.1.7 and MSVC 10.0
<li>Updated optional add-ins for QAAC encoder and FHG AAC encoder (see <a href="FAQ.html#71a113b0" target="_blank">FAQ doc</a> for details) <li>Updated optional add-ins for QAAC encoder and FHG AAC encoder (see <a href="FAQ.html#71a113b0" target="_blank">FAQ doc</a> for details)
<li>Updated DCA Enc to v2 (2012-04-19), compiled with ICL 12.1.7 and MSVC 10.0 <li>Updated DCA Enc to v2 (2012-04-19), compiled with ICL 12.1.7 and MSVC 10.0
<li>Updated language files (big thank-you to all contributors !!!)
<li>Implemented multi-threading in file analyzer for faster file import (about 2.5x to 6.0x faster!) <li>Implemented multi-threading in file analyzer for faster file import (about 2.5x to 6.0x faster!)
<li>Implemented multi-threading in initialization code for faster application startup <li>Implemented multi-threading in initialization code for faster application startup
<li>Fixed a potential crash (stack overflow) when adding a huge number of files <li>Fixed a potential crash (stack overflow) when adding a huge number of files

View File

@ -30,7 +30,7 @@
#define VER_LAMEXP_MINOR_LO 5 #define VER_LAMEXP_MINOR_LO 5
#define VER_LAMEXP_TYPE Beta #define VER_LAMEXP_TYPE Beta
#define VER_LAMEXP_PATCH 4 #define VER_LAMEXP_PATCH 4
#define VER_LAMEXP_BUILD 1086 #define VER_LAMEXP_BUILD 1087
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// Tool versions (minimum expected versions!) // Tool versions (minimum expected versions!)

View File

@ -232,7 +232,6 @@ static struct
{ {
QVariant instance; QVariant instance;
QReadWriteLock lock; QReadWriteLock lock;
} }
g_lamexp_currentTranslator; g_lamexp_currentTranslator;
@ -279,7 +278,12 @@ static const DWORD g_main_thread_id = GetCurrentThreadId();
static FILE *g_lamexp_log_file = NULL; static FILE *g_lamexp_log_file = NULL;
//CLI Arguments //CLI Arguments
static QStringList *g_lamexp_argv = NULL; static struct
{
QStringList list;
QReadWriteLock lock;
}
g_lamexp_argv;
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// GLOBAL FUNCTIONS // GLOBAL FUNCTIONS
@ -1130,7 +1134,7 @@ bool lamexp_init_qt(int argc, char* argv[])
DWORD osVersionNo = lamexp_get_os_version(); DWORD osVersionNo = lamexp_get_os_version();
if(LAMEXP_EQL_OS_VER(osVersionNo, 6, 2)) 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); lamexp_check_compatibility_mode(NULL, executableName);
} }
else else
@ -1735,9 +1739,12 @@ bool lamexp_install_translator_from_file(const QString &qmFile)
const QStringList &lamexp_arguments(void) 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; int nArgs = 0;
LPWSTR *szArglist = CommandLineToArgvW(GetCommandLineW(), &nArgs); LPWSTR *szArglist = CommandLineToArgvW(GetCommandLineW(), &nArgs);
@ -1746,7 +1753,7 @@ const QStringList &lamexp_arguments(void)
{ {
for(int i = 0; i < nArgs; i++) for(int i = 0; i < nArgs; i++)
{ {
*g_lamexp_argv << WCHAR2QSTR(szArglist[i]); g_lamexp_argv.list << WCHAR2QSTR(szArglist[i]);
} }
LocalFree(szArglist); 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 //Free CLI Arguments
LAMEXP_DELETE(g_lamexp_argv); g_lamexp_argv.list.clear();
} }
/* /*