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
@@ -183,8 +183,10 @@ pub(crate) struct Model {
|
||||
pub(crate) frame_to_id: HashMap<FrameHandle, u32>,
|
||||
pub(crate) id_to_region: IdMap<RegionHandle>,
|
||||
pub(crate) region_to_id: HashMap<RegionHandle, u32>,
|
||||
/// Region name to id, first wins: `SetPoint` anchors to a sibling region by name, after frames.
|
||||
pub(crate) region_names: HashMap<String, u32>,
|
||||
/// Region name to the first region that took it, for name lookups only (`SetPoint` anchoring
|
||||
/// to a sibling by name, after frames): first come, as the `_G` entry is (`0x701bd0`). A
|
||||
/// region's own name, for `GetName` and error strings, is [`crate::widget::Region::name`].
|
||||
pub(crate) region_by_name: HashMap<String, u32>,
|
||||
|
||||
/// Which handlers each frame has; the closures themselves live in Lua's `REG_SCRIPTS` table.
|
||||
pub(crate) scripts: HashMap<FrameHandle, HashSet<&'static str>>,
|
||||
@@ -1126,7 +1128,7 @@ impl Model {
|
||||
frame_to_id: HashMap::new(),
|
||||
id_to_region: IdMap::default(),
|
||||
region_to_id: HashMap::new(),
|
||||
region_names: HashMap::new(),
|
||||
region_by_name: HashMap::new(),
|
||||
scripts: HashMap::new(),
|
||||
on_update_frames: Vec::new(),
|
||||
on_update_joins: 0,
|
||||
|
||||
Reference in New Issue
Block a user