bootstrap: ask before updating, and name a locked folder #10

Merged
jaslopena merged 19 commits from feature/update-consent-dialog into main 2026-10-14 05:46:05 +00:00
Member

The updater currently replaces workbenches silently on every launch. This asks first.

What the user sees. One dialog per startup, listing what is available, with Update now / Not now and a don't ask again box. Nothing to update means no dialog at all - the manifest is walked first and the whole batch is confirmed once. After applying, a transient status-bar message summarises the result and offers a restart, since the new files need a reload before they are what runs.

'Don't ask again' sets SkipUpdatePrompt in User parameter:BaseApp/Preferences/Mod/ComfacCAD/Update, the same group as the channel preference: per-user, outside Mod/, and untouched by any workbench update. Edit -> Preferences -> ComfacCAD is where it is cleared.

Threading. run_updater_async runs on a daemon thread and Qt widgets may only be touched from the GUI thread, so _on_gui_thread posts via QTimer.singleShot and parks the worker on an Event when a modal answer is needed. Every path is wrapped: a broken dialog must never block an update or startup.

Degrades safely. No Qt, or no answer within 120s, falls back to the previous silent behaviour rather than leaving an install that never updates.

Also fixed here. shutil.rmtree on a target that is in use raised PermissionError, which fell through to the generic Failed downloading workbench line - no hint that anything was locked or what to do about it. Windows holds a directory open when a terminal or editor has it as its working directory, which is common on a dev machine. The error now names the folder and says to close whatever is in it, and download_and_extract_wb returns True/False so the summary reports what actually happened.

Tests. tests/updater_consent_test.py, 21 checks, offline - temp app root, local HTTP server serving purpose-built archives, stubbed FreeCAD / PySide6; no network, no live install touched. Covers decline, accept, restart accepted and declined, dont-ask persistence across a later launch, a locked folder alongside a healthy one, the git-checkout guard, and the nothing-to-do case.

Caveat worth stating: the bootstrap never updates itself and is not in any manifest, so this reaches only users who install a new installer. Existing installs keep today's silent behaviour until then.

Docs: MAINTAINING.md 6.4 currently records 'failure reporting is swallowed'. That is no longer true once this ships, and 6.1's description of silent updating needs a note about the prompt. Worth folding into this PR before merge.

Status: NOT FOR MERGE — prompt unverified

Held deliberately. The update flow works, but the consent prompt has never been
seen to render in a real FreeCAD
, so it must not ship in this state.

What is verified and worth keeping

  • The scoped-import fix (threading, urllib.error) is a real bug fix.
    run_updater_async runs on a daemon thread whose __globals__ do not contain
    this module's names, so a module-level import threading is invisible there.
    This raised NameError: name 'threading' is not defined, caught by the broad
    except and printed as a single report-view line, so the visible symptom was a
    prompt that silently never opened. Do not merge this branch without it.
  • A static guard now catches that class of bug. It parses
    run_updater_async and fails if any stdlib module is used without a local
    import. Verified against history: it flags f5377bc and 778253a (the two
    commits that carried the defect) and passes on the commits before them.
  • The locked-folder message replaces a bare Failed downloading workbench
    with the folder name and what to do. Tested offline with a real held handle.
  • COMFAC_MANIFEST lets the whole flow be exercised without publishing
    anything. Also fixes urllib.error availability.
  • 28 offline checks, including a fake whose QTimer refuses to deliver callbacks
    while the GUI is not up — the condition the original bug depended on.

Why the prompt is not ready

run_updater_async is called at InitGui.py import, before app.exec(). At that
moment FreeCADGui.getMainWindow() returns None for tens of seconds, so:

  • a QMessageBox queued there is never drawn (and, when forced, renders EMPTY —
    parenting, adjustSize() and raise_() do not fix it);
  • a task panel is the right mechanism (it is what every tool in Mod/Comfac-2D
    uses and is drawn inside the main window), but the readiness gate that would
    reach it times out before the window exists;
  • the fallback then applies the update silently, so "the workbench updated" is
    not evidence that the prompt was shown or answered.

Net effect today: the update applies, and the prompt does not appear.

The way to finish it

Fire the prompt after FreeCAD owns the frame rather than racing startup: a
document observer (slotActivateDocument) or a workbench Activated() hook.
The flow's worker/prompt split can stay; only the trigger changes. Write the test
to model FreeCAD's startup ordering first — three rounds of this were lost to
offline tests passing while the real application disagreed.

The updater currently replaces workbenches silently on every launch. This asks first. **What the user sees.** One dialog per startup, listing what is available, with `Update now` / `Not now` and a *don't ask again* box. Nothing to update means no dialog at all - the manifest is walked first and the whole batch is confirmed once. After applying, a transient status-bar message summarises the result and offers a restart, since the new files need a reload before they are what runs. **'Don't ask again'** sets `SkipUpdatePrompt` in `User parameter:BaseApp/Preferences/Mod/ComfacCAD/Update`, the same group as the channel preference: per-user, outside `Mod/`, and untouched by any workbench update. Edit -> Preferences -> ComfacCAD is where it is cleared. **Threading.** `run_updater_async` runs on a daemon thread and Qt widgets may only be touched from the GUI thread, so `_on_gui_thread` posts via `QTimer.singleShot` and parks the worker on an `Event` when a modal answer is needed. Every path is wrapped: a broken dialog must never block an update or startup. **Degrades safely.** No Qt, or no answer within 120s, falls back to the previous silent behaviour rather than leaving an install that never updates. **Also fixed here.** `shutil.rmtree` on a target that is in use raised `PermissionError`, which fell through to the generic `Failed downloading workbench` line - no hint that anything was locked or what to do about it. Windows holds a directory open when a terminal or editor has it as its working directory, which is common on a dev machine. The error now names the folder and says to close whatever is in it, and `download_and_extract_wb` returns True/False so the summary reports what actually happened. **Tests.** `tests/updater_consent_test.py`, 21 checks, offline - temp app root, local HTTP server serving purpose-built archives, stubbed FreeCAD / PySide6; no network, no live install touched. Covers decline, accept, restart accepted and declined, dont-ask persistence across a later launch, a locked folder alongside a healthy one, the git-checkout guard, and the nothing-to-do case. **Caveat worth stating:** the bootstrap never updates itself and is not in any manifest, so this reaches only users who install a new installer. Existing installs keep today's silent behaviour until then. **Docs:** `MAINTAINING.md` 6.4 currently records 'failure reporting is swallowed'. That is no longer true once this ships, and 6.1's description of silent updating needs a note about the prompt. Worth folding into this PR before merge. --- ## Status: NOT FOR MERGE — prompt unverified Held deliberately. The update flow works, but **the consent prompt has never been seen to render in a real FreeCAD**, so it must not ship in this state. ### What is verified and worth keeping * **The scoped-import fix (`threading`, `urllib.error`) is a real bug fix.** `run_updater_async` runs on a daemon thread whose `__globals__` do not contain this module's names, so a module-level `import threading` is invisible there. This raised `NameError: name 'threading' is not defined`, caught by the broad `except` and printed as a single report-view line, so the visible symptom was a prompt that silently never opened. **Do not merge this branch without it.** * **A static guard now catches that class of bug.** It parses `run_updater_async` and fails if any stdlib module is used without a local import. Verified against history: it flags `f5377bc` and `778253a` (the two commits that carried the defect) and passes on the commits before them. * **The locked-folder message** replaces a bare `Failed downloading workbench` with the folder name and what to do. Tested offline with a real held handle. * **`COMFAC_MANIFEST`** lets the whole flow be exercised without publishing anything. Also fixes `urllib.error` availability. * 28 offline checks, including a fake whose `QTimer` refuses to deliver callbacks while the GUI is not up — the condition the original bug depended on. ### Why the prompt is not ready `run_updater_async` is called at `InitGui.py` import, before `app.exec()`. At that moment `FreeCADGui.getMainWindow()` returns `None` for tens of seconds, so: * a `QMessageBox` queued there is never drawn (and, when forced, renders EMPTY — parenting, `adjustSize()` and `raise_()` do not fix it); * a task panel is the right mechanism (it is what every tool in `Mod/Comfac-2D` uses and is drawn inside the main window), but the readiness gate that would reach it times out before the window exists; * the fallback then applies the update silently, so "the workbench updated" is **not** evidence that the prompt was shown or answered. Net effect today: the update applies, and the prompt does not appear. ### The way to finish it Fire the prompt **after FreeCAD owns the frame** rather than racing startup: a document observer (`slotActivateDocument`) or a workbench `Activated()` hook. The flow's worker/prompt split can stay; only the trigger changes. Write the test to model FreeCAD's startup ordering first — three rounds of this were lost to offline tests passing while the real application disagreed.
Updates applied silently on every launch. The user now gets one dialog per
startup listing what is available - 'Update now' / 'Not now' - with a 'don't
ask again' box that sets SkipUpdatePrompt in the same preference group as the
channel. After applying, a transient status-bar message summarises the result
and offers a restart, since the new files need a reload to take effect.

The prompt only appears when there is something to do: the manifest is walked
first and the whole batch is confirmed at once, so a startup with nothing to
update produces no UI at all. A headless session (no Qt, or no answer within
120s) falls back to the previous silent behaviour rather than leaving an
install that never updates.

Threading: run_updater_async runs on a daemon thread and Qt widgets may only be
touched from the GUI thread. _on_gui_thread posts via QTimer.singleShot and
parks the worker on an Event when a modal answer is needed, so the dialog is
raised on the GUI thread without freezing FreeCAD. Every path is wrapped - a
broken dialog must never block an update or startup.

Also fixes the failure message for a locked folder. shutil.rmtree on a target
that is in use (Windows holds a directory open when a terminal or editor has it
as its CWD) raised PermissionError, which fell through to the generic 'Failed
downloading workbench' line - no hint that anything was locked or what to do.
It now names the folder and says to close whatever is in it. download_and_extract_wb
returns True/False so the summary reports what actually happened.

Verified with tests/updater_consent_test.py (21 checks, offline): decline,
accept, restart accepted and declined, dont-ask persistence, a locked folder
alongside a healthy one, the git-checkout guard, and the no-op case.
Drives the real run_updater_async against a temp app root, a local HTTP server
serving purpose-built archives, and stubbed FreeCAD / PySide6 - no network, no
live install touched. 21 checks: decline, accept, restart accepted and declined,
'don't ask again' persistence across a later launch, a locked folder alongside a
healthy one, the git-checkout guard, and the nothing-to-do case.

One world for every scenario on purpose. A fresh sandbox per scenario looked
tidier but was wrong: each sandbox reassigns sys.modules['FreeCAD'], so a worker
thread still finishing the previous scenario wrote into the next sandbox and made
its dialogs look like the new run's. Two checks failed that way for reasons that
had nothing to do with the code under test.
In the distribution repo InitGui.py is a sibling of tests/; in the installer
working copy the bootstrap is the dist-repo clone one level further down. The
suite hardcoded the latter and exited 2 from its committed home. Try both.
Exercising the consent prompt, the locked-folder path or the channel fallback
previously meant pointing the whole install at a different manifest, which is
not something you can do to a live install safely -- the only seam was to
publish a release, or to edit the deployed copy by hand.

COMFAC_MANIFEST takes a URL or a local path and wins over both the installer's
staged manifest and the remote one. Read once at startup, unset everywhere in
normal use, and it changes nothing about the default path: with the variable
absent the function is byte-for-byte the same behaviour as before.

This is a test seam, not a user feature. It cannot be set from inside FreeCAD,
so it cannot be used to redirect someone else's install.
Three defects, all found by running this in a real FreeCAD rather than the
offline suite -- which passed throughout, because its fake ran the QTimer
callback immediately instead of modelling an event loop that is not pumping yet.

1. The dialog was never drawn. run_updater_async is called at InitGui.py import,
   before app.exec(). QTimer.singleShot posted into an event loop that did not
   exist yet, so the callback was never delivered and the worker waited on an
   answer to a dialog that was never created. FreeCAD's window had no dialog in
   it at all, while the thread sat blocked.

   _on_gui_thread now waits for FreeCADGui.getMainWindow() before posting, with a
   bounded wait, and reports why it could not post instead of stalling.

