From 4bb7185a0f9606daaaf16fdf4604ecd1257aa841 Mon Sep 17 00:00:00 2001 From: lordmulder Date: Sun, 17 Apr 2011 15:53:28 +0200 Subject: [PATCH] Added global exception handler routine. --- src/Config.h | 2 +- src/Dialog_MainWindow.cpp | 2 +- src/Global.cpp | 10 ++++++++++ src/Global.h | 1 + src/Main.cpp | 5 +++-- src/Thread_FileAnalyzer.cpp | 2 +- 6 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/Config.h b/src/Config.h index 0c6ed5f9..22e8575d 100644 --- a/src/Config.h +++ b/src/Config.h @@ -30,7 +30,7 @@ #define VER_LAMEXP_MINOR_LO 2 #define VER_LAMEXP_TYPE Alpha #define VER_LAMEXP_PATCH 4 -#define VER_LAMEXP_BUILD 445 +#define VER_LAMEXP_BUILD 447 /////////////////////////////////////////////////////////////////////////////// // Tools versions diff --git a/src/Dialog_MainWindow.cpp b/src/Dialog_MainWindow.cpp index c8c48667..35879884 100644 --- a/src/Dialog_MainWindow.cpp +++ b/src/Dialog_MainWindow.cpp @@ -1083,7 +1083,7 @@ void MainWindow::closeButtonClicked(void) void MainWindow::addFilesButtonClicked(void) { ABORT_IF_BUSY; - + TEMP_HIDE_DROPBOX ( if(lamexp_themes_enabled()) diff --git a/src/Global.cpp b/src/Global.cpp index cf13b24e..f1bff7d8 100644 --- a/src/Global.cpp +++ b/src/Global.cpp @@ -296,6 +296,16 @@ const QDate &lamexp_version_date(void) return g_lamexp_version_date; } +/* + * Global exception handler + */ +LONG WINAPI lamexp_exception_handler(__in struct _EXCEPTION_POINTERS *ExceptionInfo) +{ + FatalAppExit(0, L"Unhandeled exception error3, application will exit!"); + TerminateProcess(GetCurrentProcess(), -1); + return 0; +} + /* * Qt message handler */ diff --git a/src/Global.h b/src/Global.h index dcc1abee..d8dc75e7 100644 --- a/src/Global.h +++ b/src/Global.h @@ -84,6 +84,7 @@ const char *lamexp_support_url(void); void lamexp_init_console(int argc, char* argv[]); bool lamexp_init_qt(int argc, char* argv[]); int lamexp_init_ipc(void); +LONG WINAPI lamexp_exception_handler(__in struct _EXCEPTION_POINTERS *ExceptionInfo); void lamexp_message_handler(QtMsgType type, const char *msg); void lamexp_register_tool(const QString &toolName, LockedFile *file, unsigned int version = 0); bool lamexp_check_tool(const QString &toolName); diff --git a/src/Main.cpp b/src/Main.cpp index b27e730d..f03f82d0 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -193,13 +193,13 @@ int main(int argc, char* argv[]) } else { + int iResult = -1; + SetUnhandledExceptionFilter(lamexp_exception_handler); try { - int iResult = -1; qInstallMsgHandler(lamexp_message_handler); iResult = lamexp_main(argc, argv); lamexp_finalization(); - return iResult; } catch(char *error) { @@ -225,6 +225,7 @@ int main(int argc, char* argv[]) FatalAppExit(0, L"Unhandeled exception error, application will exit!"); TerminateProcess(GetCurrentProcess(), -1); } + return iResult; } } diff --git a/src/Thread_FileAnalyzer.cpp b/src/Thread_FileAnalyzer.cpp index de2f0227..a735fc62 100644 --- a/src/Thread_FileAnalyzer.cpp +++ b/src/Thread_FileAnalyzer.cpp @@ -136,7 +136,7 @@ const AudioFileModel FileAnalyzer::analyzeFile(const QString &filePath) process.setProcessChannelMode(QProcess::MergedChannels); process.setReadChannel(QProcess::StandardOutput); process.start(m_mediaInfoBin, QStringList() << QDir::toNativeSeparators(filePath)); - + if(!process.waitForStarted()) { qWarning("MediaInfo process failed to create!");