Origin: upstream, commit:feffd0f5f7bd2462894031e216c31c60809167fa
Author: Marc Sabatella <marc@outsideshore.com>
Description: fix #290061: no space betwene header and clef change

--- a/libmscore/measure.cpp
+++ b/libmscore/measure.cpp
@@ -4133,7 +4133,8 @@ void Measure::computeMinWidth(Segment* s
             qreal w;
 
             if (ns) {
-                  if (isSystemHeader && ns->isChordRestType()) {        // this is the system header gap
+                  if (isSystemHeader && (ns->isChordRestType() || (ns->isClefType() && !ns->header()))) {
+                        // this is the system header gap
                         w = s->minHorizontalDistance(ns, true);
                         isSystemHeader = false;
                         }
--- a/libmscore/segment.cpp
+++ b/libmscore/segment.cpp
@@ -2089,6 +2089,14 @@ qreal Segment::minHorizontalDistance(Seg
             // d = qMax(d, spatium());       // minimum distance is one spatium
             // w = qMax(w, minRight()) + d;
             }
+      else if (systemHeaderGap) {
+            // first segment after header is *not* a chordrest
+            // could be a clef
+            if (st == SegmentType::TimeSig)
+                  w += score()->styleP(Sid::systemHeaderTimeSigDistance);
+            else
+                  w += score()->styleP(Sid::systemHeaderDistance);
+            }
       else if (st & (SegmentType::Clef | SegmentType::HeaderClef)) {
             if (nst == SegmentType::KeySig || nst == SegmentType::KeySigAnnounce)
                   w += score()->styleP(Sid::clefKeyDistance);
