diff --git a/aegisub/src/video_context.cpp b/aegisub/src/video_context.cpp index 5970e68de..f2d6e9301 100644 --- a/aegisub/src/video_context.cpp +++ b/aegisub/src/video_context.cpp @@ -63,8 +63,6 @@ #include "video_context.h" #include "video_frame.h" -/// @brief Constructor -/// VideoContext::VideoContext() : playback(this) , startMS(0) @@ -74,6 +72,7 @@ VideoContext::VideoContext() , arType(0) , hasSubtitles(false) , playAudioOnStep(OPT_GET("Audio/Plays When Stepping Video")) +, no_amend(false) { Bind(EVT_VIDEO_ERROR, &VideoContext::OnVideoError, this); Bind(EVT_SUBTITLES_ERROR, &VideoContext::OnSubtitlesError, this); @@ -236,15 +235,19 @@ void VideoContext::Reload() { void VideoContext::OnSubtitlesCommit(int type, std::set const& changed) { if (!IsLoaded()) return; - if (changed.empty()) + if (changed.empty() || no_amend) provider->LoadSubtitles(context->ass); else provider->UpdateSubtitles(context->ass, changed); if (!IsPlaying()) GetFrameAsync(frame_n); + + no_amend = false; } void VideoContext::OnSubtitlesSave() { + no_amend = true; + context->ass->SetScriptInfo("VFR File", MakeRelativePath(GetTimecodesName(), context->ass->filename)); context->ass->SetScriptInfo("Keyframes File", MakeRelativePath(GetKeyFramesName(), context->ass->filename)); diff --git a/aegisub/src/video_context.h b/aegisub/src/video_context.h index 37e4e4fa2..d69ac9749 100644 --- a/aegisub/src/video_context.h +++ b/aegisub/src/video_context.h @@ -130,6 +130,12 @@ class VideoContext : public wxEvtHandler { /// Cached option for audio playing when frame stepping const agi::OptionValue* playAudioOnStep; + /// Amending the frame source's copy of the subtitle file requires that it + /// be kept in perfect sync. Saving the file can add lines to the file + /// without a commit, breaking this sync, so force a non-amend after each + /// save. + bool no_amend; + void OnPlayTimer(wxTimerEvent &event); /// The timecodes from the video file