Skip to content

Commit

Permalink
Memory leak fixed, dialogs properly delete themselves when closed...
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacrobinson2000 committed Apr 14, 2020
1 parent 5bda981 commit 4299d8d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 15 deletions.
6 changes: 6 additions & 0 deletions gui/cursorhotspotedit.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,8 @@ def __init__(self, parent=None, cursor: AnimatedCursor=None):
for cur_picker in self._hotspot_picker_lst:
cur_picker.userHotspotChange.connect(self._on_hotspot_changed)
cur_picker.userDelayChange.connect(self._on_delay_changed)
# Set to delete this dialog on close...
self.setAttribute(QtCore.Qt.WA_DeleteOnClose, True)


def _share_hotspot_chg(self, state: int):
Expand Down Expand Up @@ -278,3 +280,7 @@ def closeEvent(self, evt: QtGui.QCloseEvent):
def current_cursor(self) -> AnimatedCursor:
return self._cursor


def __del__(self):
print("Deleting Hotspot Dialog...")

19 changes: 4 additions & 15 deletions gui/cursorpreviewdialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,12 @@ def __init__(self, parent=None, cursor: AnimatedCursor=None):
self.setLayout(self._main_layout)
self.setMinimumSize(self.sizeHint())

# Set to delete this dialog on close...
self.setAttribute(QtCore.Qt.WA_DeleteOnClose, True)

def closeEvent(self, evt: QtGui.QCloseEvent):
print("Closed!")
super().closeEvent(evt)

self._preview_panel.stop_and_destroy()
for cur_view in self._viewers:
cur_view.stop_and_destroy()

self.accept()


Expand Down Expand Up @@ -115,14 +113,5 @@ def mouseReleaseEvent(self, event: QtGui.QMouseEvent):
self.mouseMoveEvent(event)
self._pressed = False

def stop_and_destroy(self):
""" Forcefully destroys this CursorPreviewAreas animation timer. """
if((self._animation_timer is not None) and (self._animation_timer.isActive())):
self._animation_timer.stop()

del self._animation_timer
self._animation_timer = None
self.setCursor(QtGui.Qt.ArrowCursor)

def __del__(self):
self.stop_and_destroy()
del self._animation_timer

0 comments on commit 4299d8d

Please sign in to comment.