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:
WarmUpTill
2022-02-18 21:23:26 +01:00
committed by WarmUpTill
parent 354ef56070
commit 8e3eb8519b
6 changed files with 51 additions and 0 deletions

View File

@@ -54,6 +54,8 @@ public:
void HighlightCondition(int idx);
void PopulateMacroActions(Macro &m, uint32_t afterIdx = 0);
void PopulateMacroConditions(Macro &m, uint32_t afterIdx = 0);
void SetActionData(Macro &m);
void SetConditionData(Macro &m);
void ConnectControlSignals(MacroActionEdit *);
void ConnectControlSignals(MacroConditionEdit *);
void SwapActions(Macro *m, int pos1, int pos2);

View File

@@ -34,6 +34,7 @@ public:
std::shared_ptr<MacroAction> * = nullptr,
const std::string &id = "scene_switch");
void UpdateEntryData(const std::string &id);
void SetEntryData(std::shared_ptr<MacroAction> *);
private slots:
void ActionSelectionChanged(const QString &text);

View File

@@ -38,6 +38,7 @@ public:
bool IsRootNode();
void SetRootNode(bool);
void UpdateEntryData(const std::string &id);
void SetEntryData(std::shared_ptr<MacroCondition> *);
private slots:
void LogicSelectionChanged(int idx);