Musescore crashed when call cursor.measure(); --- A MuseScore Bug?

• Jul 6, 2011 - 09:42

I'm creating a plugin for MuseScore, And here is the code and the error I get.

function run() {
var cursor = new Cursor(curScore, true);
cursor.rewind();
while (!cursor.eos()) {

var height = 0;

try {
tick = cursor.tick();
var pos = cursor.pos();
var x = pos.x();
var y = pos.y();
print("tick="+tick);
if(cursor.isChord() || cursor.isRest()){
var measureType = typeof cursor.measure;
var measure = cursor.measure();
height = measure.boundingRect().height();
}
var s = "tick:" + tick + " point[" + x + "," + y + "] height=" + height;
print(s);
} catch (e) {
print(e);
}

cursor.next();
}
}

I have to check what cursor points to. otherwise, the plugin will corrupt MuseScore. I believe this should be caused by this piece of code in sccurosr.cpp.
case 4: // "measure",
if (context->argumentCount() == 0)
return qScriptValueFromValue(context->engine(), cursor->cr()->measure());
break;

since cursor call cursor->cr()->measure() directly, while cursor->cr() sometimes return null.

Also, It will be great if MuseScore can return a cursor if I provide a tick as parameter. And also, I believe, it's useful that a cursor always return a valid measure if the cursor really points to anything inside a measure.


Comments

Depending of what you want to achieve in your plugin, it could be better to call nextMeasure() instead of next().
What do you want to achieve?

In reply to by [DELETED] 5

Thank you for you reply, lasconic. What you said make sense.

The plugin I'm trying to develope is to show a playback line on a exported png File.

I think with your proposal, I can get same result as muse score online playback like this http://musescore.com/score/21076.

I believe with some extra work, I can get the information of what measure does a cursor belong to(for example, by analysis the coordinate of cursor.pos() against the bounding of measures, or, by tick somehow). But I think cursor.measure() returns a valid measure is, and measure contains tick/ the postion of this measure in the score(first measure, sencond measure....) would be still helpful since this would be much more straight forward for users.

Do you still have an unanswered question? Please log in first to post your question.