fix(editor): a superseded export plan or estimate never replaces the current one
Undo and redo bring back the same project instance, so a cancelled planning request passed the 'still current' check and published an empty plan (Render disabled) or blank preset estimates. Only requests that ran now publish. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
3 files changed
+11
-2
No files matched your search
@@ -577,19 +577,24 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
|
||||
private async Task RunPlanAsync(ExportPlanner planner, ProjectSettings project)
|
||||
{
|
||||
ExportPlan? plan = null;
|
||||
// A superseded request ends quietly without planning; undo and redo bring back the very same project instance,
|
||||
// so only a request that ran may publish (a failed plan publishes null: "nothing to render").
|
||||
var ran = false;
|
||||
try
|
||||
{
|
||||
await _plans.Schedule(_ =>
|
||||
{
|
||||
plan = planner.Plan(project);
|
||||
ran = true;
|
||||
return Task.CompletedTask;
|
||||
});
|
||||
}
|
||||
catch (Exception ex) when (ex is ArgumentException or InvalidOperationException or RenderException)
|
||||
{
|
||||
Log.Warning("editor", "Planning the export failed", ex);
|
||||
ran = true;
|
||||
}
|
||||
if (_disposed || !ReferenceEquals(planner, Planner) || !ReferenceEquals(project, Session.Project)) return;
|
||||
if (!ran || _disposed || !ReferenceEquals(planner, Planner) || !ReferenceEquals(project, Session.Project)) return;
|
||||
_planned = true;
|
||||
Plan = plan;
|
||||
OnPropertyChanged(nameof(RenderText));
|
||||
|
||||
@@ -412,6 +412,7 @@ public sealed class ExportTab : EditorTab
|
||||
var project = Editor.Session.Project;
|
||||
var cards = Cards;
|
||||
var plans = new ExportPlan?[cards.Count];
|
||||
var done = false;
|
||||
try
|
||||
{
|
||||
await _estimates.Schedule(token =>
|
||||
@@ -422,6 +423,7 @@ public sealed class ExportTab : EditorTab
|
||||
var export = project.Export with { Preset = project.Export.Preset.WithManual(cards[i].Choice.ExportPresetId), Overrides = new ExportOverrides(), Batch = [] };
|
||||
plans[i] = Editor.Planner.Plan(project, export);
|
||||
}
|
||||
done = true;
|
||||
return Task.CompletedTask;
|
||||
});
|
||||
}
|
||||
@@ -430,7 +432,8 @@ public sealed class ExportTab : EditorTab
|
||||
Core.Diagnostics.Log.Warning("editor", "Preset estimates failed", ex);
|
||||
return;
|
||||
}
|
||||
if (!ReferenceEquals(cards, Cards) || !ReferenceEquals(project, Editor.Session.Project)) return;
|
||||
// A superseded request stops part way (or never starts); undo can bring back the same project instance.
|
||||
if (!done || !ReferenceEquals(cards, Cards) || !ReferenceEquals(project, Editor.Session.Project)) return;
|
||||
for (var i = 0; i < cards.Count; i++) cards[i].Update(plans[i]);
|
||||
}
|
||||
|
||||
|
||||
@@ -125,6 +125,7 @@ public sealed class EditorSmokeTests
|
||||
editor.RedoCommand.Execute(null);
|
||||
Assert.Equal(0.5, editor.Session.Project.Exposure.ExposureOffsetEv);
|
||||
await editor.Session.FlushAsync();
|
||||
Assert.True(await editor.WhenIdleAsync(TimeSpan.FromSeconds(60)));
|
||||
Assert.NotNull(editor.Plan, "the export is planned");
|
||||
}
|
||||
finally
|
||||
|
||||
Reference in new issue
Block a user