Instrument IDE code to find code abusing wx.NewId. wx.NewID_abuse_fix
authorEdouard Tisserant
Tue, 26 Mar 2019 09:48:45 +0100
branchwx.NewID_abuse_fix
changeset 2553 4b967831374f
parent 2552 46a1e8d1e92c
child 2554 45d4f9a84c60
Instrument IDE code to find code abusing wx.NewId.
Beremiz.py
--- a/Beremiz.py	Fri Mar 22 14:00:35 2019 +0100
+++ b/Beremiz.py	Tue Mar 26 09:48:45 2019 +0100
@@ -33,6 +33,20 @@
 import wx
 from wx.lib.agw.advancedsplash import AdvancedSplash, AS_NOTIMEOUT, AS_CENTER_ON_SCREEN
 
+import traceback
+from pprint import pprint
+orig_NewId = wx.NewId
+log_newid = {}
+def NewId(*a,**k):
+    res = orig_NewId(*a,**k)
+    bt = '|'.join([':'.join([f,str(l)]) for f,l,_0,_1 in traceback.extract_stack()[-2:-1]])
+    log_newid[bt] = log_newid.get(bt, 0) + 1
+    worst = log_newid.items()
+    worst.sort(key=lambda x:x[1])
+    pprint(worst)
+    return res
+wx.NewId = NewId
+
 import util.paths as paths