Skip to main content
summaryrefslogtreecommitdiffstats
path: root/debug
diff options
context:
space:
mode:
authorTeodor Madan2011-04-08 08:36:14 -0400
committerTeodor Madan2011-04-08 08:36:14 -0400
commitc2a6ef0d6bb5b2d78378469216060a05e7a08daf (patch)
tree05f857280c9d73ec2de23a90a6def6a576dfb58b /debug
parentbad48fed5183ed06d369f49150df1907288f81e8 (diff)
downloadorg.eclipse.cdt-c2a6ef0d6bb5b2d78378469216060a05e7a08daf.tar.gz
org.eclipse.cdt-c2a6ef0d6bb5b2d78378469216060a05e7a08daf.tar.xz
org.eclipse.cdt-c2a6ef0d6bb5b2d78378469216060a05e7a08daf.zip
Bug 341607 - Fixed potential NPE when director is null
Diffstat (limited to 'debug')
-rw-r--r--debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/SourceUtils.java25
1 files changed, 13 insertions, 12 deletions
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/SourceUtils.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/SourceUtils.java
index 6b340857ab..46baafb313 100644
--- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/SourceUtils.java
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/SourceUtils.java
@@ -262,10 +262,14 @@ public class SourceUtils {
*/
public static Object[] findSourceElements(File file, ISourceLookupDirector director) {
IFile[] wfiles = ResourceLookup.findFilesForLocation(new Path(file.getAbsolutePath()));
- IProject launchConfigurationProject = getLaunchConfigurationProject(director);
+ IProject lcProject = null;
+ if (director != null) {
+ lcProject = getLaunchConfigurationProject(director);
+ }
+
if (wfiles.length > 0) {
- ResourceLookup.sortFilesByRelevance(wfiles, launchConfigurationProject);
- return updateUnavailableResources(wfiles, launchConfigurationProject);
+ ResourceLookup.sortFilesByRelevance(wfiles, lcProject);
+ return updateUnavailableResources(wfiles, lcProject);
}
try {
@@ -273,18 +277,15 @@ public class SourceUtils {
// systems like Windows.
wfiles = ResourceLookup.findFilesForLocation(new Path(file.getCanonicalPath()));
if (wfiles.length > 0) {
- ResourceLookup.sortFilesByRelevance(wfiles, launchConfigurationProject);
- return updateUnavailableResources(wfiles, launchConfigurationProject);
+ ResourceLookup.sortFilesByRelevance(wfiles, lcProject);
+ return updateUnavailableResources(wfiles, lcProject);
}
// The file is not already in the workspace so try to create an external translation unit for it.
- if (director != null) {
- String projectName = getLaunchConfigurationProjectName(director);
- if (projectName != null) {
- ICProject project = CoreModel.getDefault().getCModel().getCProject(projectName);
- if (project != null) {
- return new ITranslationUnit[] { CoreModel.getDefault().createTranslationUnitFrom(project, URIUtil.toURI(file.getCanonicalPath(), true)) };
- }
+ if (lcProject != null) {
+ ICProject project = CoreModel.getDefault().create(lcProject);
+ if (project != null) {
+ return new ITranslationUnit[] { CoreModel.getDefault().createTranslationUnitFrom(project, URIUtil.toURI(file.getCanonicalPath(), true)) };
}
}
} catch (IOException e) { // ignore if getCanonicalPath throws

Back to the top