Fixed a memory leak at diagramwindow