fixed a crash when accessing SlurTieSegment::m_ups with an invalid index

when no grip is selected (EditData::curGrip == Grip::NO_GRIP)
This commit is contained in:
Roman Pudashkin 2023-11-21 13:22:34 +02:00
parent ba238d13e3
commit 49a923cdf9
3 changed files with 11 additions and 6 deletions

View file

@ -273,6 +273,7 @@ public:
bool control(bool textEditing = false) const;
bool shift() const { return modifiers & ShiftModifier; }
bool isStartEndGrip() { return curGrip == Grip::START || curGrip == Grip::END; }
bool hasCurrentGrip() { return curGrip != Grip::NO_GRIP; }
};
}

View file

@ -132,9 +132,11 @@ bool SlurSegment::edit(EditData& ed)
Slur* sl = slur();
if (ed.key == Key_Home && !ed.modifiers) {
ups(ed.curGrip).off = PointF();
renderer()->layoutItem(sl);
triggerLayout();
if (ed.hasCurrentGrip()) {
ups(ed.curGrip).off = PointF();
renderer()->layoutItem(sl);
triggerLayout();
}
return true;
}

View file

@ -83,9 +83,11 @@ bool TieSegment::edit(EditData& ed)
SlurTie* sl = tie();
if (ed.key == Key_Home && !ed.modifiers) {
ups(ed.curGrip).off = PointF();
renderer()->layoutItem(sl);
triggerLayout();
if (ed.hasCurrentGrip()) {
ups(ed.curGrip).off = PointF();
renderer()->layoutItem(sl);
triggerLayout();
}
return true;
}
return false;