Permalink
Browse files

Re #1000631. Changed from thread to job for the error marker creations

A Job is more Eclipse-like, avoids creation of a new
thread and manages lock on resources.
Added comment as recommanded
  • Loading branch information...
1 parent d3ec008 commit b165b8e7043dc4b26275cda4cfeb17a20853102c @skyluc skyluc committed Oct 19, 2011
Showing with 16 additions and 7 deletions.
  1. +16 −7 org.scala-ide.sdt.core/src/scala/tools/eclipse/ScalaProject.scala
@@ -30,6 +30,9 @@ import scala.actors.Actor
import org.eclipse.jdt.core.IJarEntryResource
import java.util.Properties
import org.eclipse.jdt.core.IPackageFragmentRoot
+import org.eclipse.core.runtime.jobs.Job
+import org.eclipse.core.runtime.IStatus
+import org.eclipse.core.runtime.Status
trait BuildSuccessListener {
def buildSuccessful(): Unit
@@ -351,11 +354,15 @@ class ScalaProject(val underlying: IProject) extends HasLogger {
* Manage the possible classpath error/warning reported on the project.
*/
private def setClasspathError(severity: Int, message: String) {
- // set the state
- classpathValid= severity != IMarker.SEVERITY_ERROR
- classpathHasBeenChecked= true
- new Thread() {
- override def run() {
+ // set the state
+ classpathValid= severity != IMarker.SEVERITY_ERROR
+ classpathHasBeenChecked= true
+
+ // the marker manipulation need to be done in a Job, because it requires
+ // a change on the IProject, which is locked for modification during
+ // the classpath change notification
+ val markerJob= new Job("Update classpath error marker") {
+ override def run(monitor: IProgressMonitor): IStatus = {
// clean the markers
underlying.deleteMarkers(plugin.problemMarkerId, false, IResource.DEPTH_ZERO)
@@ -367,9 +374,11 @@ class ScalaProject(val underlying: IProject) extends HasLogger {
marker.setAttribute(IMarker.SEVERITY, severity)
case _ =>
}
-
+ Status.OK_STATUS
}
- }.start()
+ }
+ markerJob.setRule(underlying)
+ markerJob.schedule()
}
/**

0 comments on commit b165b8e

Please sign in to comment.