2. The dialog appeared empty. An unparented QMessageBox is a top-level widget with
   no owner: nothing sizes it and nothing raises it, so it showed as a small frame
   with nothing in it. Both dialogs are now parented to FreeCAD's main window and
   explicitly sized and raised (_present), each call guarded individually so a Qt
   build missing raise_() does not silently disable the whole dialog.

3. Failure modes are now distinct rather than collapsed into 'no'. _on_gui_thread
   returns 'ok' / 'no_gui' / 'timeout' / 'error'. That matters: a timeout means the
   user did not answer, so nothing is changed; 'no_gui' means there was no way to
   ask, so the update proceeds and says once that the prompt was skipped. Treating
   them alike either stalled startup for a minute (two chained 30s GUI waits) or
   silently guessed on the user's behalf.

The GUI wait is a one-shot: once the main window has been seen, later calls do not
wait for it again, and the restart offer does not re-wait at all. Startup with no
window went from 242s to under a second.

Tests: the suite now models the real startup (getMainWindow() returns None until
the GUI is up) and asserts the flow does not hang. 25 checks, stable over repeated
runs.
The dialog was still unreliable after the previous fix, because the readiness
gate polled getMainWindow() from the worker thread in a tight loop, competing
with FreeCAD while it built the GUI. Measured here, the window took tens of
seconds to appear, so a 30s budget sat right on the boundary: sometimes the
prompt was reached, sometimes it silently fell back.

The check is now driven entirely by the GUI thread. QTimer.singleShot callbacks
are queued and delivered once the loop runs, so re-posting from inside the
callback polls 'as soon as the loop lets me', with nothing spinning or sleeping
on the worker -- it waits on an Event the GUI thread sets. The budget is a named
30s, spent only when an update is actually pending, since the prompt is only
reached after the manifest says there is something to do.

Also fails fast when QApplication.instance() is None: that is not a GUI session,
so no window is coming and waiting out the budget would stall startup for
nothing.

Test note: the fake QTimer now refuses to deliver callbacks while the GUI is not
up, which is what a real event loop does and is the exact condition the original
bug depended on. The previous fake ran callbacks immediately and made a broken
dialog look like it worked. 25 checks.
The consent dialog rendered as an EMPTY box in a real FreeCAD. Parenting it to
the main window, adjustSize() and raise_() all failed to make its content appear,
so this was not a sizing problem: a QMessageBox raised from this thread during
startup does not draw its content at all.

Both prompts are now FreeCAD task panels built from ordinary Qt layouts, the same
mechanism every tool in Mod/Comfac-2D uses for its own dialog, and drawn inside
the main window rather than as a separate top-level widget. showDialog() returns
as soon as the panel is up, so the worker polls a result dict the panel fills in
from its own buttons; accept()/reject() (built-in chrome, or the panel tab being
closed) record no answer rather than an accidental yes, so closing the panel never
triggers an update.

The QMessageBox helpers (_parent_window, _present) are gone with their last
caller. Panel labels are exposed as attributes so the flow stays testable without
a GUI.

Tests: the suite now models task panels and FreeCADGui.Control.showDialog, and its
QTimer refuses to deliver callbacks while the GUI is not up -- the condition the
original bug depended on. 27 checks, including a round trip proving both answers
reach the worker.
The prompt never appeared because the updater crashed before it could ask:

    AutoSetup Network Error: Update checking failed: name 'threading' is not defined

run_updater_async runs on a daemon thread whose __globals__ do not contain this
module's names -- the function's own docstring says so, and every other module it
uses is imported locally for exactly that reason. 	hreading (used by the new
GUI hop) and urllib.error were not. The NameError was caught by the broad
except at the end of the function and printed one line to the report view, so the
visible symptom was a dialog that silently never opened.

Adds a static guard to the test suite: it parses run_updater_async and fails if any
stdlib module is referenced without an import inside the function. Verified against
history -- it flags f5377bc and 778253a, the two commits that carried the defect,
and passes on the commits before it.
Author
Member

Flagged not for merge (status section in the description).

Summary: the prompt has never been seen to render in a real FreeCAD, so it must not ship. The rest of the branch is verified and worth keeping -- notably the threading import fix, without which the updater raises NameError on every launch and silently does nothing.

