Repository navigation
Fix CUDA prompt firing on a deleted main window - #1668
Merged
Merged
Conversation
On a machine with an NVIDIA GPU and CPU-only torch, MainWindow shows the CUDA installer prompt 500 ms after it opens, via QTimer.singleShot. If the window was closed and deleted within that time, the timer still fired and CudaInstallerDialog(self) raised "wrapped C/C++ object of type MainWindow has been deleted". This made test_should_run_file_transcription_task flaky on such machines. Use a QTimer owned by the window, so it is destroyed with it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012ozoVtp2JvfpDkZ1SpBgvW
This was referenced Oct 20, 2026
raivisdejus
enabled auto-merge (squash)
October 24, 2026 14:11
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1668 +/- ##
==========================================
+ Coverage 84.13% 84.21% +0.08%
==========================================
Files 115 115
Lines 13928 13931 +3
==========================================
+ Hits 11718 11732 +14
+ Misses 2210 2199 -11
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Problem
On Windows and Linux machines with an NVIDIA GPU and CPU-only torch,
MainWindow._maybe_show_cuda_promptopens the CUDA installer prompt 500 ms after the window opens, viaQTimer.singleShot(500, _show).If the window is closed and deleted within those 500 ms, the timer still fires, and
CudaInstallerDialog(self)raises:This makes
tests/widgets/main_window_test.py::TestMainWindow::test_should_run_file_transcription_taskflaky on such machines. When a fast transcription lets the test close the window before the timer fires, pytest-qt reports the exception from the Qt event loop. CI runners have no NVIDIA GPU, so CI never hits it.Fix
The prompt now uses a
QTimerthat the window owns, so Qt destroys the timer together with the window and it can't fire on a deleted one. PyQt6'sQTimer.singleShothas no overload that takes a context object, so a parented timer is the way to tie the timer's lifetime to the window.Testing
test_cuda_prompt_shows_after_delay: on a simulated NVIDIA + CPU-torch machine, the prompt opens for the window.test_cuda_prompt_does_not_fire_after_window_is_deleted: fails without the fix and passes with it.window.settings, so they don't writeCUDA_PROMPT_SHOWNto the real user settings.tests/widgets/main_window_test.pyandtests/widgets/cuda_installer_widget_test.pypass locally (37 tests, two runs) on Fedora 44 with an RTX 3070.Found while working on #1667.
🤖 Generated with Claude Code
https://claude.ai/code/session_012ozoVtp2JvfpDkZ1SpBgvW