diff --git a/aegisub/src/video_context.cpp b/aegisub/src/video_context.cpp index bf435d06a..0be0e44c8 100644 --- a/aegisub/src/video_context.cpp +++ b/aegisub/src/video_context.cpp @@ -424,15 +424,32 @@ void VideoContext::JumpToFrame(int n) { // Not threaded else { - // Set frame number - frame_n = n; - GetFrameAsTexture(n); + try { + // Set frame number + frame_n = n; + GetFrameAsTexture(n); - // Display - UpdateDisplays(false); + // Display + UpdateDisplays(false); - // Update grid - if (!isPlaying && Options.AsBool(_T("Highlight subs in frame"))) grid->Refresh(false); + // Update grid + if (!isPlaying && Options.AsBool(_T("Highlight subs in frame"))) grid->Refresh(false); + } + catch (const wxChar *err) { + wxLogError( + _T("Failed seeking video. The video will be closed because of this.\n") + _T("If you get this error regardless of which video file you use, and also if you use dummy video, your OpenGL driver might not work with Aegisub.\n") + _T("Error message reported: %s"), + err); + Reset(); + } + catch (...) { + wxLogError( + _T("Failed seeking video. The video will be closed because of this.\n") + _T("If you get this error regardless of which video file you use, and also if you use dummy video, your OpenGL driver might not work with Aegisub.\n") + _T("No further error message given.")); + Reset(); + } } } diff --git a/aegisub/src/video_display.cpp b/aegisub/src/video_display.cpp index e9ede44f7..c0452fa43 100644 --- a/aegisub/src/video_display.cpp +++ b/aegisub/src/video_display.cpp @@ -168,7 +168,10 @@ void VideoDisplay::ShowCursor(bool show) { ////////// // Render -void VideoDisplay::Render() { +void VideoDisplay::Render() +// Yes it's legal C++ to replace the body of a function with one huge try..catch statement +try { + // Is shown? if (!IsShownOnScreen()) return; if (!wxIsMainThread()) throw _T("Error: trying to render from non-primary thread"); @@ -307,6 +310,21 @@ void VideoDisplay::Render() { //if (glGetError()) throw _T("Error finishing gl operation."); SwapBuffers(); } +catch (const wxChar *err) { + wxLogError( + _T("An error occurred trying to render the video frame to screen.\n") + _T("If you get this error regardless of which video file you use, and also if you use dummy video, your OpenGL driver might not work with Aegisub.\n") + _T("Error message reported: %s"), + err); + VideoContext::Get()->Reset(); +} +catch (...) { + wxLogError( + _T("An error occurred trying to render the video frame to screen.\n") + _T("If you get this error regardless of which video file you use, and also if you use dummy video, your OpenGL driver might not work with Aegisub.\n") + _T("No further error message given.")); + VideoContext::Get()->Reset(); +} ///////////////////////////////////