LibBars-1.0

6 - Recent change in CBH breaks LibBars

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()

User When Change
mitch0 Sep 18, 2009 at 06:59 UTC Create

You must login to post a comment. Don't have an account? Register to get one!

  • 1 comment
  • Avatar of mikk mikk Sep 18, 2009 at 23:59 UTC - 0 likes

    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?

  • 1 comment

Facts

Last updated
Mar 30, 2012
Reported
Sep 18, 2009
Status
New - Issue has not had initial review yet.
Type
Defect - A shortcoming, fault, or imperfection
Priority
Medium - Normal priority.
Votes
1

Reported by

Possible assignees