Deferred by request; the description records what was learned and the suggested way to finish it (fire the prompt after FreeCAD owns the frame, via a document observer or workbench Activated(), instead of racing startup).

Flagged **not for merge** (status section in the description). Summary: the prompt has never been seen to render in a real FreeCAD, so it must not ship. The rest of the branch is verified and worth keeping -- notably the `threading` import fix, without which the updater raises `NameError` on every launch and silently does nothing. Deferred by request; the description records what was learned and the suggested way to finish it (fire the prompt after FreeCAD owns the frame, via a document observer or workbench `Activated()`, instead of racing startup).
The prompt never rendered in a real FreeCAD. Root cause, verified against the
PySide6 6.8.3 FreeCAD ships: QTimer.singleShot(ms, fn) with no receiver queues
fn on the CALLING thread's event loop, and the updater runs on a plain Python
thread that has none. The readiness poll was therefore never delivered, its 30s
budget always ran out, and the fallback updated silently. The "empty box" seen
earlier had the same cause: the widget was built off the GUI thread.

- _post() queues onto the GUI thread with the application object as context.
  A delayed timer is still created on the calling thread even with a context
  (Qt refuses it), so delays are scheduled from the GUI thread instead.
- The wait for the main window has no time limit; the answer clock starts
  only once the prompt is on screen.
- No GUI, a prompt that fails to open, or no answer now DEFERS the update to
  the next launch. Updating silently is what hid this bug. "Don't ask again"
  still updates automatically, as chosen.
- The prompt is a non-modal QDialog over the main window, not a task panel:
  in FreeCAD 1.1's default layout the Tasks view is not brought forward, so
  the panel was created and never seen.
- Restart now: there is no Std_Restart in FreeCAD 1.1. It now closes the main
  window (unsaved-document prompts still apply) and relaunches with the same
  arguments, as Std_RestartInSafeMode does.
- The prompt's button slots used FreeCADGui without importing it.

Tests: the fakes now model Qt threading -- a fake GUI thread, the updater on a
worker, a bare or delayed singleShot from the worker never delivered, and a
late main window. 39 checks. Against the previous InitGui.py they fail 20 of
37 with the field symptom. The scoping guard now resolves names per nested
function, which is what caught the button slots.

scripts/try_update_prompt.py launches a sandboxed FreeCAD (own user home,
COMFAC_MANIFEST, a non-git dummy workbench) where the prompt can be seen on a
developer machine, whose git checkouts are always skipped.

Verified live in FreeCAD 1.1.3 through that script: the prompt renders about
5s after the window; Update now, Not now, Restart now, Later and
"Don't ask again" (and its persistence) all behave as described.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jaslopena force-pushed feature/update-consent-dialog from 0b1ab0dbc4 to f24d20a062
Some checks are pending
runner-smoke / hello (push) Waiting to run
2026-10-14 03:38:14 +00:00
Compare
Author
Member

Flagged: Can now be Merged

Flagged: **Can now be Merged**
Updates applied silently on every launch. The user now gets one dialog per
startup listing what is available - 'Update now' / 'Not now' - with a 'don't
ask again' box that sets SkipUpdatePrompt in the same preference group as the
channel. After applying, a transient status-bar message summarises the result
and offers a restart, since the new files need a reload to take effect.

The prompt only appears when there is something to do: the manifest is walked
first and the whole batch is confirmed at once, so a startup with nothing to
update produces no UI at all. A headless session (no Qt, or no answer within
120s) falls back to the previous silent behaviour rather than leaving an
install that never updates.

Threading: run_updater_async runs on a daemon thread and Qt widgets may only be
touched from the GUI thread. _on_gui_thread posts via QTimer.singleShot and
parks the worker on an Event when a modal answer is needed, so the dialog is
raised on the GUI thread without freezing FreeCAD. Every path is wrapped - a
broken dialog must never block an update or startup.

Also fixes the failure message for a locked folder. shutil.rmtree on a target
that is in use (Windows holds a directory open when a terminal or editor has it
as its CWD) raised PermissionError, which fell through to the generic 'Failed
downloading workbench' line - no hint that anything was locked or what to do.
It now names the folder and says to close whatever is in it. download_and_extract_wb
returns True/False so the summary reports what actually happened.

