From ddc8dc9eca60f375c6e618f8ed4c07a09065abce Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Thu, 2 Feb 2012 20:51:07 +0000 Subject: [PATCH] Only wrap the avisynth-using part of AvisynthVideoProvider's constructor with try/catch so that avisynth is still initialized when the catch handler runs, which is required to actually get an error message. Closes #1444. Originally committed to SVN as r6438. --- aegisub/src/video_provider_avs.cpp | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/aegisub/src/video_provider_avs.cpp b/aegisub/src/video_provider_avs.cpp index 7e9491d40..5578c88e4 100644 --- a/aegisub/src/video_provider_avs.cpp +++ b/aegisub/src/video_provider_avs.cpp @@ -53,7 +53,7 @@ #include "standard_paths.h" #include "video_provider_avs.h" -AvisynthVideoProvider::AvisynthVideoProvider(wxString filename) try +AvisynthVideoProvider::AvisynthVideoProvider(wxString filename) : last_fnum(-1) { iframe.flipped = true; @@ -145,18 +145,20 @@ file_exit: } #endif - AVSValue script = Open(fname, extension); + try { + AVSValue script = Open(fname, extension); - // Check if video was loaded properly - if (!script.IsClip() || !script.AsClip()->GetVideoInfo().HasVideo()) - throw VideoNotSupported("No usable video found"); + // Check if video was loaded properly + if (!script.IsClip() || !script.AsClip()->GetVideoInfo().HasVideo()) + throw VideoNotSupported("No usable video found"); - RGB32Video = (avs.GetEnv()->Invoke("Cache", avs.GetEnv()->Invoke("ConvertToRGB32", script))).AsClip(); - vi = RGB32Video->GetVideoInfo(); - fps = (double)vi.fps_numerator / vi.fps_denominator; -} -catch (AvisynthError const& err) { - throw VideoOpenError("Avisynth error: " + std::string(err.msg)); + RGB32Video = (avs.GetEnv()->Invoke("Cache", avs.GetEnv()->Invoke("ConvertToRGB32", script))).AsClip(); + vi = RGB32Video->GetVideoInfo(); + fps = (double)vi.fps_numerator / vi.fps_denominator; + } + catch (AvisynthError const& err) { + throw VideoOpenError("Avisynth error: " + std::string(err.msg)); + } } AvisynthVideoProvider::~AvisynthVideoProvider() {