From 38a6def683d680e41dc0a5e86f041d0cd887ae6e Mon Sep 17 00:00:00 2001 From: lordmulder Date: Mon, 30 Apr 2012 22:24:41 +0200 Subject: [PATCH] Better handling of exceptions in Avisynth code. --- src/version.h | 2 +- src/win_main.cpp | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/version.h b/src/version.h index c0a6b77..ea7c1b0 100644 --- a/src/version.h +++ b/src/version.h @@ -22,7 +22,7 @@ #define VER_X264_MAJOR 2 #define VER_X264_MINOR 0 #define VER_X264_PATCH 4 -#define VER_X264_BUILD 325 +#define VER_X264_BUILD 328 #define VER_X264_MINIMUM_REV 2189 #define VER_X264_CURRENT_API 124 diff --git a/src/win_main.cpp b/src/win_main.cpp index a1b940a..16065f0 100644 --- a/src/win_main.cpp +++ b/src/win_main.cpp @@ -51,6 +51,8 @@ const char *tpl_last = ""; #define SET_FONT_BOLD(WIDGET,BOLD) { QFont _font = WIDGET->font(); _font.setBold(BOLD); WIDGET->setFont(_font); } #define SET_TEXT_COLOR(WIDGET,COLOR) { QPalette _palette = WIDGET->palette(); _palette.setColor(QPalette::WindowText, (COLOR)); _palette.setColor(QPalette::Text, (COLOR)); WIDGET->setPalette(_palette); } +static int exceptionFilter(_EXCEPTION_RECORD *dst, _EXCEPTION_POINTERS *src) { memcpy(dst, src->ExceptionRecord, sizeof(_EXCEPTION_RECORD)); return EXCEPTION_EXECUTE_HANDLER; } + /////////////////////////////////////////////////////////////////////////////// // Constructor & Destructor /////////////////////////////////////////////////////////////////////////////// @@ -1152,6 +1154,7 @@ double MainWindow::detectAvisynthVersion(QLibrary *avsLib) { qDebug("detectAvisynthVersion(QLibrary *avsLib)"); double version_number = 0.0; + EXCEPTION_RECORD exceptionRecord; __try { @@ -1210,9 +1213,9 @@ double MainWindow::detectAvisynthVersion(QLibrary *avsLib) qWarning("It seems the Avisynth DLL is missing required API functions!"); } } - __except(1) + __except(exceptionFilter(&exceptionRecord, GetExceptionInformation())) { - qWarning("Exception in Avisynth initialization code!"); + qWarning("Exception in Avisynth initialization code! (Address: %p, Code: 0x%08x)", exceptionRecord.ExceptionAddress, exceptionRecord.ExceptionCode); version_number = -1.0; }