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

File format: store excerpts by a unique and safe name #20210

Merged

Conversation

cbjeukendrup
Copy link
Contributor

@cbjeukendrup cbjeukendrup commented Nov 26, 2023

The uniqueness of the names is guaranteed because each name is prefixed with the index of the excerpt. This has the additional advantage that we can eventually use those numbers to preserve the order of the excerpts across launches.

This PR can still read files that have already been created in older 4.2 builds.
However, for all older files, the viewstate.json file of existing excerpts won't be read, until you re-save the file in the build from this PR.
I think I know a way around that, which I'm still planning to implement, so therefore I'm marking this as draft for now. Feedback is already welcome though.

Resolves: #14477
Resolves: #19054
Resolves: #19301

@cbjeukendrup cbjeukendrup marked this pull request as draft November 26, 2023 23:37
Decouples the actual Excerpt name (shown in UI, and in the Excerpt itself) from the name under which it is saved in the MSC file. This way, the Excerpt name can be whatever the user wants, but still the excerpt can safely be saved in the file.
…standard"

For example, when opening pre-4.2 files. This also gives us more freedom to easily change the excerpt file name generation algorithm in the future.
@cbjeukendrup cbjeukendrup force-pushed the excerpts_store_by_escaped_name branch from c911118 to 8e18026 Compare December 3, 2023 14:38
@cbjeukendrup cbjeukendrup marked this pull request as ready for review December 3, 2023 14:38
@cbjeukendrup
Copy link
Contributor Author

This PR should be fully ready now!

m_fileName = fileName;
}

static inline bool isValidExcerptFileNameCharacter(char16_t c)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better to use mu::io::isAllowedFileName / io::path_t mu::io::escapeFileName

@DmitryArefiev
Copy link
Contributor

Tested #14477 #19054 #19301 on Win10, Mac13.6, LinuxMint21 - FIXED

№3 When renaming part, it should allow to create more than one SPACE in name from #14477 is not fixed, I'll log it separately

@DmitryArefiev DmitryArefiev merged commit 99c1987 into musescore:master Dec 11, 2023
@cbjeukendrup cbjeukendrup deleted the excerpts_store_by_escaped_name branch December 11, 2023 09:53
@RomanPudashkin RomanPudashkin mentioned this pull request Dec 11, 2023
@cbjeukendrup
Copy link
Contributor Author

@DmitryArefiev I found a fix for that super quickly, so I created a PR already: #20404

@Jojo-Schmitz
Copy link
Contributor

This seems to crash (well, abort on a failed assertion) when importing a Mu3 score with parts

@@ -153,6 +156,59 @@ async::Notification Excerpt::nameChanged() const
return m_nameChanged;
}

const String& Excerpt::fileName() const
{
IF_ASSERT_FAILED(!m_fileName.empty()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here it aborts when opening a Mu3 score with parts

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(in Debug builds only)

@cbjeukendrup
Copy link
Contributor Author

@Jojo-Schmitz Please check #22123

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants