Frames cannot be restored in combat #9


Open
  • Forge_User_08709434 created this issue Aug 24, 2018

    As RestorePosition uses several protected functions it cannot be used in combat. I suggest delaying frame restoration until player exits combat. Something like:

    diff --git a/LibWindow-1.1/LibWindow-1.1.lua b/LibWindow-1.1/LibWindow-1.1.lua
    index 169c94e..d1abbea 100644
    --- a/LibWindow-1.1/LibWindow-1.1.lua
    +++ b/LibWindow-1.1/LibWindow-1.1.lua
    @@ -36,6 +36,8 @@ lib.windowData = lib.windowData or {}

    lib.embeds = lib.embeds or {}

    +lib.restoreQueue = lib.restoreQueue or {}
    +
    local mixins = {} -- "FuncName"=true


    @@ -75,12 +77,13 @@ lib.utilFrame:SetScript("OnUpdate", function(this)
    end
    end)

    +lib.utilFrame:RegisterEvent("PLAYER_LEAVE_COMBAT")
    +
    local function restoreQueueSavePosition(frame)
    lib.delayedSavePosition[frame] = true
    lib.utilFrame:Show()
    end

    -
    ---------------------------------------------------------
    -- IMPORTANT APIS
    ---------------------------------------------------------
    @@ -168,6 +171,11 @@ end

    mixins["RestorePosition"]=true
    function lib.RestorePosition(frame)
    + if InCombatLockdown() then
    + lib.restoreQueue[frame] = true
    + return
    + end
    +
    local x = getStorage(frame, "x")
    local y = getStorage(frame, "y")
    local point = getStorage(frame, "point")
    @@ -279,6 +287,15 @@ lib.utilFrame:SetScript("OnEvent", function(this, event, key, state)
    end
    end
    end
    + elseif event=="PLAYER_LEAVE_COMBAT" then
    + if not InCombatLockdown() then
    + for frame in pairs(lib.restoreQueue) do
    + if frame:IsShown() then
    + lib.RestorePosition(frame)
    + end
    + end
    + lib.restoreQueue = {}
    + end
    end
    end)

     


To post a comment, please login or register a new account.