Fix #31176 - Appearing and disappearing courtesy clef

When courtesy clefs are turned off, some sequences of steps involving clef changes across system breaks result in spurious courtesy clefs being shown. Also, occasionally, the layout oscillates between showing / hiding courtesy clefs and/or fitting its measure in the same system or the next system. See http://musescore.org/en/node/31176 for details and examples.
Merge pull request #1274 from mgavioli/Fix_31176_appearing_and_disappearing_courtesy_clef

Fix #31176 - Appearing and disappearing courtesy clef