Skip to content

#1983 Guard Library mirrors against post-Save aliasing in version handlers - #1988

Closed
LarryThiessen wants to merge 1 commit into
TimothyLuke:masterfrom
LarryThiessen:fix-1983-library-mirror-aliasing
Closed

#1983 Guard Library mirrors against post-Save aliasing in version handlers#1988
LarryThiessen wants to merge 1 commit into
TimothyLuke:masterfrom
LarryThiessen:fix-1983-library-mirror-aliasing

Conversation

@LarryThiessen

Copy link
Copy Markdown
Contributor

Fixes #1983

Standalone resubmit of the second commit from closed PR #1982 — this part is independent of the content-version storage discussion there and addresses the still-open crash family in #1983.

Problem

After a Save, GSE.ReplaceSequence stores the editor's own sequence object into GSE.Library, so editframe.Sequence and the Library entry are the same table. The editor's per-version handlers also "mirror" their change into the Library display cache, which post-Save runs twice on one Versions array:

  • Delete Version removes two versions per click (2 → 0; the tree shows no version rows).
  • New Version inserts two copies, then Editor.lua:5889: attempt to index field '?' (a nil value) in GUIDrawMacroEditor.
  • Drag-reorder applies the move twice, scrambling order.

All three work before the first Save of the session (separate copies) — that's the tell.

Fix

Guard the three mirror sites with libSeq ~= sequence so the mirror only runs when the Library holds a distinct copy. Also: Delete Version decremented MetaData.Default unconditionally; it now only shifts when the deleted index is at/before the Default (same rule the content-type keys already use).

Verified

In-game: delete keeps the remaining versions; New Version creates exactly one with no error. luac -p clean. 2 files, +22/−5, cherry-picked onto current master (34b29a5).

🤖 Generated with Claude Code

…version handlers

After a Save, GSE.ReplaceSequence stores the editor's own sequence object
into GSE.Library, so editframe.Sequence and the Library entry are the
same table. The editor's per-version handlers each also "mirror" their
change into the Library display cache, which then ran twice on one
Versions array:

- Delete Version removed two versions per click (2 versions -> 0; the
  tree showed no version rows at all).
- New Version inserted two copies and crashed with a nil index in
  GUIDrawMacroEditor (Editor.lua:5889) when selecting the new node.
- Drag-reorder applied the move twice, scrambling the order.

Guard all three mirror sites with `libSeq ~= sequence` so the mirror
only runs when the Library holds a distinct copy (i.e. before the first
Save of the session).

Also: Delete Version decremented MetaData.Default unconditionally;
it now only shifts when the deleted index is at or before the Default,
matching the rule the content-type keys already use.

Fixes TimothyLuke#1983

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
(cherry picked from commit 37f7917)
@TimothyLuke

Copy link
Copy Markdown
Owner

This fixes some of the bugs and introduces other. After applying this I can’t create a new version from the right hand menu. That’s why I am working on the whole of the problem not just this part.

@LarryThiessen
LarryThiessen deleted the fix-1983-library-mirror-aliasing branch August 21, 2026 01:22
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.

[BUG] After saving, Delete Version deletes ALL versions; New Version creates two + Lua error; version drag-reorder double-moves

2 participants