Skip to content

Fix CUDA prompt firing on a deleted main window - #1668

Merged
raivisdejus merged 2 commits into
chidiwilliams:mainfrom
doqhu:fix/cuda-prompt-timer
Oct 24, 2026
Merged

raivisdejus merged 2 commits into
chidiwilliams:mainfrom
doqhu:fix/cuda-prompt-timer

Conversation

@doqhu

@doqhu doqhu commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

Problem

On Windows and Linux machines with an NVIDIA GPU and CPU-only torch, MainWindow._maybe_show_cuda_prompt opens the CUDA installer prompt 500 ms after the window opens, via QTimer.singleShot(500, _show).

If the window is closed and deleted within those 500 ms, the timer still fires, and CudaInstallerDialog(self) raises:

RuntimeError: wrapped C/C++ object of type MainWindow has been deleted

This makes tests/widgets/main_window_test.py::TestMainWindow::test_should_run_file_transcription_task flaky 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 QTimer that the window owns, so Qt destroys the timer together with the window and it can't fire on a deleted one. PyQt6's QTimer.singleShot has no overload that takes a context object, so a parented timer is the way to tie the timer's lifetime to the window.

Testing

  • New test_cuda_prompt_shows_after_delay: on a simulated NVIDIA + CPU-torch machine, the prompt opens for the window.
  • New test_cuda_prompt_does_not_fire_after_window_is_deleted: fails without the fix and passes with it.
  • Both tests mock window.settings, so they don't write CUDA_PROMPT_SHOWN to the real user settings.
  • tests/widgets/main_window_test.py and tests/widgets/cuda_installer_widget_test.py pass 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

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
@raivisdejus
raivisdejus enabled auto-merge (squash) October 24, 2026 14:11
@codecov

codecov Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.21%. Comparing base (23d848b) to head (7c10840).

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     
Flag Coverage Δ
Linux 83.47% <100.00%> (+0.07%) ⬆️
macOS 83.74% <100.00%> (+0.11%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@raivisdejus
raivisdejus merged commit ee01182 into chidiwilliams:main Oct 24, 2026
15 of 16 checks passed
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.

2 participants