Skip to content

Commit 41b7bde

Browse files
Merge pull request #32842 from CubikingChill/select-instrument-crash
Fix crash when clicking "select instrument" from "change instrument" during playback (#32078)
2 parents 4fb23b2 + 1cdf281 commit 41b7bde

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/instrumentsscene/internal/instrumentsactionscontroller.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,22 @@ void InstrumentsActionsController::changeInstrument()
6060
return;
6161
}
6262

63-
const mu::engraving::EngravingItem* element = master->notation()->interaction()->selection()->element();
64-
const mu::engraving::InstrumentChange* instrumentChange = element ? mu::engraving::toInstrumentChange(element) : nullptr;
65-
if (!instrumentChange) {
63+
INotationPtr notation = context()->currentNotation();
64+
IF_ASSERT_FAILED(notation) {
6665
return;
6766
}
6867

68+
const mu::engraving::EngravingItem* element = notation->interaction()->hitElementContext().element;
69+
if (!element) {
70+
element = notation->interaction()->selection()->element();
71+
}
72+
73+
if (!element || !element->isInstrumentChange()) {
74+
return;
75+
}
76+
77+
const mu::engraving::InstrumentChange* instrumentChange = mu::engraving::toInstrumentChange(element);
78+
6979
InstrumentKey key;
7080
key.instrumentId = instrumentChange->instrument()->id();
7181
key.partId = instrumentChange->part()->id();

0 commit comments

Comments
 (0)