dabo Commit
Revision 6914
Date: 2011-10-25 18:12:55 -0700 (Tue, 25 Oct 2011)
Author: Paul
Trac: http://trac.dabodev.com/changeset/6914
Changed:
U trunk/dabo/ui/__init__.py
U trunk/dabo/ui/uiwx/__init__.py
Log:
Fixed a memory leak: items were never getting popped off the internal
_callAfterIntervalReferences dict when called, and we call that a
lot.
Renamed the deadcheck closure since I was confused when looking at the
_callAfterIntervalReferences at first.
Diff:
Modified: trunk/dabo/ui/__init__.py
===================================================================
--- trunk/dabo/ui/__init__.py 2011-10-25 20:07:02 UTC (rev 6913)
+++ trunk/dabo/ui/__init__.py 2011-10-26 01:12:55 UTC (rev 6914)
@@ -35,13 +35,13 @@
destroyed) from attempts to call their methods. Currently this only
supports wxPython,
but if needed in other toolkits, different functionality will need to
be coded.
"""
- def retfn(self, *args, **kwargs):
+ def deadCheckFunc(self, *args, **kwargs):
if not self:
# For testing, uncomment the print line below:
# print "FOUND DEAD OBJECT"
return
return fn(self, *args, **kwargs)
- return retfn
+ return deadCheckFunc
def loadUI(uiType):
Modified: trunk/dabo/ui/uiwx/__init__.py
===================================================================
--- trunk/dabo/ui/uiwx/__init__.py 2011-10-25 20:07:02 UTC (rev 6913)
+++ trunk/dabo/ui/uiwx/__init__.py 2011-10-26 01:12:55 UTC (rev 6914)
@@ -284,7 +284,7 @@
wx.CallAfter(fnc, *args, **kwargs)
-_callAfterIntervalReferences = {}
+_callAfterIntervalReferences = dabo.ui._callAfterIntervalReferences = {}
def callAfterInterval(interval, func, *args, **kwargs):
"""
Call the given function after <interval> milliseconds have elapsed.
@@ -303,12 +303,18 @@
func_ref = func
if func.func_closure:
func_ref = func.func_code
- futureCall = _callAfterIntervalReferences.get((func_ref, args))
+ futureCall = _callAfterIntervalReferences.pop((func_ref, args), None)
if futureCall:
futureCall.Stop()
- _callAfterIntervalReferences[(func_ref, args)] =
wx.FutureCall(interval, func, *args, **kwargs)
+ def ca_func(_func_ref, _func, *args, **kwargs):
+ """Wrapper to call the user func and pop it off the references
dict."""
+ defunct = _callAfterIntervalReferences.pop((_func_ref, args),
None)
+ _func(*args, **kwargs)
+ _callAfterIntervalReferences[(func_ref, args)] =
wx.FutureCall(interval, ca_func, func_ref, func, *args, **kwargs)
+
+
def setAfter(obj, prop, val):
"""
Like callAfter(), but allows you to set a property instead of calling
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev
Searchable Archives: http://leafe.com/archives/search/dabo-dev
This message:
http://leafe.com/archives/byMID/[email protected]