Skip to content

Commit

Permalink
Percussion panel - fix panel not updating after undo/redo/reset
Browse files Browse the repository at this point in the history
  • Loading branch information
mathesoncalum committed Jan 3, 2025
1 parent 7d37064 commit 7335c37
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/notation/internal/notationinteraction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ NotationInteraction::NotationInteraction(Notation* notation, INotationUndoStackP

m_undoStack->undoRedoNotification().onNotify(this, [this]() {
endEditElement();
notifyAboutNoteInputStateChanged();
});

m_undoStack->stackChanged().onNotify(this, [this]() {
Expand Down
10 changes: 5 additions & 5 deletions src/notation/view/percussionpanel/percussionpanelmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ void PercussionPanelModel::finishEditing(bool discardChanges)
return;
}

Drumset* updatedDrumset = m_padListModel->drumset();
m_padListModel->removeEmptyRows();

NoteInputState inputState = interaction()->noteInput()->state();
Expand All @@ -205,6 +204,8 @@ void PercussionPanelModel::finishEditing(bool discardChanges)
return;
}

Drumset updatedDrumset = *m_padListModel->drumset();

for (int i = 0; i < m_padListModel->padList().size(); ++i) {
const PercussionPanelPadModel* model = m_padListModel->padList().at(i);
if (!model) {
Expand All @@ -214,7 +215,7 @@ void PercussionPanelModel::finishEditing(bool discardChanges)
const int row = i / m_padListModel->numColumns();
const int column = i % m_padListModel->numColumns();

engraving::DrumInstrument& drum = updatedDrumset->drum(model->pitch());
engraving::DrumInstrument& drum = updatedDrumset.drum(model->pitch());

drum.panelRow = row;
drum.panelColumn = column;
Expand All @@ -224,8 +225,7 @@ void PercussionPanelModel::finishEditing(bool discardChanges)
}

// Return if nothing changed after edit...
if (inst->drumset() && updatedDrumset
&& *inst->drumset() == *updatedDrumset) {
if (inst->drumset() && *inst->drumset() == updatedDrumset) {
setCurrentPanelMode(m_panelModeToRestore);
m_padListModel->focusLastActivePad();
return;
Expand All @@ -234,7 +234,7 @@ void PercussionPanelModel::finishEditing(bool discardChanges)
INotationUndoStackPtr undoStack = notation()->undoStack();

undoStack->prepareChanges(muse::TranslatableString("undoableAction", "Edit percussion panel layout"));
score()->undo(new engraving::ChangeDrumset(inst, updatedDrumset, staff->part()));
score()->undo(new engraving::ChangeDrumset(inst, &updatedDrumset, staff->part()));
undoStack->commitChanges();

setCurrentPanelMode(m_panelModeToRestore);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class PercussionPanelPadListModel : public QAbstractListModel, public muse::Inje
int numPads() const { return m_padModels.count(); }

void setDrumset(const engraving::Drumset* drumset);
engraving::Drumset* drumset() const { return m_drumset; }
const engraving::Drumset* drumset() const { return m_drumset; }

QList<PercussionPanelPadModel*> padList() const { return m_padModels; }

Expand Down

0 comments on commit 7335c37

Please sign in to comment.