-
Notifications
You must be signed in to change notification settings - Fork 815
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
Report a bug about switch_screen #2650
Comments
Same thing happened to me. I'm switching a screen that another screen has a callback on. |
Thanks for opening this issue @tsingwang. @chitter99 can you add a bit more context to your specific problem, please? Ideally with a minimal reproducible example? |
Studying this a bit further revealed that there was another similar issue because switching to the currently active screen should be a no-op but it wasn't. |
Don't forget to star the repository! Follow @textualizeio for Textual updates. |
@rodrigogiraoserrao It looks like a similar issue still exists, but now for /lib/python3.10/site-packages/textual/app.py:1732 in │
│ pop_screen │
│ │
│ 1729 │ │ │ │ "Can't pop screen; there must be at least one screen on the stack" │
│ 1730 │ │ │ ) │
│ 1731 │ │ previous_screen = self._replace_screen(screen_stack.pop()) │
│ ❱ 1732 │ │ previous_screen._pop_result_callback() │
│ 1733 │ │ self.screen._screen_resized(self.size) │
│ 1734 │ │ self.screen.post_message(events.ScreenResume()) │
│ 1735 │ │ self.log.system(f"{self.screen} is active") │
│ │
│ │
│/lib/python3.10/site-packages/textual/screen.py:635 in │
│ _pop_result_callback │
│ │
│ 632 │ ╭─── locals ────╮ │
│ 633 │ def _pop_result_callback(self) -> None: │ self = Cart() │ │
│ 634 │ │ """Remove the latest result callback from the stack.""" ╰───────────────╯ │
│ ❱ 635 │ │ self._result_callbacks.pop() │
│ 636 │ │
│ 637 │ def _refresh_layout( │
│ 638 │ │ self, size: Size | None = None, full: bool = False, scroll: bool = False │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
IndexError: pop from empty list |
@mzebrak Do you think you could create a minimal isolated example of what your code is doing, such that it displays the issue? Would be an idea to create it as a fresh issue if this is something that's a bug in the current release; feel free to refer back to this one too. |
Unfortunately, I have no idea how to reproduce it, that's all I have. I suppose some sequence of several pop screens, switch screens and pop screens again ==== EDIT: I've got it! 2023-07-31 12:43:03.893 | ⚠️ WARNING | Textual issue with _pop_result_callback: push_screen called
2023-07-31 12:43:03.895 | ⚠️ WARNING | Textual issue with _pop_result_callback: push_screen called
2023-07-31 12:43:04.438 | ⚠️ WARNING | Textual issue with _pop_result_callback: push_screen called
2023-07-31 12:43:05.852 | ⚠️ WARNING | Textual issue with _pop_result_callback: push_screen called
2023-07-31 12:43:08.068 | ⚠️ WARNING | Textual issue with _pop_result_callback: push_screen called
2023-07-31 12:43:09.302 | ⚠️ WARNING | Textual issue with _pop_result_callback: push_screen called
2023-07-31 12:43:11.912 | ⚠️ WARNING | Textual issue with _pop_result_callback: push_screen called
2023-07-31 12:43:13.077 | ⚠️ WARNING | Textual issue with _pop_result_callback: push_screen called
2023-07-31 12:43:14.283 | ⚠️ WARNING | Textual issue with _pop_result_callback: pop_screen called
2023-07-31 12:43:14.301 | ⚠️ WARNING | Textual issue with _pop_result_callback: pop_screen called
2023-07-31 12:43:14.315 | ⚠️ WARNING | Textual issue with _pop_result_callback: pop_screen called
2023-07-31 12:43:14.330 | ⚠️ WARNING | Textual issue with _pop_result_callback: pop_screen called
2023-07-31 12:43:14.341 | ⚠️ WARNING | Textual issue with _pop_result_callback: pop_screen called
2023-07-31 12:43:14.350 | ⚠️ WARNING | Textual issue with _pop_result_callback: pop_screen called
2023-07-31 12:43:14.353 | ⚠️ WARNING | Textual issue with _pop_result_callback: pop_screen called
2023-07-31 12:43:14.422 | ⚠️ WARNING | Textual issue with _pop_result_callback: switch_screen called with screen as string
2023-07-31 12:43:16.090 | ⚠️ WARNING | Textual issue with _pop_result_callback: push_screen called
2023-07-31 12:43:19.593 | ⚠️ WARNING | Textual issue with _pop_result_callback: push_screen called
2023-07-31 12:43:31.498 | ⚠️ WARNING | Textual issue with _pop_result_callback: switch_screen called
2023-07-31 12:43:34.968 | ⚠️ WARNING | Textual issue with _pop_result_callback: pop_screen called
2023-07-31 12:43:35.002 | ⚠️ WARNING | Textual issue with _pop_result_callback: pop_screen called ==== EDIT: I've created a separate issue for this: #3041 |
This is sample code. When '21' pressed, it will crash. Log below:
The direct reason is
_ push_ result_ callback
not called whenswitch_screen
, or checkself._result_callbacks
is empty when pop.The text was updated successfully, but these errors were encountered: