Thread Tools Display Modes
04-10-21, 05:40 AM   #1
LudiusMaximus
A Rage Talon Dragon Guard
 
LudiusMaximus's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2018
Posts: 324
Originally Posted by myrroddin View Post
No matter which method is used, you are safe, and won't get errors.
It must be something about pcall() then.
Another even more minimal working example:

Lua Code:
  1. local folderName = ...
  2. local myAddon = LibStub("AceAddon-3.0"):NewAddon(folderName, "AceEvent-3.0")
  3.  
  4. function myAddon:EventHandler(event)
  5.   print("EventHandler not doing anything", event)
  6. end
  7.  
  8. pcall(function() myAddon:RegisterEvent("Nonsense_Event", "EventHandler") end)
  9. myAddon:UnregisterAllEvents()

Gives me this unregister error:

Code:
AceEvent-3.0-4.lua:37: Attempt to unregister unknown event "Nonsense_Event"
__________________
~ Be the change you want to see in the world... of warcraft interface! ~
  Reply With Quote
04-14-21, 02:39 PM   #2
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,246
Originally Posted by LudiusMaximus View Post
Code:
AceEvent-3.0-4.lua:37: Attempt to unregister unknown event "Nonsense_Event"
If that is what you see for unknown events, then AceEvent is registering by table, a table that has a list of events assigned to the frame. It is the second method I suggested, not the first.

Clearly, AceEvent does not validate events before adding them to the frame's table. As per the thread's title, no, AceEvent is NOT being tricked into registering non-existent events. It is up to the addon author using AceEvent to do the validation, or simply never use events that don't exist. Which is what 99.9999999999% of authors do in their projects.

I can see why there is no validation in AceEvent. Considering the ever-increasing quantity of events, that would bloat AceEvent's code for no gain.
  Reply With Quote
04-14-21, 03:31 PM   #3
LudiusMaximus
A Rage Talon Dragon Guard
 
LudiusMaximus's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2018
Posts: 324
Originally Posted by myrroddin View Post
If that is what you see for unknown events, then AceEvent is registering by table, a table that has a list of events assigned to the frame. It is the second method I suggested, not the first.
That's what I supposed, too. But the implementation of AceEvent-3.0.lua is really beyond me...
I cannot spot any point where it would seem to maintain such a table of registered events.

What really puzzles me is why there is the unregister error when I call RegisterEvent() with callback:
Lua Code:
  1. local myAddon = LibStub("AceAddon-3.0"):NewAddon(..., "AceEvent-3.0")
  2. pcall(function() myAddon:RegisterEvent("NONSENSE_EVENT", function() end) end)
  3. myAddon:UnregisterAllEvents()
  4. -- Error: Attempt to unregister unknown event "NONSENSE_EVENT"

But no error message when I do it without callback:
Lua Code:
  1. local myAddon = LibStub("AceAddon-3.0"):NewAddon(..., "AceEvent-3.0")
  2. pcall(function() myAddon:RegisterEvent("NONSENSE_EVENT") end)
  3. myAddon:UnregisterAllEvents()
  4. -- No error.

Thanks! Your help is really appreciated.


Originally Posted by myrroddin View Post
Please provide a working example.
An example is just that a user mistypes an event they want to register. The GUI looks like this:
__________________
~ Be the change you want to see in the world... of warcraft interface! ~
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » AceEvent-3.0 tricked into registering non-existent events??


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off