[MusicXML export] decimals in metronome markings get separated

• Feb 3, 2022 - 14:59
Reported version
3.6
Type
Functional
Frequency
Few
Severity
S3 - Major
Reproducibility
Always
Status
closed
Regression
No
Workaround
No
Project

If you have a metronome tempo with decimals, in MusicXML export these decimals get separated into a words element. The full text should find it's way into the per-minute element.

To reproduce:
1. Open the MuseScore file
2. Export as MusicXML
3. Re-import it

It doesn't matter which separator you take, it get's cut at the first character that isn't a digit.

Attachment Size
decimalTempo.mscz 2.96 KB
decimalTempo.musicxml 4.31 KB

Comments

Type musescore.org Functional

Is:

      <direction placement="above">
        <direction-type>
          <metronome parentheses="no" default-x="-37.68" relative-y="20.00">
            <beat-unit>quarter</beat-unit>
            <per-minute>85</per-minute>
            </metronome>
          </direction-type>
        <direction-type>
          <words default-x="-37.68" relative-y="20.00" font-weight="bold" font-size="12">.10</words>
          </direction-type>
        <sound tempo="85.1"/>
        </direction>
 

Should be:

      <direction placement="above">
        <direction-type>
          <metronome parentheses="no" default-x="-37.68" relative-y="20.00">
            <beat-unit>quarter</beat-unit>
            <per-minute>85.10</per-minute>
            </metronome>
          </direction-type>
        <sound tempo="85.1"/>
        </direction>

I guess the culprit is:

                  QRegExp nmb("\\d+");

in 3.x's exportxml.cpp, findMetronome(), which is only looking for digits, [0-9], it probaby should be something like:

                  // One or more digits, optionally followed by a single dot or comma and one or more digits
                  QRegExp nmb("\\d+([,\\.]{1}\\d+)?");

With that it does export the tempo text correctly, but crashes right after having written that to the MusicXML file :-(
At least when build in "Debug" mode, due to a

            Q_ASSERT(!meas);

in 3.x's exportxml.cpp, elementPosition()

Disabling that Q_ASSERT() and it works! (Means that build in "Release" or "RelWithDebInfo" mode it'd work too).
Still I'd rather know what that Q_ASSERT() is meant to be good for, it also doesn't get hit without my change. @Leon Vinken?

Is that test file supposed to replace the existing one, in the 3.x branch at least? Or is it meant as an addition to the tests in the master branch (and there with a void tempo5() { mxmlIoTest("testTempo5"); } inserted after tst_mxml_io.cpp line 220)

Edit: I got it, add to master, and slighly adjusted add as testTempo6 to 3.x (my PR #9000)
Had to take out 3 lines from it, for both, master and 3.x, to pass the tests:

    <part-group type="start" number="1">
      <group-symbol>brace</group-symbol>
      </part-group>
 
Fix version
4.1.0