fix: close live document before automation exit

This commit is contained in:
codex
2026-08-03 17:04:56 +03:00
parent d8e61b7a5e
commit e7765cbdda
2 changed files with 14 additions and 6 deletions
@@ -316,9 +316,15 @@ internal sealed class FirstLimitedApplyAutomationCoordinator
// Do not close a cached automation document and then reuse it. Resolve
// the currently-live document only at the final quiescent callback.
var active = AcadApplication.DocumentManager.MdiActiveDocument;
if (active is null) { AcadApplication.Quit(); return; }
transitions.Add("NativeQuitDispatched");
active.SendStringToExecute("_.QUIT _N ", true, false, false);
if (active is not null)
{
transitions.Add("ActiveDocumentCloseRequested");
active.CloseAndDiscard();
}
// Application.Quit alone leaves the script host alive. Close the
// live document first, then request normal application shutdown.
transitions.Add("ApplicationQuitRequested");
AcadApplication.Quit();
}
catch (System.Exception exception)
{