Issue #2353 - fixed cursor memory leaks

Former-commit-id: 0481bd1eaf467d1be6b8cc2f558f2de0301969ad
This commit is contained in:
Lee Venable 2013-09-12 08:37:09 -05:00
parent dcab61ba26
commit e70475bb7b
8 changed files with 70 additions and 80 deletions

View file

@ -23,7 +23,6 @@ import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException; import org.eclipse.core.commands.ExecutionException;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Cursor;
import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI; import org.eclipse.ui.PlatformUI;
@ -37,7 +36,8 @@ import com.raytheon.viz.mpe.ui.dialogs.gagetable.GageTableDlg;
* SOFTWARE HISTORY * SOFTWARE HISTORY
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* May 28, 2009 mpduff Initial creation * May 28, 2009 mpduff Initial creation
* Sep 11, 2013 #2353 lvenable Fixed cursor memory leaks.
* *
* </pre> * </pre>
* *
@ -46,41 +46,17 @@ import com.raytheon.viz.mpe.ui.dialogs.gagetable.GageTableDlg;
*/ */
public class GageTableAction extends AbstractHandler { public class GageTableAction extends AbstractHandler {
private Cursor waitCursor = null;
private Cursor arrowCursor = null;
@Override @Override
public Object execute(ExecutionEvent event) throws ExecutionException { public Object execute(ExecutionEvent event) throws ExecutionException {
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow() Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
.getShell(); .getShell();
waitCursor = new Cursor(shell.getDisplay(), SWT.CURSOR_WAIT);
arrowCursor = new Cursor(shell.getDisplay(), SWT.CURSOR_ARROW); shell.setCursor(shell.getDisplay().getSystemCursor(SWT.CURSOR_WAIT));
shell.setCursor(waitCursor);
GageTableDlg gageTable = new GageTableDlg(); GageTableDlg gageTable = new GageTableDlg();
gageTable.open(); gageTable.open();
// try { shell.setCursor(null);
// gageTable.showGageTable();
// } catch (ParseException e) {
// e.printStackTrace();
// MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR
// | SWT.OK);
// mb.setText("Error");
// mb
// .setMessage("Unable to open Gage Table Dialog.");
// mb.open();
// } catch (IOException e) {
// MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR
// | SWT.OK);
// mb.setText("Error");
// mb
// .setMessage("Unable to open Gage Table Dialog.");
// mb.open();
// e.printStackTrace();
// }
shell.setCursor(arrowCursor);
return null; return null;
} }

View file

@ -23,7 +23,6 @@ import java.util.ArrayList;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Cursor; import org.eclipse.swt.graphics.Cursor;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI; import org.eclipse.ui.PlatformUI;
@ -50,7 +49,8 @@ import com.raytheon.viz.mpe.util.ReadTemperatureStationList;
* SOFTWARE HISTORY * SOFTWARE HISTORY
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Apr 1, 2009 snaples Initial creation * Apr 1, 2009 snaples Initial creation
* Sep 11, 2013 #2353 lvenable Fixed cursor memory leaks.
* *
* </pre> * </pre>
* *
@ -77,9 +77,7 @@ public class ScreeningOptions {
ArrayList<Station> temp_stations = DailyQcUtils.temperature_stations; ArrayList<Station> temp_stations = DailyQcUtils.temperature_stations;
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow() Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
.getShell(); .getShell();
final Cursor prevCursor = shell.getCursor(); Cursor prevCursor = shell.getCursor();
final Cursor waitCursor = new Cursor(Display.getDefault(),
SWT.CURSOR_WAIT);
if (client_data == 0) { if (client_data == 0) {
pdata[pcpn_day].stddev = 5.0f; pdata[pcpn_day].stddev = 5.0f;
@ -97,7 +95,7 @@ public class ScreeningOptions {
tdata[pcpn_day].stddev = 5.0f; tdata[pcpn_day].stddev = 5.0f;
} }
shell.setCursor(waitCursor); shell.setCursor(shell.getDisplay().getSystemCursor(SWT.CURSOR_WAIT));
/* /*
* do not estimate daily and partial point precipitation from each other * do not estimate daily and partial point precipitation from each other

View file

@ -66,6 +66,7 @@ import com.raytheon.viz.ui.perspectives.VizPerspectiveListener;
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Jul, 7 2009 snaples Initial creation * Jul, 7 2009 snaples Initial creation
* Sep 11, 2013 #2353 lvenable Fixed cursor memory leak.
* *
* </pre> * </pre>
* *
@ -382,7 +383,7 @@ public class QcFreezeOptionsDialog extends AbstractMPEDialog {
dataOptionsGroup.setLayoutData(gd); dataOptionsGroup.setLayoutData(gd);
final Shell shell = this.getParent(); final Shell shell = this.getParent();
final Cursor prevCursor = shell.getCursor(); final Cursor prevCursor = shell.getCursor();
final Cursor waitCursor = new Cursor(Display.getDefault(), final Cursor waitCursor = Display.getDefault().getSystemCursor(
SWT.CURSOR_WAIT); SWT.CURSOR_WAIT);
// Create a container to hold the label and the combo box. // Create a container to hold the label and the combo box.

View file

@ -64,9 +64,9 @@ import com.raytheon.viz.mpe.util.DailyQcUtils.Ts;
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Nov 12, 2008 snaples Initial creation * Nov 12, 2008 snaples Initial creation
* Mar 7, 2013 15657 lbousaidi fixed DQC slider and added listener to the Keys * Mar 7, 2013 15657 lbousaidi fixed DQC slider and added listener to the Keys
* when pressed. * when pressed.
* * Sep 11, 2013 #2353 lvenable Fixed cursor memory leak.
* </pre> * </pre>
* *
* @author snaples * @author snaples
@ -381,7 +381,7 @@ public class QcPrecipOptionsDialog extends AbstractMPEDialog {
dataOptionsGroup.setLayoutData(gd); dataOptionsGroup.setLayoutData(gd);
final Shell shell = this.getParent(); final Shell shell = this.getParent();
final Cursor prevCursor = shell.getCursor(); final Cursor prevCursor = shell.getCursor();
final Cursor waitCursor = new Cursor(Display.getDefault(), final Cursor waitCursor = Display.getDefault().getSystemCursor(
SWT.CURSOR_WAIT); SWT.CURSOR_WAIT);
if (MPEDisplayManager.pcpn_time_step != 1) { if (MPEDisplayManager.pcpn_time_step != 1) {
@ -910,9 +910,8 @@ public class QcPrecipOptionsDialog extends AbstractMPEDialog {
}); });
/** /**
* Add a key listener for up and down arrows * Add a key listener for up and down arrows to move up and down through
* to move up and down through the filter * the filter scale
* scale
*/ */
pntFilter.addKeyListener(new KeyAdapter() { pntFilter.addKeyListener(new KeyAdapter() {
@ -966,9 +965,8 @@ public class QcPrecipOptionsDialog extends AbstractMPEDialog {
}); });
/** /**
* Add a key listener for up and down arrows * Add a key listener for up and down arrows to move up and down through
* to move up and down through the reverse filter * the reverse filter scale
* scale
*/ */
pntRevFilter.addKeyListener(new KeyAdapter() { pntRevFilter.addKeyListener(new KeyAdapter() {
@Override @Override

View file

@ -63,6 +63,7 @@ import com.raytheon.viz.mpe.util.DailyQcUtils.Ts;
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Nov 12, 2008 snaples Initial creation * Nov 12, 2008 snaples Initial creation
* Sep 11, 2013 #2353 lvenable Fixed cursor memory leak.
* *
* </pre> * </pre>
* *
@ -375,7 +376,7 @@ public class QcTempOptionsDialog extends AbstractMPEDialog {
dataOptionsGroup.setLayoutData(gd); dataOptionsGroup.setLayoutData(gd);
final Shell shell = this.getParent(); final Shell shell = this.getParent();
final Cursor prevCursor = shell.getCursor(); final Cursor prevCursor = shell.getCursor();
final Cursor waitCursor = new Cursor(Display.getDefault(), final Cursor waitCursor = Display.getDefault().getSystemCursor(
SWT.CURSOR_WAIT); SWT.CURSOR_WAIT);
// Create a container to hold the label and the combo box. // Create a container to hold the label and the combo box.

View file

@ -57,6 +57,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
* Jan 26, 2011 7761 bkowal The value associated with polygons * Jan 26, 2011 7761 bkowal The value associated with polygons
* with the "scale" action will no * with the "scale" action will no
* longer be divided by 100. * longer be divided by 100.
* Sep 11, 2013 #2353 lvenable Fixed cursor memory leak.
* *
* </pre> * </pre>
* *
@ -120,7 +121,7 @@ public class DrawPolygonDlg extends CaveSWTDialog {
super(parentShell, SWT.DIALOG_TRIM, CAVE.DO_NOT_BLOCK); super(parentShell, SWT.DIALOG_TRIM, CAVE.DO_NOT_BLOCK);
setText("Edit Precipitation"); setText("Edit Precipitation");
this.resource = resource; this.resource = resource;
waitCursor = new Cursor(parentShell.getDisplay(), SWT.CURSOR_WAIT); waitCursor = parentShell.getDisplay().getSystemCursor(SWT.CURSOR_WAIT);
} }
@Override @Override

View file

@ -51,7 +51,8 @@ import com.raytheon.viz.ui.input.InputAdapter;
* *
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Feb 8, 2011 mschenke Initial creation * Feb 8, 2011 mschenke Initial creation
* Sep 11, 2013 #2353 lvenable Fixed cursor memory leak.
* *
* </pre> * </pre>
* *
@ -71,7 +72,7 @@ public abstract class AbstractMPEInputResource extends
map.put(PROPERTY, false); map.put(PROPERTY, false);
} }
private static final Cursor CURSOR_HAND = new Cursor(Display.getDefault(), private final Cursor CURSOR_HAND = Display.getDefault().getSystemCursor(
SWT.CURSOR_HAND); SWT.CURSOR_HAND);
/** Input handler for polygon creation and dialog opening */ /** Input handler for polygon creation and dialog opening */

View file

@ -60,6 +60,7 @@ import com.vividsolutions.jts.geom.Coordinate;
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Feb 16, 2009 snaples Initial creation * Feb 16, 2009 snaples Initial creation
* Dec 04, 2012 15544 wkwock fix missing 12z-18z after 12 * Dec 04, 2012 15544 wkwock fix missing 12z-18z after 12
* Sep 11, 2013 #2353 lvenable Fixed cursor memory leaks and Scanner resource leak.
* *
* </pre> * </pre>
* *
@ -877,13 +878,12 @@ public class DailyQcUtils {
qcDays = MPEDataManager.getInstance().getDQCDays(); qcDays = MPEDataManager.getInstance().getDQCDays();
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow() Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
.getShell(); .getShell();
Cursor prev = shell.getCursor(); Cursor prevCursor = shell.getCursor();
Cursor wait = new Cursor(Display.getDefault(), SWT.CURSOR_WAIT); shell.setCursor(Display.getDefault().getSystemCursor(SWT.CURSOR_WAIT));
shell.setCursor(wait);
new_area_flag = 1; new_area_flag = 1;
int retval = loadDataSet(); int retval = loadDataSet();
lastQcArea = currentQcArea; lastQcArea = currentQcArea;
shell.setCursor(prev); shell.setCursor(prevCursor);
return retval; return retval;
} }
@ -930,15 +930,15 @@ public class DailyQcUtils {
|| newarea == true) { || newarea == true) {
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow() Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
.getShell(); .getShell();
Cursor prev = shell.getCursor(); Cursor prevCursor = shell.getCursor();
Cursor wait = new Cursor(Display.getDefault(), SWT.CURSOR_WAIT); shell.setCursor(Display.getDefault().getSystemCursor(
shell.setCursor(wait); SWT.CURSOR_WAIT));
int retval = loadDataSet(); int retval = loadDataSet();
if (retval == 2) { if (retval == 2) {
load_gage_data_once = 1; load_gage_data_once = 1;
} }
lastQcArea = currentQcArea; lastQcArea = currentQcArea;
shell.setCursor(prev); shell.setCursor(prevCursor);
return retval; return retval;
} else { } else {
new_area_flag = 1; new_area_flag = 1;
@ -1022,11 +1022,15 @@ public class DailyQcUtils {
btime.set(Calendar.SECOND, 0); btime.set(Calendar.SECOND, 0);
hrgt12z = 0; hrgt12z = 0;
} }
/* In order to allow user access the 12~18Z point data for the most recent day, /*
advance one more day from current day if the later than 18Z */ * In order to allow user access the 12~18Z point data for the most
Calendar currentTime = Calendar.getInstance(TimeZone.getTimeZone("GMT")); * recent day, advance one more day from current day if the later than
if (currentTime.get(Calendar.HOUR_OF_DAY)>=18) { * 18Z
btime.add(Calendar.DAY_OF_MONTH, 1); */
Calendar currentTime = Calendar
.getInstance(TimeZone.getTimeZone("GMT"));
if (currentTime.get(Calendar.HOUR_OF_DAY) >= 18) {
btime.add(Calendar.DAY_OF_MONTH, 1);
} }
emonth = btime.get(Calendar.MONTH); emonth = btime.get(Calendar.MONTH);
@ -1285,7 +1289,7 @@ public class DailyQcUtils {
if (td_fp == null) { if (td_fp == null) {
statusHandler statusHandler
.handle(Priority.PROBLEM, .handle(Priority.PROBLEM,
"Could not open mpe_td_details_file in load_gage_data()."); "Could not open mpe_td_details_file in load_gage_data().");
return 0; return 0;
} }
try { try {
@ -1293,7 +1297,7 @@ public class DailyQcUtils {
} catch (IOException e) { } catch (IOException e) {
statusHandler statusHandler
.handle(Priority.PROBLEM, .handle(Priority.PROBLEM,
"Could not open mpe_td_details_file for writing, in load_gage_data()."); "Could not open mpe_td_details_file for writing, in load_gage_data().");
} }
} }
@ -1349,7 +1353,7 @@ public class DailyQcUtils {
if (freezing_stations == null) { if (freezing_stations == null) {
statusHandler statusHandler
.handle(Priority.PROBLEM, .handle(Priority.PROBLEM,
"ERROR, Could not read freezing level station list file. DailyQC stopped."); "ERROR, Could not read freezing level station list file. DailyQC stopped.");
return DAILYQC_FAILED; return DAILYQC_FAILED;
} }
System.out.println("DQC: Reading Temperature Stations List. "); System.out.println("DQC: Reading Temperature Stations List. ");
@ -1358,7 +1362,7 @@ public class DailyQcUtils {
if (temperature_stations == null) { if (temperature_stations == null) {
statusHandler statusHandler
.handle(Priority.PROBLEM, .handle(Priority.PROBLEM,
"ERROR, Could not read temperature station list file. DailyQC stopped."); "ERROR, Could not read temperature station list file. DailyQC stopped.");
return DAILYQC_FAILED; return DAILYQC_FAILED;
} }
System.out.println("DQC: Reading Precip Stations List. "); System.out.println("DQC: Reading Precip Stations List. ");
@ -1367,7 +1371,7 @@ public class DailyQcUtils {
if (precip_stations == null) { if (precip_stations == null) {
statusHandler statusHandler
.handle(Priority.PROBLEM, .handle(Priority.PROBLEM,
"ERROR, Could not read precip station list file. DailyQC stopped."); "ERROR, Could not read precip station list file. DailyQC stopped.");
return DAILYQC_FAILED; return DAILYQC_FAILED;
} }
@ -1377,7 +1381,7 @@ public class DailyQcUtils {
if (status == false) { if (status == false) {
statusHandler statusHandler
.handle(Priority.PROBLEM, .handle(Priority.PROBLEM,
"Could not read precipitation Climo file. DailyQC stopped."); "Could not read precipitation Climo file. DailyQC stopped.");
return DAILYQC_FAILED; return DAILYQC_FAILED;
} }
@ -1387,7 +1391,7 @@ public class DailyQcUtils {
if (status == false) { if (status == false) {
statusHandler statusHandler
.handle(Priority.PROBLEM, .handle(Priority.PROBLEM,
"Could not read temperature Climo file. DailyQC stopped."); "Could not read temperature Climo file. DailyQC stopped.");
return DAILYQC_FAILED; return DAILYQC_FAILED;
} }
} }
@ -1399,7 +1403,7 @@ public class DailyQcUtils {
if (status == false) { if (status == false) {
statusHandler statusHandler
.handle(Priority.PROBLEM, .handle(Priority.PROBLEM,
"Could not read precipitation PRISM file. DailyQC stopped."); "Could not read precipitation PRISM file. DailyQC stopped.");
return DAILYQC_FAILED; return DAILYQC_FAILED;
} }
@ -1408,7 +1412,7 @@ public class DailyQcUtils {
smonth, emonth); smonth, emonth);
if (status == false) { if (status == false) {
statusHandler.handle(Priority.PROBLEM, statusHandler.handle(Priority.PROBLEM,
"Could not read temperature PRISM file. DailyQC stopped."); "Could not read temperature PRISM file. DailyQC stopped.");
return DAILYQC_FAILED; return DAILYQC_FAILED;
} }
System.out.println("DQC: Finished loading Climo data. "); System.out.println("DQC: Finished loading Climo data. ");
@ -1436,7 +1440,7 @@ public class DailyQcUtils {
if (status == false) { if (status == false) {
statusHandler statusHandler
.handle(Priority.PROBLEM, .handle(Priority.PROBLEM,
"Could not map freezing level points to the HRAP grid. DailyQC stopped."); "Could not map freezing level points to the HRAP grid. DailyQC stopped.");
return DAILYQC_FAILED; return DAILYQC_FAILED;
} }
System.out.println("DQC: Mapping temperature gages to grid. "); System.out.println("DQC: Mapping temperature gages to grid. ");
@ -1447,7 +1451,7 @@ public class DailyQcUtils {
if (status == false) { if (status == false) {
statusHandler statusHandler
.handle(Priority.PROBLEM, .handle(Priority.PROBLEM,
"Could not map temp level points to the HRAP grid. DailyQC stopped."); "Could not map temp level points to the HRAP grid. DailyQC stopped.");
return DAILYQC_FAILED; return DAILYQC_FAILED;
} }
long elapsed = System.currentTimeMillis() - start; long elapsed = System.currentTimeMillis() - start;
@ -1474,7 +1478,7 @@ public class DailyQcUtils {
mean_areal_precip_global, tag); mean_areal_precip_global, tag);
if (status == false) { if (status == false) {
statusHandler.handle(Priority.PROBLEM, statusHandler.handle(Priority.PROBLEM,
"Error retrieving basin data. DailyQC Stopped."); "Error retrieving basin data. DailyQC Stopped.");
return DAILYQC_FAILED; return DAILYQC_FAILED;
} }
} }
@ -1651,12 +1655,13 @@ public class DailyQcUtils {
// open and read file containing std dev of point precip data // open and read file containing std dev of point precip data
// -------------------------------------------------------------- // --------------------------------------------------------------
BufferedReader in = null; BufferedReader in = null;
Scanner s = null;
try { try {
in = new BufferedReader(new FileReader(precc)); in = new BufferedReader(new FileReader(precc));
String ibuf = ""; String ibuf = "";
ibuf = in.readLine(); ibuf = in.readLine();
Scanner s = new Scanner(ibuf); s = new Scanner(ibuf);
pdata[m].stddev = s.nextFloat(); pdata[m].stddev = s.nextFloat();
@ -1665,7 +1670,7 @@ public class DailyQcUtils {
pdata[m].stddev = 3.0f; pdata[m].stddev = 3.0f;
} }
in.close();
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
System.out.println("File not found " + precc); System.out.println("File not found " + precc);
} catch (IOException e) { } catch (IOException e) {
@ -1674,6 +1679,12 @@ public class DailyQcUtils {
try { try {
if (in != null) { if (in != null) {
in.close(); in.close();
in = null;
}
if (s != null) {
s.close();
s = null;
} }
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
@ -1686,7 +1697,7 @@ public class DailyQcUtils {
in = new BufferedReader(new FileReader(tpointc)); in = new BufferedReader(new FileReader(tpointc));
String ibuf = ""; String ibuf = "";
ibuf = in.readLine(); ibuf = in.readLine();
Scanner s = new Scanner(ibuf); s = new Scanner(ibuf);
tdata[m].stddev = s.nextFloat(); tdata[m].stddev = s.nextFloat();
@ -1695,7 +1706,6 @@ public class DailyQcUtils {
tdata[m].stddev = 10.0f; tdata[m].stddev = 10.0f;
} }
in.close();
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
System.out.println("File not found " + tpointc); System.out.println("File not found " + tpointc);
} catch (IOException e) { } catch (IOException e) {
@ -1705,6 +1715,10 @@ public class DailyQcUtils {
if (in != null) { if (in != null) {
in.close(); in.close();
} }
if (s != null) {
s.close();
s = null;
}
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }