mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 10:22:45 -04:00
improved watching of events not listened to
This commit is contained in:
parent
a666205e42
commit
3200cdda10
@ -116,14 +116,15 @@ class Messenger:
|
|||||||
return (not self.isAccepting(event, object))
|
return (not self.isAccepting(event, object))
|
||||||
|
|
||||||
def send(self, event, sentArgs=[]):
|
def send(self, event, sentArgs=[]):
|
||||||
""" send(self, string, [arg1, arg2,...])
|
"""
|
||||||
|
event is usually a string.
|
||||||
|
sentArgs is a list of any data that you want passed along to the
|
||||||
|
handlers listening to this event.
|
||||||
|
|
||||||
Send this event, optionally passing in arguments
|
Send this event, optionally passing in arguments
|
||||||
"""
|
"""
|
||||||
if Messenger.notify.getDebug() and not self.quieting.get(event):
|
if Messenger.notify.getDebug() and not self.quieting.get(event):
|
||||||
Messenger.notify.debug('sent event: ' + event + ' sentArgs: ' + `sentArgs`)
|
Messenger.notify.debug('sent event: ' + event + ' sentArgs: ' + `sentArgs`)
|
||||||
acceptorDict = self.dict.get(event)
|
|
||||||
if not acceptorDict:
|
|
||||||
return
|
|
||||||
if __debug__:
|
if __debug__:
|
||||||
foundWatch=0
|
foundWatch=0
|
||||||
if self.isWatching:
|
if self.isWatching:
|
||||||
@ -131,6 +132,12 @@ class Messenger:
|
|||||||
if str(event).find(i) >= 0:
|
if str(event).find(i) >= 0:
|
||||||
foundWatch=1
|
foundWatch=1
|
||||||
break
|
break
|
||||||
|
acceptorDict = self.dict.get(event)
|
||||||
|
if not acceptorDict:
|
||||||
|
if __debug__:
|
||||||
|
if foundWatch:
|
||||||
|
print "Messenger: \"%s\" was sent, but no function in Python listened."%(event,)
|
||||||
|
return
|
||||||
for object in acceptorDict.keys():
|
for object in acceptorDict.keys():
|
||||||
# We have to make this apparently redundant check, because
|
# We have to make this apparently redundant check, because
|
||||||
# it is possible that one object removes its own hooks
|
# it is possible that one object removes its own hooks
|
||||||
@ -156,8 +163,7 @@ class Messenger:
|
|||||||
|
|
||||||
if __debug__:
|
if __debug__:
|
||||||
if foundWatch:
|
if foundWatch:
|
||||||
foundWatch=2
|
print "Messenger: \"%s\" --> %s%s"%(
|
||||||
print "Message: \"%s\" --> %s%s"%(
|
|
||||||
event,
|
event,
|
||||||
self.__methodRepr(method),
|
self.__methodRepr(method),
|
||||||
tuple(extraArgs + sentArgs))
|
tuple(extraArgs + sentArgs))
|
||||||
@ -167,9 +173,6 @@ class Messenger:
|
|||||||
# method itself might call accept() or acceptOnce()
|
# method itself might call accept() or acceptOnce()
|
||||||
# again.
|
# again.
|
||||||
apply(method, (extraArgs + sentArgs))
|
apply(method, (extraArgs + sentArgs))
|
||||||
if __debug__:
|
|
||||||
if foundWatch == 1:
|
|
||||||
print "Message: \"%s\" was sent, but no one listened."%(event,)
|
|
||||||
|
|
||||||
def clear(self):
|
def clear(self):
|
||||||
"""
|
"""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user