@@ -424,7 +424,7 @@ class ExportMusicXml : public muse::Injectable
424
424
void keysigTimesig (const Measure* m, const Part* p);
425
425
void chordAttributes (Chord* chord, Notations& notations, Technical& technical, TrillHash& trillStart, TrillHash& trillStop);
426
426
void wavyLineStartStop (const ChordRest* cr, Notations& notations, Ornaments& ornaments, TrillHash& trillStart, TrillHash& trillStop);
427
- void print (const Measure* const m, const int partNr, const int firstStaffOfPart, const int nrStavesInPart,
427
+ void print (const Measure* const m, const int partNr, const int firstStaffOfPart, const size_t nrStavesInPart,
428
428
const MeasurePrintContext& mpc);
429
429
void measureLayout (const double distance);
430
430
void findAndExportClef (const Measure* const m, const int staves, const track_idx_t strack, const track_idx_t etrack);
@@ -7250,7 +7250,7 @@ static bool hasPageBreak(const System* const system)
7250
7250
*/
7251
7251
7252
7252
void ExportMusicXml::print (const Measure* const m, const int partNr, const int firstStaffOfPart,
7253
- const int nrStavesInPart, const MeasurePrintContext& mpc)
7253
+ const size_t nrStavesInPart, const MeasurePrintContext& mpc)
7254
7254
{
7255
7255
const MeasureBase* const prevSysMB = lastMeasureBase (mpc.prevSystem );
7256
7256
@@ -7332,15 +7332,21 @@ void ExportMusicXml::print(const Measure* const m, const int partNr, const int f
7332
7332
}
7333
7333
7334
7334
// Staff layout elements.
7335
- for (int staffIdx = (firstStaffOfPart == 0 ) ? 1 : 0 ; staffIdx < nrStavesInPart; staffIdx++) {
7335
+ for (staff_idx_t staffIdx = (firstStaffOfPart == 0 ) ? 1 : 0 ; staffIdx < nrStavesInPart; staffIdx++) {
7336
7336
// calculate distance between this and previous staff using the bounding boxes
7337
- const int staffNr = firstStaffOfPart + staffIdx;
7338
- const RectF& prevBbox = system->staff (staffNr - 1 )->bbox ();
7337
+ const staff_idx_t staffNr = firstStaffOfPart + staffIdx;
7338
+ const staff_idx_t prevStaffNr = system->prevVisibleStaff (staffNr);
7339
+ if (prevStaffNr == muse::nidx) {
7340
+ continue ;
7341
+ }
7342
+ const RectF& prevBbox = system->staff (prevStaffNr)->bbox ();
7339
7343
const double staffDist = system->staff (staffNr)->bbox ().y () - prevBbox.y () - prevBbox.height ();
7340
7344
7341
- m_xml.startElement (" staff-layout" , { { " number" , staffIdx + 1 } });
7342
- m_xml.tag (" staff-distance" , String::number (getTenthsFromDots (staffDist), 2 ));
7343
- m_xml.endElement ();
7345
+ if (staffDist > 0 ) {
7346
+ m_xml.startElement (" staff-layout" , { { " number" , staffIdx + 1 } });
7347
+ m_xml.tag (" staff-distance" , String::number (getTenthsFromDots (staffDist), 2 ));
7348
+ m_xml.endElement ();
7349
+ }
7344
7350
}
7345
7351
7346
7352
// Measure layout elements.
@@ -8321,7 +8327,7 @@ void ExportMusicXml::writeMeasure(const Measure* const m,
8321
8327
8322
8328
m_xml.startElementRaw (measureTag);
8323
8329
8324
- print (m, partIndex, staffCount, static_cast < int >( staves) , mpc);
8330
+ print (m, partIndex, staffCount, staves, mpc);
8325
8331
8326
8332
m_attr.start ();
8327
8333
0 commit comments