From bf34e9e78f6f2f34ed23ba4fb5ea018827e88302 Mon Sep 17 00:00:00 2001 From: LoRd_MuldeR Date: Sat, 8 Dec 2012 00:21:58 +0100 Subject: [PATCH] Improved handling of fatal/critical messages in lamexp_message_handler() function. --- LameXP_VS2012.vcxproj | 5 ++--- src/Global.cpp | 11 +++++++++-- src/Main.cpp | 2 +- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/LameXP_VS2012.vcxproj b/LameXP_VS2012.vcxproj index 5f64d8ae..1c94c5e7 100644 --- a/LameXP_VS2012.vcxproj +++ b/LameXP_VS2012.vcxproj @@ -140,8 +140,7 @@ copy /Y "$(SolutionDir)\etc\Prerequisites\VisualLeakDetector\bin\Win32\*.manifes false true false - - + None true false /wd4005 %(AdditionalOptions) @@ -167,10 +166,10 @@ copy /Y "$(SolutionDir)\etc\Prerequisites\VisualLeakDetector\bin\Win32\*.manifes lamexp_entry_point - true $(QTDIR)\lib;$(QTDIR)\plugins\imageformats;$(SolutionDir)\etc\Prerequisites\VisualLeakDetector\lib\Win32;$(SolutionDir)\etc\Prerequisites\keccak\lib\$(Configuration);%(AdditionalLibraryDirectories) + true Copy plugin DLL%27s diff --git a/src/Global.cpp b/src/Global.cpp index 65c9566e..44f49ebd 100644 --- a/src/Global.cpp +++ b/src/Global.cpp @@ -523,8 +523,14 @@ static void lamexp_console_color(FILE* file, WORD attributes) */ void lamexp_message_handler(QtMsgType type, const char *msg) { + static volatile bool bFatalFlag = false; static const char *GURU_MEDITATION = "\n\nGURU MEDITATION !!!\n\n"; - + + if(bFatalFlag || (msg == NULL)) + { + return; //We are about to terminate, discard any further messages! + } + QMutexLocker lock(&g_lamexp_message_mutex); if(g_lamexp_log_file) @@ -546,6 +552,7 @@ void lamexp_message_handler(QtMsgType type, const char *msg) { case QtCriticalMsg: case QtFatalMsg: + bFatalFlag = true; fflush(stdout); fflush(stderr); lamexp_console_color(stderr, FOREGROUND_RED | FOREGROUND_INTENSITY); @@ -590,7 +597,7 @@ void lamexp_message_handler(QtMsgType type, const char *msg) OutputDebugStringA(temp.toLatin1().constData()); } - if(type == QtCriticalMsg || type == QtFatalMsg) + if(bFatalFlag) { lock.unlock(); diff --git a/src/Main.cpp b/src/Main.cpp index b3accc63..84bbbfd2 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -150,7 +150,7 @@ static int lamexp_main(int argc, char* argv[]) FileListModel *fileListModel = new FileListModel(); AudioFileModel *metaInfo = new AudioFileModel(); SettingsModel *settingsModel = new SettingsModel(); - + //Show splash screen InitializationThread *poInitializationThread = new InitializationThread(&cpuFeatures); SplashScreen::showSplash(poInitializationThread);