-
Notifications
You must be signed in to change notification settings - Fork 55
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
Convert dynamic on_trait_change uses to observe #870
Conversation
Im currently getting a strange segfault I am trying to debug. Somehow adding |
pyface/ui/wx/action/action_item.py
Outdated
action.observe(self._on_action_enabled_changed, "enabled", remove=True) | ||
action.observe(self._on_action_visible_changed, "visible", remove=True) | ||
action.observe(self._on_action_checked_changed, "checked", remove=True) | ||
action.observe(self._on_action_name_changed, "name", remove=True) |
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.
For some reason we don't remove the listener for "image" here...? I left code to match it as is but this feels like a bug? Additionally for some of the occurrences below, we do not remove
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.
Note for future ref: Maybe the segfault was related to this?
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.
Yep, definitely should be removing anything that is added.
""" Called when the selection in the tree is changed. """ | ||
|
||
selection = event.new | ||
if len(selection) > 0: | ||
self._table_viewer.input = selection[0] |
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.
This example seems to not be run-able on qt or wx. I will look if there is already an issue and open one if not.
pyface/ui/qt4/action/menu_manager.py
Outdated
self._manager.observe(self._on_enabled_changed, "enabled") | ||
self._manager.observe(self._on_visible_changed, "visible") | ||
self._manager.observe(self._on_name_changed, "name") | ||
self._manager.observe(self._on_image_changed, "image") |
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.
The manager/its subclasses do not explicitly define an "image" trait
…thing is broken)" This reverts commit 297a448.
I reverted the changes to Also, looking at this PR in its current state, it is already getting decently large so I am tempted to just arbitrarily stop here and flag it for review... Then I will leave the remaining changes for a second PR. |
Aha! looks like segfault is still occurring on CI, but I no longer am able to reproduce locally. I suspect the changes in |
This reverts commit b27e19e.
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.
LGTM with a bunch of style recommendations.
examples/application/python_editor/python_editor_application.py
Outdated
Show resolved
Hide resolved
Co-authored-by: Poruri Sai Rahul <rporuri@enthought.com>
ref: #876 |
Latest round of changes has CI failing. Looking into all the places where we need to explicitly pass |
@rahulporuri I tried to fix the CI failures in the latest commit 🤞 . However, the fixes seem very fragile, and I am not confident I didn't miss anything. We may be introducing bugs that are flying under the radar because they are not covered in tests. In other words, in the latest commit, I was trying to identify any ways that I understand style wise we want to go with just passing What are your thoughts about this? EDIT: see latest commit, where I just went ahead and did the "refactor" approach. I think this is probably the go here and in general. The only thing to note: when we do the refactor approach we will probably want to try to leave the current handler with the same name without any arguments as a standard method and then redefine a new handler that we then observe that has the event arg. This is because we may not always be certain of all the code paths that could be taken to call the handler standalone, but we will know where it is explicitly called with observe. Maybe thats not entirely true... In any case we need to be cautious to not break things! |
This reverts commit 4d6e724.
pyface/timer/tests/test_timer.py
Outdated
timer = CallbackTimer( | ||
callback=handler.callback, kwargs={'event': None} | ||
) |
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.
it is better to simply update the ConditionHandler.callback
method to set event=None
instead of updating all of the callers
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.
That makes sense to me, should I do it where I simply have event=None
as a kwarg on callback
then? Or is the most recent solution with _callback
better?
I think just having it as a kwarg makes the most sense to me
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 think just having it as a kwarg makes the most sense to me
Let's go with that approach - instead of the refactor.
This reverts commit 564e167.
@rahulporuri I was thinking of looking into making sure we remove and listeners we set up before we push this through. Should I do that, or make those fixes in a separate PR (since they didn't exist with otc before, so this PR should preserve behavior, but ultimately we will want them addressed). EDIT: on second thought I think I will do this separately. Many (most?/all?) of the cases are such that the code is transient, e.g. examples, and some tests. Still worth looking into, but I think I will leave them for a separate issue/PR |
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.
still LGTM, assuming CI is happy
that's fine by me but do open an issue |
part of #732 and #637