So, here's another newbie question:

I'm working on an app that will have several different types of scenes/UIs, which will be switched back and forth from.

I subclass each type of scene (sort of like a level in the tutorials..) from the "Scene" class (attached below). However, I find that actually deleting them when I'm done with them is problematic. They don't seem to go away like normal python objects, but rather hang around in memory causing a leak.

Is there something specific I need to do in the destructor to delete Worlds? Should I be iterating through all the children and deleting them individually?

Thanks for any help,

justin



class Scene( World ):
    """World that accepts commands and has a built-in idler, which
    will return another scene when done idling, or None if the sequence
    is finished.
    """

    def __init__( self ):
        self.__idler = None
        World.__init__( self )

        self.__camera = soya.Camera(self)
        self.__group = widget.Group()
        self.__group.add( self.camera )
        self.__group.add( widget.FPSLabel() )
        soya.set_root_widget( self.__group )

    def idle( self ):
        soya.set_root_widget( self.__group )
        self.__idler = Idler(self)
        return self.__idler.idle()

    def screenshot( self ):
        import time
        import os

        time_str = time.strftime( "%Y%m%d_%H%M" )
        file = "%s_%s.jpg" % ( self.__class__.__name__, time_str )
        ss = os.path.join( "results", file )

        soya.screenshot().resize( _SCREENSHOT_SIZE ).save(ss)

    def stop( self, val ):
        if self.__idler is not None:
            self.__idler.stop( val )
            self.__idler = None

    camera = property( lambda self: self.__camera )
    group = property( lambda self: self.__group )

Reply via email to