View Single Post
09-06-08, 03:23 PM   #1
acapela
A Cobalt Mageweaver
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 241
Hook infinite loop?

posted this over at WoWAce as well... very confusing (to me ). hopefully someone here can help. so...

bear with me. this is all black magic to me (i understand the theory, but my practice is very very shaky). i am working with the addon "Aloft" (nameplate mod, heavily modularized), pulled off WoWAce.

the addon otherwise seems to "work", but in trying to figure out some flow of control, i added some tracing to a module, and things ran amok. i have simplified the code a few lines at a time, until it equates to the example below, and the problem persists.

so, the module is declared fairly simply:

local AloftModule = Aloft:NewModule("AloftModule", "AceEvent-2.0", "AceHook-2.1")
there is a hook function basically like this:

function AloftModule:UpdateMethod(frame)
ChatFrame7:AddMessage("enter")
self.hooks[this]["OnUpdate"](this)
ChatFrame7:AddMessage("exit")
end
it is being hooked (in the module, during module initialization) as follows:

ChatFrame7:AddMessage("hook OnUpdate")
self:HookScript(someframe, "OnUpdate", "UpdateMethod")
ChatFrame7:AddMessage("hook OnUpdate complete")
my results (to ChatFrame7) consist of what appears to be an infinite loop:

hook OnUpdate
enter
exit
enter
exit
enter
exit
...
i have done a "tostring(frame)" in these diagnostics, and the same pointer value (i.e. the same frame) is involved throughout. i have also commented out the invocation to "self.hooks[this]["OnUpdate"](this)". this being Aloft, the frame involved is a nameplate frame (specifically, the underlying nameplate frame supplied by the WoW client... this is in the process of trying to plug Aloft into these underlying nameplate frames).

it really looks like a single call to AceHook-2.1:HookScript() churns forever.

i hope i am missing something that is obvious to others, and that this has a simple resolution (whether i understand it or not :-)).

thanks in advice for any advice.
  Reply With Quote