-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
File format: store excerpts by a unique and safe name #20210
Conversation
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.
c911118
to
8e18026
Compare
This PR should be fully ready now! |
m_fileName = fileName; | ||
} | ||
|
||
static inline bool isValidExcerptFileNameCharacter(char16_t c) |
There was a problem hiding this comment.
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 I found a fix for that super quickly, so I created a PR already: #20404 |
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()) { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(in Debug builds only)
@Jojo-Schmitz Please check #22123 |
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