Browse Source

added creation stack trace to all GUI items in __debug__

Darren Ranalli 19 năm trước cách đây
mục cha
commit
ebd1a01733
1 tập tin đã thay đổi với 6 bổ sung0 xóa
  1. 6 0
      direct/src/gui/DirectGuiBase.py

+ 6 - 0
direct/src/gui/DirectGuiBase.py

@@ -12,6 +12,7 @@ from direct.directtools.DirectUtil import ROUND_TO
 from direct.showbase import DirectObject
 from direct.showbase import DirectObject
 from direct.task import Task
 from direct.task import Task
 from direct.showbase import ShowBase
 from direct.showbase import ShowBase
+from direct.showbase.PythonUtil import recordCreationStack
 import string, types
 import string, types
 
 
 """
 """
@@ -647,6 +648,11 @@ def toggleGuiGridSnap():
 def setGuiGridSpacing(spacing):
 def setGuiGridSpacing(spacing):
     DirectGuiWidget.gridSpacing = spacing
     DirectGuiWidget.gridSpacing = spacing
 
 
+if __debug__:
+    # this will help track down who created DirectGui objects
+    # call obj.getCreationStackTrace() to figure out who created it
+    DirectGuiBase = recordCreationStack(DirectGuiBase)
+
 class DirectGuiWidget(DirectGuiBase, NodePath):
 class DirectGuiWidget(DirectGuiBase, NodePath):
     # Toggle if you wish widget's to snap to grid when draggin
     # Toggle if you wish widget's to snap to grid when draggin
     snapToGrid = 0
     snapToGrid = 0