Skip to content

Commit

Permalink
Merge pull request #1137 from ZLLentz/fix_reldisp_nonpydm
Browse files Browse the repository at this point in the history
FIX: maintain reference to related displays to avoid gc
  • Loading branch information
jbellister-slac authored Jan 8, 2025
2 parents e320a28 + e8e2391 commit 52f581e
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions pydm/widgets/related_display_button.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ def __init__(
# but standard icons are already colored and can not be set.
self._pydm_icon_color = QColor(90, 90, 90)

# Retain references to subdisplays to avoid garbage collection
self._subdisplays = []

@only_if_channel_set
def check_enable_state(self) -> None:
"""
Expand Down Expand Up @@ -602,6 +605,13 @@ def open_display(self, filename, macro_string="", target=None):
# Not a pydm app: need to give our new display proper pydm styling
# Usually done in PyDMApplication
merge_widget_stylesheet(widget=display)
# Clean up references to closed subdisplays
for old_display in list(self._subdisplays):
# isVisible only goes False after clicking "close"
if not old_display.isVisible():
self._subdisplays.remove(old_display)
# Retain a reference to avoid garbage collection
self._subdisplays.append(display)
return display

def context_menu(self):
Expand Down

0 comments on commit 52f581e

Please sign in to comment.