forked from mia/Aegisub
Use SetSelectionAndActive whenever both are set at once
I'm not sure if this fixes any current actual problems as using slightly stale data is normally only a problem when lines are being deleted, but it's easier to fix it across the board than to figure out where it is and isn't needed, and the speed impact of batching is trivial. Originally committed to SVN as r6753.
This commit is contained in:
parent
f756aa73c1
commit
06e23b9296
8 changed files with 23 additions and 23 deletions
|
@ -321,9 +321,10 @@ void AssKaraoke::SplitLines(std::set<AssDialogue*> const& lines, agi::Context *c
|
|||
--it;
|
||||
}
|
||||
|
||||
c->selectionController->SetSelectedSet(sel);
|
||||
AssDialogue *new_active = c->selectionController->GetActiveLine();
|
||||
if (!sel.count(c->selectionController->GetActiveLine()))
|
||||
c->selectionController->SetActiveLine(*sel.begin());
|
||||
new_active = *sel.begin();
|
||||
c->selectionController->SetSelectionAndActive(sel, new_active);
|
||||
|
||||
if (did_split)
|
||||
c->ass->Commit(_("splitting"), AssFile::COMMIT_DIAG_ADDREM | AssFile::COMMIT_DIAG_FULL);
|
||||
|
|
|
@ -955,9 +955,10 @@ namespace Automation4 {
|
|||
lua_pop(L, 1);
|
||||
}
|
||||
|
||||
c->selectionController->SetSelectedSet(sel);
|
||||
if (active_line && (active_idx > 0 || !sel.count(c->selectionController->GetActiveLine())))
|
||||
c->selectionController->SetActiveLine(active_line);
|
||||
AssDialogue *new_active = c->selectionController->GetActiveLine();
|
||||
if (active_line && (active_idx > 0 || !sel.count(new_active)))
|
||||
new_active = active_line;
|
||||
c->selectionController->SetSelectionAndActive(sel, new_active);
|
||||
}
|
||||
|
||||
stackcheck.check_stack(1);
|
||||
|
|
|
@ -189,8 +189,7 @@ static void duplicate_lines(agi::Context *c, bool shift) {
|
|||
|
||||
c->ass->Commit(_("duplicate lines"), AssFile::COMMIT_DIAG_ADDREM);
|
||||
|
||||
c->selectionController->SetSelectedSet(new_sel);
|
||||
c->selectionController->SetActiveLine(new_active);
|
||||
c->selectionController->SetSelectionAndActive(new_sel, new_active);
|
||||
}
|
||||
|
||||
/// Duplicate the selected lines.
|
||||
|
@ -249,8 +248,7 @@ static void combine_lines(agi::Context *c, void (*combiner)(AssDialogue *, AssDi
|
|||
c->ass->Line.erase(out, c->ass->Line.end());
|
||||
sel.clear();
|
||||
sel.insert(first);
|
||||
c->selectionController->SetActiveLine(first);
|
||||
c->selectionController->SetSelectedSet(sel);
|
||||
c->selectionController->SetSelectionAndActive(sel, first);
|
||||
c->ass->Commit(message, AssFile::COMMIT_DIAG_ADDREM | AssFile::COMMIT_DIAG_FULL);
|
||||
}
|
||||
|
||||
|
|
|
@ -173,8 +173,7 @@ struct subtitle_insert_after : public validate_nonempty_selection {
|
|||
c->ass->Commit(_("line insertion"), AssFile::COMMIT_DIAG_ADDREM);
|
||||
SelectionController<AssDialogue>::Selection sel;
|
||||
sel.insert(new_line);
|
||||
c->selectionController->SetSelectedSet(sel);
|
||||
c->selectionController->SetActiveLine(new_line);
|
||||
c->selectionController->SetSelectionAndActive(sel, new_line);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -221,8 +220,7 @@ struct subtitle_insert_before : public validate_nonempty_selection {
|
|||
c->ass->Commit(_("line insertion"), AssFile::COMMIT_DIAG_ADDREM);
|
||||
SelectionController<AssDialogue>::Selection sel;
|
||||
sel.insert(new_line);
|
||||
c->selectionController->SetSelectedSet(sel);
|
||||
c->selectionController->SetActiveLine(new_line);
|
||||
c->selectionController->SetSelectionAndActive(sel, new_line);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -275,6 +275,11 @@ void DialogSelection::Process(wxCommandEvent&) {
|
|||
con->selectionController->SetActiveLine(*new_sel.begin());
|
||||
con->selectionController->SetSelectedSet(new_sel);
|
||||
|
||||
AssDialogue *new_active = con->selectionController->GetActiveLine();
|
||||
if (new_sel.size() && !new_sel.count(new_active))
|
||||
new_active = *new_sel.begin();
|
||||
con->selectionController->SetSelectionAndActive(new_sel, new_active);
|
||||
|
||||
Close();
|
||||
}
|
||||
|
||||
|
|
|
@ -267,10 +267,9 @@ bool DialogSpellChecker::CheckLine(AssDialogue *active_line, int start_pos, int
|
|||
|
||||
std::map<wxString, wxString>::const_iterator auto_rep = auto_replace.find(word);
|
||||
if (auto_rep == auto_replace.end()) {
|
||||
context->selectionController->SetActiveLine(active_line);
|
||||
SelectionController<AssDialogue>::Selection sel;
|
||||
sel.insert(active_line);
|
||||
context->selectionController->SetSelectedSet(sel);
|
||||
context->selectionController->SetSelectionAndActive(sel, active_line);
|
||||
SetWord(word);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -155,11 +155,9 @@ void SubtitlesGrid::RecombineLines() {
|
|||
newSel.insert(*lines.begin());
|
||||
|
||||
// Restore selection
|
||||
SetSelectedSet(newSel);
|
||||
if (find(newSel.begin(), newSel.end(), activeLine) == newSel.end()) {
|
||||
if (!newSel.count(activeLine))
|
||||
activeLine = *newSel.begin();
|
||||
}
|
||||
SetActiveLine(activeLine);
|
||||
SetSelectionAndActive(newSel, activeLine);
|
||||
|
||||
context->ass->Commit(_("combining"), AssFile::COMMIT_DIAG_ADDREM | AssFile::COMMIT_DIAG_FULL);
|
||||
}
|
||||
|
|
|
@ -355,11 +355,11 @@ void VisualTool<FeatureType>::RemoveSelection(feature_iterator feat) {
|
|||
|
||||
// Set the active line to an arbitrary selected line if we just
|
||||
// deselected the active line
|
||||
if (feat->line == c->selectionController->GetActiveLine()) {
|
||||
c->selectionController->SetActiveLine(*sel.begin());
|
||||
}
|
||||
AssDialogue *new_active = c->selectionController->GetActiveLine();
|
||||
if (feat->line == new_active)
|
||||
new_active = *sel.begin();
|
||||
|
||||
c->selectionController->SetSelectedSet(sel);
|
||||
c->selectionController->SetSelectionAndActive(sel, new_active);
|
||||
}
|
||||
|
||||
//////// PARSERS
|
||||
|
|
Loading…
Reference in a new issue