Skip to content

Commit

Permalink
Merge pull request kivy#6441 from matham/leak
Browse files Browse the repository at this point in the history
Move proxy_ref to EventDispatcher.
  • Loading branch information
matham authored Jul 31, 2019
2 parents e8a0914 + a0ffc16 commit f9a225e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
1 change: 1 addition & 0 deletions kivy/_event.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ cdef class EventDispatcher(ObjectWithUid):
cdef dict __storage
cdef object __weakref__
cdef public set _kwargs_applied_init
cdef public object _proxy_ref
cpdef dict properties(self)


Expand Down
18 changes: 16 additions & 2 deletions kivy/_event.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ from libc.string cimport memset
from functools import partial
from collections import defaultdict
from kivy.weakmethod import WeakMethod
from kivy.weakproxy import WeakProxy
from kivy.compat import string_types
from kivy.properties cimport (Property, PropertyStorage, ObjectProperty,
NumericProperty, StringProperty, ListProperty, DictProperty,
Expand Down Expand Up @@ -166,6 +167,7 @@ cdef class EventDispatcher(ObjectWithUid):

self.__event_stack = {}
self.__storage = {}
self._proxy_ref = None

__cls__ = self.__class__

Expand Down Expand Up @@ -890,10 +892,22 @@ cdef class EventDispatcher(ObjectWithUid):

@property
def proxy_ref(self):
'''Default implementation of proxy_ref, returns self.
'''Returns a :class:`~kivy.weakproxy.WeakProxy` reference to the
:class:`EventDispatcher`.
.. versionadded:: 1.9.0
.. versionchanged:: 2.0.0
Previously it just returned itself, now it actually returns a
:class:`~kivy.weakproxy.WeakProxy`.
'''
return self
_proxy_ref = self._proxy_ref
if _proxy_ref is not None:
return _proxy_ref

self._proxy_ref = _proxy_ref = WeakProxy(self)
return _proxy_ref


cdef class BoundCallback:
Expand Down

0 comments on commit f9a225e

Please sign in to comment.