auto handle late init call(and error report) with element creation queue
This commit is contained in:
@@ -20,6 +20,14 @@ local Context = {
|
||||
_zIndexOrderedElements = {}, -- Array of elements sorted by z-index (lowest to highest)
|
||||
-- Focus management guard
|
||||
_settingFocus = false,
|
||||
|
||||
initialized = false,
|
||||
|
||||
-- Initialization state tracking
|
||||
---@type "uninitialized"|"initializing"|"ready"
|
||||
_initState = "uninitialized",
|
||||
---@type table[] Queue of {props: ElementProps, callback: function(element)|nil}
|
||||
_initQueue = {},
|
||||
}
|
||||
|
||||
---@return number, number -- scaleX, scaleY
|
||||
|
||||
@@ -194,7 +194,7 @@ function Element.new(props)
|
||||
if elementMode == nil then
|
||||
elementMode = Element._Context._immediateMode and "immediate" or "retained"
|
||||
end
|
||||
|
||||
|
||||
-- If retained mode and has an ID, check if element already exists in parent's children
|
||||
if elementMode == "retained" and props.id and props.id ~= "" and props.parent then
|
||||
-- Check if this element already exists in parent's restored children
|
||||
@@ -292,7 +292,7 @@ function Element.new(props)
|
||||
|
||||
-- Track whether ID was auto-generated (before ID assignment)
|
||||
local idWasAutoGenerated = not props.id or props.id == ""
|
||||
|
||||
|
||||
-- Auto-generate ID if not provided (for all elements)
|
||||
if idWasAutoGenerated then
|
||||
self.id = Element._StateManager.generateID(props, props.parent)
|
||||
@@ -524,7 +524,7 @@ function Element.new(props)
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
self.border = {
|
||||
top = normalizeBorderValue(props.border.top),
|
||||
right = normalizeBorderValue(props.border.right),
|
||||
@@ -1065,7 +1065,7 @@ function Element.new(props)
|
||||
end
|
||||
tempHeight = 0
|
||||
end
|
||||
|
||||
|
||||
-- Get scaled 9-patch content padding from ThemeManager
|
||||
local scaledPadding = self._themeManager:getScaledContentPadding(tempWidth, tempHeight)
|
||||
if scaledPadding then
|
||||
|
||||
Reference in New Issue
Block a user