From adf3d1d1f32ef4cc8836ee45051f790d6aab742a Mon Sep 17 00:00:00 2001 From: Matthew Einhorn Date: Sat, 27 Jul 2019 18:58:43 -0400 Subject: [PATCH 1/3] Move proxy_ref to EventDispatcher. --- kivy/_event.pxd | 1 + kivy/_event.pyx | 17 +++++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/kivy/_event.pxd b/kivy/_event.pxd index 9cc169f918..18f511aa9d 100644 --- a/kivy/_event.pxd +++ b/kivy/_event.pxd @@ -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) diff --git a/kivy/_event.pyx b/kivy/_event.pyx index a9d5c95f4e..e2053e2960 100644 --- a/kivy/_event.pyx +++ b/kivy/_event.pyx @@ -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, @@ -890,10 +891,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: From 90f799a5bfe17d4a8f4922717be1b77520222603 Mon Sep 17 00:00:00 2001 From: matham Date: Sat, 27 Jul 2019 19:08:19 -0400 Subject: [PATCH 2/3] Update _event.pyx --- kivy/_event.pyx | 1 + 1 file changed, 1 insertion(+) diff --git a/kivy/_event.pyx b/kivy/_event.pyx index e2053e2960..bca7f0a4eb 100644 --- a/kivy/_event.pyx +++ b/kivy/_event.pyx @@ -167,6 +167,7 @@ cdef class EventDispatcher(ObjectWithUid): self.__event_stack = {} self.__storage = {} + self._proxy_ref = None. __cls__ = self.__class__ From a0ffc162d76fb5e9c916c4bd21072b73953c5358 Mon Sep 17 00:00:00 2001 From: matham Date: Sat, 27 Jul 2019 21:25:12 -0400 Subject: [PATCH 3/3] Update _event.pyx --- kivy/_event.pyx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kivy/_event.pyx b/kivy/_event.pyx index bca7f0a4eb..a92aa0a813 100644 --- a/kivy/_event.pyx +++ b/kivy/_event.pyx @@ -167,7 +167,7 @@ cdef class EventDispatcher(ObjectWithUid): self.__event_stack = {} self.__storage = {} - self._proxy_ref = None. + self._proxy_ref = None __cls__ = self.__class__