diff --git a/libmscore/score.cpp b/libmscore/score.cpp index c130abd4ffd0..3b7a713a9297 100644 --- a/libmscore/score.cpp +++ b/libmscore/score.cpp @@ -2080,6 +2080,26 @@ bool Score::appendScore(Score* score) if (styleB(StyleIdx::concertPitch) != score->styleB(StyleIdx::concertPitch)) score->cmdConcertPitchChanged(styleB(StyleIdx::concertPitch), true); + // convert any "generated" initial clefs into real "non-generated" clefs if clef type changes + if (score->firstMeasure()) { + Segment* initialClefSegment = score->firstMeasure()->findSegment(Segment::Type::Clef, 0); // find clefs at first tick of first measure + if (initialClefSegment) { + for (int staffIdx = 0; staffIdx < score->nstaves(); ++staffIdx) { + int track = staffIdx * VOICES; + Staff* staff = score->staff(staffIdx); + Clef* initialClef = static_cast(initialClefSegment->element(track)); + + // if the first clef of score to append is generated and + // if the first clef of score to append is of different type than clef at final tick of first score + if (initialClef->generated() && initialClef->clefType() != this->staff(staffIdx)->clef(tickOfAppend)) { + + // then convert that generated clef into a real non-generated clef so that its different type will be copied to joined score + score->undoChangeClef(staff, initialClefSegment, initialClef->clefType()); + } + } + } + } + // clone the measures MeasureBaseList* ml = &score->_measures; for (MeasureBase* mb = ml->first(); mb; mb = mb->next()) { diff --git a/mtest/libmscore/album/album_76101-01.mscx b/mtest/libmscore/album/album_76101-01.mscx new file mode 100644 index 000000000000..243c25216fd4 --- /dev/null +++ b/mtest/libmscore/album/album_76101-01.mscx @@ -0,0 +1,122 @@ + + + + + 0 + 480 + + 1 + 1 + 1 + 0 + + + + + + + + + + + threefour-in-C# + + + + + + + + + + stdNormal + + + Piano + + Piano + Pno. + Piano + 21 + 108 + 21 + 108 + keyboard.piano + F + + 100 + 95 + + + 100 + 33 + + + 100 + 50 + + + 100 + 67 + + + 100 + 100 + + + 120 + 67 + + + 120 + 100 + + + + + + + + + + 4 + 4 + 1 + + + measure + + + + + + measure + + + + end + 1 + + + + + diff --git a/mtest/libmscore/album/album_76101-02.mscx b/mtest/libmscore/album/album_76101-02.mscx new file mode 100644 index 000000000000..a912c62a4da8 --- /dev/null +++ b/mtest/libmscore/album/album_76101-02.mscx @@ -0,0 +1,127 @@ + + + + + 0 + 480 + + 1 + 1 + 1 + 0 + + + + + + + + + + + threeF + + + + + + + + + + stdNormal + + F + + + Piano + + Piano + Pno. + Piano + 21 + 108 + 21 + 108 + keyboard.piano + F + + 100 + 95 + + + 100 + 33 + + + 100 + 50 + + + 100 + 67 + + + 100 + 100 + + + 120 + 67 + + + 120 + 100 + + + + + + + + + + -1 + + + 3 + 4 + 1 + + + measure + + + + + + measure + + + + end + 1 + + + + + diff --git a/mtest/libmscore/album/album_76101-ref.mscx b/mtest/libmscore/album/album_76101-ref.mscx new file mode 100644 index 000000000000..0620ad05b5d6 --- /dev/null +++ b/mtest/libmscore/album/album_76101-ref.mscx @@ -0,0 +1,156 @@ + + + + + 0 + 480 + + 1 + 1 + 1 + 0 + + + + + + + + + + + threefour-in-C# + + + + + + + + + + stdNormal + + + Piano + + Piano + Pno. + Piano + 21 + 108 + 21 + 108 + keyboard.piano + F + + 100 + 95 + + + 100 + 33 + + + 100 + 50 + + + 100 + 67 + + + 100 + 100 + + + 120 + 67 + + + 120 + 100 + + + + + + + + + + 4 + 4 + 1 + + + measure + + + + + + line + + + section + + + measure + + + + end + 1 + + + + + F + F + + + -1 + + + 3 + 4 + 1 + + + measure + + + + + + measure + + + + end + 1 + + + + + diff --git a/mtest/libmscore/album/tst_album.cpp b/mtest/libmscore/album/tst_album.cpp index b8c926186db0..0bce2fa287e1 100644 --- a/mtest/libmscore/album/tst_album.cpp +++ b/mtest/libmscore/album/tst_album.cpp @@ -30,6 +30,7 @@ class TestAlbum : public QObject, public MTest void initTestCase(); void album01(); void album_78521(); + void album_76101(); }; @@ -74,6 +75,25 @@ void TestAlbum::album_78521() QVERIFY(compareFiles("album_78521-vbox-vbox-empty.mscx", DIR + "album_78521-vbox-vbox-empty-ref.mscx")); } +//--------------------------------------------------------- +// album_76101 +// appends two scores that do not have manually-inserted initial clefs +// album_76101-01.mscx is two measures of treble clef +// album_76101-02.mscx is two measures of bass clef +// desired behavior is for initial clef of second score to be copied even if initial clef element is "generated" (which occurs if intial clef was not manually inserted) +// this test verifies that there is a non-generated clef added to final tick of final measure of first section +//-------------------------------------------------------- + +void TestAlbum::album_76101() + { + Album album; + album.setName("test"); + album.append(new AlbumItem(root + "/" + DIR + "album_76101-01.mscx")); + album.append(new AlbumItem(root + "/" + DIR + "album_76101-02.mscx")); + album.createScore("album_76101.mscx"); + QVERIFY(compareFiles("album_76101.mscx", DIR + "album_76101-ref.mscx")); + } + QTEST_MAIN(TestAlbum) #include "tst_album.moc"