forked from mia/Aegisub
Use remove_and_dispose_if where applicable
This commit is contained in:
parent
6ab8345148
commit
174a992974
2 changed files with 11 additions and 23 deletions
|
@ -517,12 +517,9 @@ static void delete_lines(agi::Context *c, wxString const& commit_message) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete selected lines
|
// Delete selected lines
|
||||||
for (entryIter it = c->ass->Line.begin(); it != c->ass->Line.end(); ) {
|
c->ass->Line.remove_and_dispose_if([&sel](AssEntry const& e) {
|
||||||
if (sel.count(static_cast<AssDialogue*>(&*it)))
|
return sel.count(const_cast<AssDialogue *>(static_cast<const AssDialogue*>(&e)));
|
||||||
delete &*it++;
|
}, [](AssEntry *e) { delete e; });
|
||||||
else
|
|
||||||
++it;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If we didn't get a new active line then we just deleted all the dialogue
|
// If we didn't get a new active line then we just deleted all the dialogue
|
||||||
// lines, so make a new one
|
// lines, so make a new one
|
||||||
|
|
|
@ -182,24 +182,16 @@ void SubtitleFormat::ConvertNewlines(AssFile &file, wxString const& newline, boo
|
||||||
}
|
}
|
||||||
|
|
||||||
void SubtitleFormat::StripComments(AssFile &file) {
|
void SubtitleFormat::StripComments(AssFile &file) {
|
||||||
for (entryIter it = file.Line.begin(); it != file.Line.end(); ) {
|
file.Line.remove_and_dispose_if([](AssEntry const& e) {
|
||||||
AssDialogue *diag = dynamic_cast<AssDialogue*>(&*it);
|
const AssDialogue *diag = dynamic_cast<const AssDialogue*>(&e);
|
||||||
if (!diag || (!diag->Comment && diag->Text.size()))
|
return diag && (diag->Comment || !diag->Text);
|
||||||
++it;
|
}, [](AssEntry *e) { delete e; });
|
||||||
else {
|
|
||||||
delete &*it++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SubtitleFormat::StripNonDialogue(AssFile &file) {
|
void SubtitleFormat::StripNonDialogue(AssFile &file) {
|
||||||
for (entryIter it = file.Line.begin(); it != file.Line.end(); ) {
|
file.Line.remove_and_dispose_if([](AssEntry const& e) {
|
||||||
if (dynamic_cast<AssDialogue*>(&*it))
|
return e.Group() != ENTRY_DIALOGUE;
|
||||||
++it;
|
}, [](AssEntry *e) { delete e; });
|
||||||
else {
|
|
||||||
delete &*it++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool dialog_start_lt(AssEntry &pos, AssDialogue *to_insert) {
|
static bool dialog_start_lt(AssEntry &pos, AssDialogue *to_insert) {
|
||||||
|
@ -318,8 +310,7 @@ void SubtitleFormat::LoadFormats() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SubtitleFormat::DestroyFormats() {
|
void SubtitleFormat::DestroyFormats() {
|
||||||
for (auto it = formats.begin(); it != formats.end(); )
|
delete_clear(formats);
|
||||||
delete *it++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class Cont, class Pred>
|
template<class Cont, class Pred>
|
||||||
|
|
Loading…
Reference in a new issue