1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-04 14:55:41 +02:00

Bug 330594 - ResourceException checking HasNatureExpression when project closed

This commit is contained in:
James Blackburn 2010-11-18 21:11:21 +00:00
parent f9b519b6dd
commit ee312e0773

View file

@ -15,9 +15,7 @@ import org.eclipse.cdt.managedbuilder.core.IHoldsOptions;
import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement; import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
import org.eclipse.cdt.managedbuilder.core.IOption; import org.eclipse.cdt.managedbuilder.core.IOption;
import org.eclipse.cdt.managedbuilder.core.IResourceInfo; import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
@ -55,18 +53,12 @@ public class HasNatureExpression implements IBooleanExpression {
IProject project = resource.getProject(); IProject project = resource.getProject();
try { try {
IProjectDescription projDesc = project.getDescription(); if (project.isAccessible())
String[] natures = projDesc.getNatureIds(); return project.hasNature(natureId);
for (int i = 0; i < natures.length; ++i) {
if (natureId.equals(natures[i]))
return true;
}
// Not found
return false;
} catch (CoreException e) { } catch (CoreException e) {
ManagedBuilderCorePlugin.log(e); // Project close concurrently => Nature not available.
return false;
} }
return false;
} }
} }