Issue #2925 - added runAsync dispose checks.

Change-Id: I4048f4b4ae8976d93b1bee89179be527ee3139e5

Former-commit-id: 43cfdc587a [formerly 112f7a886e] [formerly 43cfdc587a [formerly 112f7a886e] [formerly 397cb233d4 [formerly 2ebffdcfca606309daa3ed587f696a95af0b094e]]]
Former-commit-id: 397cb233d4
Former-commit-id: 30f7cac193 [formerly 2a6f9e8a85]
Former-commit-id: 60f93fef09
This commit is contained in:
Lee Venable 2014-03-20 12:58:42 -05:00
parent 51eda792e5
commit bf055bee25
6 changed files with 82 additions and 52 deletions

View file

@ -88,6 +88,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
* 04/08/2012 1229 rferrel Made dialog non-blocking. * 04/08/2012 1229 rferrel Made dialog non-blocking.
* 10/15/2012 1229 rferrel Changes for non-blocking HelpUsageDlg. * 10/15/2012 1229 rferrel Changes for non-blocking HelpUsageDlg.
* 16 Aug 2013 #2256 lvenable Fixed image and cursor memory leaks. * 16 Aug 2013 #2256 lvenable Fixed image and cursor memory leaks.
* 19Mar2014 #2925 lvenable Added dispose checks for runAsync.
* *
* </pre> * </pre>
* *
@ -830,14 +831,16 @@ public class CigVisDistributionDlg extends CaveSWTDialog implements
} }
} }
if (isDisposed() == false) { VizApp.runAsync(new Runnable() {
VizApp.runAsync(new Runnable() { @Override
@Override public void run() {
public void run() { if (isDisposed()) {
setBusyCursor(false); return;
} }
});
} setBusyCursor(false);
}
});
} }
} }
}; };
@ -895,6 +898,10 @@ public class CigVisDistributionDlg extends CaveSWTDialog implements
@Override @Override
public void run() { public void run() {
if (isDisposed()) {
return;
}
((ICigVisTabComp) byMonthTab.getControl()) ((ICigVisTabComp) byMonthTab.getControl())
.setCigVisData(data); .setCigVisData(data);
((ICigVisTabComp) byHourTab.getControl()) ((ICigVisTabComp) byHourTab.getControl())

View file

@ -47,9 +47,10 @@ import com.raytheon.viz.aviation.monitor.AvnPyUtil;
* SOFTWARE HISTORY * SOFTWARE HISTORY
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Oct 5, 2009 avarani Initial creation * Oct 5, 2009 avarani Initial creation
* Mar 31,2011 8774 rferrel killProcess when doing a disposed * Mar 31,2011 8774 rferrel killProcess when doing a disposed
* Apr 4, 2011 8896 rferrel Made timeout configurable * Apr 4, 2011 8896 rferrel Made timeout configurable
* 19Mar2014 #2925 lvenable Added dispose checks for runAsync.
* *
* </pre> * </pre>
* *
@ -196,15 +197,16 @@ public class CigVisTrendDataManager implements PyProcessListener {
pythonScript = null; pythonScript = null;
} }
} }
if (CigVisTrendDataManager.this.parent.isDisposed() == false) {
VizApp.runAsync(new Runnable() { VizApp.runAsync(new Runnable() {
@Override @Override
public void run() { public void run() {
if (CigVisTrendDataManager.this.parent.isDisposed() == false) {
CigVisTrendDataManager.this.parent CigVisTrendDataManager.this.parent
.resetCursor(); .resetCursor();
} }
}); }
} });
} }
} }
}; };
@ -256,7 +258,9 @@ public class CigVisTrendDataManager implements PyProcessListener {
VizApp.runAsync(new Runnable() { VizApp.runAsync(new Runnable() {
@Override @Override
public void run() { public void run() {
parent.dataReceived(); if (parent.isDisposed() == false) {
parent.dataReceived();
}
} }
}); });
} }

View file

@ -89,6 +89,7 @@ import com.raytheon.viz.ui.dialogs.ICloseCallback;
* 10/15/2012 1229 rferrel Changes for non-blocking HelpUsageDlg. * 10/15/2012 1229 rferrel Changes for non-blocking HelpUsageDlg.
* 11/26/2012 1298 rferrel Non-blocking dialog code cleanup. * 11/26/2012 1298 rferrel Non-blocking dialog code cleanup.
* 12 Aug 2013 #2256 lvenable Disposed of masterImage. * 12 Aug 2013 #2256 lvenable Disposed of masterImage.
* 19Mar2014 #2925 lvenable Added dispose checks for runAsync.
* *
* </pre> * </pre>
* *
@ -723,21 +724,24 @@ public class WeatherPlotDialog extends CaveSWTDialog {
@Override @Override
public void run() { public void run() {
dataMgr.loadCacheData(siteId); dataMgr.loadCacheData(siteId);
if (isDisposed() == false) {
VizApp.runAsync(new Runnable() { VizApp.runAsync(new Runnable() {
@Override @Override
public void run() { public void run() {
if (dataMgr.loadData(siteId, currentTime)) { if (isDisposed()) {
updateSiteTimeLabel(); return;
displayData();
} else {
// Something cleared the cache try again.
populateData();
}
setCursorBusy(false);
} }
});
} if (dataMgr.loadData(siteId, currentTime)) {
updateSiteTimeLabel();
displayData();
} else {
// Something cleared the cache try again.
populateData();
}
setCursorBusy(false);
}
});
} }
}); });
thread.start(); thread.start();

View file

@ -64,6 +64,7 @@ import com.raytheon.uf.viz.core.exception.VizException;
* 3/31/2011 8774 rferrel killProcess when doing a disposed * 3/31/2011 8774 rferrel killProcess when doing a disposed
* 4/4/2011 8896 rferrel Made timeout configurable * 4/4/2011 8896 rferrel Made timeout configurable
* 3/9/2012 14530 zhao Revised wind rose plot to match AWIPS-1 * 3/9/2012 14530 zhao Revised wind rose plot to match AWIPS-1
* 19Mar2014 #2925 lvenable Added dispose checks for runAsync and cleaned up code.
* *
* </pre> * </pre>
* *
@ -77,7 +78,7 @@ public class WindRoseDataMgr implements PyProcessListener {
private static WindRoseDataMgr instance = null; private static WindRoseDataMgr instance = null;
private static WindRoseCanvasComp canvas; private WindRoseCanvasComp canvas;
private String siteId; private String siteId;
@ -246,12 +247,12 @@ public class WindRoseDataMgr implements PyProcessListener {
final int flightCat, final String site, WindRoseCanvasComp canvas) { final int flightCat, final String site, WindRoseCanvasComp canvas) {
final int timeout = ClimateTimeoutManager.getInstance() final int timeout = ClimateTimeoutManager.getInstance()
.getWindRoseTimeout(); .getWindRoseTimeout();
WindRoseDataMgr.canvas = canvas; this.canvas = canvas;
if (site.equals(siteId) && (Integer.parseInt(monthStr) == month) if (site.equals(siteId) && (Integer.parseInt(monthStr) == month)
&& (Integer.parseInt(numMonths) == this.numMonths) && (Integer.parseInt(numMonths) == this.numMonths)
&& flightCat == this.flightCat) { && flightCat == this.flightCat) {
WindRoseDataMgr.canvas.resetCursor(); this.canvas.resetCursor();
return; return;
} }
@ -315,14 +316,14 @@ public class WindRoseDataMgr implements PyProcessListener {
} }
} }
if (WindRoseDataMgr.canvas.isDisposed() == false) { VizApp.runAsync(new Runnable() {
VizApp.runAsync(new Runnable() { @Override
@Override public void run() {
public void run() { if (WindRoseDataMgr.this.canvas.isDisposed() == false) {
WindRoseDataMgr.canvas.resetCursor(); WindRoseDataMgr.this.canvas.resetCursor();
} }
}); }
} });
} }
} }
}; };
@ -554,7 +555,7 @@ public class WindRoseDataMgr implements PyProcessListener {
} }
for (int i = 0; i < dblArray.length; ++i) { for (int i = 0; i < dblArray.length; ++i) {
dblArray[i] = (dblArray[i] / totalCount) * 100; dblArray[i] = (dblArray[i] / totalCount) * 100;
} }
return dblArray; return dblArray;
@ -622,10 +623,11 @@ public class WindRoseDataMgr implements PyProcessListener {
public void printData(String filename) { public void printData(String filename) {
File file = new File(filename); File file = new File(filename);
FileWriter writer; FileWriter writer = null;
BufferedWriter buf = null;
try { try {
writer = new FileWriter(file); writer = new FileWriter(file);
BufferedWriter buf = new BufferedWriter(writer); buf = new BufferedWriter(writer);
for (int i = 0; i < numMonths; i++) { for (int i = 0; i < numMonths; i++) {
int monthIdx = month + i; int monthIdx = month + i;
@ -688,11 +690,15 @@ public class WindRoseDataMgr implements PyProcessListener {
buf.write("\n"); buf.write("\n");
} }
} }
buf.close();
writer.close();
} catch (IOException e) { } catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} finally {
try {
buf.close();
writer.close();
} catch (IOException e) {
// Ignore
}
} }
} }
} }

