Skip to content

Fix Refresh crash when no backup folder is available - #11

Open
jpmartins98 wants to merge 1 commit into
sachk:mainfrom
jpmartins98:fix-empty-refresh-crash
Open

Fix Refresh crash when no backup folder is available#11
jpmartins98 wants to merge 1 commit into
sachk:mainfrom
jpmartins98:fix-empty-refresh-crash

Conversation

@jpmartins98

@jpmartins98 jpmartins98 commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Summary

Make Refresh safe when no backup folder is selected, remembered, or automatically discovered.

Problem and root cause

The landing page currently creates a FunctionWorker even when there are no roots to scan. Because this zero-work worker can complete immediately and is only retained in a local variable, the operation has a race-prone lifetime and can crash the application when Refresh is clicked in the empty state.

Changes

  • Filter recent backup hints before starting a refresh.
  • Resolve automatically discovered roots once per refresh.
  • Complete synchronously with an empty result when no roots are available.
  • Pass the resolved automatic roots into _discover_backup_rows() instead of discovering them again.
  • Retain the active FunctionWorker on LandingPage until it reports a result or error.
  • Clear the worker reference in both completion paths.
  • Preserve the existing pending-refresh behavior.
  • Add a regression test proving that an empty refresh does not start the thread pool and returns to the idle state.

Why this PR is needed

Refresh is visible before a backup is selected and must be safe on a clean installation, after removing a backup drive, or on systems where automatic discovery returns nothing. An empty state is normal application state, not an exceptional condition.

Compatibility and risk

Scans with real roots continue through the existing background worker. The synchronous path is used only when there is provably no work. Backup parsing and discovery rules are unchanged.

Validation

  • Targeted refresh and application tests: 33 passed.
  • Combined validation with all proposed PRs: 118 passed, 2 skipped.
  • Validated with a real Qt landing page using the offscreen platform.
  • No merge conflicts with the other proposed branches.

AI disclosure

This PR and all changes introduced by it, including implementation, tests, and this description, were generated by OpenAI Codex under the user's direction. The resulting changes were reviewed through source inspection and the validation described above

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.

1 participant