Keep the old subtitles file alive until the new one is fully announced

This fixes crashes from touching dangling references to lines in the old
subtitle file in the handlers for the various signals triggered when a
new file is opened.
This commit is contained in:
Thomas Goyne 2014-05-06 09:27:36 -07:00
parent ca1cf8d9e7
commit 47b8627ad3
1 changed files with 3 additions and 4 deletions

View File

@ -173,6 +173,8 @@ void SubsController::SetSelectionController(SelectionController *selection_contr
}
void SubsController::Load(agi::fs::path const& filename, std::string charset) {
AssFile temp;
try {
try {
if (charset.empty())
@ -198,10 +200,7 @@ void SubsController::Load(agi::fs::path const& filename, std::string charset) {
}
}
const SubtitleFormat *reader = SubtitleFormat::GetReader(filename, charset);
AssFile temp;
reader->ReadFile(&temp, filename, context->videoController->FPS(), charset);
SubtitleFormat::GetReader(filename, charset)->ReadFile(&temp, filename, context->videoController->FPS(), charset);
// Make sure the file has at least one style and one dialogue line
if (temp.Styles.empty())