Skip to content

Commit 6f36fe6

Browse files
claritymakerjonathanslenders
authored andcommitted
Moved the invalidate handler to it's own method so that the remove function will properly remove it.
1 parent 9bbe0ef commit 6f36fe6

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

prompt_toolkit/application/application.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ def _update_invalidate_events(self):
458458
# Remove all the original event handlers. (Components can be removed
459459
# from the UI.)
460460
for ev in self._invalidate_events:
461-
ev -= self.invalidate
461+
ev -= self._invalidate_handler
462462

463463
# Gather all new events.
464464
# (All controls are able to invalidate themselves.)
@@ -469,12 +469,14 @@ def gather_events():
469469

470470
self._invalidate_events = list(gather_events())
471471

472-
# Attach invalidate event handler.
473-
def invalidate(sender):
474-
self.invalidate()
475-
476472
for ev in self._invalidate_events:
477-
ev += invalidate
473+
ev += self._invalidate_handler
474+
475+
def _invalidate_handler(self, sender):
476+
"""
477+
Handler to allow invalidate to be called with the correct signature.
478+
"""
479+
self.invalidate()
478480

479481
def _on_resize(self):
480482
"""
@@ -623,7 +625,7 @@ def flush_input():
623625
# invalidate should not trigger a repaint in
624626
# terminated applications.)
625627
for ev in self._invalidate_events:
626-
ev -= self.invalidate
628+
ev -= self._invalidate_handler
627629
self._invalidate_events = []
628630

629631
# Wait for CPR responses.

0 commit comments

Comments
 (0)