Skip to content

Commit

Permalink
#17906 (Using MIDI input to input chords causes crash): Reworked mov…
Browse files Browse the repository at this point in the history
…eToNextInput() logic in addPitch(). moveToNextInput() is called before actually inserting a new node, except if adding to a chord or if it is the first note inserted. A new flag InputState::moveBeforeAdding has been added just for this purpuse.
  • Loading branch information
muelleki committed Jan 10, 2013
1 parent 3e11d32 commit e8159e1
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
6 changes: 4 additions & 2 deletions libmscore/cmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -384,9 +384,12 @@ qDebug("add pitch %d %d", pitch, addFlag);
Note* n = addNote(chord, pitch);
setLayoutAll(false);
setLayout(chord->measure());
moveToNextInputPos();
return n;
}
if (_is.moveBeforeAdding())
moveToNextInputPos();
else
_is.setMoveBeforeAdding(true);
expandVoice();

// insert note
Expand Down Expand Up @@ -444,7 +447,6 @@ qDebug("add pitch %d %d", pitch, addFlag);
qDebug("addPitch: cannot find slur note");
setLayoutAll(true);
}
moveToNextInputPos();
return note;
}

Expand Down
1 change: 1 addition & 0 deletions libmscore/input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ InputState::InputState() :
_segment(0),
_string(VISUAL_STRING_NONE),
_repitchMode(false),
_moveBeforeAdding(false),
rest(false),
pitch(72),
noteType(NOTE_NORMAL),
Expand Down
4 changes: 4 additions & 0 deletions libmscore/input.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class InputState {
Segment* _segment; // current segment
int _string; // visual string selected for input (TAB staves only)
bool _repitchMode;
bool _moveBeforeAdding;

public:
bool rest; // rest mode
Expand Down Expand Up @@ -70,6 +71,9 @@ class InputState {
bool repitchMode() const { return _repitchMode; }
void setRepitchMode(bool val) { _repitchMode = val; }

bool moveBeforeAdding() const { return _moveBeforeAdding; }
void setMoveBeforeAdding(bool val) { _moveBeforeAdding = val; }

StaffGroup staffGroup() const;
};

Expand Down
1 change: 1 addition & 0 deletions libmscore/score.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2714,6 +2714,7 @@ void Score::setInputState(Element* e)
e = static_cast<Chord*>(e)->upNote();

_is.setDrumNote(-1);
_is.setMoveBeforeAdding(false);
// _is.setDrumset(0);
if (e->type() == Element::NOTE) {
Note* note = static_cast<Note*>(e);
Expand Down

0 comments on commit e8159e1

Please sign in to comment.