From 53415bb6790ac4126c9b9f0fb12993a698670a03 Mon Sep 17 00:00:00 2001 From: David Rose Date: Wed, 18 Jul 2001 17:26:01 +0000 Subject: [PATCH] call closeWindow on exit --- direct/src/showbase/ShowBase.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/direct/src/showbase/ShowBase.py b/direct/src/showbase/ShowBase.py index f3fded5988..cad67502c2 100644 --- a/direct/src/showbase/ShowBase.py +++ b/direct/src/showbase/ShowBase.py @@ -86,6 +86,11 @@ class ShowBase: self.renderTop.node(), self.initialState) self.win = chanConfig.getWin() + + # Now that we've assigned a window, assign an exitfunc. + self.oldexitfunc = getattr(sys, 'exitfunc', None) + sys.exitfunc = self.exitfunc + self.cameraList = [] for i in range(chanConfig.getNumGroups()): self.cameraList.append(self.render.attachNewNode( @@ -227,6 +232,25 @@ class ShowBase: self.restart() + def exitfunc(self): + """exitfunc(self) + + This should be assigned to sys.exitfunc to be called just + before Python shutdown. It guarantees that the Panda window + is closed cleanly, so that we free system resources, restore + the desktop and keyboard functionality, etc. + """ + + # temporary try..except for old pandas. + try: + self.win.closeWindow() + except: + pass + + if self.oldexitfunc: + self.oldexitfunc() + + def addAngularIntegrator(self): """addAngularIntegrator(self)""" if (self.physicsMgrAngular == 0):