Skip to content

fix(MoveAnything): nil-guard MAMover and MAMove frame loops - #108

Open
Xurkon wants to merge 1 commit into
Ascension-Addons:mainfrom
Xurkon:fix/moveanything-nil-guard
Open

fix(MoveAnything): nil-guard MAMover and MAMove frame loops#108
Xurkon wants to merge 1 commit into
Ascension-Addons:mainfrom
Xurkon:fix/moveanything-nil-guard

Conversation

@Xurkon

@Xurkon Xurkon commented Apr 25, 2026

Copy link
Copy Markdown
Contributor

Summary

Add nil checks to both loops in the MoveAnything skin that iterate over MAMover[1..20] and MAMove[1..17] global frames. Without these checks, ElvUI AddOnSkins throws a nil-index error when MoveAnything is enabled but few other addons are active at login.

Root Cause Analysis

Error: attempt to index field '?' (a nil value)

Location: ElvUI_AddOnSkins/Skins/Addons/moveAnything.lua, lines 29-32 and 49-52

MoveAnything creates mover and move frames dynamically at runtime — one pair per addon it manages. It does not create 20 MAMover slots or 17 MAMove slots upfront; it only creates as many as there are enabled addons to move. When ElvUI's AddOnSkins callback fires at login, if only a handful of addons are enabled, the vast majority of _G["MAMover" .. i] and _G["MAMove" .. i] entries are nil.

The original code blindly indexed these globals without checking existence first:

-- MAMover loop (original)
for i = 1, 20 do
    _G["MAMover" .. i .. "Backdrop"]:SetTemplate("Transparent")  -- nil if i > active movers
    _G["MAMover" .. i]:HookScript("OnShow", moverOnShow)         -- nil crash here
end

-- MAMove loop (original)
for i = 1, 17 do
    _G["MAMove" .. i .. "Backdrop"]:SetTemplate("Default")     -- nil crash here too
    ...
end

Trigger conditions:

  • MoveAnything is enabled in the client's addon list
  • Fewer than 20 addons are being moved by MoveAnything (common — most users only move a handful)
  • ElvUI AddOnSkins has the MoveAnything skin enabled

Fix

Guard both loops with existence checks before attempting to call methods on the frame objects:

for i = 1, 20 do
    local mover = _G["MAMover" .. i]
    local backdrop = _G["MAMover" .. i .. "Backdrop"]
    if mover and backdrop then
        backdrop:SetTemplate("Transparent")
        mover:HookScript("OnShow", moverOnShow)
        mover:SetScript("OnEnter", moverOnEnter)
        mover:SetScript("OnLeave", moverOnLeave)
    end
end
for i = 1, 17 do
    local moveFrame = _G["MAMove" .. i]
    local backdrop = _G["MAMove" .. i .. "Backdrop"]
    if moveFrame and backdrop then
        backdrop:SetTemplate("Default")
        S:HandleCheckBox(_G["MAMove" .. i .. "Move"])
        S:HandleCheckBox(_G["MAMove" .. i .. "Hide"])
        S:HandleButton(_G["MAMove" .. i .. "Reset"])
        if i ~= 1 then
            moveFrame:SetPoint("TOPLEFT", "MAMove" .. (i - 1), "BOTTOMLEFT", 0, -SPACING)
        end
    end
end

Side-effect improvement: The second loop previously re-indexed _G["MAMove" .. i] for the SetPoint call. The fix stores the frame in a local variable first, eliminating that redundant lookup.

Testing

  1. Enable MoveAnything with ElvUI AddOnSkins
  2. Ensure only a small number of addons are checked as "movable" in MoveAnything's options (fewer than 20)
  3. Reload UI — no nil-index error should appear in bugsack/bugger
  4. Open MoveAnything options — all visible movers/move rows should still be properly styled

Add nil checks in both loops that iterate over MAMover[1..20] and
MAMove[1..17] global frames. MoveAnything only creates mover/move
frames for whatever addons are currently enabled, so when ElvUI
skins the addon at login with few/no other addons active, most of
those _G entries are nil.

Root cause: attempt to index field '?' (a nil value) when
AddOnSkins' callback fires and tries to style MAMover* or MAMove*
frames that don't yet exist.

Side-effect fix: reusing moveFrame in SetPoint anchor instead of
re-indexing _G[MAMove .. i].
Copilot AI review requested due to automatic review settings April 25, 2026 19:51

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR hardens the MoveAnything skin in ElvUI AddOnSkins by avoiding nil-index errors when MoveAnything hasn’t created the full set of expected mover/move frames at login.

Changes:

  • Add nil-guards when iterating over MAMover1..20 frames before applying templates and hook scripts.
  • Add nil-guards when iterating over MAMove1..17 frames before applying templates/handling controls.
  • Use locals (mover, moveFrame, backdrop) to reduce repeated global lookups in both loops.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants