fix(corelib): prevent duplicate child insertion in UIMiniWindowContainer (#1807)

Bug Fixes
- Improved mini-window placement when moving widgets between containers.
- Prevented widgets from remaining attached to an outdated parent during scheduled insertion.
- Preserved reliable insertion as target positions become available.
This commit is contained in:
João Pedro M. C. Hluchan 2026-08-14 20:11:41 -03:00 committed by GitHub
parent 3a049b36b3
commit df85bfdcbc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -176,21 +176,27 @@ function UIMiniWindowContainer:scheduleInsert(widget, index)
oldParent:removeChild(widget)
end
self:insertChild(index, widget)
end
while true do
local placed = false
for nIndex, nWidget in pairs(self.scheduledWidgets) do
if nIndex - 1 <= self:getChildCount() then
while true do
local placed = false
for nIndex, nWidget in pairs(self.scheduledWidgets) do
if nIndex - 1 <= self:getChildCount() then
local nOldParent = nWidget:getParent()
if nOldParent ~= self then
if nOldParent then
nOldParent:removeChild(nWidget)
end
self:insertChild(nIndex, nWidget)
self.scheduledWidgets[nIndex] = nil
placed = true
break
end
end
if not placed then
self.scheduledWidgets[nIndex] = nil
placed = true
break
end
end
if not placed then
break
end
end
end
end