Skip to content

Commit

Permalink
Use active message pump in pop screen (#3315)
Browse files Browse the repository at this point in the history
* Use active message pump in pop screen

* message pump
  • Loading branch information
willmcgugan authored Sep 15, 2023
1 parent 149c5e2 commit ce32abd
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

- Fixed a crash when removing an option from an `OptionList` while the mouse is hovering over the last option https://github.com/Textualize/textual/issues/3270
- Fixed a crash in `MarkdownViewer` when clicking on a link that contains an anchor https://github.com/Textualize/textual/issues/3094
- Fixed wrong message pump in pop_screen https://github.com/Textualize/textual/pull/3315

### Changed

Expand Down
8 changes: 5 additions & 3 deletions src/textual/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -1783,9 +1783,11 @@ def push_screen(
self.screen.post_message(events.ScreenSuspend())
self.screen.refresh()
next_screen, await_mount = self._get_screen(screen)
next_screen._push_result_callback(
self.screen if self._screen_stack else None, callback
)
try:
message_pump = active_message_pump.get()
except LookupError:
message_pump = self.app
next_screen._push_result_callback(message_pump, callback)
self._load_screen_css(next_screen)
self._screen_stack.append(next_screen)
self.stylesheet.update(next_screen)
Expand Down
6 changes: 3 additions & 3 deletions src/textual/screen.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class ResultCallback(Generic[ScreenResultType]):

def __init__(
self,
requester: Widget | None,
requester: MessagePump,
callback: ScreenResultCallbackType[ScreenResultType] | None,
) -> None:
"""Initialise the result callback object.
Expand All @@ -81,7 +81,7 @@ def __init__(
requester: The object making a request for the callback.
callback: The callback function.
"""
self.requester: Widget | None = requester
self.requester = requester
"""The object in the DOM that requested the callback."""
self.callback: ScreenResultCallbackType | None = callback
"""The callback function."""
Expand Down Expand Up @@ -685,7 +685,7 @@ def _invoke_later(self, callback: CallbackType, sender: MessagePump) -> None:

def _push_result_callback(
self,
requester: Widget | None,
requester: MessagePump,
callback: ScreenResultCallbackType[ScreenResultType] | None,
) -> None:
"""Add a result callback to the screen.
Expand Down

0 comments on commit ce32abd

Please sign in to comment.