Verified with tests/updater_consent_test.py (21 checks, offline): decline,
accept, restart accepted and declined, dont-ask persistence, a locked folder
alongside a healthy one, the git-checkout guard, and the no-op case.
Drives the real run_updater_async against a temp app root, a local HTTP server
serving purpose-built archives, and stubbed FreeCAD / PySide6 - no network, no
live install touched. 21 checks: decline, accept, restart accepted and declined,
'don't ask again' persistence across a later launch, a locked folder alongside a
healthy one, the git-checkout guard, and the nothing-to-do case.

One world for every scenario on purpose. A fresh sandbox per scenario looked
tidier but was wrong: each sandbox reassigns sys.modules['FreeCAD'], so a worker
thread still finishing the previous scenario wrote into the next sandbox and made
its dialogs look like the new run's. Two checks failed that way for reasons that
had nothing to do with the code under test.
In the distribution repo InitGui.py is a sibling of tests/; in the installer
working copy the bootstrap is the dist-repo clone one level further down. The
suite hardcoded the latter and exited 2 from its committed home. Try both.
Exercising the consent prompt, the locked-folder path or the channel fallback
previously meant pointing the whole install at a different manifest, which is
not something you can do to a live install safely -- the only seam was to
publish a release, or to edit the deployed copy by hand.

COMFAC_MANIFEST takes a URL or a local path and wins over both the installer's
staged manifest and the remote one. Read once at startup, unset everywhere in
normal use, and it changes nothing about the default path: with the variable
absent the function is byte-for-byte the same behaviour as before.

This is a test seam, not a user feature. It cannot be set from inside FreeCAD,
so it cannot be used to redirect someone else's install.
Three defects, all found by running this in a real FreeCAD rather than the
offline suite -- which passed throughout, because its fake ran the QTimer
callback immediately instead of modelling an event loop that is not pumping yet.

1. The dialog was never drawn. run_updater_async is called at InitGui.py import,
   before app.exec(). QTimer.singleShot posted into an event loop that did not
   exist yet, so the callback was never delivered and the worker waited on an
   answer to a dialog that was never created. FreeCAD's window had no dialog in
   it at all, while the thread sat blocked.

   _on_gui_thread now waits for FreeCADGui.getMainWindow() before posting, with a
   bounded wait, and reports why it could not post instead of stalling.

2. The dialog appeared empty. An unparented QMessageBox is a top-level widget with
   no owner: nothing sizes it and nothing raises it, so it showed as a small frame
   with nothing in it. Both dialogs are now parented to FreeCAD's main window and
   explicitly sized and raised (_present), each call guarded individually so a Qt
   build missing raise_() does not silently disable the whole dialog.

3. Failure modes are now distinct rather than collapsed into 'no'. _on_gui_thread
   returns 'ok' / 'no_gui' / 'timeout' / 'error'. That matters: a timeout means the
   user did not answer, so nothing is changed; 'no_gui' means there was no way to
   ask, so the update proceeds and says once that the prompt was skipped. Treating
   them alike either stalled startup for a minute (two chained 30s GUI waits) or
   silently guessed on the user's behalf.

The GUI wait is a one-shot: once the main window has been seen, later calls do not
wait for it again, and the restart offer does not re-wait at all. Startup with no
window went from 242s to under a second.

Tests: the suite now models the real startup (getMainWindow() returns None until
the GUI is up) and asserts the flow does not hang. 25 checks, stable over repeated
runs.
The dialog was still unreliable after the previous fix, because the readiness
gate polled getMainWindow() from the worker thread in a tight loop, competing
with FreeCAD while it built the GUI. Measured here, the window took tens of
seconds to appear, so a 30s budget sat right on the boundary: sometimes the
prompt was reached, sometimes it silently fell back.

The check is now driven entirely by the GUI thread. QTimer.singleShot callbacks
are queued and delivered once the loop runs, so re-posting from inside the
callback polls 'as soon as the loop lets me', with nothing spinning or sleeping
on the worker -- it waits on an Event the GUI thread sets. The budget is a named
30s, spent only when an update is actually pending, since the prompt is only
reached after the manifest says there is something to do.

Also fails fast when QApplication.instance() is None: that is not a GUI session,
so no window is coming and waiting out the budget would stall startup for
nothing.

