musescore / musescore/MuseScore
Don't call `Shape::right()` etc. on empty shapes
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 15.1k
- Forks
- 3.3k
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 91
Description
See the discussion at https://github.com/musescore/MuseScore/pull/24486.
When calling Shape::right() etc. on empty shapes, ±DBL_MAX is returned, which is a bit dangerous. We could just add if (empty()) { return 0; }, but actually such methods should just not be called on empty shapes. Adding return 0; would hide the problem.
Therefore, we decided that IF_ASSERT_FAILED(!empty()) { return 0; } would be more appropriate. However, this reveals quite a number of cases where we were calling such methods on empty shapes. Some are trivially avoidable, others require a bit more thought. See https://github.com/musescore/MuseScore/compare/master...cbjeukendrup:MuseScore:zzz_backup/shape_right_assert_nonempty for an initial attempt at such fixes.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.