Issue #2353 - fixed cursor memory leaks

Former-commit-id: e70475bb7b [formerly e70475bb7b [formerly 0481bd1eaf467d1be6b8cc2f558f2de0301969ad]]
Former-commit-id: a52ea0a481
Former-commit-id: 15d4b2e7f3
This commit is contained in:
Lee Venable 2013-09-12 08:37:09 -05:00
parent bc4627a22d
commit d64d1ffad3
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.ExecutionException;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Cursor;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI;
@ -37,7 +36,8 @@ import com.raytheon.viz.mpe.ui.dialogs.gagetable.GageTableDlg;
* SOFTWARE HISTORY
* 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>
*
@ -46,41 +46,17 @@ import com.raytheon.viz.mpe.ui.dialogs.gagetable.GageTableDlg;
*/
public class GageTableAction extends AbstractHandler {
private Cursor waitCursor = null;
private Cursor arrowCursor = null;
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
.getShell();
waitCursor = new Cursor(shell.getDisplay(), SWT.CURSOR_WAIT);
arrowCursor = new Cursor(shell.getDisplay(), SWT.CURSOR_ARROW);
shell.setCursor(waitCursor);
shell.setCursor(shell.getDisplay().getSystemCursor(SWT.CURSOR_WAIT));
GageTableDlg gageTable = new GageTableDlg();
gageTable.open();
// try {
// 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);
shell.setCursor(null);
return null;
}

View file

