Plugin identify objects uniquely

• Oct 19, 2023 - 11:15

"The MuseScore 3.x plugin QML/Javascript implementation uses wrapper objects to delegate property/method calls to the actual underlying MuseScore C++ objects. The current wrapper strategy creates new wrappers whenever needed which leads to many wrappers possibly pointing to the same internal MuseScore object. This makes it impossible to compare wrappers to see if they point to the same MuseScore object"

This problem was discussed in https://musescore.org/en/node/293837 and the issue was closed, but I encounter exactly the same problem in MuseScore 3.6.2 Plugin API. I attached a plugin that prints the references of system objects for all the bars. Despite several bars being in the same system, the corresponding system reference is always diferent and checking for equality will always return False. I guess this is because each access still creates a new wrapper instance to the same object. This makes it impossible to check weather bars are in the same system, chords have the same beam,...

What is the current status on that matter?

Attachment Size
referenceTest.qml 503 bytes

Comments

pls try

posY of System
curScore.is( ) seems bugged in this case
debugger
https://musescore.org/en/handbook/developers-handbook/plugins-3x#:~:tex…

var cursor = curScore.newCursor();
cursor.rewind(Cursor.SCORE_START);
 
//loop over measures
var measureIdx = 0, temp
while(cursor.measure) {
  console.log("----- Measure "+measureIdx+" -----\n"+
    "measureIdx "+measureIdx+"'s parent is a "+cursor.measure.parent.name+
    ": posX : "+cursor.measure.parent.posX+
    ", posY : "+cursor.measure.parent.posY       );
  if(temp) console.log( 
    "measureIdx "+(measureIdx-1)+"'s parent is measureIdx "+measureIdx+"'s parent : "+
    curScore.is(temp,cursor.measure.parent) )
  temp=cursor.measure.parent
  cursor.nextMeasure()
  measureIdx++;
}

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