Skip to content

Commit

Permalink
fix #305018: fix a crash on adding a note with unrewound Cursor
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitrio95 committed May 8, 2020
1 parent 63efceb commit 11a00f7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
4 changes: 4 additions & 0 deletions mscore/plugin/api/cursor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,10 @@ void Cursor::addNote(int pitch, bool addToChord)
qWarning("Cursor::addNote: invalid pitch: %d", pitch);
return;
}
if (!segment()) {
qWarning("Cursor::addNote: cursor location is undefined, use rewind() to define its location");
return;
}
if (!inputState().duration().isValid())
setDuration(1, 4);
NoteVal nval(pitch);
Expand Down
10 changes: 9 additions & 1 deletion mscore/plugin/api/cursor.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,15 @@ class Score;

//---------------------------------------------------------
// @@ Cursor
/// Cursor can be used by plugins to manipulate the score
/// Cursor can be used by plugins to manipulate the score.
/// Cursor object for a score can be obtained with
/// \ref Score.newCursor method. After creating a cursor
/// it does not point to any location in a score. To define
/// its initial location use \ref rewind or \ref rewindToTick
/// methods. Alternatively, you can set its
/// \ref inputStateMode to \ref INPUT_STATE_SYNC_WITH_SCORE "Cursor.INPUT_STATE_SYNC_WITH_SCORE"
/// to make cursor location be synchronized with
/// user-visible note input state.
//---------------------------------------------------------

class Cursor : public QObject {
Expand Down

0 comments on commit 11a00f7

Please sign in to comment.