Update for bug 12078 from unit test runs
authorEd Swartz <ed.swartz@nokia.com>
Wed, 15 Sep 2010 16:55:53 -0500
changeset 2019 b3e017e14335
parent 2018 5034d483c2e2
child 2020 d6760e7efd55
Update for bug 12078 from unit test runs
builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/builder/CarbideLanguageData.java
--- a/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/builder/CarbideLanguageData.java	Wed Sep 15 16:55:03 2010 -0500
+++ b/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/builder/CarbideLanguageData.java	Wed Sep 15 16:55:53 2010 -0500
@@ -49,10 +49,12 @@
 import org.eclipse.core.runtime.content.IContentType;
 import org.eclipse.core.runtime.content.IContentTypeManager;
 import org.eclipse.core.runtime.content.IContentTypeSettings;
+import org.eclipse.core.runtime.jobs.Job;
 
 import com.nokia.carbide.cdt.builder.CarbideBuilderPlugin;
 import com.nokia.carbide.cdt.builder.EpocEngineHelper;
 import com.nokia.carbide.cdt.builder.project.ICarbideBuildConfiguration;
+import com.nokia.carbide.cdt.builder.project.ICarbideProjectInfo;
 import com.nokia.carbide.cpp.epoc.engine.model.sbv.ISBVView;
 import com.nokia.carbide.cpp.epoc.engine.preprocessor.IDefine;
 import com.nokia.carbide.cpp.internal.api.sdk.ISBSv1BuildContext;
@@ -146,16 +148,16 @@
 		}
 		
 		if (cacheBuilt) {
+			
 			// Bug 12078: persisting the cache requires setting the project 
 			// description, or else it gets thrown away (!).
 			// But we must save the cache in a workspace job because this code
 			// is usually called when the project description is being read for 
 			// the first time (thus saving just throws an exception).
-			WorkspaceJob job = new WorkspaceJob("Saving Carbide indexer cache for " + carbideBuildConfig.getDisplayString()) {
+			Job job = new Job("Saving Carbide indexer cache for " + carbideBuildConfig.getDisplayString()) {
 
 				@Override
-				public IStatus runInWorkspace(IProgressMonitor monitor)
-						throws CoreException {
+				protected IStatus run(IProgressMonitor monitor) {
 					persistCache(monitor);
 					
 					return Status.OK_STATUS;
@@ -163,7 +165,13 @@
 				
 			};
 			job.setRule(ResourcesPlugin.getWorkspace().getRoot());
-			job.schedule();
+			job.setSystem(true);
+			job.setPriority(Job.LONG);
+			job.schedule(5000);	
+				// This scheduling delay is a gross HACK: WorkspaceModelProvider#saveStorage()
+				// has had and still has problems with deadlocks on saving
+				// model content.  This job exacerbates it unless we wait a
+				// while before locking the workspace.
 		}
 
 		switch(kind) {
@@ -358,8 +366,15 @@
 
 	private void persistCache(IProgressMonitor monitor) {
 		// persist the cache between IDE launches.
+		if (!isValid())
+			return;
 		try {
-			final IProject project = carbideBuildConfig.getCarbideProject().getProject();
+			ICarbideProjectInfo carbideProject = carbideBuildConfig.getCarbideProject();
+			if (carbideProject == null)
+				return;
+			final IProject project = carbideProject.getProject();
+			if (project == null)
+				return;
 			ICProjectDescription projDes = CoreModel.getDefault().getProjectDescription(project);
 			if (projDes != null) {
 				ICConfigurationDescription configDes = projDes.getConfigurationById(carbideBuildConfig.getBuildContext().getConfigurationID());