Repository navigation
fix(hud): keep a due message timer off a cleared closure - #1615
Merged
Merged
Conversation
`make test` crashed in test_key_hold.py: the CanvasHud message timer called a lambda whose closure the garbage collector had cleared. test_hud_message_wrap.py leaves a HUD with a pending timer in a reference cycle. A collection on a background thread clears the lambda, and PyQt defers the widget's delete because it is on the wrong thread. The first event loop spin then runs the due timer before the deferred delete, and the lambda reads a NULL closure. The timer now connects to a bound method, as _progress_timer does. Pick Better's move timer had the same lambda and now connects to QLabel.clear. The crashing command failed in 5 of 5 runs before this change and passed in 4 of 4 after it. Fixes marcinz606#1614 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kurtwindisch
marked this pull request as ready for review
November 5, 2026 22:36
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #1614.
make testcrashed with a segfault intests/test_key_hold.py, onmaintoo. The CanvasHud message timer called a lambda whose closure the garbage collector had cleared. The issue has the full cause and a reproduction.CanvasHud: the message timer connects to a bound method,_expire_message, as_progress_timerbeside it does. PyQt holds no closure for a bound method, so a collection has nothing to clear.QLabel.clear.test_a_message_timer_survives_a_collection_on_another_threadruns the reproduction in a subprocess, because the failure is a segfault.I have no report of this crash in the running app. A HUD normally lives as long as the window, so the known trigger is the test suite. The other lambdas on
dlg.finishedsignals are not timers, and this PR leaves them as they are.Test plan
pytest tests/ --cov=negpy --cov-report=term-missing: crashed in 5 of 5 runs before the change, and passed in 4 of 4 after it (10762 passed)hud.py(exit code -11) and passes on the new onemake lintandmake typepassEscwhile the summary shows🤖 Generated with Claude Code