Skip to content

Fix pointer style crash during early theme changes - #6682

Open
deepakganesh78 wants to merge 1 commit into
Textualize:mainfrom
deepakganesh78:fix/issue6360-pointer-theme-crash
Open

Fix pointer style crash during early theme changes#6682
deepakganesh78 wants to merge 1 commit into
Textualize:mainfrom
deepakganesh78:fix/issue6360-pointer-theme-crash

Conversation

@deepakganesh78

Copy link
Copy Markdown

Fixes #6360

Reproduction

A minimal app that sets pointer: default in CSS and switches to textual-light in __init__ crashes during startup because CSS is refreshed before any screen has been pushed.

Root cause

Updating a pointer style calls obj.node.screen.update_pointer_shape(). For the App node during early theme application, App.screen raises ScreenStackError because the screen stack is still empty; the pointer-style code only handled NoScreen.

Fix

Treat ScreenStackError like NoScreen for pointer updates, deferring pointer-shape refresh until a screen exists. This preserves existing pointer updates once the app is mounted.

Compatibility notes

This only suppresses an early pointer-shape refresh when no active screen exists. Existing validation and mounted pointer-style behavior are unchanged.

Validation

  • python -m pytest tests\test_app.py::test_app_pointer_style_with_theme_before_screen_stack tests\test_app.py::test_pointer_shape -q → 2 passed
  • Verified regression: with the source fix reverted, tests\test_app.py::test_app_pointer_style_with_theme_before_screen_stack fails with ScreenStackError: No screens on stack.
  • python -m pytest tests --ignore=tests\snapshot_tests -q → 3013 passed, 1 skipped, 4 xfailed

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use of pointer style can cause a startup crash if setting a theme

1 participant