diff --git a/src/ass_file.cpp b/src/ass_file.cpp index 75c44c8f9..bd06c562e 100644 --- a/src/ass_file.cpp +++ b/src/ass_file.cpp @@ -177,11 +177,7 @@ int AssFile::Commit(wxString const& desc, int type, int amend_id, AssDialogue *s PushState({desc, &amend_id, single_line}); - std::set changed_lines; - if (single_line) - changed_lines.insert(single_line); - - AnnounceCommit(type, changed_lines); + AnnounceCommit(type, single_line); return amend_id; } diff --git a/src/ass_file.h b/src/ass_file.h index f291c2ea3..db848cd1e 100644 --- a/src/ass_file.h +++ b/src/ass_file.h @@ -80,7 +80,7 @@ struct ProjectProperties { class AssFile { /// A set of changes has been committed to the file (AssFile::COMMITType) - agi::signal::Signal const&> AnnounceCommit; + agi::signal::Signal AnnounceCommit; agi::signal::Signal PushState; public: /// The lines in the file diff --git a/src/async_video_provider.cpp b/src/async_video_provider.cpp index 72a6d8bfb..33dbe4bca 100644 --- a/src/async_video_provider.cpp +++ b/src/async_video_provider.cpp @@ -115,24 +115,19 @@ void AsyncVideoProvider::LoadSubtitles(const AssFile *new_subs) throw() { }); } -void AsyncVideoProvider::UpdateSubtitles(const AssFile *new_subs, std::set const& changes) throw() { +void AsyncVideoProvider::UpdateSubtitles(const AssFile *new_subs, const AssDialogue *changed) throw() { uint_fast32_t req_version = ++version; - // Copy just the lines which were changed, then replace the lines at the - // same indices in the worker's copy of the file with the new entries - std::vector changed; - for (auto d : changes) - changed.push_back(new AssDialogue(*d)); - + // Copy just the line which were changed, then replace the line at the + // same index in the worker's copy of the file with the new entry + auto copy = new AssDialogue(*changed); worker->Async([=]{ int i = 0; auto it = subs->Events.begin(); - for (auto& update : changed) { - std::advance(it, update->Row - i); - i = update->Row; - subs->Events.insert(it, *update); - delete &*it--; - } + std::advance(it, copy->Row - i); + i = copy->Row; + subs->Events.insert(it, *copy); + delete &*it--; single_frame = NEW_SUBS_FILE; ProcAsync(req_version, true); diff --git a/src/async_video_provider.h b/src/async_video_provider.h index 139f7bc2a..ce5c83dbc 100644 --- a/src/async_video_provider.h +++ b/src/async_video_provider.h @@ -92,7 +92,7 @@ public: /// /// This function only supports changes to existing lines, and not /// insertions or deletions. - void UpdateSubtitles(const AssFile *subs, std::set const& changes) throw(); + void UpdateSubtitles(const AssFile *subs, const AssDialogue *changes) throw(); /// @brief Queue a request for a frame /// @brief frame Frame number diff --git a/src/audio_karaoke.cpp b/src/audio_karaoke.cpp index 60dd4c390..6d3d16fa9 100644 --- a/src/audio_karaoke.cpp +++ b/src/audio_karaoke.cpp @@ -113,8 +113,8 @@ void AudioKaraoke::OnActiveLineChanged(AssDialogue *new_line) { } } -void AudioKaraoke::OnFileChanged(int type, std::set const& changed) { - if (enabled && (type & AssFile::COMMIT_DIAG_FULL) && (changed.empty() || changed.count(active_line))) { +void AudioKaraoke::OnFileChanged(int type, const AssDialogue *changed) { + if (enabled && (type & AssFile::COMMIT_DIAG_FULL) && (!changed || changed == active_line)) { LoadFromLine(); split_area->Refresh(false); } diff --git a/src/audio_karaoke.h b/src/audio_karaoke.h index e798bfc2b..2d14207d0 100644 --- a/src/audio_karaoke.h +++ b/src/audio_karaoke.h @@ -137,7 +137,7 @@ class AudioKaraoke final : public wxWindow { void OnActiveLineChanged(AssDialogue *new_line); void OnContextMenu(wxContextMenuEvent&); void OnEnableButton(wxCommandEvent &evt); - void OnFileChanged(int type, std::set const& changed); + void OnFileChanged(int type, const AssDialogue *changed); void OnMouse(wxMouseEvent &event); void OnPaint(wxPaintEvent &event); void OnSize(wxSizeEvent &event); diff --git a/src/video_controller.cpp b/src/video_controller.cpp index afe3b0865..065247797 100644 --- a/src/video_controller.cpp +++ b/src/video_controller.cpp @@ -65,7 +65,7 @@ void VideoController::OnNewVideoProvider(AsyncVideoProvider *new_provider) { color_matrix = provider ? provider->GetColorSpace() : ""; } -void VideoController::OnSubtitlesCommit(int type, std::set const& changed) { +void VideoController::OnSubtitlesCommit(int type, const AssDialogue *changed) { if (!provider) return; if ((type & AssFile::COMMIT_SCRIPTINFO) || type == AssFile::COMMIT_NEW) { @@ -76,10 +76,10 @@ void VideoController::OnSubtitlesCommit(int type, std::set } } - if (changed.empty()) + if (!changed) provider->LoadSubtitles(context->ass.get()); else - provider->UpdateSubtitles(context->ass.get(), changed); + provider->UpdateSubtitles(context->ass.get(), {changed}); } void VideoController::OnActiveLineChanged(AssDialogue *line) { diff --git a/src/video_controller.h b/src/video_controller.h index 27b5a4342..c15c5c8f1 100644 --- a/src/video_controller.h +++ b/src/video_controller.h @@ -104,7 +104,7 @@ class VideoController final : public wxEvtHandler { void OnVideoError(VideoProviderErrorEvent const& err); void OnSubtitlesError(SubtitlesProviderErrorEvent const& err); - void OnSubtitlesCommit(int type, std::set const& changed); + void OnSubtitlesCommit(int type, const AssDialogue *changed); void OnNewVideoProvider(AsyncVideoProvider *provider); void OnActiveLineChanged(AssDialogue *line);