Originally Posted by sezz
did you try if it works without using acevent which itself uses callbackhandler and that's propably why it doesn's work as you expect it?
Lua Code:
local f = CreateFrame("Frame"); local EventExists = function(event) if (pcall(function() f:RegisterEvent(event); end)) then f:UnregisterEvent(event); return true; end end
|
What you suggest is a good way to check if an event exists! Do you think it is more efficient than my solution:
Lua Code:
if not APIDocumentation then
LoadAddOn("Blizzard_APIDocumentation");
end
local allEvents = APIDocumentation:GetAPITableByTypeName("event")
local EventExists = function(event)
local eventExists = false
for k, v in pairs(allEvents) do
if event == v.LiteralName then
eventExists = true
break
end
end
return eventExists
end
My problem was really AceEvent's UnregisterAllEvents() function that tries to unregister non-existing events that were tried to be registered using pcall(). Maybe AceEvent assumes that a script will never continue after its RegisterEvent() fails. So it does not bother to remove a non-existent event from its own table of (putatively) registered events...?