Browse Source

*** empty log message ***

Joe Shochet 24 years ago
parent
commit
355b730108

+ 11 - 4
direct/src/actor/Actor.py

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

+ 10 - 1
direct/src/actor/DistributedActor.py

@@ -21,5 +21,14 @@ class DistributedActor(DistributedNode.DistributedNode, Actor.Actor):
 
 
     def disable(self):
     def disable(self):
         # remove all anims, on all parts and all lods
         # 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)
         DistributedNode.DistributedNode.disable(self)
+
+    def delete(self):
+        try:
+            self.DistributedActor_deleted
+        except:
+            self.DistributedActor_deleted = 1
+            DistributedNode.DistributedNode.delete(self)
+            Actor.Actor.delete(self)
+

+ 11 - 0
direct/src/distributed/CRCache.py

@@ -12,6 +12,17 @@ class CRCache:
         self.fifo = []
         self.fifo = []
         return None
         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):
     def cache(self, distObj):
         # Only distributed objects are allowed in the cache
         # Only distributed objects are allowed in the cache
         assert(isinstance(distObj, DistributedObject.DistributedObject))
         assert(isinstance(distObj, DistributedObject.DistributedObject))

+ 7 - 2
direct/src/distributed/DistributedNode.py

@@ -24,8 +24,13 @@ class DistributedNode(DistributedObject.DistributedObject, NodePath.NodePath):
         DistributedObject.DistributedObject.disable(self)
         DistributedObject.DistributedObject.disable(self)
 
 
     def delete(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):
     def generate(self):
         # Turn on dead reckoning
         # Turn on dead reckoning

+ 13 - 7
direct/src/distributed/DistributedObject.py

@@ -35,12 +35,13 @@ class DistributedObject(PandaObject):
             self.deleteImminent = 0
             self.deleteImminent = 0
         return None
         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):
     def setNeverDisable(self, bool):
         assert((bool == 1) or (bool == 0))
         assert((bool == 1) or (bool == 0))
@@ -112,7 +113,12 @@ class DistributedObject(PandaObject):
         """delete(self)
         """delete(self)
         Inheritors should redefine this to take appropriate action on delete
         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):
     def generate(self):
         """generate(self)
         """generate(self)

+ 5 - 5
direct/src/gui/Button.py

@@ -126,11 +126,11 @@ class Button(DirectObject):
     def cleanup(self):
     def cleanup(self):
         if (self.managed):
         if (self.managed):
             self.unmanage()
             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
         return None
 
 
     def __str__(self):
     def __str__(self):

+ 0 - 9
direct/src/gui/OnscreenText.py

@@ -208,15 +208,6 @@ class OnscreenText(PandaObject, NodePath):
 
 
         # Set ourselves up as the NodePath that points to this node.
         # Set ourselves up as the NodePath that points to this node.
         self.assign(parent.attachNewNode(self.textNode))
         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):
     def cleanup(self):
 	"""cleanup(self)
 	"""cleanup(self)

+ 6 - 13
direct/src/showbase/DirectObject.py

@@ -7,31 +7,24 @@ class DirectObject:
     This is the class that all Direct/SAL classes should inherit from
     This is the class that all Direct/SAL classes should inherit from
     """
     """
     #def __del__(self):
     #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
     # Event Handling
-
-    # object.accept('mouse', object.handleMouse)
-    # object.accept('mouse', object.handleMouse, [1,2])
-    
     def accept(self, event, method, extraArgs=[]):
     def accept(self, event, method, extraArgs=[]):
         messenger.accept(event, self, method, extraArgs, 1)
         messenger.accept(event, self, method, extraArgs, 1)
+
     def acceptOnce(self, event, method, extraArgs=[]):
     def acceptOnce(self, event, method, extraArgs=[]):
         messenger.accept(event, self, method, extraArgs, 0)
         messenger.accept(event, self, method, extraArgs, 0)
+
     def ignore(self, event):
     def ignore(self, event):
         messenger.ignore(event, self)
         messenger.ignore(event, self)
+
     def ignoreAll(self):
     def ignoreAll(self):
         messenger.ignoreAll(self)
         messenger.ignoreAll(self)
+
     def isAccepting(self, event):
     def isAccepting(self, event):
         return messenger.isAccepting(event, self)
         return messenger.isAccepting(event, self)
+
     def isIgnoring(self, event):
     def isIgnoring(self, event):
         return messenger.isIgnoring(event, self)
         return messenger.isIgnoring(event, self)
     
     

+ 30 - 40
direct/src/showbase/ShowBase.py

@@ -261,18 +261,12 @@ class ShowBase:
             AudioManager.spawnUpdate()
             AudioManager.spawnUpdate()
 
 
     def loadSfx(self, name):
     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):
     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):
     def unloadSfx(self, sfx):
         if sfx:
         if sfx:
@@ -284,45 +278,41 @@ class ShowBase:
 
 
     def playSfx(self, sfx, looping = None, interupt = 1, volume = None,
     def playSfx(self, sfx, looping = None, interupt = 1, volume = None,
                 time = 0.):
                 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)
                     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,
     def playMusic(self, music, looping = None, interupt = 1, volume = None,
                   restart = None, time = 0.):
                   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)
                     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):
     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):
     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):
     def dataloop(self, state):
         # traverse the data graph.  This reads all the control
         # traverse the data graph.  This reads all the control