Skip to content

Commit cc47368

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 76b0818 commit cc47368

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

src/engraving/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);

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"
@@ -263,6 +265,17 @@ static void fixupScore(Score* score)
263265
score->setSaved(false);
264266
}
265267

268+
static void checkScore(Score* score)
269+
{
270+
if (score->parts().first()->nstaves() > 1) {
271+
Measure* measure = score->lastMeasure();
272+
Segment* segment = measure->findSegment(SegmentType::EndBarLine, measure->endTick());
273+
BarLine* barline = (BarLine*)(segment->element(0));
274+
bool span = barline->spanStaff();
275+
QVERIFY(barline->spanStaff());
276+
}
277+
}
278+
266279
void TestMxmlIO::setValue(const std::string& key, const Val& value)
267280
{
268281
settings()->setValue(Settings::Key(MODULE_NAME, key), value);
@@ -284,6 +297,7 @@ void TestMxmlIO::mxmlIoTest(const char* file)
284297
MasterScore* score = readScore(XML_IO_DATA_DIR + file + ".xml");
285298
QVERIFY(score);
286299
fixupScore(score);
300+
checkScore(score);
287301
score->doLayout();
288302
QVERIFY(saveMusicXml(score, QString(file) + ".xml"));
289303
QVERIFY(saveCompareMusicXmlScore(score, QString(file) + ".xml", XML_IO_DATA_DIR + file + ".xml"));
@@ -305,6 +319,7 @@ void TestMxmlIO::mxmlIoTestRef(const char* file)
305319
MasterScore* score = readScore(XML_IO_DATA_DIR + file + ".xml");
306320
QVERIFY(score);
307321
fixupScore(score);
322+
checkScore(score);
308323
score->doLayout();
309324
QVERIFY(saveMusicXml(score, QString(file) + ".xml"));
310325
QVERIFY(saveCompareMusicXmlScore(score, QString(file) + ".xml", XML_IO_DATA_DIR + file + "_ref.xml"));

0 commit comments

Comments
 (0)