Ambitus crash in plugins
Reported version
3.2
Type
Plugins
Frequency
Many
Severity
S4 - Minor
Reproducibility
Always
Status
closed
Regression
No
Workaround
No
Project
It's tedious to have to add an ambitus to every part of a 16-part piece (and when did anyone want an ambitus on only one part?) so I tried to write a plugin to do it. However all I achieved was to crash Musescore:
var cursor = curScore.newCursor();
cursor.voice = 0;
cursor.staffIdx = 0;
cursor.rewind(Cursor.SCORE_START);
cursor.next(); //still crashes without this line
var el=newElement(Element.AMBITUS);
cursor.add(el); //always crashes
I looked to see if I could locate the Clef element as the ambitus is normally dropped on the clef but the cursor always seems to point to chord segments, never a clef or time change.
David
Fix version
3.3.3
Comments
Outside of a plugin it is possible to add several ambitus at once. Click a clef, ctrl+click additional clefs the double click the ambitus in the palette to apply one to all of those staves at once.
BTW, frequency is how many times it's been reported - you're #1.
Confirmed.
It's crashing after, where in a debug build, you would get an assertion failure:
void Segment::add(Element* el)
:
case ElementType::AMBITUS:
// FAILS Q_ASSERT Test. _segmentType is ChordRest! It wants SegmentType::Ambitus.
Q_ASSERT(_segmentType == SegmentType::Ambitus);
checkElement(el, track);
_elist[track] = el;
setEmpty(false);
break;
See the code comment above. The code says it can only add an ElementType::AMBITUS element to an SegmentType::Ambitus segment. How to get such a thing I don't know. But this is what happening.
It's bad news that scripted code can crash the application.
Thank you, Mike - I don't need to write the plugin now! I would never have thought of selecting all the clefs and double-clicking the ambitus, but it certainly works. Perhaps this tip could find its way into the help, or did I miss it?
Selecting elements in the score then double-clicking the desired plaette icon is the recommended way of adding anything to your score, this is indeed covered. See for instance https://musescore.org/en/handbook/3/palettes
This is a bug that should be addressed. And the actual problem is related to ambitus being added in a plugin leads to a crash.
It is implied, though not explicitly stated that you can select multiple clefs and add an ambitus to each because of the way they are added. I'll think of a way to make this clearer in the handbook.
Pull request: https://github.com/musescore/MuseScore/pull/5397
Fixed in branch master, commit 99d3dd9ec9
_fix #292474 ambitus crash in plugins
Resolves: https://musescore.org/en/node/292474
This also resolves this issue reported in the forum: https://musescore.org/en/node/294734
It was achieved by extending plugin functionalities from commit c77d904eaaeb549efaaedd33a16ef1934d854ae3. By adding:
* Support for elements that were causing application to crash such as: symbol, fingering, bend, notehead (note level), and clef and ambitus.
* You can now add and remove elements from notes using
Note::add()
andNote::remove()
._Fixed in branch master, commit dc804994c9
_Merge pull request #5397 from eduardomourar/feature/292474-ambitus-crash-plugin
fix #292474: Ambitus crash in plugins_
Automatically closed -- issue fixed for 2 weeks with no activity.