Stanzilla / WoWUIBugs

World of Warcraft UI Bug Tracker
166 stars 7 forks source link

EventUtil.ContinueOnAddOnLoaded not functional #418

Closed shooter-z closed 1 year ago

shooter-z commented 1 year ago

PTR 10.1, build 48898

EventUtil.ContinueOnAddOnLoaded("ADDON_LOADED", function() print("ContinueOnAddOnLoaded") end, "Blizzard_EventTrace") does not execute its callback. ADDON_LOADED returns additional bool arg2, and since ContinueOnAddOnLoaded only passes event, callback and addon name to RegisterOnceFrameEventAndCallback , there is no arg2 to compare and test inside callback wrapper fails preventing callback from being executed. We either need a way to pass additional params to ContinueOnAddOnLoaded, or it itself needs to pass false as optional arg2 to RegisterOnceFrameEventAndCallback.

Meorawr commented 1 year ago

I'd complained about this quirk of RegisterOnceFrameEventAndCallback a while back - will probe.

The proper fix is just to have that function only compare the number of values it was initially supplied rather than the number of values supplied in the event payload:

diff --git a/Interface/SharedXML/EventUtil.lua b/Interface/SharedXML/EventUtil.lua
index 7225d817..15b9d430 100644
--- a/Interface/SharedXML/EventUtil.lua
+++ b/Interface/SharedXML/EventUtil.lua
@@ -64,7 +64,7 @@ function EventUtil.RegisterOnceFrameEventAndCallback(frameEvent, callback, ...)
    local handle = nil;
    local requiredEventArgs = SafePack(...);
    local CallbackWrapper = function(callbackHandlerID, ...)
-       for i = 1, select("#", ...) do
+       for i = 1, requiredEventArgs.n do
            if select(i, ...) ~= requiredEventArgs[i] then
                return;
            end
Meorawr commented 1 year ago

This should be fixed in an upcoming (likely next) build.

Meorawr commented 1 year ago

Resolved in 10.1.0.49092.

shooter-z commented 1 year ago

Sadly, the issue still remains. While your fix was implemented, and by itself would be enough, at the same time new nil parameter was added to RegisterOnceFrameEventAndCallback call from ContinueOnAddOnLoaded, and when safepacked it bumps requiredEventArgs.n to 2 which... again causes early exit on the same check that the original issue.

Meorawr commented 1 year ago

I'll re-complain :)

Meorawr commented 1 year ago

This should be absolutely 100% fixed for real in 10.1.0.49190.

shooter-z commented 1 year ago

Confirmed fixed.