Bug 9566. Serialize the saving of Carbide project data and Carbide launguage data. New CDT 6.0 thorws exception if not done.
authortimkelly
Mon, 10 Aug 2009 10:47:20 -0500
changeset 398 d0373668f9ff
parent 396 2ee12718a766
child 399 23528f18d3fd
Bug 9566. Serialize the saving of Carbide project data and Carbide launguage data. New CDT 6.0 thorws exception if not done.
builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/builder/BuildConfigurationData.java
builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/builder/CarbideLanguageData.java
builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/builder/CarbideProjectInfo.java
builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/builder/CarbideProjectModifier.java
--- a/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/builder/BuildConfigurationData.java	Fri Aug 07 15:50:06 2009 -0500
+++ b/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/builder/BuildConfigurationData.java	Mon Aug 10 10:47:20 2009 -0500
@@ -42,6 +42,7 @@
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.NullProgressMonitor;
 import org.eclipse.core.runtime.Status;
+import org.eclipse.swt.widgets.Display;
 
 import com.nokia.carbide.cdt.builder.CarbideBuilderPlugin;
 import com.nokia.carbide.cdt.builder.EpocEngineHelper;
@@ -269,12 +270,12 @@
 	private void persistCache() {
 		// persist the cache between IDE launches.
 		try {
-			ICarbideProjectInfo cpi = carbideBuildConfig.getCarbideProject();
+			final ICarbideProjectInfo cpi = carbideBuildConfig.getCarbideProject();
 			if (cpi == null) {
 				return;
 			}
 			
-			ICProjectDescription projDes = CoreModel.getDefault().getProjectDescription(cpi.getProject());
+			ICProjectDescription projDes = CoreModel.getDefault().getProjectDescription(cpi.getProject(), false);
 			if (projDes != null) {
 				ICConfigurationDescription configDes = projDes.getConfigurationById(carbideBuildConfig.getDisplayString());
 				if (configDes != null) {
@@ -292,8 +293,17 @@
 					}
 					storage.setAttribute(FILES_CACHE, filesCacheValue);
 
-					// save the CDT project description
-					CCorePlugin.getDefault().setProjectDescription(cpi.getProject(), projDes, true, new NullProgressMonitor());
+					Display.getDefault().asyncExec(new Runnable() {
+						public void run() {
+							ICProjectDescription projDes = CoreModel.getDefault().getProjectDescription(cpi.getProject());
+							try {
+								// save the CDT project description
+								CCorePlugin.getDefault().setProjectDescription(cpi.getProject(), projDes, true, new NullProgressMonitor());
+							} catch (CoreException e) {
+								CarbideBuilderPlugin.log(e);
+							}
+						}
+					});
 				}
 			}
 		} catch (CoreException e) {
--- a/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/builder/CarbideLanguageData.java	Fri Aug 07 15:50:06 2009 -0500
+++ b/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/builder/CarbideLanguageData.java	Mon Aug 10 10:47:20 2009 -0500
@@ -27,6 +27,7 @@
 import org.eclipse.core.resources.ProjectScope;
 import org.eclipse.core.runtime.*;
 import org.eclipse.core.runtime.content.*;
+import org.eclipse.swt.widgets.Display;
 
 import com.nokia.carbide.cdt.builder.CarbideBuilderPlugin;
 import com.nokia.carbide.cdt.builder.EpocEngineHelper;
@@ -309,8 +310,8 @@
 	private void persistCache() {
 		// persist the cache between IDE launches.
 		try {
-			IProject project = carbideBuildConfig.getCarbideProject().getProject();
-			ICProjectDescription projDes = CoreModel.getDefault().getProjectDescription(project);
+			final IProject project = carbideBuildConfig.getCarbideProject().getProject();
+			ICProjectDescription projDes = CoreModel.getDefault().getProjectDescription(project, false);
 			if (projDes != null) {
 				ICConfigurationDescription configDes = projDes.getConfigurationById(carbideBuildConfig.getDisplayString());
 				if (configDes != null) {
@@ -344,8 +345,17 @@
 					}
 					storage.setAttribute(FILES_CACHE, filesCacheValue);
 
-					// save the CDT project description
-					CCorePlugin.getDefault().setProjectDescription(project, projDes, true, new NullProgressMonitor());
+					Display.getDefault().asyncExec(new Runnable() {
+						public void run() {
+							ICProjectDescription projDes = CoreModel.getDefault().getProjectDescription(project);
+							try {
+								// save the CDT project description
+								CCorePlugin.getDefault().setProjectDescription(project, projDes, true, new NullProgressMonitor());
+							} catch (CoreException e) {
+								CarbideBuilderPlugin.log(e);
+							}
+						}
+					});
 				}
 			}
 		} catch (CoreException e) {
--- a/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/builder/CarbideProjectInfo.java	Fri Aug 07 15:50:06 2009 -0500
+++ b/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/builder/CarbideProjectInfo.java	Mon Aug 10 10:47:20 2009 -0500
@@ -83,9 +83,9 @@
 		this.projectTracker = new TrackedResource(project);
 		
 		try {
-			ICProjectDescription projDes = getProjectDescription();
+			ICProjectDescription projDes = getProjectDescription(false);
 			if (projDes != null) {
-				initializeDefaults(projDes);
+				initializeDefaults();
 
 				ICStorageElement storage = projDes.getStorage(CarbideBuilderPlugin.getCarbideBuilderExtensionID(), false);
 				if (storage != null) {
@@ -232,7 +232,7 @@
 		}
 	}
 	
-	protected void initializeDefaults(ICProjectDescription projDes) {
+	protected void initializeDefaults() {
 		overrideWorkspaceSettings = false;
 
 		if (CarbideBuilderPlugin.getBuildManager().isCarbideSBSv2Project(projectTracker.getProject())) {
@@ -260,7 +260,7 @@
 		
 		List<ICarbideBuildConfiguration> configs = new ArrayList<ICarbideBuildConfiguration>();
 		
-		ICProjectDescription projectDescription = getProjectDescription();
+		ICProjectDescription projectDescription = getProjectDescription(false);
 		if (projectDescription != null) {
 			for (ICConfigurationDescription config : projectDescription.getConfigurations()) {
 				CConfigurationData data = config.getConfigurationData();
@@ -274,7 +274,7 @@
 	}
 	
 	public ICarbideBuildConfiguration getNamedConfiguration(String configName) {
-		ICProjectDescription projectDescription = getProjectDescription();
+		ICProjectDescription projectDescription = getProjectDescription(false);
 		if (projectDescription != null) {
 			ICConfigurationDescription config = projectDescription.getConfigurationByName(configName);
 			if (config != null) {
@@ -289,7 +289,7 @@
 	}
 	
 	public ICarbideBuildConfiguration getDefaultConfiguration() {
-		ICProjectDescription projectDescription = getProjectDescription();
+		ICProjectDescription projectDescription = getProjectDescription(false);
 		if (projectDescription == null)
 			return null;
 		ICConfigurationDescription config = projectDescription.getActiveConfiguration();
@@ -412,8 +412,8 @@
 		return workingDir;
 	}
 	
-	protected ICProjectDescription getProjectDescription() {
-		return CoreModel.getDefault().getProjectDescription(projectTracker.getProject());
+	protected ICProjectDescription getProjectDescription(boolean writable) {
+		return CoreModel.getDefault().getProjectDescription(projectTracker.getProject(), writable);
 	}
 	
 	public int getCleanLevel() {
--- a/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/builder/CarbideProjectModifier.java	Fri Aug 07 15:50:06 2009 -0500
+++ b/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/builder/CarbideProjectModifier.java	Mon Aug 10 10:47:20 2009 -0500
@@ -45,7 +45,7 @@
 		super(projDes.getProject());
 		this.projDes = projDes;
 		
-		initializeDefaults(projDes);
+		initializeDefaults();
 	}
 
 	/*
@@ -56,7 +56,7 @@
 		// get the latest ICProjectDescription
 		super(cpi.projectTracker.getProject());
 
-		projDes = getProjectDescription();
+		projDes = getProjectDescription(true);
 		projectRelativeBldInfPath = cpi.projectRelativeBldInfPath;
 		buildFromInf = cpi.buildFromInf;
 		overrideWorkspaceSettings = cpi.overrideWorkspaceSettings;