Reconnect the 'modified' signal after setting a new ListBox.body - #474
Merged
Merged
Conversation
Ensure that the cached canvas is marked invalidated when a newly set ListBox.body is modified at runtime. Fixes urwid#428
penguinolog
approved these changes
Mar 29, 2023
penguinolog
reviewed
Mar 29, 2023
|
|
||
|
|
||
| class ListBoxSetBodyTest(unittest.TestCase): | ||
| def test_signal_connected(self): |
Collaborator
There was a problem hiding this comment.
a bit more paranoid validation can be used, but current is already validating issue fix
class ListBoxSetBodyTest(unittest.TestCase):
def test_signal_connected(self):
lb = urwid.ListBox([])
modified_callbacks = lb.body._urwid_signals['modified']
self.assertEqual(1, len(modified_callbacks))
callback = modified_callbacks[0][1]
self.assertEqual(lb._invalidate, callback, "Initial callback was not assigned")
lb.body = urwid.SimpleListWalker([])
new_modified_callbacks = lb.body._urwid_signals['modified']
self.assertEqual(1, len(new_modified_callbacks), "Unexpected amount of callbacks for new body")
new_callback = new_modified_callbacks[0][1]
self.assertEqual(lb._invalidate, new_callback, "Callback was not updated")
self.assertEqual(callback, new_callback)
Contributor
Author
|
🎉 |
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ensure that the cached canvas is marked invalidated when a newly set ListBox.body is modified at runtime.
Fixes #428
Checklist
masterorpython-dual-supportbranchtoxsuccessfully in local environmentDescription:
Currently,
ListBoxlistens tomodifiedevents from theListWalkerset as itsbodyonly on initialization. If a newListWalkeris assigned toListBox.bodylater, the signals from it would be ignored.