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

Use active message pump in pop screen #3315

Merged
merged 2 commits into from
Sep 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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