-
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
Improvements around hairpins and dynamics, item snapping, alignment, staff centering, and autoplace #23046
Improvements around hairpins and dynamics, item snapping, alignment, staff centering, and autoplace #23046
Conversation
6a83e75
to
71e87e5
Compare
549e20a
to
6ea9fc6
Compare
6ea9fc6
to
cc4dedf
Compare
171da23
to
09f45ab
Compare
@RomanPudashkin the utests are fixed now. It's ready for review, when you can. |
09f45ab
to
8bd516c
Compare
@@ -604,6 +622,11 @@ class EngravingItem : public EngravingObject | |||
double m_mag = 1.0; // standard magnification (derived value) | |||
ld_field<PointF> m_pos = "pos"; // Reference position, relative to _parent, set by autoplace | |||
ld_field<Shape> m_shape = "shape"; | |||
|
|||
EngravingItem* m_itemSnappedBefore = 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.
I suspect that there will be 2 problems with this change:
- these items may be deleted before the item storing them, so we will get invalid pointers here. And there will be no easy way to update the pointers, since these items probably don't have a parent-child relationship
- I also suspect that these pointers might start being used quite uncontrollably to change item properties at unexpected times (i.e. for hacks). Adding const could help at least with this 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.
I totally agree. Unfortunately I can't see a better way of doing this at the moment. In order to achieve these engraving requirements the items need to be aware of each other in a non-const way, because they must be able to influence each other's layout properties, position in the score, and even UI behaviour (drop operations, dragging, etc). At the moment this works safely because I have made sure that these connections get reset and recomputed at every layout, which means they never survive editing operations, so they don't risk pointing to invalidated stuff. Also, they are stored in LayoutData which is never copied so that's also safer. But yes I agree that it's not ideal.
I did try to explore a different solution when I started: instead of having item A point to B and B point to A, create a new entity C which holds the pointers to A and B. But in the end I dropped it because it wasn't much better: C still holds pointers to A and B which could become invalidated; we would have to manage a large number of C items (one for every snapping-chain) which also adds performance cost; then who is the owner of C? etc.
I'm not sure that there is a "good" solution to this until our library uses only raw pointers. One day, these could all be weak_ptr
...
Resolves: #16845 (and much else)