mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-08-30 13:15:43 -05:00
Fix potential crashes when adding or removing macro segments
I wrongly assumed that std::deque would guarantee that pointers to elements in deque would not be invalidated by insert() or erase() but this is not the case it seems. "" An erase in the middle of the deque invalidates all the iterators and references to elements of the deque. An erase at either end of the deque invalidates only the iterators and the references to the erased elements. "" I guess I got lucky noone ran into these sorts of crashes for now?
This commit is contained in:
@@ -254,6 +254,39 @@ void AdvSceneSwitcher::PopulateMacroConditions(Macro &m, uint32_t afterIdx)
|
||||
conditionsList->SetHelpMsgVisible(conditions.size() == 0);
|
||||
}
|
||||
|
||||
void AdvSceneSwitcher::SetActionData(Macro &m)
|
||||
{
|
||||
auto &actions = m.Actions();
|
||||
for (int idx = 0; idx < actionsList->ContentLayout()->count(); idx++) {
|
||||
auto item = actionsList->ContentLayout()->itemAt(idx);
|
||||
if (!item) {
|
||||
continue;
|
||||
}
|
||||
auto widget = static_cast<MacroActionEdit *>(item->widget());
|
||||
if (!widget) {
|
||||
continue;
|
||||
}
|
||||
widget->SetEntryData(&*(actions.begin() + idx));
|
||||
}
|
||||
}
|
||||
|
||||
void AdvSceneSwitcher::SetConditionData(Macro &m)
|
||||
{
|
||||
auto &conditions = m.Conditions();
|
||||
for (int idx = 0; idx < conditionsList->ContentLayout()->count();
|
||||
idx++) {
|
||||
auto item = conditionsList->ContentLayout()->itemAt(idx);
|
||||
if (!item) {
|
||||
continue;
|
||||
}
|
||||
auto widget = static_cast<MacroConditionEdit *>(item->widget());
|
||||
if (!widget) {
|
||||
continue;
|
||||
}
|
||||
widget->SetEntryData(&*(conditions.begin() + idx));
|
||||
}
|
||||
}
|
||||
|
||||
void AdvSceneSwitcher::SetEditMacro(Macro &m)
|
||||
{
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user