diff --git a/LameXP_VS2013.vcxproj b/LameXP_VS2013.vcxproj index 6161d0f8..068c5c54 100644 --- a/LameXP_VS2013.vcxproj +++ b/LameXP_VS2013.vcxproj @@ -146,7 +146,6 @@ copy /Y "$(SolutionDir)\etc\Prerequisites\VisualLeakDetector\bin\Win32\*.manifes false false false - None true false /wd4005 %(AdditionalOptions) @@ -178,7 +177,6 @@ copy /Y "$(SolutionDir)\etc\Prerequisites\VisualLeakDetector\bin\Win32\*.manifes $(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/Config.h b/src/Config.h index 111caf8b..86633dc2 100644 --- a/src/Config.h +++ b/src/Config.h @@ -34,8 +34,8 @@ #define VER_LAMEXP_MINOR_HI 1 #define VER_LAMEXP_MINOR_LO 1 #define VER_LAMEXP_TYPE Beta -#define VER_LAMEXP_PATCH 1 -#define VER_LAMEXP_BUILD 1597 +#define VER_LAMEXP_PATCH 2 +#define VER_LAMEXP_BUILD 1600 #define VER_LAMEXP_CONFG 1558 /////////////////////////////////////////////////////////////////////////////// diff --git a/src/Global.h b/src/Global.h index d699a091..a999073e 100644 --- a/src/Global.h +++ b/src/Global.h @@ -115,18 +115,15 @@ bool lamexp_exec_shell(const QWidget *win, const QString &url, const QString &pa void lamexp_finalization(void); unsigned __int64 lamexp_free_diskspace(const QString &path, bool *ok = NULL); void lamexp_free_window_icon(lamexp_icon_t *icon); -void lamexp_init_error_handlers(void); int lamexp_init_ipc(void); bool lamexp_init_qt(int argc, char* argv[]); bool lamexp_install_translator(const QString &language); bool lamexp_install_translator_from_file(const QString &qmFile); -void lamexp_invalid_param_handler(const wchar_t*, const wchar_t*, const wchar_t*, unsigned int, uintptr_t); void lamexp_ipc_read(unsigned int *command, char* message, size_t buffSize); void lamexp_ipc_send(unsigned int command, const char* message); bool lamexp_is_executable(const QString &path); bool lamexp_is_hibernation_supported(void); const QString lamexp_lookup_tool(const QString &toolName); -void lamexp_message_handler(QtMsgType type, const char *msg); const char *lamexp_mulders_url(void); void lamexp_natural_string_sort(QStringList &list, const bool bIgnoreCase); int lamexp_network_status(void); diff --git a/src/Global_Win32.cpp b/src/Global_Win32.cpp index a9c269df..34be1943 100644 --- a/src/Global_Win32.cpp +++ b/src/Global_Win32.cpp @@ -190,73 +190,12 @@ bool lamexp_detect_wine(void) return g_lamexp_wine.bIsWine; } -/* - * Qt message handler - */ -void lamexp_message_handler(QtMsgType type, const char *msg) -{ - if((!msg) || (!(msg[0]))) - { - return; - } - - MUtils::Terminal::write(type, msg); - - if((type == QtCriticalMsg) || (type == QtFatalMsg)) - { - MUtils::OS::fatal_exit(MUTILS_WCHR(QString::fromUtf8(msg))); - } -} - -/* - * Invalid parameters handler - */ -static void lamexp_invalid_param_handler(const wchar_t* exp, const wchar_t* fun, const wchar_t* fil, unsigned int, uintptr_t) -{ - MUtils::OS::fatal_exit(L"Invalid parameter handler invoked, application will exit!"); -} - -/* - * Signal handler - */ -static void lamexp_signal_handler(int signal_num) -{ - signal(signal_num, lamexp_signal_handler); - MUtils::OS::fatal_exit(L"Signal handler invoked, application will exit!"); -} - -/* - * Global exception handler - */ -static LONG WINAPI lamexp_exception_handler(struct _EXCEPTION_POINTERS *ExceptionInfo) -{ - MUtils::OS::fatal_exit(L"Unhandeled exception handler invoked, application will exit!"); - return LONG_MAX; -} - -/* - * Initialize error handlers - */ -void lamexp_init_error_handlers(void) -{ - SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX); - SetUnhandledExceptionFilter(lamexp_exception_handler); - SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_ABOVE_NORMAL); - _set_invalid_parameter_handler(lamexp_invalid_param_handler); - - static const int signal_num[6] = { SIGABRT, SIGFPE, SIGILL, SIGINT, SIGSEGV, SIGTERM }; - - for(size_t i = 0; i < 6; i++) - { - signal(signal_num[i], lamexp_signal_handler); - } -} - /* * Check for debugger (detect routine) */ static __forceinline bool lamexp_check_for_debugger(void) { + return false; __try { CloseHandle((HANDLE)((DWORD_PTR)-3)); diff --git a/src/Main.cpp b/src/Main.cpp index 399b5aed..cb9dcb85 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -39,6 +39,7 @@ #include #include #include +#include //Qt includes #include @@ -51,18 +52,12 @@ // Main function /////////////////////////////////////////////////////////////////////////////// -static int lamexp_main(int argc, char* argv[]) +static int lamexp_main(int &argc, char **argv) { int iResult = -1; int iShutdown = shutdownFlag_None; bool bAccepted = true; - //Get CLI arguments - const QStringList &arguments = MUtils::OS::arguments(); - - //Init console - MUtils::Terminal::setup(arguments, MUTILS_DEBUG || lamexp_version_demo()); - //Print version info qDebug("LameXP - Audio Encoder Front-End v%d.%02d %s (Build #%03d)", lamexp_version_major(), lamexp_version_minor(), lamexp_version_release(), lamexp_version_build()); qDebug("Copyright (c) 2004-%04d LoRd_MuldeR . Some rights reserved.", qMax(MUtils::Version::app_build_date().year(), MUtils::OS::current_date().year())); @@ -84,6 +79,9 @@ static int lamexp_main(int argc, char* argv[]) qWarning("---------------------------------------------------------\n"); } + //Get CLI arguments + const QStringList &arguments = MUtils::OS::arguments(); + //Enumerate CLI arguments qDebug("Command-Line Arguments:"); for(int i = 0; i < arguments.count(); i++) @@ -103,6 +101,7 @@ static int lamexp_main(int argc, char* argv[]) //Initialize Qt if(!lamexp_init_qt(argc, argv)) { + lamexp_finalization(); return -1; } @@ -132,10 +131,12 @@ static int lamexp_main(int argc, char* argv[]) messageBox.exec(); messageProducerThread->wait(); MUTILS_DELETE(messageProducerThread); + lamexp_finalization(); return -1; } MUTILS_DELETE(messageProducerThread); } + lamexp_finalization(); return 0; } @@ -144,6 +145,7 @@ static int lamexp_main(int argc, char* argv[]) { if(!arguments[i].compare("--kill", Qt::CaseInsensitive) || !arguments[i].compare("--force-kill", Qt::CaseInsensitive)) { + lamexp_finalization(); return 0; } } @@ -217,6 +219,7 @@ static int lamexp_main(int argc, char* argv[]) } //Terminate + lamexp_finalization(); return iResult; } @@ -224,58 +227,7 @@ static int lamexp_main(int argc, char* argv[]) // Applicaton entry point /////////////////////////////////////////////////////////////////////////////// -static int _main(int argc, char* argv[]) -{ - if(MUTILS_DEBUG) - { - int iResult = -1; - qInstallMsgHandler(lamexp_message_handler); - iResult = lamexp_main(argc, argv); - lamexp_finalization(); - return iResult; - } - else - { - int iResult = -1; - try - { - qInstallMsgHandler(lamexp_message_handler); - iResult = lamexp_main(argc, argv); - lamexp_finalization(); - } - catch(const std::exception &error) - { - PRINT_ERROR("\nGURU MEDITATION !!!\n\nException error:\n%s\n", error.what()); - MUtils::OS::fatal_exit(L"Unhandeled C++ exception error, application will exit!"); - } - catch(...) - { - PRINT_ERROR("\nGURU MEDITATION !!!\n\nUnknown exception error!\n"); - MUtils::OS::fatal_exit(L"Unhandeled C++ exception error, application will exit!"); - } - return iResult; - } -} - int main(int argc, char* argv[]) { - if(MUTILS_DEBUG) - { - int exit_code = -1; - LAMEXP_MEMORY_CHECK(_main, exit_code, argc, argv); - return exit_code; - } - else - { - __try - { - lamexp_init_error_handlers(); - return _main(argc, argv); - } - __except(1) - { - PRINT_ERROR("\nGURU MEDITATION !!!\n\nUnhandeled structured exception error!\n"); - MUtils::OS::fatal_exit(L"Unhandeled structured exception error, application will exit!"); - } - } + return MUtils::Startup::startup(argc, argv, lamexp_main); }