Skip to content

Let MintPrint Settings close while a Query is running (1.3.4) - #103

Open
boingball wants to merge 1 commit into
mainfrom
fix/prefs-quit-during-query
Open

boingball wants to merge 1 commit into
mainfrom
fix/prefs-quit-during-query

Conversation

@boingball

Copy link
Copy Markdown
Owner

Problem

A user reported this: after connecting once, they reopened MintPrint Settings with the printer switched off. The window seemed stuck in a loop looking for the printer, and they couldn't quit.

Cause:

  • main() runs the startup printer-status refresh (perform_query_flow_allocated) before process_window_events() starts.
  • Every network wait in the Query path (mp_connect_with_timeout, query_printer_attributes send/receive/parse) drained the window's IDCMP port with GT_GetIMsg/GT_ReplyIMsg and discarded each message. Close-gadget clicks were lost.
  • A successful Query saves the endpoint as ip:631. On the next start, port_hint == 631 produced the port list {631, 631}: two attempts each at 8 s, so 4 × 8 s ≈ 32 s of "Trying …:631 (attempt n/3)" lines. On a stack where FIONBIO fails, the code falls back to a blocking connect(), which can take minutes.

Changes

  • New mp_pump_gui_during_query() replaces the five drain loops. It still replies to every message, but records IDCMP_CLOSEWINDOW (cancel + quit) and Ctrl-C (cancel only).
    • The connect wait stops with EINTR on cancel. The receive loop stops and query_printer_attributes() returns the new -3. The perform_query_flow() retry loops stop too.
    • process_window_events() exits straight away if a close arrived during the startup refresh or during a Query started from a button.
  • A saved port 631 is tried on its own (2 attempts, ≈16 s with the printer off) instead of {631, 631}. Explicit non-631 hints and the no-hint case are unchanged.
  • A failed or cancelled Query now reloads the endpoint's capability cache. query_printer_attributes() empties the num_supported_* lists before connecting, so with the printer off they no longer matched the dropdowns still on screen. Ink levels aren't cached, so they stay cleared as before.
  • Version bumped 1.3.3 → 1.3.4. That covers MINTPRINT_SETTINGS_VERSION, the $VER date (23.10.2026), a CHANGELOG entry, and the README / Aminet readme "What's new" sections.

Not changed

  • The blocking-connect() fallback used when IoctlSocket(FIONBIO) fails still can't be interrupted.
  • SSDP/mDNS discovery still discards window messages during its own short, bounded waits.

Testing

  • make -k check locally: every host suite passes. test-postscript couldn't run here because Ghostscript isn't installed; CI installs it. These suites don't cover MintPrintSettings.c.
  • Not compiled or run for m68k. Neither this environment nor CI has the m68k-amigaos toolchain. It needs a make gui build and a check on real hardware:
    1. Query a printer once so ip:631 is saved.
    2. Switch the printer off and reopen Settings.
    3. Click close during "Trying …". The window should close within about 250 ms.
    4. Reopen and wait it out. It should give up after two attempts with "Scan failed", and the dropdowns should keep their cached choices.

Generated by Claude Code

The startup printer-status refresh runs before process_window_events(),
and every network wait drained and discarded the window's IDCMP
messages. With the saved printer switched off, close-gadget clicks were
thrown away until every retry timed out, and a saved "ip:631" endpoint
made perform_query_flow() try port 631 twice over.

- Route the Query's message drains through mp_pump_gui_during_query(),
  which still replies to everything but records IDCMP_CLOSEWINDOW (cancel
  and quit) and Ctrl-C (cancel). Connect, receive and the retry loop stop
  on cancel; query_printer_attributes() returns -3 for it.
- A port hint of 631 is now tried on its own instead of {631, 631}.
- After a failed or cancelled Query, reload the endpoint's capability
  cache so the lists match the dropdowns still on screen.
- Bump MintPrint Settings to 1.3.4 with release notes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EJn7USrjfyvMsbkXBQ7rEp
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