Skip to content
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

Avoid writing to preferences on helper creation #343

Merged
merged 4 commits into from
Jul 4, 2024

Conversation

mdickinson
Copy link
Member

@mdickinson mdickinson commented Jun 27, 2024

This PR fixes the PreferencesHelper to avoid writing to the preferences the first time a helper is created for a given Preferences object.

The issue was that on creation, PreferencesHelper._initialize was being called twice: once with notify=False and again with notify=True, as a result of the listener to the preferences trait. This PR avoids the second call by making that listener only run post creation (using post_init=True).

Closes #342
Closes #74

Checklist

  • Add a news fragment if this PR is news-worthy for end users. (see docs/releases/README.rst)

@mdickinson
Copy link
Member Author

@flongford Would you be able to review?

@mdickinson mdickinson requested a review from flongford July 3, 2024 06:55
Copy link

@flongford flongford left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. The use of an additional observe listener seems appropriate here and appears to resolve the reported issue.

I can't think of any immediate downstream consequences of this change, but I expect these can be simply handled in a case-by-case basis.

@mdickinson mdickinson merged commit b559b37 into main Jul 4, 2024
19 checks passed
@mdickinson mdickinson deleted the fix/preferences-written-on-helper-creation branch July 4, 2024 14:50
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.

Preferences written on helper creation Preferences helper will call _initialize twice at construction
2 participants