A region keeps its own name; only the name lookup is first-come (#944)
Region names lived in one first-wins name → id map that also served `GetName`, so a second region given a taken name answered `GetName()` with nil and was `<unnamed>` in its error strings. In 1.12.1 the name lives on the region: `SetName` (`0x76c650`) keeps the region's own copy at `[+0x98]`, freed by its destructor (`0x76c560`) and read back by `GetName`. Only `_G` is first-come (`0x701bd0`, `0x701c8a`). Each region now carries its name; `GetName` and the error strings read it directly, and the name map is a first-come lookup only, whose entry a free drops only when it holds that region. Tests: same name twice, `$parentText` under colliding parents, the second region's error string, a free leaving a same-named sibling's name. Fixes #939 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
73623e31fa
commit
87bf5904ff
@@ -110,7 +110,7 @@ fn ensure_lines(lua: &Lua, this: &Table, n: usize) -> mlua::Result<()> {
|
||||
return None;
|
||||
}
|
||||
let id = model
|
||||
.region_names
|
||||
.region_by_name
|
||||
.get(&format!("{frame_name}Text{cell}{i}"))
|
||||
.copied()?;
|
||||
let rh = model.id_to_region.get(&id).copied()?;
|
||||
@@ -228,12 +228,12 @@ fn ensure_lines(lua: &Lua, this: &Table, n: usize) -> mlua::Result<()> {
|
||||
// Adopted pairs are already named and published by the loader.
|
||||
if adopted_left.is_none() {
|
||||
let ln = format!("{frame_name}TextLeft{i}");
|
||||
model.region_names.entry(ln.clone()).or_insert(left_id);
|
||||
crate::script::region::set_region_name(&mut model, left, left_id, &ln);
|
||||
publish.push((left_id, ln));
|
||||
}
|
||||
if adopted_right.is_none() {
|
||||
let rn = format!("{frame_name}TextRight{i}");
|
||||
model.region_names.entry(rn.clone()).or_insert(right_id);
|
||||
crate::script::region::set_region_name(&mut model, right, right_id, &rn);
|
||||
publish.push((right_id, rn));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user