From 47b8627ad39ca992a7a57af3a541e5621c875f68 Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Tue, 6 May 2014 09:27:36 -0700 Subject: [PATCH] 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. --- src/subs_controller.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/subs_controller.cpp b/src/subs_controller.cpp index a1fdeaf8d..1f66d92d9 100644 --- a/src/subs_controller.cpp +++ b/src/subs_controller.cpp @@ -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())