You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
After using "Reload Display" (Ctrl+R), the previous instance of the Display class is not deleted. I suspect (but don't know for sure) that it is not getting garbage collected.
Expected behavior
The previous instance of the display class should not exist anymore.
Steps to Reproduce
The following code-only display file lets you see the problem happening:
from pydm import Display
from qtpy.QtWidgets import QLabel, QVBoxLayout, QHBoxLayout
from qtpy.QtCore import QTimer
class MyDisplay(Display):
def __init__(self, parent=None, args=[]):
super(MyDisplay, self).__init__(parent=parent, args=args)
self.timer = QTimer(self)
self.timer.setInterval(1000)
self.timer.timeout.connect(self.tick)
self.timer.start()
self.setup_ui()
def setup_ui(self):
main = QHBoxLayout()
sub = QVBoxLayout()
for i in range(10):
sub.addWidget(QLabel(str(i)))
main.addLayout(sub)
self.setLayout(main)
def tick(self):
print("Tick...")
def ui_filename(self):
return None
def ui_filepath(self):
return None
Open this display in PyDM, and in your terminal, you'll see "Tick..." get printed every second. Now do "Reload Display". You'll see that "Tick..." is now printed two times per second - a sign that the old instance of the display, along with its old timer, is still kicking around somewhere in memory.
Possible Solution
I suspect a reference to the Display class is getting stored somewhere at the PyDMApplication level (maybe something like the Rules evaluation engine?) that doesn't get cleared when Reload Display is called. The best way to solve that really depends on the details, but maybe something like using a weakref somewhere would work...
My Platform
Shouldn't matter, but I did my testing on RHEL7, Python 3.10.14, and PyDM 1.24.1
The text was updated successfully, but these errors were encountered:
Describe the bug
After using "Reload Display" (Ctrl+R), the previous instance of the Display class is not deleted. I suspect (but don't know for sure) that it is not getting garbage collected.
Expected behavior
The previous instance of the display class should not exist anymore.
Steps to Reproduce
The following code-only display file lets you see the problem happening:
Open this display in PyDM, and in your terminal, you'll see "Tick..." get printed every second. Now do "Reload Display". You'll see that "Tick..." is now printed two times per second - a sign that the old instance of the display, along with its old timer, is still kicking around somewhere in memory.
Possible Solution
I suspect a reference to the Display class is getting stored somewhere at the PyDMApplication level (maybe something like the Rules evaluation engine?) that doesn't get cleared when Reload Display is called. The best way to solve that really depends on the details, but maybe something like using a weakref somewhere would work...
My Platform
Shouldn't matter, but I did my testing on RHEL7, Python 3.10.14, and PyDM 1.24.1
The text was updated successfully, but these errors were encountered: