From: <sag...@us...> - 2011-08-25 15:46:33
|
Revision: 999 http://modplug.svn.sourceforge.net/modplug/?rev=999&view=rev Author: saga-games Date: 2011-08-25 15:46:25 +0000 (Thu, 25 Aug 2011) Log Message: ----------- [Mod] Changed exception handling a bit more again, added exception handler for notification thread. [Mod] OpenMPT: Version is now 1.20.00.13 Modified Paths: -------------- trunk/OpenMPT/mptrack/ExceptionHandler.cpp trunk/OpenMPT/mptrack/ExceptionHandler.h trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/version.h Modified: trunk/OpenMPT/mptrack/ExceptionHandler.cpp =================================================================== --- trunk/OpenMPT/mptrack/ExceptionHandler.cpp 2011-08-24 16:43:02 UTC (rev 998) +++ trunk/OpenMPT/mptrack/ExceptionHandler.cpp 2011-08-25 15:46:25 UTC (rev 999) @@ -12,24 +12,11 @@ #include "Mainfrm.h" #include "snddev.h" #include "Moddoc.h" +#include <shlwapi.h> #include "ExceptionHandler.h" #include "dbghelp.h" -void ExceptionHandler::RegisterMainThread() -//----------------------------------------- -{ - ::SetUnhandledExceptionFilter(UnhandledExceptionFilterMain); -} - - -void ExceptionHandler::RegisterAudioThread() -//------------------------------------------ -{ - ::SetUnhandledExceptionFilter(UnhandledExceptionFilterAudio); -} - - LONG ExceptionHandler::UnhandledExceptionFilterMain(_EXCEPTION_POINTERS *pExceptionInfo) //-------------------------------------------------------------------------------------- { @@ -44,6 +31,13 @@ } +LONG ExceptionHandler::UnhandledExceptionFilterNotify(_EXCEPTION_POINTERS *pExceptionInfo) +//---------------------------------------------------------------------------------------- +{ + return UnhandledExceptionFilter(pExceptionInfo, "notify"); +} + + typedef BOOL (WINAPI *MINIDUMPWRITEDUMP)(HANDLE hProcess, DWORD dwPid, HANDLE hFile, MINIDUMP_TYPE DumpType, CONST PMINIDUMP_EXCEPTION_INFORMATION ExceptionParam, CONST PMINIDUMP_USER_STREAM_INFORMATION UserStreamParam, @@ -64,6 +58,9 @@ pMainFrame->audioCloseDevice(); } + CString errorMessage; + errorMessage.Format("Unhandled exception 0x%X at address %p occoured in the %s thread.", pExceptionInfo->ExceptionRecord->ExceptionCode, pExceptionInfo->ExceptionRecord->ExceptionAddress, threadName); + const CString timestampDir = (CTime::GetCurrentTime()).Format("%Y-%m-%d %H.%M.%S\\"); CString baseRescuePath; { @@ -78,7 +75,7 @@ baseRescuePath.Append(timestampDir); if(!PathIsDirectory(baseRescuePath) && !CreateDirectory(baseRescuePath, nullptr)) { - ::MessageBox(window, "A crash has been detected and OpenMPT will be closed.\nOpenMPT was unable to create a directory for saving debug information and modified files to.", "OpenMPT Crash", MB_ICONERROR); + errorMessage.AppendFormat("\n\nCould not create the following directory for saving debug information and modified files to:\n%s", baseRescuePath); } } @@ -102,6 +99,8 @@ pDump(GetCurrentProcess(), GetCurrentProcessId(), hFile, MiniDumpNormal, &ExInfo, NULL, NULL); ::CloseHandle(hFile); + + errorMessage.AppendFormat("\n\nDebug information have been saved to\n%s", baseRescuePath); } } ::FreeLibrary(hDll); @@ -134,11 +133,11 @@ if(numFiles > 0) { - CString message; - message.Format("A crash has been detected in the %s thread and OpenMPT will be closed.\n%d modified file%s been rescued to\n\n%s\n\nNote: It cannot be guaranteed that rescued files are still intact.", threadName, numFiles, (numFiles == 1 ? " has" : "s have"), baseRescuePath); - ::MessageBox(window, message, "OpenMPT Crash", MB_ICONERROR); + errorMessage.AppendFormat("\n\n%d modified file%s been rescued, but it cannot be guaranteed that %s still intact.", numFiles, (numFiles == 1 ? " has" : "s have"), (numFiles == 1 ? "it is" : "they are")); } } + + ::MessageBox(window, errorMessage, "OpenMPT Crash", MB_ICONERROR); // Let Windows handle the exception... return EXCEPTION_CONTINUE_SEARCH; Modified: trunk/OpenMPT/mptrack/ExceptionHandler.h =================================================================== --- trunk/OpenMPT/mptrack/ExceptionHandler.h 2011-08-24 16:43:02 UTC (rev 998) +++ trunk/OpenMPT/mptrack/ExceptionHandler.h 2011-08-25 15:46:25 UTC (rev 999) @@ -18,13 +18,18 @@ { public: - static void RegisterMainThread(); - static void RegisterAudioThread(); + // Call this in the main thread to activate unhandled exception filtering for this thread. + static void RegisterMainThread() { ::SetUnhandledExceptionFilter(UnhandledExceptionFilterMain); }; + // Call this in the audio thread to activate unhandled exception filtering for this thread. + static void RegisterAudioThread() { ::SetUnhandledExceptionFilter(UnhandledExceptionFilterAudio); }; + // Call this in the notification thread to activate unhandled exception filtering for this thread. + static void RegisterNotifyThread() { ::SetUnhandledExceptionFilter(UnhandledExceptionFilterNotify); }; protected: static LONG WINAPI UnhandledExceptionFilterMain(_EXCEPTION_POINTERS *pExceptionInfo); static LONG WINAPI UnhandledExceptionFilterAudio(_EXCEPTION_POINTERS *pExceptionInfo); + static LONG WINAPI UnhandledExceptionFilterNotify(_EXCEPTION_POINTERS *pExceptionInfo); static LONG UnhandledExceptionFilter(_EXCEPTION_POINTERS *pExceptionInfo, const CString threadName); }; Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2011-08-24 16:43:02 UTC (rev 998) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2011-08-25 15:46:25 UTC (rev 999) @@ -782,24 +782,13 @@ } -void Terminate_NotifyThread() -//--------------------------- -{ - //TODO: Why does this not get called. - AfxMessageBox("Notify thread terminated unexpectedly. Attempting to shut down audio device"); - CMainFrame* pMainFrame = CMainFrame::GetMainFrame(); - if (pMainFrame->gpSoundDevice) pMainFrame->gpSoundDevice->Reset(); - pMainFrame->audioCloseDevice(); - exit(-1); -} - // Notify thread DWORD WINAPI CMainFrame::NotifyThread(LPVOID) //------------------------------------------- { CMainFrame *pMainFrm; - set_terminate(Terminate_NotifyThread); + ExceptionHandler::RegisterNotifyThread(); SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_BELOW_NORMAL); for (;;) @@ -1317,7 +1306,7 @@ CSoundFile *pSndFile = pModDoc->GetSoundFile(); if ((!pSndFile) || (!pSndFile->GetType())) return FALSE; const bool bPaused = pSndFile->IsPaused(); - const bool bPatLoop = (pSndFile->m_dwSongFlags & SONG_PATTERNLOOP) ? true : false; + const bool bPatLoop = (pSndFile->m_dwSongFlags & SONG_PATTERNLOOP) != 0; pSndFile->ResetChannels(); // Select correct bidi loop mode when playing a module. pSndFile->SetupITBidiMode(); @@ -2311,17 +2300,6 @@ { case ID_NETLINK_MODPLUG: pszURL = "http://openmpt.org/"; break; case ID_NETLINK_TOP_PICKS: pszURL = "http://openmpt.org/top_picks"; break; - /* - case ID_NETLINK_OPENMPTWIKI:pszURL = "http://wiki.openmpt.org/"; break; -// case ID_NETLINK_UT: pszURL = "http://www.united-trackers.org"; break; -// case ID_NETLINK_OSMUSIC: pszURL = "http://www.osmusic.net/"; break; -// case ID_NETLINK_HANDBOOK: pszURL = "http://www.modplug.com/mods/handbook/handbook.htm"; break; - case ID_NETLINK_MPTFR: pszURL = "http://mpt.new.fr/"; break; - case ID_NETLINK_FORUMS: pszURL = "http://forum.openmpt.org/"; break; - case ID_NETLINK_PLUGINS: pszURL = "http://www.kvraudio.com/"; break; - case ID_NETLINK_MODARCHIVE: pszURL = "http://modarchive.org/"; break; - case ID_NETLINK_OPENMPTWIKI_GERMAN: pszURL = "http://wikide.openmpt.org/Hauptseite"; break; - */ } if (pszURL) return CTrackApp::OpenURL(pszURL); return FALSE; Modified: trunk/OpenMPT/mptrack/version.h =================================================================== --- trunk/OpenMPT/mptrack/version.h 2011-08-24 16:43:02 UTC (rev 998) +++ trunk/OpenMPT/mptrack/version.h 2011-08-25 15:46:25 UTC (rev 999) @@ -15,7 +15,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 20 #define VER_MINOR 00 -#define VER_MINORMINOR 12 +#define VER_MINORMINOR 13 //Creates version number from version parts that appears in version string. //For example MAKE_VERSION_NUMERIC(1,17,02,28) gives version number of This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |