*** empty log message ***

This commit is contained in:
Joe Shochet 2001-06-03 22:17:30 +00:00
parent 885812729c
commit 355b730108
9 changed files with 93 additions and 81 deletions

View File

@ -73,11 +73,10 @@ class Actor(PandaObject, NodePath):
"""
try:
self.__initialized
self.Actor_initialized
return
except:
self.__initialized = 1
self.Actor_initialized = 1
# initialize our NodePath essence
NodePath.__init__(self)
@ -190,6 +189,13 @@ class Actor(PandaObject, NodePath):
# copy the anim dictionary from other
self.__copyAnimControls(other)
def delete(self):
try:
self.Actor_deleted
return
except:
self.Actor_deleted = 1
self.cleanup()
def __str__(self):
"""__str__(self)
@ -252,7 +258,8 @@ class Actor(PandaObject, NodePath):
self.__partBundleDict = None
del(self.__animControlDict)
self.__animControlDict = None
self.removeNode()
if not self.isEmpty():
self.removeNode()
# accessing

View File

@ -21,5 +21,14 @@ class DistributedActor(DistributedNode.DistributedNode, Actor.Actor):
def disable(self):
# remove all anims, on all parts and all lods
Actor.Actor.unloadAnims(None, None, None)
Actor.Actor.unloadAnims(self, None, None, None)
DistributedNode.DistributedNode.disable(self)
def delete(self):
try:
self.DistributedActor_deleted
except:
self.DistributedActor_deleted = 1
DistributedNode.DistributedNode.delete(self)
Actor.Actor.delete(self)

View File

@ -12,6 +12,17 @@ class CRCache:
self.fifo = []
return None
def flush(self):
"""
Delete each item in the cache then clear all references to them
"""
CRCache.notify.debug("Flushing the cache")
for distObj in self.dict.values():
distObj.delete()
# Null out all references to the objects so they will get gc'd
self.dict = {}
self.fifo = []
def cache(self, distObj):
# Only distributed objects are allowed in the cache
assert(isinstance(distObj, DistributedObject.DistributedObject))

View File

@ -24,8 +24,13 @@ class DistributedNode(DistributedObject.DistributedObject, NodePath.NodePath):
DistributedObject.DistributedObject.disable(self)
def delete(self):
self.removeNode()
DistributedObject.DistributedObject.delete(self)
try:
self.DistributedNode_deleted
except:
self.DistributedNode_deleted = 1
if not self.isEmpty():
self.removeNode()
DistributedObject.DistributedObject.delete(self)
def generate(self):
# Turn on dead reckoning

View File

@ -35,12 +35,13 @@ class DistributedObject(PandaObject):
self.deleteImminent = 0
return None
def __del__(self):
"""
For debugging purposes, this just prints out what got deleted
"""
DistributedObject.notify.debug("Destructing: " + self.__class__.__name__ +
" id: " + str(self.doId))
# def __del__(self):
# """
# For debugging purposes, this just prints out what got deleted
# """
# DistributedObject.notify.debug("Destructing: " + self.__class__.__name__ +
# " id: " + str(self.doId))
# PandaObject.__del__(self)
def setNeverDisable(self, bool):
assert((bool == 1) or (bool == 0))
@ -112,7 +113,12 @@ class DistributedObject(PandaObject):
"""delete(self)
Inheritors should redefine this to take appropriate action on delete
"""
pass
try:
self.DistributedObject_deleted
except:
self.DistributedObject_deleted = 1
del self.cr
return
def generate(self):
"""generate(self)

View File

@ -126,11 +126,11 @@ class Button(DirectObject):
def cleanup(self):
if (self.managed):
self.unmanage()
self.lUp = None
self.lLit = None
self.lDown = None
self.lInactive = None
self.button = None
del self.lUp
del self.lLit
del self.lDown
del self.lInactive
del self.button
return None
def __str__(self):

View File

@ -208,15 +208,6 @@ class OnscreenText(PandaObject, NodePath):
# Set ourselves up as the NodePath that points to this node.
self.assign(parent.attachNewNode(self.textNode))
def __del__(self):
# Make sure the node is removed when we delete the
# OnscreenText object. This means we don't have to explicitly
# remove an OnscreenText object; it can do it by itself.
# Maybe this will be too confusing because we *do* have to
# explicitly remove other kinds of onscreen objects.
self.cleanup()
NodePath.__del__(self)
def cleanup(self):
"""cleanup(self)

View File

@ -7,31 +7,24 @@ class DirectObject:
This is the class that all Direct/SAL classes should inherit from
"""
#def __del__(self):
# print "Destructing: ", self.__class__.__name__
# print "Destructing: ", self.__class__.__name__
# This is really old and we really should not be relying on it
# One day I'll see if anybody still needs this
#try:
# self.cleanup()
#except AttributeError:
# # No cleanup() method defined
# pass
# Event Handling
# object.accept('mouse', object.handleMouse)
# object.accept('mouse', object.handleMouse, [1,2])
def accept(self, event, method, extraArgs=[]):
messenger.accept(event, self, method, extraArgs, 1)
def acceptOnce(self, event, method, extraArgs=[]):
messenger.accept(event, self, method, extraArgs, 0)
def ignore(self, event):
messenger.ignore(event, self)
def ignoreAll(self):
messenger.ignoreAll(self)
def isAccepting(self, event):
return messenger.isAccepting(event, self)
def isIgnoring(self, event):
return messenger.isIgnoring(event, self)

View File

@ -261,18 +261,12 @@ class ShowBase:
AudioManager.spawnUpdate()
def loadSfx(self, name):
if name:
if base.wantSfx:
s = loader.loadSound(name)
return s
return None
if (name and base.wantSfx):
return loader.loadSound(name)
def loadMusic(self, name):
if name:
if base.wantMusic:
m = loader.loadSound(name)
return m
return None
if (name and base.wantMusic):
return loader.loadSound(name)
def unloadSfx(self, sfx):
if sfx:
@ -284,45 +278,41 @@ class ShowBase:
def playSfx(self, sfx, looping = None, interupt = 1, volume = None,
time = 0.):
if sfx:
if base.wantSfx:
if not interupt:
if not (sfx.status() == AudioSound.PLAYING):
AudioManager.play(sfx, time)
else:
if (sfx and base.wantSfx):
if not interupt:
if not (sfx.status() == AudioSound.PLAYING):
AudioManager.play(sfx, time)
if looping:
AudioManager.setLoop(sfx, 1)
if volume:
AudioManager.setVolume(sfx, volume)
else:
AudioManager.play(sfx, time)
if looping:
AudioManager.setLoop(sfx, 1)
if volume:
AudioManager.setVolume(sfx, volume)
def playMusic(self, music, looping = None, interupt = 1, volume = None,
restart = None, time = 0.):
if music:
if base.wantMusic:
if not interupt:
if not (music.status() == AudioSound.PLAYING):
AudioManager.play(music, time)
else:
if (music and base.wantMusic):
if not interupt:
if not (music.status() == AudioSound.PLAYING):
AudioManager.play(music, time)
if looping:
AudioManager.setLoop(music, 1)
if volume:
AudioManager.setVolume(music, volume)
if restart:
restart[0].accept("restart-music", restart[1])
else:
AudioManager.play(music, time)
if looping:
AudioManager.setLoop(music, 1)
if volume:
AudioManager.setVolume(music, volume)
if restart:
restart[0].accept("restart-music", restart[1])
def stopSfx(self, sfx):
if sfx:
if base.wantSfx:
AudioManager.stop(sfx)
if (sfx and base.wantSfx):
AudioManager.stop(sfx)
def stopMusic(self, music, restart = None):
if music:
if base.wantMusic:
AudioManager.stop(music)
if restart:
restart[0].ignore("restart-music")
if (music and base.wantMusic):
AudioManager.stop(music)
if restart:
restart[0].ignore("restart-music")
def dataloop(self, state):
# traverse the data graph. This reads all the control