Test note: the fake QTimer now refuses to deliver callbacks while the GUI is not
up, which is what a real event loop does and is the exact condition the original
bug depended on. The previous fake ran callbacks immediately and made a broken
dialog look like it worked. 25 checks.
The consent dialog rendered as an EMPTY box in a real FreeCAD. Parenting it to
the main window, adjustSize() and raise_() all failed to make its content appear,
so this was not a sizing problem: a QMessageBox raised from this thread during
startup does not draw its content at all.

Both prompts are now FreeCAD task panels built from ordinary Qt layouts, the same
mechanism every tool in Mod/Comfac-2D uses for its own dialog, and drawn inside
the main window rather than as a separate top-level widget. showDialog() returns
as soon as the panel is up, so the worker polls a result dict the panel fills in
from its own buttons; accept()/reject() (built-in chrome, or the panel tab being
closed) record no answer rather than an accidental yes, so closing the panel never
triggers an update.

The QMessageBox helpers (_parent_window, _present) are gone with their last
caller. Panel labels are exposed as attributes so the flow stays testable without
a GUI.

Tests: the suite now models task panels and FreeCADGui.Control.showDialog, and its
QTimer refuses to deliver callbacks while the GUI is not up -- the condition the
original bug depended on. 27 checks, including a round trip proving both answers
reach the worker.
The prompt never appeared because the updater crashed before it could ask:

    AutoSetup Network Error: Update checking failed: name 'threading' is not defined

run_updater_async runs on a daemon thread whose __globals__ do not contain this
module's names -- the function's own docstring says so, and every other module it
uses is imported locally for exactly that reason. 	hreading (used by the new
GUI hop) and urllib.error were not. The NameError was caught by the broad
except at the end of the function and printed one line to the report view, so the
visible symptom was a dialog that silently never opened.

Adds a static guard to the test suite: it parses run_updater_async and fails if any
stdlib module is referenced without an import inside the function. Verified against
history -- it flags f5377bc and 778253a, the two commits that carried the defect,
and passes on the commits before it.
The prompt never rendered in a real FreeCAD. Root cause, verified against the
PySide6 6.8.3 FreeCAD ships: QTimer.singleShot(ms, fn) with no receiver queues
fn on the CALLING thread's event loop, and the updater runs on a plain Python
thread that has none. The readiness poll was therefore never delivered, its 30s
budget always ran out, and the fallback updated silently. The "empty box" seen
earlier had the same cause: the widget was built off the GUI thread.

- _post() queues onto the GUI thread with the application object as context.
  A delayed timer is still created on the calling thread even with a context
  (Qt refuses it), so delays are scheduled from the GUI thread instead.
- The wait for the main window has no time limit; the answer clock starts
  only once the prompt is on screen.
- No GUI, a prompt that fails to open, or no answer now DEFERS the update to
  the next launch. Updating silently is what hid this bug. "Don't ask again"
  still updates automatically, as chosen.
- The prompt is a non-modal QDialog over the main window, not a task panel:
  in FreeCAD 1.1's default layout the Tasks view is not brought forward, so
  the panel was created and never seen.
- Restart now: there is no Std_Restart in FreeCAD 1.1. It now closes the main
  window (unsaved-document prompts still apply) and relaunches with the same
  arguments, as Std_RestartInSafeMode does.
- The prompt's button slots used FreeCADGui without importing it.

Tests: the fakes now model Qt threading -- a fake GUI thread, the updater on a
worker, a bare or delayed singleShot from the worker never delivered, and a
late main window. 39 checks. Against the previous InitGui.py they fail 20 of
37 with the field symptom. The scoping guard now resolves names per nested
function, which is what caught the button slots.

scripts/try_update_prompt.py launches a sandboxed FreeCAD (own user home,
COMFAC_MANIFEST, a non-git dummy workbench) where the prompt can be seen on a
developer machine, whose git checkouts are always skipped.

Verified live in FreeCAD 1.1.3 through that script: the prompt renders about
5s after the window; Update now, Not now, Restart now, Later and
"Don't ask again" (and its persistence) all behave as described.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
comfac-dist/ComfacCAD!10
No description provided.