diff --git a/direct/src/showbase/PythonUtil.py b/direct/src/showbase/PythonUtil.py index c72aeaa601..6a5b8d4801 100644 --- a/direct/src/showbase/PythonUtil.py +++ b/direct/src/showbase/PythonUtil.py @@ -2907,8 +2907,11 @@ def recordCreationStack(cls): return self.__moved_init__(*args, **kArgs) def getCreationStackTrace(self): return self._creationStackTrace + def printCreationStackTrace(self): + print self._creationStackTrace cls.__init__ = __recordCreationStack_init__ cls.getCreationStackTrace = getCreationStackTrace + cls.printCreationStackTrace = printCreationStackTrace return cls @@ -3204,6 +3207,14 @@ def logBlock(id, msg): print str(msg) print '/LOGBLOCK(%03d) >>' % id +# __dev__ is not defined at import time, call this after it's defined +def recordFunctorCreationStacks(): + global Functor + if __dev__: + if not hasattr(Functor, '_functorCreationStacksRecorded'): + Functor = recordCreationStack(Functor) + Functor._functorCreationStacksRecorded = True + import __builtin__ __builtin__.Functor = Functor __builtin__.Stack = Stack diff --git a/direct/src/showbase/ShowBase.py b/direct/src/showbase/ShowBase.py index 3a9ba28224..870af6e000 100644 --- a/direct/src/showbase/ShowBase.py +++ b/direct/src/showbase/ShowBase.py @@ -20,6 +20,7 @@ from direct.task.TaskManagerGlobal import * from JobManagerGlobal import * from EventManagerGlobal import * from PythonUtil import * +from direct.showbase import PythonUtil from direct.particles.ParticleManagerGlobal import * from PhysicsManagerGlobal import * #from direct.interval.IntervalManager import ivalMgr @@ -317,6 +318,9 @@ class ShowBase(DirectObject.DirectObject): ShowBase.notify.info('__dev__ == %s' % __dev__) + # set up recording of Functor creation stacks in __dev__ + PythonUtil.recordFunctorCreationStacks() + if __dev__ or self.config.GetBool('want-e3-hacks', False): if self.config.GetBool('track-gui-items', True): # dict of guiId to gui item, for tracking down leaks