View file

@ -34,7 +34,8 @@ import com.raytheon.viz.aviation.observer.TafMonitorDlg;
* SOFTWARE HISTORY * SOFTWARE HISTORY
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Sep 3, 2009 njensen Initial creation * Sep 3, 2009 njensen Initial creation
* 19Mar2014 #2925 lvenable Added dispose checks for runAsync.
* *
* </pre> * </pre>
* *
@ -56,7 +57,9 @@ public abstract class MonitorObserver implements IAlertObserver {
VizApp.runAsync(new Runnable() { VizApp.runAsync(new Runnable() {
@Override @Override
public void run() { public void run() {
dialog.getMessageBar().setMessageText(msg, GREEN); if (dialog.isDisposed() == false) {
dialog.getMessageBar().setMessageText(msg, GREEN);
}
} }
}); });
} }

View file

@ -93,6 +93,7 @@ import com.raytheon.viz.avnconfig.IStatusSettable;
* 20JUL2012 14570 gzhang/zhao Add data structure for highlighting correct time groups in TAF viewer * 20JUL2012 14570 gzhang/zhao Add data structure for highlighting correct time groups in TAF viewer
* 01/02/2013 15606 gzhang Remove GridData widthHint so button/label size change with GUI * 01/02/2013 15606 gzhang Remove GridData widthHint so button/label size change with GUI
* 03/07/2013 1735 rferrel Flag to indicate grid data is needed. * 03/07/2013 1735 rferrel Flag to indicate grid data is needed.
* 19Mar2014 #2925 lvenable Added dispose checks for runAsync.
* </pre> * </pre>
* *
* @author lvenable * @author lvenable
@ -554,8 +555,11 @@ public class TafSiteComp {
if (taf == null) { if (taf == null) {
VizApp.runAsync(new Runnable() { VizApp.runAsync(new Runnable() {
public void run() { public void run() {
siteIdBtn.setBackground(getErrorColor()); if (siteIdBtn.isDisposed() == false
tafTimeLbl.setText("HH:MM"); && tafTimeLbl.isDisposed() == false) {
siteIdBtn.setBackground(getErrorColor());
tafTimeLbl.setText("HH:MM");
}
} }
}); });
} }
@ -824,6 +828,8 @@ public class TafSiteComp {
// Update viewer with new TAF. // Update viewer with new TAF.
VizApp.runAsync(new Runnable() { VizApp.runAsync(new Runnable() {
public void run() { public void run() {
// Not checking for a dispose since this is an interface.
// The method should be responsible for handling this.
tveDlg.updateSettings(TafSettings.UPDATE_VIEW, stationName); tveDlg.updateSettings(TafSettings.UPDATE_VIEW, stationName);
} }
}); });