@ -23,7 +23,6 @@ import java.util.ArrayList;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Cursor;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI;
@ -50,7 +49,8 @@ import com.raytheon.viz.mpe.util.ReadTemperatureStationList;
* SOFTWARE HISTORY
* 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>
*
@ -77,9 +77,7 @@ public class ScreeningOptions {
ArrayList<Station> temp_stations = DailyQcUtils.temperature_stations;
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
.getShell();
final Cursor prevCursor = shell.getCursor();
final Cursor waitCursor = new Cursor(Display.getDefault(),
SWT.CURSOR_WAIT);
Cursor prevCursor = shell.getCursor();
if (client_data == 0) {
pdata[pcpn_day].stddev = 5.0f;
@ -97,7 +95,7 @@ public class ScreeningOptions {
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

View file

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

View file

@ -63,6 +63,7 @@ import com.raytheon.viz.mpe.util.DailyQcUtils.Ts;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Nov 12, 2008 snaples Initial creation
* Sep 11, 2013 #2353 lvenable Fixed cursor memory leak.
*
* </pre>
*
@ -375,7 +376,7 @@ public class QcTempOptionsDialog extends AbstractMPEDialog {
dataOptionsGroup.setLayoutData(gd);
final Shell shell = this.getParent();
final Cursor prevCursor = shell.getCursor();
final Cursor waitCursor = new Cursor(Display.getDefault(),
final Cursor waitCursor = Display.getDefault().getSystemCursor(
SWT.CURSOR_WAIT);
// 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
* with the "scale" action will no
* longer be divided by 100.
* Sep 11, 2013 #2353 lvenable Fixed cursor memory leak.
*
* </pre>
*
@ -120,7 +121,7 @@ public class DrawPolygonDlg extends CaveSWTDialog {
super(parentShell, SWT.DIALOG_TRIM, CAVE.DO_NOT_BLOCK);
setText("Edit Precipitation");
this.resource = resource;
waitCursor = new Cursor(parentShell.getDisplay(), SWT.CURSOR_WAIT);
waitCursor = parentShell.getDisplay().getSystemCursor(SWT.CURSOR_WAIT);
}
@Override

View file

@ -51,7 +51,8 @@ import com.raytheon.viz.ui.input.InputAdapter;
*
* 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>
*
@ -71,7 +72,7 @@ public abstract class AbstractMPEInputResource extends
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);
/** 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
* 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>
*
@ -877,13 +878,12 @@ public class DailyQcUtils {
qcDays = MPEDataManager.getInstance().getDQCDays();
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
.getShell();
Cursor prev = shell.getCursor();
Cursor wait = new Cursor(Display.getDefault(), SWT.CURSOR_WAIT);
shell.setCursor(wait);
Cursor prevCursor = shell.getCursor();
shell.setCursor(Display.getDefault().getSystemCursor(SWT.CURSOR_WAIT));
new_area_flag = 1;
int retval = loadDataSet();
lastQcArea = currentQcArea;
shell.setCursor(prev);
shell.setCursor(prevCursor);
return retval;
}
@ -930,15 +930,15 @@ public class DailyQcUtils {
|| newarea == true) {
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
.getShell();
Cursor prev = shell.getCursor();
Cursor wait = new Cursor(Display.getDefault(), SWT.CURSOR_WAIT);
shell.setCursor(wait);
Cursor prevCursor = shell.getCursor();
shell.setCursor(Display.getDefault().getSystemCursor(
SWT.CURSOR_WAIT));
int retval = loadDataSet();
if (retval == 2) {
load_gage_data_once = 1;
}
lastQcArea = currentQcArea;
shell.setCursor(prev);
shell.setCursor(prevCursor);
return retval;
} else {
new_area_flag = 1;
@ -1022,11 +1022,15 @@ public class DailyQcUtils {
btime.set(Calendar.SECOND, 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 */
Calendar currentTime = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
if (currentTime.get(Calendar.HOUR_OF_DAY)>=18) {
btime.add(Calendar.DAY_OF_MONTH, 1);
/*
* 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
*/
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);
@ -1285,7 +1289,7 @@ public class DailyQcUtils {
if (td_fp == null) {
statusHandler
.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;
}
try {
@ -1293,7 +1297,7 @@ public class DailyQcUtils {
} catch (IOException e) {
statusHandler
.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) {
statusHandler
.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;
}
System.out.println("DQC: Reading Temperature Stations List. ");
@ -1358,7 +1362,7 @@ public class DailyQcUtils {
if (temperature_stations == null) {
statusHandler
.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;
}
System.out.println("DQC: Reading Precip Stations List. ");
@ -1367,7 +1371,7 @@ public class DailyQcUtils {
if (precip_stations == null) {
statusHandler
.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;
}
@ -1377,7 +1381,7 @@ public class DailyQcUtils {
if (status == false) {
statusHandler
.handle(Priority.PROBLEM,
"Could not read precipitation Climo file. DailyQC stopped.");
"Could not read precipitation Climo file. DailyQC stopped.");
return DAILYQC_FAILED;
}
@ -1387,7 +1391,7 @@ public class DailyQcUtils {
if (status == false) {
statusHandler
.handle(Priority.PROBLEM,
"Could not read temperature Climo file. DailyQC stopped.");
"Could not read temperature Climo file. DailyQC stopped.");
return DAILYQC_FAILED;
}
}
@ -1399,7 +1403,7 @@ public class DailyQcUtils {
if (status == false) {
statusHandler
.handle(Priority.PROBLEM,
"Could not read precipitation PRISM file. DailyQC stopped.");
"Could not read precipitation PRISM file. DailyQC stopped.");
return DAILYQC_FAILED;
}
@ -1408,7 +1412,7 @@ public class DailyQcUtils {
smonth, emonth);
if (status == false) {
statusHandler.handle(Priority.PROBLEM,
"Could not read temperature PRISM file. DailyQC stopped.");
"Could not read temperature PRISM file. DailyQC stopped.");
return DAILYQC_FAILED;
}
System.out.println("DQC: Finished loading Climo data. ");
@ -1436,7 +1440,7 @@ public class DailyQcUtils {
if (status == false) {
statusHandler
.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;
}
System.out.println("DQC: Mapping temperature gages to grid. ");
@ -1447,7 +1451,7 @@ public class DailyQcUtils {
if (status == false) {
statusHandler
.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;
}
long elapsed = System.currentTimeMillis() - start;
@ -1474,7 +1478,7 @@ public class DailyQcUtils {
mean_areal_precip_global, tag);
if (status == false) {
statusHandler.handle(Priority.PROBLEM,
"Error retrieving basin data. DailyQC Stopped.");
"Error retrieving basin data. DailyQC Stopped.");
return DAILYQC_FAILED;
}
}
@ -1651,12 +1655,13 @@ public class DailyQcUtils {
// open and read file containing std dev of point precip data
// --------------------------------------------------------------
BufferedReader in = null;
Scanner s = null;
try {
in = new BufferedReader(new FileReader(precc));
String ibuf = "";
ibuf = in.readLine();
Scanner s = new Scanner(ibuf);
s = new Scanner(ibuf);
pdata[m].stddev = s.nextFloat();
@ -1665,7 +1670,7 @@ public class DailyQcUtils {
pdata[m].stddev = 3.0f;
}
in.close();
} catch (FileNotFoundException e) {
System.out.println("File not found " + precc);
} catch (IOException e) {
@ -1674,6 +1679,12 @@ public class DailyQcUtils {
try {
if (in != null) {
in.close();
in = null;
}
if (s != null) {
s.close();
s = null;
}
} catch (IOException e) {
e.printStackTrace();
@ -1686,7 +1697,7 @@ public class DailyQcUtils {
in = new BufferedReader(new FileReader(tpointc));
String ibuf = "";
ibuf = in.readLine();
Scanner s = new Scanner(ibuf);
s = new Scanner(ibuf);
tdata[m].stddev = s.nextFloat();
@ -1695,7 +1706,6 @@ public class DailyQcUtils {
tdata[m].stddev = 10.0f;
}
in.close();
} catch (FileNotFoundException e) {
System.out.println("File not found " + tpointc);
} catch (IOException e) {
@ -1705,6 +1715,10 @@ public class DailyQcUtils {
if (in != null) {
in.close();
}
if (s != null) {
s.close();
s = null;
}
} catch (IOException e) {
e.printStackTrace();
}