@@ -2350,7 +2350,7 @@ void MusicXMLParserPass2::attributes(const QString& partId, Measure* measure, co
2350
2350
} else if (_e.name () == " measure-style" ) {
2351
2351
measureStyle (measure);
2352
2352
} else if (_e.name () == " staff-details" ) {
2353
- staffDetails (partId);
2353
+ staffDetails (partId, measure );
2354
2354
} else if (_e.name () == " time" ) {
2355
2355
time (partId, measure, tick);
2356
2356
} else if (_e.name () == " transpose" ) {
@@ -2383,7 +2383,7 @@ static void setStaffLines(Score* score, staff_idx_t staffIdx, int stafflines)
2383
2383
Parse the /score-partwise/part/measure/attributes/staff-details node.
2384
2384
*/
2385
2385
2386
- void MusicXMLParserPass2::staffDetails (const QString& partId)
2386
+ void MusicXMLParserPass2::staffDetails (const QString& partId, Measure* measure )
2387
2387
{
2388
2388
// logDebugTrace("MusicXMLParserPass2::staffDetails");
2389
2389
@@ -2409,7 +2409,20 @@ void MusicXMLParserPass2::staffDetails(const QString& partId)
2409
2409
StringData* t = new StringData;
2410
2410
QString visible = _e.attributes ().value (" print-object" ).toString ();
2411
2411
if (visible == " no" ) {
2412
- _score->staff (staffIdx)->setVisible (false );
2412
+ if (measure && !measure->hasVoices (staffIdx) && measure->isOnlyRests (0 )) {
2413
+ // measures with print-object="no" are generally exported by exporters such as dolet when empty staves are hidden.
2414
+ // for this reason, if we see an empty measure with print-object="no", we can assume that this indicates we should set
2415
+ // the hide empty staves style.
2416
+ _score->setStyleValue (Sid::hideEmptyStaves, true );
2417
+ _score->setStyleValue (Sid::dontHideStavesInFirstSystem, false );
2418
+ } else if (measure) {
2419
+ // this is a measure with things in it, but is also print-object="no". I assume that means that the measure itself needs
2420
+ // to be hidden, not the entire staff.
2421
+ measure->setStaffVisible (staffIdx, false );
2422
+ } else {
2423
+ // this doesn't apply to a measure, so we'll assume the entire staff has to be hidden.
2424
+ _score->staff (staffIdx)->setVisible (false );
2425
+ }
2413
2426
} else if (!visible.isEmpty () && visible != " yes" ) {
2414
2427
_logger->logError (QString (" print-object should be \" yes\" or \" no\" " ));
2415
2428
}
0 commit comments