Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Cortell2010-02-26 15:19:34 +0000
committerJohn Cortell2010-02-26 15:19:34 +0000
commit4d5d92560b4af888b4f03f27092606e6e7f7a313 (patch)
tree5716b5d74a60cf2982339ad35864be42e1ad1e38 /launch/org.eclipse.cdt.launch
parent97acd431e00f634e7cac9142ebea831b386969c5 (diff)
downloadorg.eclipse.cdt-4d5d92560b4af888b4f03f27092606e6e7f7a313.tar.gz
org.eclipse.cdt-4d5d92560b4af888b4f03f27092606e6e7f7a313.tar.xz
org.eclipse.cdt-4d5d92560b4af888b4f03f27092606e6e7f7a313.zip
[277663] Binary is revalidated after each keystroke
Diffstat (limited to 'launch/org.eclipse.cdt.launch')
-rw-r--r--launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CMainTab.java101
1 files changed, 68 insertions, 33 deletions
diff --git a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CMainTab.java b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CMainTab.java
index 03b0f4f073..b0cb73247f 100644
--- a/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CMainTab.java
+++ b/launch/org.eclipse.cdt.launch/src/org/eclipse/cdt/launch/ui/CMainTab.java
@@ -144,6 +144,24 @@ public class CMainTab extends CLaunchConfigurationTab {
private final Map<IPath, Boolean> fBinaryExeCache = new HashMap<IPath, Boolean>();
+ /**
+ * Name of most recently checked program; avoid constantly checking binary.
+ * See bug 277663.
+ */
+ private String fPreviouslyCheckedProgram;
+
+ /**
+ * Validity result of most recently checked program; avoid constantly
+ * checking binary. See bug 277663. N/A if fPreviouslyCheckedProgram = null;
+ */
+ private boolean fPreviouslyCheckedProgramIsValid;
+
+ /**
+ * Validity error message of most recently checked program; avoid constantly
+ * checking binary. See bug 277663. N/A if fPreviouslyCheckedProgram = null.
+ */
+ private String fPreviouslyCheckedProgramErrorMsg;
+
public CMainTab() {
this(WANTS_TERMINAL);
@@ -213,6 +231,9 @@ public class CMainTab extends CLaunchConfigurationTab {
fProjText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent evt) {
+ // if project changes, invalidate program name cache
+ fPreviouslyCheckedProgram = null;
+
updateBuildConfigCombo(EMPTY_STRING);
updateLaunchConfigurationDialog();
}
@@ -841,44 +862,58 @@ public class CMainTab extends CLaunchConfigurationTab {
setErrorMessage(LaunchMessages.getString("CMainTab.Program_does_not_exist")); //$NON-NLS-1$
return false;
}
- IPath exePath = new Path(name);
- if (!exePath.isAbsolute()) {
- IPath location = project.getLocation();
- if (location == null) {
- setErrorMessage(LaunchMessages.getString("CMainTab.Program_does_not_exist")); //$NON-NLS-1$
- return false;
+ // Avoid constantly checking the binary if nothing relevant has
+ // changed (binary or project name). See bug 277663.
+ if (name.equals(fPreviouslyCheckedProgram)) {
+ if (fPreviouslyCheckedProgramErrorMsg != null) {
+ setErrorMessage(fPreviouslyCheckedProgramErrorMsg);
}
-
- exePath = location.append(name);
- if (!exePath.toFile().exists()) {
- // Try the old way, which is required to support linked resources.
- IFile projFile = null;
- try {
- projFile = project.getFile(name);
- }
- catch (IllegalArgumentException exc) {} // thrown if relative path that resolves to a root file ("..\somefile")
- if (projFile == null || !projFile.exists()) {
- setErrorMessage(LaunchMessages.getString("CMainTab.Program_does_not_exist")); //$NON-NLS-1$
- return false;
+ return fPreviouslyCheckedProgramIsValid;
+ }
+ else {
+ fPreviouslyCheckedProgram = name;
+ fPreviouslyCheckedProgramIsValid = true; // we'll flip this below if not true
+ fPreviouslyCheckedProgramErrorMsg = null; // we'll set this below if there's an error
+ IPath exePath = new Path(name);
+ if (!exePath.isAbsolute()) {
+ IPath location = project.getLocation();
+ if (location == null) {
+
+ setErrorMessage(fPreviouslyCheckedProgramErrorMsg = LaunchMessages.getString("CMainTab.Program_does_not_exist")); //$NON-NLS-1$
+ return (fPreviouslyCheckedProgramIsValid = false);
}
- else {
- exePath = projFile.getLocation();
+
+ exePath = location.append(name);
+ if (!exePath.toFile().exists()) {
+ // Try the old way, which is required to support linked resources.
+ IFile projFile = null;
+ try {
+ projFile = project.getFile(name);
+ }
+ catch (IllegalArgumentException exc) {} // thrown if relative path that resolves to a root file ("..\somefile")
+ if (projFile == null || !projFile.exists()) {
+ setErrorMessage(fPreviouslyCheckedProgramErrorMsg = LaunchMessages.getString("CMainTab.Program_does_not_exist")); //$NON-NLS-1$
+ return (fPreviouslyCheckedProgramIsValid = false);
+ }
+ else {
+ exePath = projFile.getLocation();
+ }
}
+ }
+ if (!exePath.toFile().exists()) {
+ setErrorMessage(fPreviouslyCheckedProgramErrorMsg = LaunchMessages.getString("CMainTab.Program_does_not_exist")); //$NON-NLS-1$
+ return (fPreviouslyCheckedProgramIsValid = false);
}
- }
- if (!exePath.toFile().exists()) {
- setErrorMessage(LaunchMessages.getString("CMainTab.Program_does_not_exist")); //$NON-NLS-1$
- return false;
- }
- try {
- if (!isBinary(project, exePath)) {
- setErrorMessage(LaunchMessages.getString("CMainTab.Program_is_not_a_recongnized_executable")); //$NON-NLS-1$
- return false;
+ try {
+ if (!isBinary(project, exePath)) {
+ setErrorMessage(fPreviouslyCheckedProgramErrorMsg = LaunchMessages.getString("CMainTab.Program_is_not_a_recongnized_executable")); //$NON-NLS-1$
+ return (fPreviouslyCheckedProgramIsValid = false);
+ }
+ } catch (CoreException e) {
+ LaunchUIPlugin.log(e);
+ setErrorMessage(fPreviouslyCheckedProgramErrorMsg = e.getLocalizedMessage());
+ return (fPreviouslyCheckedProgramIsValid = false);
}
- } catch (CoreException e) {
- LaunchUIPlugin.log(e);
- setErrorMessage(e.getLocalizedMessage());
- return false;
}
}

Back to the top