From 1f831be1706fae5eb5d0f355721650e17f7b9fb1 Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Mon, 4 Feb 2013 15:35:17 -0800 Subject: [PATCH] Ask the user if they want to close the current file before prompting for a new file to open rather than after --- aegisub/src/command/recent.cpp | 1 + aegisub/src/command/subtitle.cpp | 5 +++++ aegisub/src/subs_controller.cpp | 2 -- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/aegisub/src/command/recent.cpp b/aegisub/src/command/recent.cpp index c641e4c28..f8d2af2ec 100644 --- a/aegisub/src/command/recent.cpp +++ b/aegisub/src/command/recent.cpp @@ -93,6 +93,7 @@ struct recent_subtitle_entry : public Command { STR_HELP("Open recent subtitles") void operator()(agi::Context *c, int id) { + if (c->subsController->TryToClose() == wxCANCEL) return; c->subsController->Load(config::mru->GetEntry("Subtitle", id)); } }; diff --git a/aegisub/src/command/subtitle.cpp b/aegisub/src/command/subtitle.cpp index e8627f47d..c9d62473f 100644 --- a/aegisub/src/command/subtitle.cpp +++ b/aegisub/src/command/subtitle.cpp @@ -260,6 +260,7 @@ struct subtitle_open : public Command { STR_HELP("Opens a subtitles file") void operator()(agi::Context *c) { + if (c->subsController->TryToClose() == wxCANCEL) return; auto filename = OpenFileSelector(_("Open subtitles file"), "Path/Last/Subtitles", "","", SubtitleFormat::GetWildcards(0), c->parent); if (!filename.empty()) c->subsController->Load(filename); @@ -273,6 +274,7 @@ struct subtitle_open_autosave : public Command { STR_HELP("Open a previous version of a file which was autosaved by Aegisub") void operator()(agi::Context *c) { + if (c->subsController->TryToClose() == wxCANCEL) return; DialogAutosave dialog(c->parent); if (dialog.ShowModal() == wxID_OK) c->subsController->Load(dialog.ChosenFile()); @@ -287,6 +289,8 @@ struct subtitle_open_charset : public Command { STR_HELP("Opens a subtitles file with a specific charset") void operator()(agi::Context *c) { + if (c->subsController->TryToClose() == wxCANCEL) return; + auto filename = OpenFileSelector(_("Open subtitles file"), "Path/Last/Subtitles", "","", SubtitleFormat::GetWildcards(0), c->parent); if (filename.empty()) return; @@ -306,6 +310,7 @@ struct subtitle_open_video : public Command { CMD_TYPE(COMMAND_VALIDATE) void operator()(agi::Context *c) { + if (c->subsController->TryToClose() == wxCANCEL) return; c->subsController->Load(c->videoController->GetVideoName(), "binary"); } diff --git a/aegisub/src/subs_controller.cpp b/aegisub/src/subs_controller.cpp index b835437da..f0d0c9e5a 100644 --- a/aegisub/src/subs_controller.cpp +++ b/aegisub/src/subs_controller.cpp @@ -83,8 +83,6 @@ SubsController::SubsController(agi::Context *context) } void SubsController::Load(agi::fs::path const& filename, std::string charset) { - if (TryToClose() == wxCANCEL) return; - // TextFileReader does this automatically, but relying on that results in // the user being prompted twice if it can't be auto-detected, since we // open the file twice below.