-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
[MU4] Fix GH#10653: Crash converting to whole note #10654
Conversation
1e92538
to
5d5915b
Compare
twice, on a certain score. Backport of musescore#10654
twice, on a certain score. Backport of musescore#10654
5d5915b
to
90a4ce6
Compare
twice, on a certain score. Backport of musescore#10654
90a4ce6
to
c649569
Compare
Cool! Just tested it and it seems to be solving the crash. @RomanPudashkin / @Eism - if you are happy with this, it would be nice to merge (removes a P0). Thanks @Jojo-Schmitz ! |
What about merging this? |
Any particular reason not to merge this? |
@bkunda - when you get a moment, can you test this and assuming all's good, recommend to merge? I can't quite manage it at the mo. |
The logs for this run have apparently expired so I can no longer download any artifacts. |
twice, on a certain score.
c649569
to
cd4b088
Compare
Downside of letting PRs sit for such a long time... |
@@ -4830,6 +4830,9 @@ static EngravingItem* findLinkedVoiceElement(EngravingItem* e, Staff* nstaff) | |||
Measure* measure = segment->measure(); | |||
Measure* m = score->tick2measure(measure->tick()); | |||
Segment* s = m->findSegment(segment->segmentType(), segment->tick()); | |||
if (!s) { |
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.
This looks very suspicious. Where do these null pointers come from? It looks like this PR fixes the consequence of the problem, not the cause
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.
Well, I don't quite understand the question, obviously this one comes from findSegment()
.
That in turn used findSegmentR()
//---------------------------------------------------------
// findSegmentR
// Search for a segment of type st at measure relative
// position t.
//---------------------------------------------------------
Segment* Measure::findSegmentR(SegmentType st, const Fraction& t) const
{
Segment* s;
if (t > (ticks() * Fraction(1, 2))) {
// search backwards
for (s = last(); s && s->rtick() > t; s = s->prev()) {
}
while (s && s->prev() && s->prev()->rtick() == t) {
s = s->prev();
}
} else {
// search forwards
for (s = first(); s && s->rtick() < t; s = s->next()) {
}
}
for (; s && s->rtick() == t; s = s->next()) {
if (s->segmentType() & st) {
return s;
}
}
return 0;
}
Which indeed may return a nullptr
.
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.
Why does it return null in this case? It usually indicates some other, more complicated problem
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.
Dunno. The method does on occasions and on purpose return a nullptr
. So callers should take care of those and not relying on it to never do that.
If it were illegal, an assert()
would be due in that findSegmentR()
, wouldn't it?
It took me some time to figure out the real cause of the crash, and now I understand it. For example, the user selects a measure with 4 quarter notes and clicks on the whole-note button in the note input bar:
|
This PR fixes one symptom of the problem (crash in one scenario), but it doesn't fix the problem completely (removed element in the selection). For example, if I cherry-pick the changes from the PR, I can't select anything in the note input bar after the steps from the issue (due to the corrupted selection list). I guess we will be able to reproduce this crash in other scenarios as well (even with the fix from the PR) |
Ah, I see. Or should that function never return 0 and that needs to get checked and prevented right there? |
Let's try this fix #13183 It prevents removed elements from being added to the selected element list |
That's fine, and of course better than my attempt here, but #13183 still allows |
twice, on a certain score. Backport of musescore#10654
Backport of musescore#22314 Seems to build upon an backport of musescore#10654, which got closed in favor of musescore#13183
Backport of musescore#22314 Seems to build upon an backport of musescore#10654, which got closed in favor of musescore#13183
Backport of musescore#22314 Seems to build upon an backport of musescore#10654, which got closed in favor of musescore#13183
Resolves: #10653
Same issue with (and originally reported for) MU3