forked from mia/Aegisub
Eliminate a pointless set that only ever had zero or one entries
This commit is contained in:
parent
5201773a3b
commit
372b9fe115
8 changed files with 18 additions and 27 deletions
|
@ -177,11 +177,7 @@ int AssFile::Commit(wxString const& desc, int type, int amend_id, AssDialogue *s
|
||||||
|
|
||||||
PushState({desc, &amend_id, single_line});
|
PushState({desc, &amend_id, single_line});
|
||||||
|
|
||||||
std::set<const AssDialogue*> changed_lines;
|
AnnounceCommit(type, single_line);
|
||||||
if (single_line)
|
|
||||||
changed_lines.insert(single_line);
|
|
||||||
|
|
||||||
AnnounceCommit(type, changed_lines);
|
|
||||||
|
|
||||||
return amend_id;
|
return amend_id;
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,7 +80,7 @@ struct ProjectProperties {
|
||||||
|
|
||||||
class AssFile {
|
class AssFile {
|
||||||
/// A set of changes has been committed to the file (AssFile::COMMITType)
|
/// A set of changes has been committed to the file (AssFile::COMMITType)
|
||||||
agi::signal::Signal<int, std::set<const AssDialogue*> const&> AnnounceCommit;
|
agi::signal::Signal<int, const AssDialogue*> AnnounceCommit;
|
||||||
agi::signal::Signal<AssFileCommit> PushState;
|
agi::signal::Signal<AssFileCommit> PushState;
|
||||||
public:
|
public:
|
||||||
/// The lines in the file
|
/// The lines in the file
|
||||||
|
|
|
@ -115,24 +115,19 @@ void AsyncVideoProvider::LoadSubtitles(const AssFile *new_subs) throw() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void AsyncVideoProvider::UpdateSubtitles(const AssFile *new_subs, std::set<const AssDialogue*> const& changes) throw() {
|
void AsyncVideoProvider::UpdateSubtitles(const AssFile *new_subs, const AssDialogue *changed) throw() {
|
||||||
uint_fast32_t req_version = ++version;
|
uint_fast32_t req_version = ++version;
|
||||||
|
|
||||||
// Copy just the lines which were changed, then replace the lines at the
|
// Copy just the line which were changed, then replace the line at the
|
||||||
// same indices in the worker's copy of the file with the new entries
|
// same index in the worker's copy of the file with the new entry
|
||||||
std::vector<AssDialogue *> changed;
|
auto copy = new AssDialogue(*changed);
|
||||||
for (auto d : changes)
|
|
||||||
changed.push_back(new AssDialogue(*d));
|
|
||||||
|
|
||||||
worker->Async([=]{
|
worker->Async([=]{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
auto it = subs->Events.begin();
|
auto it = subs->Events.begin();
|
||||||
for (auto& update : changed) {
|
std::advance(it, copy->Row - i);
|
||||||
std::advance(it, update->Row - i);
|
i = copy->Row;
|
||||||
i = update->Row;
|
subs->Events.insert(it, *copy);
|
||||||
subs->Events.insert(it, *update);
|
delete &*it--;
|
||||||
delete &*it--;
|
|
||||||
}
|
|
||||||
|
|
||||||
single_frame = NEW_SUBS_FILE;
|
single_frame = NEW_SUBS_FILE;
|
||||||
ProcAsync(req_version, true);
|
ProcAsync(req_version, true);
|
||||||
|
|
|
@ -92,7 +92,7 @@ public:
|
||||||
///
|
///
|
||||||
/// This function only supports changes to existing lines, and not
|
/// This function only supports changes to existing lines, and not
|
||||||
/// insertions or deletions.
|
/// insertions or deletions.
|
||||||
void UpdateSubtitles(const AssFile *subs, std::set<const AssDialogue *> const& changes) throw();
|
void UpdateSubtitles(const AssFile *subs, const AssDialogue *changes) throw();
|
||||||
|
|
||||||
/// @brief Queue a request for a frame
|
/// @brief Queue a request for a frame
|
||||||
/// @brief frame Frame number
|
/// @brief frame Frame number
|
||||||
|
|
|
@ -113,8 +113,8 @@ void AudioKaraoke::OnActiveLineChanged(AssDialogue *new_line) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioKaraoke::OnFileChanged(int type, std::set<const AssDialogue *> const& changed) {
|
void AudioKaraoke::OnFileChanged(int type, const AssDialogue *changed) {
|
||||||
if (enabled && (type & AssFile::COMMIT_DIAG_FULL) && (changed.empty() || changed.count(active_line))) {
|
if (enabled && (type & AssFile::COMMIT_DIAG_FULL) && (!changed || changed == active_line)) {
|
||||||
LoadFromLine();
|
LoadFromLine();
|
||||||
split_area->Refresh(false);
|
split_area->Refresh(false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -137,7 +137,7 @@ class AudioKaraoke final : public wxWindow {
|
||||||
void OnActiveLineChanged(AssDialogue *new_line);
|
void OnActiveLineChanged(AssDialogue *new_line);
|
||||||
void OnContextMenu(wxContextMenuEvent&);
|
void OnContextMenu(wxContextMenuEvent&);
|
||||||
void OnEnableButton(wxCommandEvent &evt);
|
void OnEnableButton(wxCommandEvent &evt);
|
||||||
void OnFileChanged(int type, std::set<const AssDialogue *> const& changed);
|
void OnFileChanged(int type, const AssDialogue *changed);
|
||||||
void OnMouse(wxMouseEvent &event);
|
void OnMouse(wxMouseEvent &event);
|
||||||
void OnPaint(wxPaintEvent &event);
|
void OnPaint(wxPaintEvent &event);
|
||||||
void OnSize(wxSizeEvent &event);
|
void OnSize(wxSizeEvent &event);
|
||||||
|
|
|
@ -65,7 +65,7 @@ void VideoController::OnNewVideoProvider(AsyncVideoProvider *new_provider) {
|
||||||
color_matrix = provider ? provider->GetColorSpace() : "";
|
color_matrix = provider ? provider->GetColorSpace() : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
void VideoController::OnSubtitlesCommit(int type, std::set<const AssDialogue *> const& changed) {
|
void VideoController::OnSubtitlesCommit(int type, const AssDialogue *changed) {
|
||||||
if (!provider) return;
|
if (!provider) return;
|
||||||
|
|
||||||
if ((type & AssFile::COMMIT_SCRIPTINFO) || type == AssFile::COMMIT_NEW) {
|
if ((type & AssFile::COMMIT_SCRIPTINFO) || type == AssFile::COMMIT_NEW) {
|
||||||
|
@ -76,10 +76,10 @@ void VideoController::OnSubtitlesCommit(int type, std::set<const AssDialogue *>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (changed.empty())
|
if (!changed)
|
||||||
provider->LoadSubtitles(context->ass.get());
|
provider->LoadSubtitles(context->ass.get());
|
||||||
else
|
else
|
||||||
provider->UpdateSubtitles(context->ass.get(), changed);
|
provider->UpdateSubtitles(context->ass.get(), {changed});
|
||||||
}
|
}
|
||||||
|
|
||||||
void VideoController::OnActiveLineChanged(AssDialogue *line) {
|
void VideoController::OnActiveLineChanged(AssDialogue *line) {
|
||||||
|
|
|
@ -104,7 +104,7 @@ class VideoController final : public wxEvtHandler {
|
||||||
void OnVideoError(VideoProviderErrorEvent const& err);
|
void OnVideoError(VideoProviderErrorEvent const& err);
|
||||||
void OnSubtitlesError(SubtitlesProviderErrorEvent const& err);
|
void OnSubtitlesError(SubtitlesProviderErrorEvent const& err);
|
||||||
|
|
||||||
void OnSubtitlesCommit(int type, std::set<const AssDialogue *> const& changed);
|
void OnSubtitlesCommit(int type, const AssDialogue *changed);
|
||||||
void OnNewVideoProvider(AsyncVideoProvider *provider);
|
void OnNewVideoProvider(AsyncVideoProvider *provider);
|
||||||
void OnActiveLineChanged(AssDialogue *line);
|
void OnActiveLineChanged(AssDialogue *line);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue