Now using global "fatal exit" function.
This commit is contained in:
parent
6a2c9e463f
commit
337a65bb2d
@ -167,8 +167,7 @@ LONG WINAPI x264_exception_handler(__in struct _EXCEPTION_POINTERS *ExceptionInf
|
||||
if(mainThread) TerminateThread(mainThread, ULONG_MAX);
|
||||
}
|
||||
|
||||
FatalAppExit(0, L"Unhandeled exception handler invoked, application will exit!");
|
||||
TerminateProcess(GetCurrentProcess(), -1);
|
||||
x264_fatal_exit(L"Unhandeled exception handler invoked, application will exit!");
|
||||
return LONG_MAX;
|
||||
}
|
||||
|
||||
@ -183,8 +182,7 @@ void x264_invalid_param_handler(const wchar_t*, const wchar_t*, const wchar_t*,
|
||||
if(mainThread) TerminateThread(mainThread, ULONG_MAX);
|
||||
}
|
||||
|
||||
FatalAppExit(0, L"Invalid parameter handler invoked, application will exit!");
|
||||
TerminateProcess(GetCurrentProcess(), -1);
|
||||
x264_fatal_exit(L"Invalid parameter handler invoked, application will exit!");
|
||||
}
|
||||
|
||||
/*
|
||||
@ -274,9 +272,7 @@ void x264_message_handler(QtMsgType type, const char *msg)
|
||||
if(type == QtCriticalMsg || type == QtFatalMsg)
|
||||
{
|
||||
lock.unlock();
|
||||
MessageBoxW(NULL, QWCHAR(QString::fromUtf8(msg)), L"Simple x264 Launcher - GURU MEDITATION", MB_ICONERROR | MB_TOPMOST | MB_TASKMODAL);
|
||||
FatalAppExit(0, L"The application has encountered a critical error and will exit now!");
|
||||
TerminateProcess(GetCurrentProcess(), -1);
|
||||
x264_fatal_exit(L"The application has encountered a critical error and will exit now!", QWCHAR(QString::fromUtf8(msg)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -906,8 +902,11 @@ static void WINAPI x264_debug_thread_proc(__in LPVOID lpParameter)
|
||||
{
|
||||
Sleep(333);
|
||||
}
|
||||
for(;;)
|
||||
{
|
||||
TerminateProcess(GetCurrentProcess(), -1);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Check for debugger (startup routine)
|
||||
@ -916,13 +915,42 @@ static HANDLE x264_debug_thread_init(void)
|
||||
{
|
||||
if(IsDebuggerPresent() || x264_check_for_debugger())
|
||||
{
|
||||
FatalAppExit(0, L"Not a debug build. Please unload debugger and try again!");
|
||||
TerminateProcess(GetCurrentProcess(), -1);
|
||||
x264_fatal_exit(L"Not a debug build. Please unload debugger and try again!");
|
||||
}
|
||||
|
||||
return CreateThread(NULL, NULL, reinterpret_cast<LPTHREAD_START_ROUTINE>(&x264_debug_thread_proc), NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Fatal application exit
|
||||
*/
|
||||
#pragma intrinsic(_InterlockedExchange)
|
||||
void x264_fatal_exit(const wchar_t* exitMessage, const wchar_t* errorBoxMessage)
|
||||
{
|
||||
static volatile long bFatalFlag = 0L;
|
||||
|
||||
if(_InterlockedExchange(&bFatalFlag, 1L) == 0L)
|
||||
{
|
||||
if(GetCurrentThreadId() != g_main_thread_id)
|
||||
{
|
||||
HANDLE mainThread = OpenThread(THREAD_TERMINATE, FALSE, g_main_thread_id);
|
||||
if(mainThread) TerminateThread(mainThread, ULONG_MAX);
|
||||
}
|
||||
|
||||
if(errorBoxMessage)
|
||||
{
|
||||
MessageBoxW(NULL, errorBoxMessage, L"Simple x264 Launcher - GURU MEDITATION", MB_ICONERROR | MB_TOPMOST | MB_TASKMODAL);
|
||||
}
|
||||
|
||||
FatalAppExit(0, exitMessage);
|
||||
|
||||
for(;;)
|
||||
{
|
||||
TerminateProcess(GetCurrentProcess(), -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialize debug thread
|
||||
*/
|
||||
|
@ -122,5 +122,6 @@ void x264_init_console(int argc, char* argv[]);
|
||||
bool x264_init_qt(int argc, char* argv[]);
|
||||
const x264_cpu_t x264_detect_cpu_features(int argc, char **argv);
|
||||
bool x264_shutdown_computer(const QString &message, const unsigned long timeout, const bool forceShutdown);
|
||||
void x264_fatal_exit(const wchar_t* exitMessage, const wchar_t* errorBoxMessage = NULL);
|
||||
SIZE_T x264_dbg_private_bytes(void);
|
||||
void x264_finalization(void);
|
||||
|
12
src/main.cpp
12
src/main.cpp
@ -126,24 +126,21 @@ static int _main(int argc, char* argv[])
|
||||
fflush(stdout);
|
||||
fflush(stderr);
|
||||
fprintf(stderr, "\nGURU MEDITATION !!!\n\nException error message: %s\n", error);
|
||||
FatalAppExit(0, L"Unhandeled C++ exception error, application will exit!");
|
||||
TerminateProcess(GetCurrentProcess(), -1);
|
||||
x264_fatal_exit(L"Unhandeled C++ exception error, application will exit!");
|
||||
}
|
||||
catch(int error)
|
||||
{
|
||||
fflush(stdout);
|
||||
fflush(stderr);
|
||||
fprintf(stderr, "\nGURU MEDITATION !!!\n\nException error code: 0x%X\n", error);
|
||||
FatalAppExit(0, L"Unhandeled C++ exception error, application will exit!");
|
||||
TerminateProcess(GetCurrentProcess(), -1);
|
||||
x264_fatal_exit(L"Unhandeled C++ exception error, application will exit!");
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
fflush(stdout);
|
||||
fflush(stderr);
|
||||
fprintf(stderr, "\nGURU MEDITATION !!!\n");
|
||||
FatalAppExit(0, L"Unhandeled C++ exception error, application will exit!");
|
||||
TerminateProcess(GetCurrentProcess(), -1);
|
||||
x264_fatal_exit(L"Unhandeled C++ exception error, application will exit!");
|
||||
}
|
||||
return iResult;
|
||||
}
|
||||
@ -168,8 +165,7 @@ int main(int argc, char* argv[])
|
||||
fflush(stdout);
|
||||
fflush(stderr);
|
||||
fprintf(stderr, "\nGURU MEDITATION !!!\n\nUnhandeled structured exception error! [code: 0x%X]\n", GetExceptionCode());
|
||||
FatalAppExit(0, L"Unhandeled structured exception error, application will exit!");
|
||||
TerminateProcess(GetCurrentProcess(), -1);
|
||||
x264_fatal_exit(L"Unhandeled structured exception error, application will exit!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,7 @@
|
||||
#define VER_X264_MAJOR 2
|
||||
#define VER_X264_MINOR 0
|
||||
#define VER_X264_PATCH 7
|
||||
#define VER_X264_BUILD 403
|
||||
#define VER_X264_BUILD 404
|
||||
|
||||
#define VER_X264_MINIMUM_REV 2223
|
||||
#define VER_X264_CURRENT_API 129
|
||||
|
Loading…
Reference in New Issue
Block a user