From 9bc33989660e32ce0444a3685c3519c537e2399e Mon Sep 17 00:00:00 2001 From: Vivian Kong Date: Fri, 16 Jan 2009 14:49:39 +0000 Subject: [PATCH] bug 261211 --- .../org/eclipse/cdt/core/CProjectNature.java | 30 ++++++++++++------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CProjectNature.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CProjectNature.java index 97fe184ad0c..7ccd8d45a9f 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CProjectNature.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CProjectNature.java @@ -20,6 +20,7 @@ import org.eclipse.core.resources.IProjectDescription; import org.eclipse.core.resources.IProjectNature; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.NullProgressMonitor; public class CProjectNature implements IProjectNature { @@ -55,17 +56,24 @@ public class CProjectNature implements IProjectNature { * */ public static void addNature(IProject project, String natureId, IProgressMonitor monitor) throws CoreException { - IProjectDescription description = project.getDescription(); - String[] prevNatures = description.getNatureIds(); - for (String prevNature : prevNatures) { - if (natureId.equals(prevNature)) - return; - } - String[] newNatures = new String[prevNatures.length + 1]; - System.arraycopy(prevNatures, 0, newNatures, 0, prevNatures.length); - newNatures[prevNatures.length] = natureId; - description.setNatureIds(newNatures); - project.setDescription(description, monitor); + try { + if (monitor == null) { + monitor = new NullProgressMonitor(); + } + IProjectDescription description = project.getDescription(); + String[] prevNatures = description.getNatureIds(); + for (String prevNature : prevNatures) { + if (natureId.equals(prevNature)) + return; + } + String[] newNatures = new String[prevNatures.length + 1]; + System.arraycopy(prevNatures, 0, newNatures, 0, prevNatures.length); + newNatures[prevNatures.length] = natureId; + description.setNatureIds(newNatures); + project.setDescription(description, monitor); + } finally { + monitor.done(); + } } /**