Skip to content

fixup: fix setters for doc_background_pattern_width/height_unitentry …#1773

Open
Doublonmousse wants to merge 1 commit into
flxzt:mainfrom
Doublonmousse:fix_unsaved_width_height
Open

fixup: fix setters for doc_background_pattern_width/height_unitentry …#1773
Doublonmousse wants to merge 1 commit into
flxzt:mainfrom
Doublonmousse:fix_unsaved_width_height

Conversation

@Doublonmousse

Copy link
Copy Markdown
Collaborator

…on setup

Otherwise the following occurs :

  • the unitentry starts with default dpi and value whereas the engine has the correct value
  • setting the dpi first makes the unitentry recalculate with the new dpi but default value so a new value in px is applied to the engine through the connect_notify on "value"
  • setting the value in px afterwards will recalculate the value (this time with the correct dpi/value/unit combo) so the value in px is correct but this triggers again a modification on the engine because we changed this value just before.

This thus triggers 2*2 updates of the engine upon startup. But changing the order isn't enough (as in that case the first change of the value will return the expected value in px but not the second one if the unit is not px (because of the dpi scaling changing when setting the dpi with a unit != from px.).

To fix this, create a setter that changes both dpi and value in a way where the value property is only set once with the correct value_in_px callback

Fixes #1258. Replaces #1453

NOTE : the else part in set_dpi_and_value_px is not technically needed for the fix (I kinda figured it'd be better to have an helper function with all cases covered anyway, and that it's a little clearer this way)

…on setup

Otherwise the following occurs :
- the unitentry starts with default dpi and value whereas the engine has the correct value
- setting the dpi first makes the unitentry recalculate with the new dpi but default value so a new value in px is applied to the engine through the connect_notify on "value"
- setting the value in px afterwards will recalculate the value (this time with the correct dpi/value/unit combo) so the value in px is correct but this triggers again a modification on the engine because we changed this value just before.

This thus triggers 2*2 updates of the engine upon startup. But changing the order isn't enough (as in that case the first change of the value will return the expected value in px but not the second one if the unit is not px (because of the dpi scaling changing when setting the dpi with a unit != from px.).

To fix this, create a setter that changes both dpi and value in a way where the value property is only set once with the correct value_in_px callback
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.

Empty document created on startup handled by Rnote as modified by default while it should be considered as empty and unmodified by default

1 participant