Skip to content

Commit

Permalink
fix #276978 crash during open .gpx file
Browse files Browse the repository at this point in the history
  • Loading branch information
wschweer committed Nov 29, 2018
1 parent af128b5 commit 5fadc46
Show file tree
Hide file tree
Showing 182 changed files with 310 additions and 12 deletions.
2 changes: 1 addition & 1 deletion libmscore/clef.cpp
Expand Up @@ -224,7 +224,7 @@ void Clef::layout()

void Clef::draw(QPainter* painter) const
{
if (symId == SymId::noSym || (staff() && !staff()->staffType(tick())->genClef()))
if (symId == SymId::noSym || (staff() && !const_cast<const Staff*>(staff())->staffType(tick())->genClef()))
return;
painter->setPen(curColor());
drawSymbol(symId, painter);
Expand Down
6 changes: 5 additions & 1 deletion libmscore/staff.cpp
Expand Up @@ -49,7 +49,7 @@ namespace Ms {
Staff::Staff(Score* score)
: ScoreElement(score)
{
// initFromStaffType(0);
initFromStaffType(0);
}

//---------------------------------------------------------
Expand Down Expand Up @@ -986,10 +986,14 @@ void Staff::staffTypeListChanged(int tick)

StaffType* Staff::setStaffType(int tick, const StaffType& nst)
{
#if 0
#ifndef NDEBUG
auto i = _staffTypeList.find(tick);
if (i != _staffTypeList.end()) {
qDebug("there is already a type at %d", tick);
}
#endif
#endif
return _staffTypeList.setStaffType(tick, nst);
}

Expand Down
2 changes: 1 addition & 1 deletion libmscore/timesig.cpp
Expand Up @@ -352,7 +352,7 @@ void TimeSig::layout()

void TimeSig::draw(QPainter* painter) const
{
if (staff() && !staff()->staffType(tick())->genTimesig())
if (staff() && !const_cast<const Staff*>(staff())->staffType(tick())->genTimesig())
return;
painter->setPen(curColor());

Expand Down
5 changes: 2 additions & 3 deletions mscore/file.cpp
Expand Up @@ -2227,6 +2227,8 @@ void importExtension(QString name)

Score::FileError readScore(MasterScore* score, QString name, bool ignoreVersionError)
{
ScoreLoad sl;

QFileInfo info(name);
QString suffix = info.suffix().toLower();
score->setName(info.completeBaseName());
Expand Down Expand Up @@ -2311,8 +2313,6 @@ Score::FileError readScore(MasterScore* score, QString name, bool ignoreVersionE
score->setCreated(true); // force save as for imported files
}

{
ScoreLoad sl;
score->rebuildMidiMapping();
score->setSoloMute();
for (Score* s : score->scoreList()) {
Expand All @@ -2323,7 +2323,6 @@ Score::FileError readScore(MasterScore* score, QString name, bool ignoreVersionE
score->updateChannel();
score->setSaved(false);
score->update();
}

if (!ignoreVersionError && !MScore::noGui)
if (!score->sanityCheck(QString()))
Expand Down
2 changes: 0 additions & 2 deletions mscore/importgtp-gp5.cpp
Expand Up @@ -864,9 +864,7 @@ bool GuitarPro5::read(QFile* fp)
//
for (int staffIdx = 0; staffIdx < staves; ++staffIdx) {
Part* part = new Part(score);
StaffType st;
Staff* s = new Staff(score);
s->initFromStaffType(&st);
s->setPart(part);
part->insertStaff(s, -1);
score->staves().push_back(s);
Expand Down
6 changes: 4 additions & 2 deletions mscore/importgtp-gp6.cpp
Expand Up @@ -1621,8 +1621,10 @@ int GuitarPro6::readBeats(QString beats, GPPartInfo* partInfo, Measure* measure,
else if (currentNode.nodeName() == "Dynamic") {}
else if (!currentNode.nodeName().compare("Chord")) {
int k = currentNode.toElement().text().toInt();
if (fretDiagrams[k])
segment->add(fretDiagrams[k]);
if (fretDiagrams[k]) {
// TODO: free fretDiagrams
segment->add(new FretDiagram(*fretDiagrams[k]));
}
}
else if (currentNode.nodeName() == "Timer") {
//int time = currentNode.toElement().text().toInt();
Expand Down
4 changes: 2 additions & 2 deletions mscore/inspector/inspectorNote.cpp
Expand Up @@ -129,8 +129,8 @@ void InspectorNote::setElement()
n.beam->setEnabled(note->chord()->beam());
n.tuplet->setEnabled(note->chord()->tuplet());

bool isNHGroupEnabled = note->chord()->staff()->isPitchedStaff(note->tick())
&& note->chord()->staff()->staffType(note->tick())->noteHeadScheme() == NoteHeadScheme::HEAD_NORMAL;
const StaffType* st = const_cast<const Staff*>(note->chord()->staff())->staffType(note->tick());
bool isNHGroupEnabled = (st->group() == StaffGroup::STANDARD) && (st->noteHeadScheme() == NoteHeadScheme::HEAD_NORMAL);
n.noteHeadGroup->setEnabled(isNHGroupEnabled);

InspectorElementBase::setElement();
Expand Down
1 change: 1 addition & 0 deletions mtest/biab/chords-ref.mscx
Expand Up @@ -26,6 +26,7 @@
<Part>
<Staff id="1">
<StaffType group="pitched">
<name>stdNormal</name>
</StaffType>
</Staff>
<trackName></trackName>
Expand Down
2 changes: 2 additions & 0 deletions mtest/guitarpro/UncompletedMeasure.gpx-ref.mscx
Expand Up @@ -26,6 +26,7 @@
<Part>
<Staff id="1">
<StaffType group="pitched">
<name>stdNormal</name>
</StaffType>
</Staff>
<trackName>el.guit.</trackName>
Expand Down Expand Up @@ -149,6 +150,7 @@
<Staff id="1">
<linkedTo>1</linkedTo>
<StaffType group="pitched">
<name>stdNormal</name>
</StaffType>
<bracket type="0" span="2" col="0"/>
</Staff>
Expand Down
2 changes: 2 additions & 0 deletions mtest/guitarpro/accent.gpx-ref.mscx
Expand Up @@ -26,6 +26,7 @@
<Part>
<Staff id="1">
<StaffType group="pitched">
<name>stdNormal</name>
</StaffType>
</Staff>
<trackName>S-Gt</trackName>
Expand Down Expand Up @@ -182,6 +183,7 @@
<Staff id="1">
<linkedTo>1</linkedTo>
<StaffType group="pitched">
<name>stdNormal</name>
</StaffType>
<bracket type="0" span="2" col="0"/>
</Staff>
Expand Down
2 changes: 2 additions & 0 deletions mtest/guitarpro/arpeggio.gpx-ref.mscx
Expand Up @@ -26,6 +26,7 @@
<Part>
<Staff id="1">
<StaffType group="pitched">
<name>stdNormal</name>
</StaffType>
</Staff>
<trackName>S-Gt</trackName>
Expand Down Expand Up @@ -196,6 +197,7 @@
<Staff id="1">
<linkedTo>1</linkedTo>
<StaffType group="pitched">
<name>stdNormal</name>
</StaffType>
<bracket type="0" span="2" col="0"/>
</Staff>
Expand Down
2 changes: 2 additions & 0 deletions mtest/guitarpro/artificial-harmonic.gpx-ref.mscx
Expand Up @@ -26,6 +26,7 @@
<Part>
<Staff id="1">
<StaffType group="pitched">
<name>stdNormal</name>
</StaffType>
</Staff>
<trackName>E-Gt</trackName>
Expand Down Expand Up @@ -324,6 +325,7 @@
<Staff id="1">
<linkedTo>1</linkedTo>
<StaffType group="pitched">
<name>stdNormal</name>
</StaffType>
<bracket type="0" span="2" col="0"/>
</Staff>
Expand Down
2 changes: 2 additions & 0 deletions mtest/guitarpro/basic-bend.gp5-ref.mscx
Expand Up @@ -26,6 +26,7 @@
<Part>
<Staff id="1">
<StaffType group="pitched">
<name>stdNormal</name>
</StaffType>
</Staff>
<trackName>Track 1</trackName>
Expand Down Expand Up @@ -125,6 +126,7 @@
<Staff id="1">
<linkedTo>1</linkedTo>
<StaffType group="pitched">
<name>stdNormal</name>
</StaffType>
<bracket type="0" span="2" col="0"/>
</Staff>
Expand Down
2 changes: 2 additions & 0 deletions mtest/guitarpro/brush.gp4-ref.mscx
Expand Up @@ -26,6 +26,7 @@
<Part>
<Staff id="1">
<StaffType group="pitched">
<name>stdNormal</name>
</StaffType>
</Staff>
<trackName>Track 1</trackName>
Expand Down Expand Up @@ -160,6 +161,7 @@
<Staff id="1">
<linkedTo>1</linkedTo>
<StaffType group="pitched">
<name>stdNormal</name>
</StaffType>
<bracket type="0" span="2" col="0"/>
</Staff>
Expand Down
2 changes: 2 additions & 0 deletions mtest/guitarpro/brush.gp5-ref.mscx
Expand Up @@ -26,6 +26,7 @@
<Part>
<Staff id="1">
<StaffType group="pitched">
<name>stdNormal</name>
</StaffType>
</Staff>
<trackName>Track 1</trackName>
Expand Down Expand Up @@ -155,6 +156,7 @@
<Staff id="1">
<linkedTo>1</linkedTo>
<StaffType group="pitched">
<name>stdNormal</name>
</StaffType>
<bracket type="0" span="2" col="0"/>
</Staff>
Expand Down
2 changes: 2 additions & 0 deletions mtest/guitarpro/brush.gpx-ref.mscx
Expand Up @@ -26,6 +26,7 @@
<Part>
<Staff id="1">
<StaffType group="pitched">
<name>stdNormal</name>
</StaffType>
</Staff>
<trackName>S-Gt</trackName>
Expand Down Expand Up @@ -196,6 +197,7 @@
<Staff id="1">
<linkedTo>1</linkedTo>
<StaffType group="pitched">
<name>stdNormal</name>
</StaffType>
<bracket type="0" span="2" col="0"/>
</Staff>
Expand Down
2 changes: 2 additions & 0 deletions mtest/guitarpro/capo-fret.gp3-ref.mscx
Expand Up @@ -26,6 +26,7 @@
<Part>
<Staff id="1">
<StaffType group="pitched">
<name>stdNormal</name>
</StaffType>
</Staff>
<trackName>Track 1</trackName>
Expand Down Expand Up @@ -164,6 +165,7 @@
<Staff id="1">
<linkedTo>1</linkedTo>
<StaffType group="pitched">
<name>stdNormal</name>
</StaffType>
<bracket type="0" span="2" col="0"/>
</Staff>
Expand Down
2 changes: 2 additions & 0 deletions mtest/guitarpro/capo-fret.gp4-ref.mscx
Expand Up @@ -26,6 +26,7 @@
<Part>
<Staff id="1">
<StaffType group="pitched">
<name>stdNormal</name>
</StaffType>
</Staff>
<trackName>Track 1</trackName>
Expand Down Expand Up @@ -166,6 +167,7 @@
<Staff id="1">
<linkedTo>1</linkedTo>
<StaffType group="pitched">
<name>stdNormal</name>
</StaffType>
<bracket type="0" span="2" col="0"/>
</Staff>
Expand Down
2 changes: 2 additions & 0 deletions mtest/guitarpro/capo-fret.gp5-ref.mscx
Expand Up @@ -26,6 +26,7 @@
<Part>
<Staff id="1">
<StaffType group="pitched">
<name>stdNormal</name>
</StaffType>
</Staff>
<trackName>Track 1</trackName>
Expand Down Expand Up @@ -166,6 +167,7 @@
<Staff id="1">
<linkedTo>1</linkedTo>
<StaffType group="pitched">
<name>stdNormal</name>
</StaffType>
<bracket type="0" span="2" col="0"/>
</Staff>
Expand Down
2 changes: 2 additions & 0 deletions mtest/guitarpro/clefs.gpx-ref.mscx
Expand Up @@ -26,6 +26,7 @@
<Part>
<Staff id="1">
<StaffType group="pitched">
<name>stdNormal</name>
</StaffType>
</Staff>
<trackName>A-Piano</trackName>
Expand Down Expand Up @@ -241,6 +242,7 @@
<Staff id="1">
<linkedTo>1</linkedTo>
<StaffType group="pitched">
<name>stdNormal</name>
</StaffType>
</Staff>
<trackName></trackName>
Expand Down
2 changes: 2 additions & 0 deletions mtest/guitarpro/copyright.gp3-ref.mscx
Expand Up @@ -26,6 +26,7 @@
<Part>
<Staff id="1">
<StaffType group="pitched">
<name>stdNormal</name>
</StaffType>
</Staff>
<trackName>Track 1</trackName>
Expand Down Expand Up @@ -111,6 +112,7 @@
<Staff id="1">
<linkedTo>1</linkedTo>
<StaffType group="pitched">
<name>stdNormal</name>
</StaffType>
<bracket type="0" span="2" col="0"/>
</Staff>
Expand Down
2 changes: 2 additions & 0 deletions mtest/guitarpro/copyright.gp4-ref.mscx
Expand Up @@ -26,6 +26,7 @@
<Part>
<Staff id="1">
<StaffType group="pitched">
<name>stdNormal</name>
</StaffType>
</Staff>
<trackName>Track 1</trackName>
Expand Down Expand Up @@ -123,6 +124,7 @@
<Staff id="1">
<linkedTo>1</linkedTo>
<StaffType group="pitched">
<name>stdNormal</name>
</StaffType>
<bracket type="0" span="2" col="0"/>
</Staff>
Expand Down
2 changes: 2 additions & 0 deletions mtest/guitarpro/copyright.gp5-ref.mscx
Expand Up @@ -26,6 +26,7 @@
<Part>
<Staff id="1">
<StaffType group="pitched">
<name>stdNormal</name>
</StaffType>
</Staff>
<trackName>Track 1</trackName>
Expand Down Expand Up @@ -113,6 +114,7 @@
<Staff id="1">
<linkedTo>1</linkedTo>
<StaffType group="pitched">
<name>stdNormal</name>
</StaffType>
<bracket type="0" span="2" col="0"/>
</Staff>
Expand Down
2 changes: 2 additions & 0 deletions mtest/guitarpro/copyright.gpx-ref.mscx
Expand Up @@ -26,6 +26,7 @@
<Part>
<Staff id="1">
<StaffType group="pitched">
<name>stdNormal</name>
</StaffType>
</Staff>
<trackName>S-Gt</trackName>
Expand Down Expand Up @@ -178,6 +179,7 @@
<Staff id="1">
<linkedTo>1</linkedTo>
<StaffType group="pitched">
<name>stdNormal</name>
</StaffType>
<bracket type="0" span="2" col="0"/>
</Staff>
Expand Down
2 changes: 2 additions & 0 deletions mtest/guitarpro/crescendo-diminuendo.gpx-ref.mscx
Expand Up @@ -26,6 +26,7 @@
<Part>
<Staff id="1">
<StaffType group="pitched">
<name>stdNormal</name>
</StaffType>
</Staff>
<trackName>S-Gt</trackName>
Expand Down Expand Up @@ -240,6 +241,7 @@
<Staff id="1">
<linkedTo>1</linkedTo>
<StaffType group="pitched">
<name>stdNormal</name>
</StaffType>
<bracket type="0" span="2" col="0"/>
</Staff>
Expand Down
2 changes: 2 additions & 0 deletions mtest/guitarpro/dead-note.gpx-ref.mscx
Expand Up @@ -26,6 +26,7 @@
<Part>
<Staff id="1">
<StaffType group="pitched">
<name>stdNormal</name>
</StaffType>
</Staff>
<trackName>S-Gt</trackName>
Expand Down Expand Up @@ -180,6 +181,7 @@
<Staff id="1">
<linkedTo>1</linkedTo>
<StaffType group="pitched">
<name>stdNormal</name>
</StaffType>
<bracket type="0" span="2" col="0"/>
</Staff>
Expand Down

0 comments on commit 5fadc46

Please sign in to comment.