Skip to content

Commit

Permalink
Fix resource leak issue - 372
Browse files Browse the repository at this point in the history
Scenario - If we have multiple level of parents for chart widget and If
we dispose bottom most(top most is chart) widget by invoking dispose
chart widget get disposed without calling chart.dispose(). Any
subsequent call to dispose never calls dispose for it's children. So
checking if chart disposed in the dispose method never give an
opportunity to children dispose in the above Scenario. I have added
chart disposed safety check at Title because this was causing the issue
#289.

Fixes #372
  • Loading branch information
raghucssit committed Feb 5, 2024
1 parent 9b90a7c commit 452e1f4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
12 changes: 5 additions & 7 deletions org.eclipse.swtchart/src/org/eclipse/swtchart/Chart.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2008, 2023 SWTChart project.
* Copyright (c) 2008, 2024 SWTChart project.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -386,12 +386,10 @@ public void update() {
@Override
public void dispose() {

if(!isDisposed()) {
title.dispose();
legend.dispose();
axisSet.dispose();
super.dispose();
}
title.dispose();
legend.dispose();
axisSet.dispose();
super.dispose();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2008, 2023 SWTChart project.
* Copyright (c) 2008, 2024 SWTChart project.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -277,8 +277,9 @@ public ChartLayoutData getLayoutData() {
* Disposes the resources.
*/
public void dispose() {

chart.removePaintListener(this);
if(!chart.isDisposed()) {
chart.removePaintListener(this);
}
}

@Override
Expand Down

0 comments on commit 452e1f4

Please sign in to comment.