Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UpdateCallIn("Shutdown") makes widget removal fail when widget:Shutdown throws an error #3022

Open
MasterBel2 opened this issue May 16, 2024 · 2 comments
Labels
Bug Something isn't working

Comments

@MasterBel2
Copy link
Contributor

MasterBel2 commented May 16, 2024

Usually, if widget:Shutdown() errors, the widget is successfully removed and can be fully disabled.

Example code:

function widget:GetInfo()
    return {
        name = "Test Shutdown Error (Standard)"
    }
end

local DeferredInit

function widget:Update()
    error()
end

function widget:Shutdown()
    Spring.Echo("Normal Shutdown")
    error()
end

However, if you update the Shutdown callin after init, e.g. when deferring your init until after another widget loads, widget removal fails. The widget selector will show the widgets name in yellow (as when you call widgetHandler:RemoveWidget(self) or when the widget errors out normally), however clicking on the widgets name will not fully disable it (turn it red) and errors will continue to be thrown.

Error message: [t=00:00:29.658501][f=-000001] Error: [LuaUI::RunCallInTraceback] error=2 (LUA_ERRRUN) callin=Update trace=[Internal Lua error: Call failure] [No traceback returned]

Example code:

function widget:GetInfo()
    return {
        name = "Test Shutdown Error (Deferred Init)"
    }
end

local DeferredInit

function widget:Update()
    if DeferredInit then 
        DeferredInit(widget)
        DeferredInit = nil

        error()
    end
end

function widget:Initialize()
    DeferredInit = function(widget)
        function widget:Shutdown()
            Spring.Echo("Deferred Init Shutdown")
            error() -- if this error is not thrown, there is no issue with widget removal
        end

        widgetHandler:UpdateCallIn("Shutdown")
    end
end
@MasterBel2 MasterBel2 added the Bug Something isn't working label May 16, 2024
@MasterBel2
Copy link
Contributor Author

Haha I took another look at this and seems I was fully mistaken on whats actually going on. Lemme close this until I work it out

@MasterBel2
Copy link
Contributor Author

Ok, no, the issue is a thing, I just confused myself. Time to take a break lol

@MasterBel2 MasterBel2 reopened this May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant