Skip to content

Commit 48d70f4

Browse files
committed
Fix SB.view nil access and GroupField child registration
1. Fix crash at editor.lua:154 - check SB.view exists before accessing - During View:init(), SB.view hasn't been assigned yet - Editors are created before SB.view is set in widget.lua 2. Fix GroupField child field registration logic - Changed from checking SB.view.useRmlUi (which is nil during init) - Now checks: if field.fields exists AND field.Added doesn't exist - RmlUi GroupFields: have .fields, no .Added → register children here - Chili GroupFields: have .fields, have .Added → register in Added() - This works regardless of when SB.view is set Fixes: - "attempt to index field 'view' (a nil value)" crash - "Attempted to set non-existent field: sunDirX" (and other GroupField children)
1 parent 279fd1a commit 48d70f4

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

scen_edit/view/editor.lua

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ function Editor:Finalize(children, opts)
151151
classname = opts.classname,
152152
}
153153
-- Only set main panel in Chili mode
154-
if not SB.view.useRmlUi and SB.view.tabbedWindow then
154+
if SB.view and not SB.view.useRmlUi and SB.view.tabbedWindow then
155155
SB.view.tabbedWindow:SetMainPanel(self.window)
156156
end
157157
else
@@ -363,8 +363,10 @@ function Editor:AddField(field)
363363
end
364364
self:_AddField(field)
365365

366-
-- In RmlUi mode, register child fields of GroupField
367-
if SB.view and SB.view.useRmlUi and field.fields then
366+
-- Register child fields of GroupField
367+
-- RmlUi GroupFields have .fields but no .Added method (handled here)
368+
-- Chili GroupFields have .fields and .Added method (handled in Added())
369+
if field.fields and not field.Added then
368370
for _, childField in ipairs(field.fields) do
369371
if childField.name then
370372
self:_AddField(childField)

0 commit comments

Comments
 (0)