diff --git a/src/subs_controller.cpp b/src/subs_controller.cpp index 5aff32e18..1685cc88e 100644 --- a/src/subs_controller.cpp +++ b/src/subs_controller.cpp @@ -178,12 +178,6 @@ ProjectProperties SubsController::Load(agi::fs::path const& filename, std::strin SubtitleFormat::GetReader(filename, charset)->ReadFile(&temp, filename, context->project->Timecodes(), charset); - // Make sure the file has at least one style and one dialogue line - if (temp.Styles.empty()) - temp.Styles.push_back(*new AssStyle); - if (temp.Events.empty()) - temp.Events.push_back(*new AssDialogue); - context->ass->swap(temp); auto props = context->ass->Properties; @@ -328,6 +322,12 @@ void SubsController::OnCommit(AssFileCommit c) { undo_stack.pop_back(); } + // Make sure the file has at least one style and one dialogue line + if (context->ass->Styles.empty()) + context->ass->Styles.push_back(*new AssStyle); + if (context->ass->Events.empty()) + context->ass->Events.push_back(*new AssDialogue); + redo_stack.clear(); undo_stack.emplace_back(context, c.message, commit_id);