Skip to content

Commit

Permalink
Maintain references to CallLater instances.
Browse files Browse the repository at this point in the history
  • Loading branch information
mesalu committed Jan 4, 2018
1 parent a5cfe9b commit 2d5e073
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions etg/_core.py
Expand Up @@ -333,6 +333,7 @@ def run():
""",
items = [
PyCodeDef('__instances = {}'),
PyFunctionDef('__init__', '(self, millis, callableObj, *args, **kwargs)',
doc="""\
Constructs a new :class:`wx.CallLater` object.
Expand Down Expand Up @@ -373,6 +374,7 @@ def run():
if args or kwargs:
self.SetArgs(*args, **kwargs)
self.Stop()
CallLater.__instances[self] = "value irrelevant" # Maintain a reference to avoid GC
self.timer = wx.PyTimer(self.Notify)
self.timer.Start(self.millis, wx.TIMER_ONE_SHOT)
self.running = True"""),
Expand All @@ -381,6 +383,8 @@ def run():
PyFunctionDef('Stop', '(self)',
doc="Stop and destroy the timer.",
body="""\
if self in CallLater.__instances:
del CallLater.__instances[self]
if self.timer is not None:
self.timer.Stop()
self.timer = None"""),
Expand Down

0 comments on commit 2d5e073

Please sign in to comment.