Skip to content

Commit

Permalink
Merge pull request #11558 from HemantAntony/11502-change_instrument_a…
Browse files Browse the repository at this point in the history
…lways_applied

Fix #11502: Change instrument always applied
  • Loading branch information
RomanPudashkin committed May 10, 2022
2 parents 719d293 + 15c5797 commit 59e9c6d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
19 changes: 14 additions & 5 deletions src/notation/internal/notationinteraction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1316,7 +1316,11 @@ bool NotationInteraction::drop(const PointF& pos, Qt::KeyboardModifiers modifier

EngravingItem* dropElement = el->drop(m_dropData.ed);
if (dropElement && dropElement->isInstrumentChange()) {
selectInstrument(toInstrumentChange(dropElement));
if (!selectInstrument(toInstrumentChange(dropElement))) {
rollback();
accepted = true;
break;
}
}
score()->addRefresh(el->canvasBoundingRect());
if (dropElement) {
Expand Down Expand Up @@ -1356,19 +1360,21 @@ bool NotationInteraction::drop(const PointF& pos, Qt::KeyboardModifiers modifier
return accepted;
}

void NotationInteraction::selectInstrument(Ms::InstrumentChange* instrumentChange)
bool NotationInteraction::selectInstrument(Ms::InstrumentChange* instrumentChange)
{
if (!instrumentChange) {
return;
return false;
}

RetVal<Instrument> selectedInstrument = selectInstrumentScenario()->selectInstrument();
if (!selectedInstrument.ret) {
return;
return false;
}

instrumentChange->setInit(true);
instrumentChange->setupInstrument(&selectedInstrument.val);

return true;
}

//! NOTE Copied from Palette::applyPaletteElement
Expand Down Expand Up @@ -1719,7 +1725,10 @@ void NotationInteraction::applyDropPaletteElement(Ms::Score* score, Ms::Engravin

Ms::EngravingItem* el = target->drop(*dropData);
if (el && el->isInstrumentChange()) {
selectInstrument(toInstrumentChange(el));
if (!selectInstrument(toInstrumentChange(el))) {
rollback();
return;
}
}

if (el && !score->inputState().noteEntryMode()) {
Expand Down
2 changes: 1 addition & 1 deletion src/notation/internal/notationinteraction.h
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ class NotationInteraction : public INotationInteraction, public async::Asyncable
bool dropCanvas(EngravingItem* e);
void resetDropElement();

void selectInstrument(Ms::InstrumentChange* instrumentChange);
bool selectInstrument(Ms::InstrumentChange* instrumentChange);

void applyDropPaletteElement(Ms::Score* score, Ms::EngravingItem* target, Ms::EngravingItem* e, Qt::KeyboardModifiers modifiers,
PointF pt = PointF(), bool pasteMode = false);
Expand Down

0 comments on commit 59e9c6d

Please sign in to comment.