Skip to content

Commit

Permalink
Fix destroy
Browse files Browse the repository at this point in the history
  • Loading branch information
acbart committed Nov 9, 2023
1 parent 61065b7 commit b6bc076
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 11 deletions.
4 changes: 4 additions & 0 deletions change_log.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
Change Log
==========

# Version 0.6.2

* Fixed bug with destroying designer objects leaving behind its render event (and therefore leaving it on the screen!)

# Version 0.6.1

* Fix error in designer object layers caused by the scene rewrite
Expand Down
2 changes: 1 addition & 1 deletion designer/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from os import environ

environ['PYGAME_HIDE_SUPPORT_PROMPT'] = '1'
__version__ = '0.6.1'
__version__ = '0.6.2'

# For `debug` support on Mac, we need to preload tkinter
from designer.system import setup_debug_mode
Expand Down
15 changes: 7 additions & 8 deletions designer/core/scene.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import sys

try:
from weakref import ref as _wref
from weakref import ref as _wref, WeakMethod
except ImportError:
_wref = lambda x: x

Expand Down Expand Up @@ -281,10 +281,11 @@ def _unregister(self, event_namespace, handler):
event_namespace = event_namespace[:-2]
self._handlers[event_namespace] = [h for h
in self._handlers[event_namespace]
if ((not hasattr(h[0], '__self__') and handler != h[0])
or hasattr(h[0], '__self__')
and ((h[0].__func__ is not handler.__func__)
or (h[0].__self__ is not handler.__self__)))]
if ((not isinstance(h[0], WeakMethod)) and handler != h[0])
or (isinstance(h[0], _wref) or isinstance(h[0], WeakMethod))
and ((not hasattr(h[0](), '__self__') and handler != h[0]())
or hasattr(h[0](), '__self__') and ((h[0]().__func__ is not handler.__func__)
or (h[0]().__self__ is not handler.__self__)))]
if not self._handlers[event_namespace]:
del self._handlers[event_namespace]

Expand Down Expand Up @@ -465,11 +466,9 @@ def _remove_static_blit(self, key):
"""
Removes this object from the static blit list
"""
try:
if key in self._static_blits:
x = self._static_blits.pop(key)
self._clear_this_frame.append(x.rect)
except:
pass

def _draw(self):
"""
Expand Down
4 changes: 2 additions & 2 deletions designer/objects/designer_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -545,10 +545,10 @@ def destroy(self):
remember to ``del`` the reference to it.
"""
self._active = False
designer.GLOBAL_DIRECTOR._untrack_object(self)
self._scene()._unregister_object(self)
self._scene()._remove_static_blit(self)
self._scene()._unregister_object(self)
self._parent()._remove_child(self)
designer.GLOBAL_DIRECTOR._untrack_object(self)
unregister('director.render', self._draw)

def _reactivate(self):
Expand Down

0 comments on commit b6bc076

Please sign in to comment.