Problem with curScore in plugin.
When using the following code to check for the presence of a score at the start of the MIDISightReader plugin:
if (typeof curScore === 'undefined')
{
// There's no current score loaded.
showMessage("Error", "Please load a score before using the MIDI sight reader plugin.\n");
return;
}
... it normally works fine.
However, if you load a score, run the MIDISightReaderPlugin, then close the score without saving, the variable curScore is not 'undefined' anymore. So when running the plugin again, the above code does not get called and MuseScore crashes when curScore.save(...) is subsequently called.
It is possibly related to the MIDISightReaderPlugin using OSC to change the colour of notes in the score.
Nightly build 5659.
Windows Vista 32-bit.
Comments
With the new QML plugin framework, checking for curScore with the code below does not work at all - MuseScore crashes whever there is no score open.
if (typeof curScore === 'undefined')
Qt.quit();
Works fine for me, GIT commit: c65f00f from 10Aug2012
Try this QML file on nightly build MuseScoreNightly-2012-08-10-c65f00f.7z for Windows (Vista 32-bit):
import QtQuick 1.0
import MuseScore 1.0
import FileIO 1.0
MuseScore
{
menuPath: "Plugins.RunTest"
version: "0.01"
description: "TEST."
onRun:
{
if (typeof curScore === 'undefined')
Qt.quit();
console.log("-----------------");
console.log(menuPath);
console.log(midiFile.source);
// Write the score to a MIDI file.
writeScore(curScore, midiFile.source, "mid");
Qt.quit()
}
FileIO
{
id: midiFile
source: tempPath() + "/MIDI_Sight_Reader.mid"
onError: console.log(msg)
}
}
I tried several others that use the same mechanism and none chrashed.
Yes, others seem to work fine.
However, the QML file above crashes.
Strange!
So it may be related to the FileIO stuff?
The crash happens on writeScore() so the condition is not working. A working condition is
if (curScore == null)
I will protect the writeScore method again null scores.
WriteScore is protected in d84d4aa660
Yes, the condition (in many of the QML example files) does not seem to work.
This does:
if (curScore == null)
{
Qt.quit();
return;
}
Or to be sure to be sure:
if (typeof curScore === 'undefined' || curScore == null)
{
Qt.quit();
return;
}
Automatically closed -- issue fixed for 2 weeks with no activity.
In reply to #9 by DonH
I wonder if the order of the tests is best, i.e. would if (curScore == null || typeof curScore === 'undefined') be better