Skip to content

Conversation

@MelkorBalrog
Copy link
Owner

Summary

  • register and uninstall Windows resize hooks globally so callbacks stop before the interpreter releases the GIL
  • keep window resize controllers detaching native hooks even during Python finalization to prevent late callbacks
  • document the shutdown safety change in HISTORY

Testing

  • python -m pytest (fails: missing optional dependencies such as PIL prevent test collection)
  • python -m radon cc -s -j gui/utils/window_resizer.py gui/utils/win32_hooks.py (fails: radon not installed)

Codex Task

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +203 to +207
try:
_HOOKS.discard(self)
except Exception:
pass
return

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Win32 hook finalizer skips uninstall during shutdown

When sys.is_finalizing() is true, _Win32WindowProcHook.__del__ now drops the hook from _HOOKS and returns without calling uninstall, so the patched window procedure remains installed while the CFUNCTYPE callback is being torn down. During interpreter shutdown WindowResizeController.__del__ also exits immediately (window_resizer.py:333-334), so hooks created by controllers are collected via this branch and never reach the new atexit cleanup (the hook has already been removed from _HOOKS). On Windows any late WM messages in that window tear-down window will then call a freed callback, risking crashes precisely during interpreter exit—the scenario this change was meant to prevent.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant