Add some error catching in the OpenGL code, this should make most OpenGL-related problems less fatal, though it can still cause funky UI problems I think.

At least the user should get a slightly more useful error message now.
Updates #799.

Originally committed to SVN as r2998.
This commit is contained in:
Niels Martin Hansen 2009-06-01 15:26:26 +00:00
parent da78539ab2
commit 60970e5f29
2 changed files with 43 additions and 8 deletions

View File

@ -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();
}
}
}

View File

@ -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();
}
///////////////////////////////////