Dropping a bracket onto a bracket causes a crash

• Jun 19, 2018 - 14:37
Reported version
3.0
Type
Functional
Severity
S2 - Critical
Status
closed
Project

When I try to change a system bracket from one type to another, MuseScore crashes.

To reproduce:
1. Drag a bracket from the palette to any system.
2. Drag another bracket from the palette and drop it onto the bracket created in step 1.

At this point, MuseScore will crash. This is because Bracket::drop() returns an element that it has just deleted. The calling function will then try to select the element that has just been deleted, and that is when the crash occurs. Bracket::drop() should instead return either nullptr or this.


Comments

The purpose of the return value of Element::drop() is to select the appropriate element after the drop takes place. In the case of Bracket::drop(), the correct return value is this. In MuseScore 3, brackets are deleted and recreated during layout, so even if Bracket::drop() returns this, the bracket will not be selected after layout occurs. Score::doLayoutRange() is smart enough to remove brackets from the selection list before it erases the systems. It might be nice if it added back to the selection list any brackets it deselected after the brackets are recreated.