From b1f81ac56184a172f093b0a640890de9ded405d7 Mon Sep 17 00:00:00 2001 From: Matt Deacalion Stevens Date: Sun, 21 May 2017 10:58:36 +0100 Subject: Fix `unobserve_property` RuntimeError --- mpv.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'mpv.py') diff --git a/mpv.py b/mpv.py index 600e7c6..0782cec 100644 --- a/mpv.py +++ b/mpv.py @@ -681,8 +681,15 @@ class MPV(object): fmts = self._property_handlers[name] for fmt, handlers in fmts.items(): handlers.remove(handler) - if not handlers: - del fmts[fmt] + + # remove all properties that have no handlers + empty_props = [ + fmt for fmt, handler in fmts.items() if not handler + ] + + for fmt in empty_props: + del fmts[fmt] + if not fmts: _mpv_unobserve_property(self._event_handle, hash(name)&0xffffffffffffffff) -- cgit