Skip to content

Conversation

@mike-spa
Copy link
Contributor

@mike-spa mike-spa commented Nov 6, 2025

Prompted from this consideration, I took a closer look at the functions in scoretree.cpp, namely scanParent and scanChildren. As far as I could see, they were introduced for some score tree visualization feature back in version 3, but as far as I'm aware that feature doesn't exist in version 4. Everything about this is quite weird, because the parent and child relationships sometimes don't follow the true hierarchy of our model (ChordRests collect spanners among their children, Spanner collect SpannerSegment even though the parent of a SpannerSegment is always the System, scanParent sometimes returns an item that isn't the parent...). Most of these functions are either stale or are a copy of the corresponding scanElements method. The "source of truth" is obviously scanElements, cause that's what we use to determine what is drawn on screen.

This PR:

  • Removes all the scanParent and scanChildren functions, moving all the relevant functionality to scanElements
  • Introduces EngravingObject::getChildren, which collects the list of children using scanElements
  • Refactors scanElements using std::function instead of the old C-style function pointers. This makes everything nicer, especially avoiding all the void* pointers.
  • Removes from scanElements all the logic that had to do with showing or not showing the item on screen. The whole point of something like scanElement is that it doesn't know what func will do, so putting that logic in scanElement is an antipattern. Deciding whether or not to collect an element should be decided inside func itself.

@mike-spa mike-spa force-pushed the cleanupScanParentAndScanChildren branch from bd9297a to 84175c0 Compare November 6, 2025 16:59
@mike-spa mike-spa force-pushed the cleanupScanParentAndScanChildren branch from 84175c0 to 60e2470 Compare November 12, 2025 13:09
@mike-spa mike-spa merged commit a53c53c into musescore:master Nov 14, 2025
11 of 12 checks passed
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