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

Fix #23977: Export to MusicXml wavy line starts in second voices #25811

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 25 additions & 5 deletions src/engraving/dom/score.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4572,11 +4572,31 @@ ChordRest* Score::findCR(Fraction tick, track_idx_t track) const
}

//---------------------------------------------------------
// findCRinStaff
// findChordRestEndingBeforeTickInStaff
// find last chord/rest on staff that ends before tick
//---------------------------------------------------------

ChordRest* Score::findChordRestEndingBeforeTickInStaff(const Fraction& tick, staff_idx_t staffIdx) const
{
return findChordRestEndingBeforeTickInStaffAndVoice(tick, staffIdx, false, 0);
}

//-----------------------------------------------------------------
// findChordRestEndingBeforeTickInStaffAndVoice
// find last chord/rest on staff and voice that ends before tick
//-----------------------------------------------------------------
ChordRest* Score::findChordRestEndingBeforeTickInStaffAndVoice(const Fraction& tick, staff_idx_t staffIdx, voice_idx_t voice) const
{
return findChordRestEndingBeforeTickInStaffAndVoice(tick, staffIdx, true, voice);
}

//-----------------------------------------------------------------
// findChordRestEndingBeforeTickInStaffAndVoice
// find last chord/rest on staff and voice that ends before tick
// allow no specific voice
//-----------------------------------------------------------------
ChordRest* Score::findChordRestEndingBeforeTickInStaffAndVoice(const Fraction& tick, staff_idx_t staffIdx, bool forceVoice,
voice_idx_t voice) const
{
Fraction ptick = tick - Fraction::fromTicks(1);
Measure* m = tick2measureMM(ptick);
Expand All @@ -4589,9 +4609,9 @@ ChordRest* Score::findChordRestEndingBeforeTickInStaff(const Fraction& tick, sta
ptick = m->tick();
}

Segment* s = m->first(SegmentType::ChordRest);
track_idx_t strack = staffIdx * VOICES;
track_idx_t etrack = strack + VOICES;
Segment* s = m->first(SegmentType::ChordRest);
track_idx_t strack = staffIdx * VOICES;
track_idx_t etrack = strack + VOICES;
track_idx_t actualTrack = strack;

Fraction lastTick = Fraction(-1, 1);
Expand All @@ -4602,7 +4622,7 @@ ChordRest* Score::findChordRestEndingBeforeTickInStaff(const Fraction& tick, sta
// found a segment; now find longest cr on this staff that does not overlap tick
for (track_idx_t t = strack; t < etrack; ++t) {
ChordRest* cr = toChordRest(ns->element(t));
if (cr) {
if ((cr) && ((!forceVoice) || voice == cr->voice())) {
Fraction endTick = cr->tick() + cr->actualTicks();
if (endTick >= lastTick && endTick <= tick) {
s = ns;
Expand Down
3 changes: 3 additions & 0 deletions src/engraving/dom/score.h
Original file line number Diff line number Diff line change
Expand Up @@ -925,6 +925,7 @@ class Score : public EngravingObject, public muse::Injectable

ChordRest* findCR(Fraction tick, track_idx_t track) const;
ChordRest* findChordRestEndingBeforeTickInStaff(const Fraction& tick, staff_idx_t staffIdx) const;
ChordRest* findChordRestEndingBeforeTickInStaffAndVoice(const Fraction& tick, staff_idx_t staffIdx, voice_idx_t voice) const;
ChordRest* findChordRestEndingBeforeTickInTrack(const Fraction& tick, track_idx_t trackIdx) const;
void insertTime(const Fraction& tickPos, const Fraction& tickLen);

Expand Down Expand Up @@ -1055,6 +1056,8 @@ class Score : public EngravingObject, public muse::Injectable
Note* getSelectedNote();
ChordRest* nextTrack(ChordRest* cr, bool skipMeasureRepeatRests = true);
ChordRest* prevTrack(ChordRest* cr, bool skipMeasureRepeatRests = true);
ChordRest* findChordRestEndingBeforeTickInStaffAndVoice(const Fraction& tick, staff_idx_t staffIdx, bool forceVoice,
voice_idx_t voice) const;

void addTempo();
void addMetronome();
Expand Down
2 changes: 1 addition & 1 deletion src/engraving/dom/trill.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,6 @@ String Trill::accessibleInfo() const

void Trill::doComputeEndElement()
{
setEndElement(score()->findChordRestEndingBeforeTickInStaff(tick2(), track2staff(track2())));
setEndElement(score()->findChordRestEndingBeforeTickInStaffAndVoice(tick2(), track2staff(track2()), voice()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8504,15 +8504,18 @@ static void addWavyLine(ChordRest* cr, const Fraction& tick,
if (!wavyLineType.empty()) {
const Fraction ticks = cr->ticks();
const track_idx_t track = cr->track();
const track_idx_t trk = (track / VOICES) * VOICES; // first track of staff
Trill*& trill = trills[wavyLineNo];
if (wavyLineType == u"start" || wavyLineType == u"startstop") {
if (trill) {
logger->logError(String(u"overlapping wavy-line number %1").arg(wavyLineNo + 1), xmlreader);
} else {
trill = Factory::createTrill(cr->score()->dummy());
trill->setTrack(trk);
trill->setTrack2(trk);
trill->setTrack(track);
trill->setTrack2(track);

trill->setOrnament(Factory::createOrnament(cr));
trill->ornament()->setAnchor(ArticulationAnchor::AUTO);

if (wavyLineType == u"start") {
spanners[trill] = std::pair<int, int>(tick.ticks(), -1);
// LOGD("trill=%p inserted at first tick %d", trill, tick);
Expand Down
3 changes: 3 additions & 0 deletions src/inspector/models/abstractinspectormodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,9 @@ mu::engraving::Sid AbstractInspectorModel::styleIdByPropertyId(const mu::engravi
mu::engraving::Sid result = mu::engraving::Sid::NOSTYLE;

for (const mu::engraving::EngravingItem* element : m_elementList) {
IF_ASSERT_FAILED(element) {

This comment was marked as outdated.

Copy link
Contributor

Choose a reason for hiding this comment

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

I can reproduce the crash, but I think it might be better to fix the issue further upstream.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added this lines before I solved the problem within importmusicxmlpass2.cpp. Therefore I can delete them.

About:

I can reproduce the crash, but I think it might be better to fix the issue further upstream.

I haven't been able to reproduce now the crash. Could yo provide me with an example to test it and solve it please ?

Thanks

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry to bother @miiizen , could you please tell me how you can reproduce the crash ?

continue;
}
result = element->getPropertyStyle(pid);

if (result != mu::engraving::Sid::NOSTYLE) {
Expand Down