From 11a00f78e49a6506647cce49f5061c2769c783d1 Mon Sep 17 00:00:00 2001 From: Dmitri Ovodok Date: Fri, 8 May 2020 06:33:35 +0300 Subject: [PATCH] fix #305018: fix a crash on adding a note with unrewound Cursor --- mscore/plugin/api/cursor.cpp | 4 ++++ mscore/plugin/api/cursor.h | 10 +++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/mscore/plugin/api/cursor.cpp b/mscore/plugin/api/cursor.cpp index ffd17c9ae180f..b56a5fd6d6c3d 100644 --- a/mscore/plugin/api/cursor.cpp +++ b/mscore/plugin/api/cursor.cpp @@ -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); diff --git a/mscore/plugin/api/cursor.h b/mscore/plugin/api/cursor.h index 67d7f3c31b39e..877dc9ffb306a 100644 --- a/mscore/plugin/api/cursor.h +++ b/mscore/plugin/api/cursor.h @@ -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 {