Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #305018: fix a crash on adding a note with unrewound Cursor #6059

Merged
merged 1 commit into from
May 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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