From f191acace1fe790a23d402c27dea499d2cd7f884 Mon Sep 17 00:00:00 2001 From: Darren Ranalli Date: Mon, 14 May 2007 23:11:17 +0000 Subject: [PATCH] only record creation stack in dev --- direct/src/gui/DirectGuiBase.py | 31 +++++++++++++++++++------------ direct/src/task/Task.py | 2 +- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/direct/src/gui/DirectGuiBase.py b/direct/src/gui/DirectGuiBase.py index 90b5f10b3d..653d1a520b 100644 --- a/direct/src/gui/DirectGuiBase.py +++ b/direct/src/gui/DirectGuiBase.py @@ -13,8 +13,11 @@ from direct.showbase import DirectObject from direct.task import Task from direct.showbase import ShowBase from direct.showbase.PythonUtil import recordCreationStack +from pandac.PandaModules import PStatCollector import string, types +guiObjectCollector = PStatCollector("Client::GuiObjects") + """ Base class for all Direct Gui items. Handles composite widgets and command line argument parsing. @@ -648,9 +651,9 @@ def toggleGuiGridSnap(): def setGuiGridSpacing(spacing): DirectGuiWidget.gridSpacing = spacing -if __debug__: - # this will help track down who created DirectGui objects - # call obj.getCreationStackTrace() to figure out who created it +if __dev__: + # this will help track down the code that created DirectGui objects + # call obj.getCreationStackTrace() to figure out what code created it DirectGuiBase = recordCreationStack(DirectGuiBase) class DirectGuiWidget(DirectGuiBase, NodePath): @@ -723,6 +726,8 @@ class DirectGuiWidget(DirectGuiBase, NodePath): self.guiItem.setId(self['guiId']) self.guiId = self.guiItem.getId() if __dev__: + guiObjectCollector.addLevel(1) + guiObjectCollector.flushLevel() # track gui items by guiId for tracking down leaks if hasattr(base, 'guiItems'): if self.guiId in base.guiItems: @@ -1020,16 +1025,18 @@ class DirectGuiWidget(DirectGuiBase, NodePath): self.updateFrameStyle() def destroy(self): - if __dev__: - if hasattr(base, 'guiItems'): - if self.guiId in base.guiItems: - del base.guiItems[self.guiId] - else: - base.notify.warning( - 'DirectGuiWidget.destroy(): ' - 'gui item %s not in base.guiItems' % - self.guiId) if hasattr(self, "frameStyle"): + if __dev__: + guiObjectCollector.subLevel(1) + guiObjectCollector.flushLevel() + if hasattr(base, 'guiItems'): + if self.guiId in base.guiItems: + del base.guiItems[self.guiId] + else: + base.notify.warning( + 'DirectGuiWidget.destroy(): ' + 'gui item %s not in base.guiItems' % + self.guiId) # Destroy children for child in self.getChildrenAsList(): childGui = self.guiDict.get(child.getName()) diff --git a/direct/src/task/Task.py b/direct/src/task/Task.py index 902bdb479a..9232683dea 100644 --- a/direct/src/task/Task.py +++ b/direct/src/task/Task.py @@ -76,7 +76,7 @@ class Task: debugTaskTraceback = 0 # base.config.GetBool('debug-task-traceback', 0) count = 0 def __init__(self, callback, priority = 0): - if __debug__: + if __dev__: if self.debugTaskTraceback: self.debugInitTraceback = StackTrace("Task "+str(callback), 1, 10) # Unique ID for each task