Recent change in CBH breaks LibBars #6


  • New
  • Defect
Open
Assigned to ardentvark
  • mitchnull created this issue Sep 18, 2009

    A recent change in CallbackHandler added some internal stuff that breaks the way LibBars clears all registrations. The below patch reportedly fixes the issue:

    Index: LibBars-1.0.lua
    ===================================================================
    --- LibBars-1.0.lua     (revision 17)
    +++ LibBars-1.0.lua     (working copy)
    @@ -1059,21 +1059,15 @@
            self.timerLabel:SetFont(f, s or 10, m)

            -- Cancel all registered callbacks. CBH doesn't seem to provide a method to do this.
    -       if self.callbacks.insertQueue then
    -               for eventname, callbacks in pairs(self.callbacks.insertQueue) do
    -                       for k, v in pairs(callbacks) do
    -                               callbacks[k] = nil
    -                       end
    -               end
    -       end
    -       for eventname, callbacks in pairs(self.callbacks.events) do
    -               for k, v in pairs(callbacks) do
    -                       callbacks[k] = nil
    -               end
    -               if self.callbacks.OnUnused then
    -                       self.callbacks.OnUnused(self.callbacks, target, eventname)
    -               end
    -       end
    +        local listeners = {}
    +        for eventname, callbacks in pairs(self.callbacks.events) do
    +            for listener, callback in pairs(callbacks) do
    +                listeners[listener] = true
    +            end
    +        end
    +        for listener, _ in pairs(listeners) do
    +            self.UnregisterAllCallbacks(listener)
    +        end
    end

    function barPrototype:GetGroup()

  • mitchnull added the tags New Defect Sep 18, 2009
  • Forge_User_96189362 posted a comment Sep 18, 2009

    This patch is semi-broken in that it doesn't examine the insertQueue.

    Either way, digging into the innards of CBH like this is something that (for now obvious reasons i hope) you should never do. I'm thinking adding an :UnregisterAll() on the registry object is the way to go.

    Though, I must ask, why is this even needed? An operation like this causes clients to not receive any further callbacks at all, perhaps in a situation where they have internal state EXPECTING callbacks?


To post a comment, please login or register a new account.