Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash when using $M or $m (date and time) macros on a file that has never been saved #17137

Closed
rednoise0 opened this issue Apr 4, 2023 · 6 comments · Fixed by #17715
Closed
Assignees
Labels
crash Issues involving a crash of MuseScore P1 Priority: High regression_ms3 Regression from MS3 (3.6.2)

Comments

@rednoise0
Copy link

Issue type

Crash or freeze

Bug description

When using my own template where I altered the footer style to include either date ($M) or time ($m) variables, Musescrore 4.0.2 crashes immediately when creating a new score based on that template. This happens on three different computers, one running Windows 11, two on Windows 10, fully updated.

No crash when editing the footer for a document, only when that document is used as a template and a new score is created from it.

I tried a couple other variables and it didn't crash. It suspect it's only the date and time variables.

Sample template attached below. Logs folder attached below

CrashTestTemplate.zip
logs.zip

Steps to reproduce

  1. Edit a template by going to Format | Style |Header, Footer
  2. add $M or $m to any of the Footer Text boxes (I haven't tried it with the Header fields.)
  3. Save and close the template.
  4. Go to File | New | My Templates and chose the template you edited.
  5. When you click Done, Musescore crashes hard and tries to send a crash report to Microsoft.

Screenshots/Screen recordings

No response

MuseScore Version

version (64-bit): 4.0.2-230651553, revision: github-musescore-musescore-dbe7c6d

Regression

Yes, this used to work in Musescore 3.x and now is broken

Operating system

Windows 10 Pro Version 10.0.19045 Build 19045

Additional context

(attached in Description above, but here they are again.)

logs.zip
CrashTestTemplate.zip

@muse-bot muse-bot added crash Issues involving a crash of MuseScore regression Regression on a prior release labels Apr 4, 2023
@Jojo-Schmitz
Copy link
Contributor

Stems from https://musescore.org/en/node/347698

@oktophonie
Copy link
Contributor

A not dissimilar issue: #15313

@DmitryArefiev DmitryArefiev added regression_ms3 Regression from MS3 (3.6.2) and removed regression Regression on a prior release labels Apr 27, 2023
@bkunda bkunda added P2 Priority: Medium P1 Priority: High and removed P2 Priority: Medium labels May 5, 2023
@bkunda bkunda assigned mike-spa and unassigned RomanPudashkin May 22, 2023
@mike-spa
Copy link
Contributor

This crash is not related to templates: it happens any time you use the $M macro on a file that has never been saved. To see this, create a new file from "Choose instruments", go to Style -> Heder/Footer, use the $M macro somewhere, see crash. The crash is due to the fact that, because the file isn't yet saved to a path, the "last modified" info isn't really available.

@mike-spa mike-spa changed the title Crash when using template containing altered footer style Crash when using $M or $m (date and time) macros on a file that has never been saved May 24, 2023
@Jojo-Schmitz
Copy link
Contributor

Jojo-Schmitz commented May 24, 2023

Looking at the code that shouldn't happen though, a not-yet saved score is "dirty" (i.e. has changes that are nor yet saved), so the current date gets used:

            case 'm':
                if (score()->dirty()) {
                    d += Time::currentTime().toString(DateFormat::ISODate);
                } else {
                    d += masterScore()->fileInfo()->lastModified().time().toString(DateFormat::ISODate);
                }
                break;
            case 'M':
                if (score()->dirty()) {
                    d += Date::currentDate().toString(DateFormat::ISODate);
                } else {
                    d += masterScore()->fileInfo()->lastModified().date().toString(DateFormat::ISODate);
                }
                break;

So I suspect that for some reason the score isn't marked dirty?

@mike-spa
Copy link
Contributor

Good point. However, score()->dirty() actually just checks if the undo stack is empty, which it clearly is when the score has just been created

@Jojo-Schmitz
Copy link
Contributor

Jojo-Schmitz commented May 24, 2023

Well, that did work in Mu3 though
Actually creating a new score does mark it dirty in Mu4, as seen by the asterisk (Mu3 did not, but did mark it dirty as soon as a $M got added to header/footer and didn't crash on templates using it, it just leaves the corresponding field empty).

I suspect it to be a fallout of the QString to mu::String changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crash Issues involving a crash of MuseScore P1 Priority: High regression_ms3 Regression from MS3 (3.6.2)
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

8 participants