mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-04 06:45:43 +02:00
[277663] Binary is revalidated after each keystroke
This commit is contained in:
parent
97acd431e0
commit
4d5d92560b
1 changed files with 70 additions and 35 deletions
|
@ -144,6 +144,24 @@ public class CMainTab extends CLaunchConfigurationTab {
|
||||||
|
|
||||||
private final Map<IPath, Boolean> fBinaryExeCache = new HashMap<IPath, Boolean>();
|
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() {
|
public CMainTab() {
|
||||||
this(WANTS_TERMINAL);
|
this(WANTS_TERMINAL);
|
||||||
|
@ -213,6 +231,9 @@ public class CMainTab extends CLaunchConfigurationTab {
|
||||||
fProjText.addModifyListener(new ModifyListener() {
|
fProjText.addModifyListener(new ModifyListener() {
|
||||||
|
|
||||||
public void modifyText(ModifyEvent evt) {
|
public void modifyText(ModifyEvent evt) {
|
||||||
|
// if project changes, invalidate program name cache
|
||||||
|
fPreviouslyCheckedProgram = null;
|
||||||
|
|
||||||
updateBuildConfigCombo(EMPTY_STRING);
|
updateBuildConfigCombo(EMPTY_STRING);
|
||||||
updateLaunchConfigurationDialog();
|
updateLaunchConfigurationDialog();
|
||||||
}
|
}
|
||||||
|
@ -841,44 +862,58 @@ public class CMainTab extends CLaunchConfigurationTab {
|
||||||
setErrorMessage(LaunchMessages.getString("CMainTab.Program_does_not_exist")); //$NON-NLS-1$
|
setErrorMessage(LaunchMessages.getString("CMainTab.Program_does_not_exist")); //$NON-NLS-1$
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
IPath exePath = new Path(name);
|
// Avoid constantly checking the binary if nothing relevant has
|
||||||
if (!exePath.isAbsolute()) {
|
// changed (binary or project name). See bug 277663.
|
||||||
IPath location = project.getLocation();
|
if (name.equals(fPreviouslyCheckedProgram)) {
|
||||||
if (location == null) {
|
if (fPreviouslyCheckedProgramErrorMsg != null) {
|
||||||
setErrorMessage(LaunchMessages.getString("CMainTab.Program_does_not_exist")); //$NON-NLS-1$
|
setErrorMessage(fPreviouslyCheckedProgramErrorMsg);
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
return fPreviouslyCheckedProgramIsValid;
|
||||||
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;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
exePath = projFile.getLocation();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!exePath.toFile().exists()) {
|
|
||||||
setErrorMessage(LaunchMessages.getString("CMainTab.Program_does_not_exist")); //$NON-NLS-1$
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
try {
|
else {
|
||||||
if (!isBinary(project, exePath)) {
|
fPreviouslyCheckedProgram = name;
|
||||||
setErrorMessage(LaunchMessages.getString("CMainTab.Program_is_not_a_recongnized_executable")); //$NON-NLS-1$
|
fPreviouslyCheckedProgramIsValid = true; // we'll flip this below if not true
|
||||||
return false;
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue