When opening and closing the slightly modified example dialog (examples/dialog/main.py) multiple times, this allocates a few extra MB of RAM each time the dialog is opened, which are never freed.
The problem can be traced down to dialog.editor.scene.set_state(state).
from nodes import ConstantNode, OperationNode, OutputNode, SquareRootNode
from PyQt5.QtWidgets import QApplication, QMainWindow, QPushButton
from QNodeEditor import NodeEditorDialog
def run_dialog(state: dict):
dialog.editor.scene.set_state(state)
succeeded = dialog.exec()
state.update(dialog.editor.scene.get_state())
if __name__ == "__main__":
# Create an application and a main window with a button
state = {}
app = QApplication([])
window = QMainWindow()
dialog = NodeEditorDialog()
dialog.editor.available_nodes = {
"Constant": ConstantNode,
"Math": {"Operation": OperationNode, "Square root": SquareRootNode},
"Output": OutputNode,
}
dialog.editor.output_node = OutputNode
# Create a button that when pressed opens the dialog
button = QPushButton("Open node editor")
state = {}
button.clicked.connect(lambda _: run_dialog(state))
window.setCentralWidget(button)
# Start the application
window.show()
app.exec()
When opening and closing the slightly modified example dialog (examples/dialog/main.py) multiple times, this allocates a few extra MB of RAM each time the dialog is opened, which are never freed.
The problem can be traced down to
dialog.editor.scene.set_state(state)
.Details: QNodeEditor 1.0.6, Python 3.12 (virtualenv) OS: