Page size should always be written to the .mscx file

• Apr 13, 2019 - 17:03
Reported version
3.x-dev
Type
Functional
Frequency
Many
Severity
S4 - Minor
Reproducibility
Always
Status
needs info
Regression
No
Workaround
No
Project

MuseScore's installed templates all omit the page size tags so that the new scores created from them will be in the user's default page size, which can vary. These templates are the only files that should work this way. All user documents should specify the page size so that they do not open in another user's default page size.

The solution is to always store the page size in the .mscx file, except when MScore::saveTemplateMode is true. I will fix this issue in an upcoming PR. I wanted to create the issue now, while it is fresh in my mind.

This issue was discussed in detail on the developers' chat, ending here:
https://t.me/musescoreeditorchat/33280


Comments

Status active needs info

As discussed and shown there, page size is written to the score file in any case already (except when using--template-mode). In which cases do you believe it is not?

I have cases where it does not, and my newer code cleans up all the rounding so that it happens consistently. The current code does it because of rounding errors in the chain of calculations, spin-box widgets, and storage. In the current code, it is a bug - a convenient bug, but a bug all the same. It does not function as designed. I'm changing the design and cleaning up the functionality.

The current code in MStyle::isDefault() does a strict == comparison against the MScore::_baseStyle value:
https://github.com/sidewayss/MuseScore/blob/25c8a3e8557fd854be58703a40b…
This is a floating point comparison and subject to glitches anyway. On top of that there is rounding happening at various stages of unit conversion, in pagesettings.ui, and when Qt converts values to text for file storage.
Even a value as coarse as 8.27 can get stored in the file as the A4 page width in Inches. The unrounded value in the baseStyle is 8.267716535. That's not even within +/- 0.01, much less a strict ==.

As I said, this is for a future PR. My currently pending PR cleans up all this baseStyle and rounding stuff. The PR contains lots of mtest -ref.mscx files that changed because the rounded baseStyle values they had stored for page width/height/margins are now optimized out of the file - as has always been intended by the code.

So currently it does get written in all and any cases (except when using `--template-mode'), but does so only due to a bug, at least partly?

To clarify my last comment, which I see now is oddly unclear:
Many of the current mtest -ref.mscx files do not store the page size. Their Style tag looks like this:

<Style>
      <Spatium>1.764</Spatium>
</Style>

It's easy to generate a file like that.
So the current behavior is inconsistent in this regard.