Skip to content

[cuegui] Fix crash when closing preview dialog before images are ready#2395

Merged
ramonfigueiredo merged 1 commit into
AcademySoftwareFoundation:masterfrom
ramonfigueiredo:cuegui/fix-cuetopia-preview-dialog-close-crash
Jun 4, 2026
Merged

[cuegui] Fix crash when closing preview dialog before images are ready#2395
ramonfigueiredo merged 1 commit into
AcademySoftwareFoundation:masterfrom
ramonfigueiredo:cuegui/fix-cuetopia-preview-dialog-close-crash

Conversation

@ramonfigueiredo

@ramonfigueiredo ramonfigueiredo commented Jun 4, 2026

Copy link
Copy Markdown
Collaborator

Related Issues

Summarize your change.

  • Closing the "Waiting for preview images..." dialog before the preview images were ready crashed the app with "QThread: Destroyed while thread is still running" / Aborted.
  • The close handler only set the watch thread's terminate flag without waiting for the QThread to exit, so the thread (parented to the dialog) was destroyed mid-execution, which Qt treats as a fatal error.
  • Fix PreviewProcessorDialog.__close to stop the thread and wait() for it to finish before the dialog is destroyed, and guard against the thread not yet existing.
  • Make PreviewProcessorWatchThread.run sleep in small slices so it reacts to stop() promptly instead of freezing the GUI for up to a second, and move the timeout check before the sleep.

- Closing the "Waiting for preview images..." dialog before the preview images were ready crashed the app with "QThread: Destroyed while thread is still running" / Aborted.
- The close handler only set the watch thread's terminate flag without waiting for the QThread to exit, so the thread (parented to the dialog) was destroyed mid-execution, which Qt treats as a fatal error.
- Fix PreviewProcessorDialog.__close to stop the thread and wait() for it to finish before the dialog is destroyed, and guard against the thread not yet existing.
- Make PreviewProcessorWatchThread.run sleep in small slices so it reacts to stop() promptly instead of freezing the GUI for up to a second, and move the timeout check before the sleep.
@coderabbitai

coderabbitai Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The PR fixes thread lifecycle management in the Preview widget. PreviewProcessorDialog.__close now calls stop() and wait() on the watch thread before dialog destruction, preventing Qt fatal errors. PreviewProcessorWatchThread.run replaces a single 1-second sleep with 10 iterations of 0.1-second sleeps that check the terminate flag, enabling responsive GUI shutdown.

Changes

Thread Lifecycle Management

Layer / File(s) Summary
Safe thread shutdown with responsive reaction
cuegui/cuegui/PreviewWidget.py
PreviewProcessorDialog.__close calls stop() and wait() on the watch thread before destruction. PreviewProcessorWatchThread.run checks the terminate flag in 0.1s intervals instead of blocking for 1 second, allowing responsive shutdown.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Suggested reviewers

  • DiegoTavares
  • lithorus

Poem

🐰 The threads now dance in harmony,
No more fatal crashes in our GUI,
With stop() and wait(), we reign supreme,
A hundred milliseconds, a smoother dream!
Qt frowns no more when we depart.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main fix: preventing a crash when closing the preview dialog before images are ready, which directly matches the core changes made to handle thread shutdown properly.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@ramonfigueiredo ramonfigueiredo self-assigned this Jun 4, 2026
@ramonfigueiredo

Copy link
Copy Markdown
Collaborator Author

@DiegoTavares / @lithorus
Ready for review!

@ramonfigueiredo ramonfigueiredo merged commit c1ad07c into AcademySoftwareFoundation:master Jun 4, 2026
24 of 25 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