mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-18 20:53:50 -04:00
various fixes
This commit is contained in:
parent
fa8c808562
commit
bf911bb728
@ -41,6 +41,9 @@ class InterestState:
|
|||||||
self.clearEvents()
|
self.clearEvents()
|
||||||
def isPendingDelete(self):
|
def isPendingDelete(self):
|
||||||
return self.state == InterestState.StatePendingDel
|
return self.state == InterestState.StatePendingDel
|
||||||
|
def __repr__(self):
|
||||||
|
return 'InterestState(desc=%s, state=%s, scope=%s, event=%s, parentId=%s, zoneIdList=%s)' % (
|
||||||
|
self.desc, self.state, self.scope, self.events, self.parentId, self.zoneIdList)
|
||||||
|
|
||||||
# scope value for interest changes that have no complete event
|
# scope value for interest changes that have no complete event
|
||||||
NO_SCOPE = 0
|
NO_SCOPE = 0
|
||||||
@ -105,6 +108,10 @@ class DoInterestManager(DirectObject.DirectObject):
|
|||||||
self.notify.warning(
|
self.notify.warning(
|
||||||
'removeInterest: interest %s already pending removal' %
|
'removeInterest: interest %s already pending removal' %
|
||||||
handle)
|
handle)
|
||||||
|
# this interest is already pending delete, so let's just tack this
|
||||||
|
# callback onto the list
|
||||||
|
if event is not None:
|
||||||
|
intState.addEvent(event)
|
||||||
else:
|
else:
|
||||||
if len(intState.events) > 0:
|
if len(intState.events) > 0:
|
||||||
# we're not pending a removal, but we have outstanding events?
|
# we're not pending a removal, but we have outstanding events?
|
||||||
@ -116,7 +123,8 @@ class DoInterestManager(DirectObject.DirectObject):
|
|||||||
scopeId = self._getNextScopeId()
|
scopeId = self._getNextScopeId()
|
||||||
intState.state = InterestState.StatePendingDel
|
intState.state = InterestState.StatePendingDel
|
||||||
intState.scope = scopeId
|
intState.scope = scopeId
|
||||||
intState.addEvent(event)
|
if event is not None:
|
||||||
|
intState.addEvent(event)
|
||||||
if self.InterestDebug:
|
if self.InterestDebug:
|
||||||
print 'INTEREST DEBUG: removeInterest(): handle=%s, event=%s' % (
|
print 'INTEREST DEBUG: removeInterest(): handle=%s, event=%s' % (
|
||||||
handle, event)
|
handle, event)
|
||||||
@ -222,10 +230,10 @@ class DoInterestManager(DirectObject.DirectObject):
|
|||||||
print "Note: interests with a Scope of 0 do not get" \
|
print "Note: interests with a Scope of 0 do not get" \
|
||||||
" done/finished notices."
|
" done/finished notices."
|
||||||
print "******************* Interest Sets **************"
|
print "******************* Interest Sets **************"
|
||||||
format = '%6s %' + str(DoInterestManager._debug_maxDescriptionLen) + 's %10s %8s %5s %9s %9s %s'
|
format = '%6s %' + str(DoInterestManager._debug_maxDescriptionLen) + 's %10s %5s %9s %9s %10s'
|
||||||
print format % (
|
print format % (
|
||||||
"Handle", "Description", "State", "Scope", "Event",
|
"Handle", "Description", "State", "Scope",
|
||||||
"ScopeId", "ParentId", "ZoneIdList")
|
"ParentId", "ZoneIdList", "Event")
|
||||||
for id, state in DoInterestManager._interests.items():
|
for id, state in DoInterestManager._interests.items():
|
||||||
if len(state.events) == 0:
|
if len(state.events) == 0:
|
||||||
event = ''
|
event = ''
|
||||||
@ -233,8 +241,8 @@ class DoInterestManager(DirectObject.DirectObject):
|
|||||||
event = state.events[0]
|
event = state.events[0]
|
||||||
else:
|
else:
|
||||||
event = state.events
|
event = state.events
|
||||||
print format % (id, state.desc, state.state, state.scope, event,
|
print format % (id, state.desc, state.state, state.scope,
|
||||||
state.scope, state.parentId, state.zoneIdList)
|
state.parentId, state.zoneIdList, event)
|
||||||
print "************************************************"
|
print "************************************************"
|
||||||
|
|
||||||
def _sendAddInterest(self, handle, scopeId, parentId, zoneIdList, description,
|
def _sendAddInterest(self, handle, scopeId, parentId, zoneIdList, description,
|
||||||
@ -308,10 +316,14 @@ class DoInterestManager(DirectObject.DirectObject):
|
|||||||
DoInterestManager.notify.debug(
|
DoInterestManager.notify.debug(
|
||||||
"handleInterestDoneMessage--> Received handle %s, scope %s" % (
|
"handleInterestDoneMessage--> Received handle %s, scope %s" % (
|
||||||
handle, scopeId))
|
handle, scopeId))
|
||||||
|
eventsToSend = []
|
||||||
# if the scope matches, send out the event
|
# if the scope matches, send out the event
|
||||||
if scopeId == DoInterestManager._interests[handle].scope:
|
if scopeId == DoInterestManager._interests[handle].scope:
|
||||||
DoInterestManager._interests[handle].scope = NO_SCOPE
|
DoInterestManager._interests[handle].scope = NO_SCOPE
|
||||||
DoInterestManager._interests[handle].sendEvents()
|
# the event handlers may call back into the interest manager. Send out
|
||||||
|
# the events after we're once again in a stable state.
|
||||||
|
#DoInterestManager._interests[handle].sendEvents()
|
||||||
|
eventsToSend = list(DoInterestManager._interests[handle].getEvents())
|
||||||
else:
|
else:
|
||||||
DoInterestManager.notify.warning(
|
DoInterestManager.notify.warning(
|
||||||
"handleInterestDoneMessage--> handle: %s: Expecting scope %s, got %s" % (
|
"handleInterestDoneMessage--> handle: %s: Expecting scope %s, got %s" % (
|
||||||
@ -322,7 +334,8 @@ class DoInterestManager(DirectObject.DirectObject):
|
|||||||
"finished", state.desc, handle, scopeId, state.parentId,
|
"finished", state.desc, handle, scopeId, state.parentId,
|
||||||
state.zoneIdList)
|
state.zoneIdList)
|
||||||
self._considerRemoveInterest(handle)
|
self._considerRemoveInterest(handle)
|
||||||
|
for event in eventsToSend:
|
||||||
|
messenger.send(event)
|
||||||
assert self.printInterestsIfDebug()
|
assert self.printInterestsIfDebug()
|
||||||
|
|
||||||
if __debug__:
|
if __debug__:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user