Ver Fonte

reorder acceptOnce cleanup

David Rose há 23 anos atrás
pai
commit
5a32627a8d
1 ficheiros alterados com 7 adições e 5 exclusões
  1. 7 5
      direct/src/showbase/Messenger.py

+ 7 - 5
direct/src/showbase/Messenger.py

@@ -129,21 +129,23 @@ class Messenger:
             callInfo = acceptorDict.get(object)
             if callInfo:
                 method, extraArgs, persistent = callInfo
-                apply(method, (extraArgs + sentArgs))
                 # If this object was only accepting this event once,
                 # remove it from the dictionary
                 if not persistent:
                     # notify the object that the event has been triggered
                     object._INTERNAL_acceptOnceExpired(event)
-                    # We need to check this because the apply above might
-                    # have done an ignore.
-                    if acceptorDict.has_key(object):
-                        del acceptorDict[object]
+                    del acceptorDict[object]
                     # If the dictionary at this event is now empty, remove
                     # the event entry from the Messenger altogether
                     if (self.dict.has_key(event) and (len(self.dict[event]) == 0)):
                         del self.dict[event]
 
+                # It is important to make the actual call here, after
+                # we have cleaned up the accept hook, because the
+                # method itself might call accept() or acceptOnce()
+                # again.
+                apply(method, (extraArgs + sentArgs))
+
     def clear(self):
         """clear(self)
         Start fresh with a clear dict