ffmpegsource video provider now cleans up after itself properly even if loading the video file failed

Originally committed to SVN as r2373.
This commit is contained in:
Karl Blomster 2008-09-23 01:19:31 +00:00
parent cc85096bbd
commit 9b4f389fb2

View file

@ -58,7 +58,12 @@ FFmpegSourceVideoProvider::FFmpegSourceVideoProvider(Aegisub::String filename, d
MessageSize = sizeof(FFMSErrorMessage);
// and here we go
try {
LoadVideo(filename, fps);
} catch (...) {
Close();
throw;
}
}
///////////////
@ -92,12 +97,14 @@ void FFmpegSourceVideoProvider::LoadVideo(Aegisub::String filename, double fps)
Progress.ProgressDialog->Show();
Progress.ProgressDialog->SetProgress(0,1);
Index = FFMS_MakeIndex(FileNameWX.char_str(), 0, "", FFmpegSourceVideoProvider::UpdateIndexingProgress, &Progress, FFMSErrorMessage, MessageSize);
Index = FFMS_MakeIndex(FileNameWX.char_str(), 1, NULL, FFmpegSourceVideoProvider::UpdateIndexingProgress, &Progress, FFMSErrorMessage, MessageSize);
if (Index == NULL) {
Progress.ProgressDialog->Destroy();
ErrorMsg.Printf(_T("FFmpegSource video provider: %s"), FFMSErrorMessage);
throw ErrorMsg;
}
Progress.ProgressDialog->Destroy();
// write it to disk
if (FFMS_WriteIndex(CacheName.char_str(), Index, FFMSErrorMessage, MessageSize)) {
ErrorMsg.Printf(_T("FFmpegSource video provider: %s"), FFMSErrorMessage);