forked from mia/Aegisub
Fix crash when rearranging styles in the style manager
Inserting lines already in an intrusive list at a different position does not work, unlike with unintrusive lists. Instead, swap each item in to the correct place.
This commit is contained in:
parent
8e10d67d2f
commit
3f840ceec8
1 changed files with 7 additions and 9 deletions
|
@ -771,16 +771,14 @@ void DialogStyleManager::MoveStyles(bool storage, int type) {
|
||||||
do_move(styleMap, type, first, last, false);
|
do_move(styleMap, type, first, last, false);
|
||||||
|
|
||||||
// Replace styles
|
// Replace styles
|
||||||
entryIter next;
|
|
||||||
int curn = 0;
|
int curn = 0;
|
||||||
for (entryIter cur = c->ass->Line.begin(); cur != c->ass->Line.end(); cur = next) {
|
for (auto it = c->ass->Line.begin(); it != c->ass->Line.end(); ++it) {
|
||||||
next = cur;
|
if (!dynamic_cast<AssStyle*>(&*it)) continue;
|
||||||
next++;
|
|
||||||
if (dynamic_cast<AssStyle*>(&*cur)) {
|
auto new_style_at_pos = c->ass->Line.iterator_to(*styleMap[curn]);
|
||||||
c->ass->Line.insert(cur, *styleMap[curn]);
|
EntryList::node_algorithms::swap_nodes(it.pointed_node(), new_style_at_pos.pointed_node());
|
||||||
c->ass->Line.erase(cur);
|
if (++curn == styleMap.size()) break;
|
||||||
curn++;
|
it = new_style_at_pos;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
c->ass->Commit(_("style move"), AssFile::COMMIT_STYLES);
|
c->ass->Commit(_("style move"), AssFile::COMMIT_STYLES);
|
||||||
|
|
Loading…
Reference in a new issue