Beremiz.py
branchwx.NewID_abuse_fix
changeset 2569 4f4d778c9376
parent 2553 4b967831374f
child 2570 1df8262b7d15
equal deleted inserted replaced
2567:eb9392511989 2569:4f4d778c9376
    32 
    32 
    33 import wx
    33 import wx
    34 from wx.lib.agw.advancedsplash import AdvancedSplash, AS_NOTIMEOUT, AS_CENTER_ON_SCREEN
    34 from wx.lib.agw.advancedsplash import AdvancedSplash, AS_NOTIMEOUT, AS_CENTER_ON_SCREEN
    35 
    35 
    36 import traceback
    36 import traceback
       
    37 import time
    37 from pprint import pprint
    38 from pprint import pprint
    38 orig_NewId = wx.NewId
    39 orig_NewId = wx.NewId
    39 log_newid = {}
    40 log_newid = {}
       
    41 last = 0 
    40 def NewId(*a,**k):
    42 def NewId(*a,**k):
       
    43     global last
    41     res = orig_NewId(*a,**k)
    44     res = orig_NewId(*a,**k)
    42     bt = '|'.join([':'.join([f,str(l)]) for f,l,_0,_1 in traceback.extract_stack()[-2:-1]])
    45     bt = '|'.join([':'.join([f,str(l)]) for f,l,_0,_1 in traceback.extract_stack()[-2:-1]])
    43     log_newid[bt] = log_newid.get(bt, 0) + 1
    46     log_newid[bt] = log_newid.get(bt, 0) + 1
    44     worst = log_newid.items()
    47     worst = log_newid.items()
    45     worst.sort(key=lambda x:x[1])
    48     worst.sort(key=lambda x:x[1])
    46     pprint(worst)
    49     now = time.time()
       
    50     if now - last > 1:
       
    51         pprint(worst)
       
    52         last = now
    47     return res
    53     return res
    48 wx.NewId = NewId
    54 wx.NewId = NewId
    49 
    55 
    50 import util.paths as paths
    56 import util.paths as paths
    51 
    57