mirror of
https://github.com/mehah/otclient
synced 2026-08-15 16:29:06 -04:00
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:
parent
3a049b36b3
commit
df85bfdcbc
1 changed files with 15 additions and 9 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue