fix: recover fixture activation raised during document open
This commit is contained in:
@@ -195,6 +195,16 @@ internal sealed class FirstLimitedApplyAutomationCoordinator
|
||||
document.CommandCancelled += OnCommandCancelled;
|
||||
documentHandlersSubscribed = true;
|
||||
Transition(CoordinatorState.Running, "AutomationRunning");
|
||||
// DocumentActivated can be raised synchronously by Open before the
|
||||
// coordinator receives the returned Document. Confirm the current
|
||||
// active document after assignment so that one missed event cannot
|
||||
// strand the workflow waiting for another startup Idle.
|
||||
if (ReferenceEquals(AcadApplication.DocumentManager.MdiActiveDocument, document))
|
||||
{
|
||||
fixtureDocumentActivated = true;
|
||||
transitions.Add("FixtureDocumentActiveAfterOpen");
|
||||
TryActivateProjectAndVerifyContext();
|
||||
}
|
||||
}
|
||||
catch (System.Exception ex) { FailFromCallback("Start", ex, "AUTOMATION_START_FAILED"); }
|
||||
}
|
||||
|
||||
@@ -98,6 +98,15 @@ public sealed class FoundationTests
|
||||
Assert.Contains("FixtureDocumentActivated", source);
|
||||
}
|
||||
|
||||
[Fact] public void AutomationDocumentActivation_RecoversSynchronousOpenEvent()
|
||||
{
|
||||
var source = File.ReadAllText(Path.Combine(ProjectRoot, "src", "PRecAnnot.Plant3D2026", "FirstLimitedApplyAutomation.cs"));
|
||||
var start = source[source.IndexOf("public void Start()", StringComparison.Ordinal)..source.IndexOf("private void CompleteLifecycleProbe", StringComparison.Ordinal)];
|
||||
Assert.Contains("FixtureDocumentActiveAfterOpen", start);
|
||||
Assert.Contains("ReferenceEquals(AcadApplication.DocumentManager.MdiActiveDocument, document)", start);
|
||||
Assert.Contains("TryActivateProjectAndVerifyContext();", start);
|
||||
}
|
||||
|
||||
[Fact] public void AutomationControlledExit_QueuesNativeQuitAfterPublicCommand()
|
||||
{
|
||||
var source = File.ReadAllText(Path.Combine(ProjectRoot, "src", "PRecAnnot.Plant3D2026", "FirstLimitedApplyAutomation.cs"));
|
||||
|
||||
Reference in New Issue
Block a user