From b74b1f936abc1321024ff3699ae58d977d333785 Mon Sep 17 00:00:00 2001 From: Intubun <41478036+Intubun@users.noreply.github.com> Date: Mon, 4 May 2026 13:29:49 +0200 Subject: [PATCH] Save and restore GrDisplayStatus across long operations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CIFGenSubcells() and extSubtree() set GrDisplayStatus = DISPLAY_IN_PROGRESS while they run a 5-second progress timer, then unconditionally restore DISPLAY_IDLE on exit. In native builds the initial state is always IDLE, so this is harmless. In WASM/headless builds the null display driver sets DISPLAY_SUSPEND at startup, and forcing IDLE at the end of these long operations destroys the SUSPEND guard that protects WindUpdate() from running display callbacks against a non-existent screen. Save the previous status before overwriting and restore it on exit. This is also reentrant-safe: nested DISPLAY_IN_PROGRESS scopes (e.g. extract followed by gds write) now keep the outer state intact. * cif/CIFhier.c — CIFGenSubcells * extract/ExtSubtree.c — extSubtree --- cif/CIFhier.c | 6 ++++-- extract/ExtSubtree.c | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/cif/CIFhier.c b/cif/CIFhier.c index 828bf289..d9b36025 100644 --- a/cif/CIFhier.c +++ b/cif/CIFhier.c @@ -735,8 +735,10 @@ CIFGenSubcells( /* This routine can take a long time, so use the display * timer to force a 5-second progress check (like is done - * with extract) + * with extract). Save and restore GrDisplayStatus so that + * a headless (DISPLAY_SUSPEND) build isn't left in DISPLAY_IDLE. */ + unsigned char savedDisplayStatus = GrDisplayStatus; GrDisplayStatus = DISPLAY_IN_PROGRESS; SigSetTimer(5); /* Print at 5-second intervals */ cuts = 0; @@ -861,7 +863,7 @@ CIFGenSubcells( CIFHierTileOps += CIFTileOps - oldTileOps; - GrDisplayStatus = DISPLAY_IDLE; + GrDisplayStatus = savedDisplayStatus; SigRemoveTimer(); UndoEnable(); diff --git a/extract/ExtSubtree.c b/extract/ExtSubtree.c index 7b68b1fd..733baddf 100644 --- a/extract/ExtSubtree.c +++ b/extract/ExtSubtree.c @@ -174,8 +174,10 @@ extSubtree(parentUse, reg, f) int cuts, totcuts; float pdone, plast; SearchContext scx; + int savedDisplayStatus; /* Use the display timer to force a 5-second progress check */ + savedDisplayStatus = GrDisplayStatus; GrDisplayStatus = DISPLAY_IN_PROGRESS; SigSetTimer(5); /* Print at 5-second intervals */ @@ -348,7 +350,7 @@ done: /* Output connections and node adjustments */ extOutputConns(&ha.ha_connHash, f); HashKill(&ha.ha_connHash); - GrDisplayStatus = DISPLAY_IDLE; + GrDisplayStatus = savedDisplayStatus; SigRemoveTimer(); /* Clear the CU_SUB_EXTRACTED flag from all children instances */