Regression: Qml access to annotations leads to crash

• Jun 22, 2016 - 10:58
Reported version
2.1
Type
Functional
Severity
S3 - Major
Status
closed
Project

Using the object returned by Segment::qmlAnnotations crashes MuseScore.
I think this was introduced in c14a4e7e

      QList qmlAnnotations;
      foreach (Element* e : _annotations)
            qmlAnnotations.append(*e);
      return QQmlListProperty(this, qmlAnnotations);

As described in http://doc.qt.io/qt-5/qqmllistproperty.html#QQmlListProperty, a local variable cannot be used for QQmlListProperty::QQmlListProperty(QObject *object, QList &list):
The list reference must remain valid for as long as object exists.

I consider this of major priority since every plugin that uses the documented annotations property will eventually crash MuseScore.


Comments

Status (old) closed active

I'm writing a plugin that needs to read TempoText elements, which I believe should be accessible via Segment.annotations. However, when I try to assign

var x = segment.annotations[0]

where segment.annotations has length 1, MuseScore hangs. Is this another instance of this bug?

I found this big change from 5 months ago which changed how annotations access works -- is this relevant?

https://github.com/musescore/MuseScore/commit/90b1991912d33981dc7bc7d23…

I'm writing a plugin that needs to read TempoText elements, which I believe should be accessible via Segment.annotations. However, when I try to assign

var x = segment.annotations[0]

where segment.annotations has length 1, MuseScore hangs. Is this another instance of this bug?

I found this big change from 5 months ago which changed how annotations access works -- is this relevant?

https://github.com/musescore/MuseScore/commit/90b1991912d33981dc7bc7d23…

@jeetee: Thanks so much. I'm in version 2.1, but I can't reproduce the crash now, and all seems fine; I think it was a bug elsewhere in my code after all. I can confirm that this is working:


for (var i = 0; i < segment.annotations.length; i++) {
if (segment.annotations[i].type === Element.TEMPO_TEXT) {
console.log("Found TempoText");
console.log(segment.annotations[i].tempo);
console.log(segment.annotations[i].followText);
}
}

Sorry for the false alarm -- and thanks for the link to the TempoChanges plugin; it helped me confirm I wasn't doing something crazy.