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

Add support for section restart to MEI import #23022

Merged
merged 2 commits into from
Jun 23, 2024

Conversation

rettinghaus
Copy link
Contributor

This PR adds support for MEI's section@restart to the MEI importer.

(Also it removes an outdated comment I overlooked in #22943.)

@rettinghaus rettinghaus changed the title Add support for section restart in MEI import Add support for section restart to MEI import May 30, 2024
@rettinghaus rettinghaus force-pushed the mei/restart branch 3 times, most recently from 5b507f4 to 71780a2 Compare June 7, 2024 11:02
@rettinghaus rettinghaus force-pushed the mei/restart branch 3 times, most recently from 2b47ee9 to 52be828 Compare June 13, 2024 14:45
Comment on lines 1261 to 1262
Measure* measure = dynamic_cast<Measure*>(m_score->measures()->last());
if (measure) {
Copy link
Contributor

Choose a reason for hiding this comment

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

The following would be more MuseScore-idiomatic:

Suggested change
Measure* measure = dynamic_cast<Measure*>(m_score->measures()->last());
if (measure) {
MeasureBase* mb = m_score->measures()->last();
if (mb->isMeasure()) {

Alternatively, at the start of the method do:

MeasureBase* lastMeasureBase = !m_score->measures()->empty() ? m_score->measures()->last() : nullptr

and then check if (lastMeasureBase) or lastMeasureBase && lastMeasureBase->isMeasure() where appropriate (also at the bottom of the method)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@cbjeukendrup Thanks, looks more elegant now. But unit test fail. Any idea?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, I think I see the potential problem: what's the last measure at the top of the method, might not be the last measure anymore at the bottom of the method. In between, this->readMeasure for example might add another measure.

So, it looks like you inevitably need to query the last measure twice.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Of course, you're right. I reverted the latter change, so now it should be good to go.

src/importexport/mei/internal/meiimporter.cpp Outdated Show resolved Hide resolved
@cbjeukendrup cbjeukendrup merged commit 5203474 into musescore:master Jun 23, 2024
11 checks passed
@rettinghaus rettinghaus deleted the mei/restart branch June 24, 2024 06:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants