Skip to content

Commit cc0c71d

Browse files
Dylan Nicholsonwizofaus
authored andcommitted
[MU4] fix #290694 - ensure that final barline created automatically (e.g. during musicxml import) spans to next staff if on a multi-stave part
1 parent 73b50d9 commit cc0c71d

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

src/importexport/musicxml/tests/tst_mxml_io.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
#include "libmscore/measure.h"
3131
#include "libmscore/staff.h"
3232
#include "libmscore/keysig.h"
33+
#include "libmscore/part.h"
34+
#include "libmscore/barline.h"
3335
// end includes required for fixupScore()
3436

3537
#include "settings.h"
@@ -262,6 +264,17 @@ static void fixupScore(Score* score)
262264
score->setSaved(false);
263265
}
264266

267+
static void checkScore(Score* score)
268+
{
269+
if (score->parts().first()->nstaves() > 1) {
270+
Measure* measure = score->lastMeasure();
271+
Segment* segment = measure->findSegment(SegmentType::EndBarLine, measure->endTick());
272+
BarLine* barline = (BarLine*)(segment->element(0));
273+
bool span = barline->spanStaff();
274+
QVERIFY(barline->spanStaff());
275+
}
276+
}
277+
265278
void TestMxmlIO::setValue(const std::string& key, const Val& value)
266279
{
267280
settings()->setValue(Settings::Key(MODULE_NAME, key), value);
@@ -283,6 +296,7 @@ void TestMxmlIO::mxmlIoTest(const char* file)
283296
MasterScore* score = readScore(XML_IO_DATA_DIR + file + ".xml");
284297
QVERIFY(score);
285298
fixupScore(score);
299+
checkScore(score);
286300
score->doLayout();
287301
QVERIFY(saveMusicXml(score, QString(file) + ".xml"));
288302
QVERIFY(saveCompareMusicXmlScore(score, QString(file) + ".xml", XML_IO_DATA_DIR + file + ".xml"));
@@ -304,6 +318,7 @@ void TestMxmlIO::mxmlIoTestRef(const char* file)
304318
MasterScore* score = readScore(XML_IO_DATA_DIR + file + ".xml");
305319
QVERIFY(score);
306320
fixupScore(score);
321+
checkScore(score);
307322
score->doLayout();
308323
QVERIFY(saveMusicXml(score, QString(file) + ".xml"));
309324
QVERIFY(saveCompareMusicXmlScore(score, QString(file) + ".xml", XML_IO_DATA_DIR + file + "_ref.xml"));

src/libmscore/measure.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3927,6 +3927,11 @@ void Measure::setEndBarLineType(BarLineType val, int track, bool visible, QColor
39273927
bl = new BarLine(score());
39283928
bl->setParent(seg);
39293929
bl->setTrack(track);
3930+
Part* part = score()->staff(track / VOICES)->part();
3931+
// by default, barlines for multi-staff parts should span across staves
3932+
if (part && part->nstaves() > 1) {
3933+
bl->setSpanStaff(true);
3934+
}
39303935
score()->addElement(bl);
39313936
}
39323937
bl->setGenerated(false);

0 commit comments

Comments
 (0)