Issue #1004 change plots to synchronize with dispose instead of joining since join allows paint to happen

Change-Id: I6011a5fedc155ab8d515d3c6eb5d368f582c59bd

Former-commit-id: aece671b35405e1f278439c9a1a8230dad5cf4c2
This commit is contained in:
Ben Steffensmeier 2012-08-10 16:22:45 -05:00
parent c6a121962f
commit 603a9c90e4
3 changed files with 34 additions and 37 deletions

View file

@ -145,26 +145,29 @@ public class PlotModelDataRequestJob extends Job {
// TODO need to determine if this type of plot is a combination or
// not
combineData(stationQuery);
if (monitor.isCanceled()) {
break;
}
synchronized (this) {
if (monitor.isCanceled()) {
break;
}
for (PlotInfo[] infos : stationQuery) {
// schedule next work for other jobs
// TODO investigate further, shouldn't be possible to get a null
// here, but somehow we do
if (infos[0].pdv != null) {
switch (task.getRequestType()) {
case PLOT_ONLY:
this.generatorJob.enqueue(infos);
break;
case SAMPLE_ONLY:
this.sampleJob.enqueue(infos);
break;
case PLOT_AND_SAMPLE:
this.generatorJob.enqueue(infos);
this.sampleJob.enqueue(infos);
break;
for (PlotInfo[] infos : stationQuery) {
// schedule next work for other jobs
// TODO investigate further, shouldn't be possible to get a
// null
// here, but somehow we do
if (infos[0].pdv != null) {
switch (task.getRequestType()) {
case PLOT_ONLY:
this.generatorJob.enqueue(infos);
break;
case SAMPLE_ONLY:
this.sampleJob.enqueue(infos);
break;
case PLOT_AND_SAMPLE:
this.generatorJob.enqueue(infos);
this.sampleJob.enqueue(infos);
break;
}
}
}
}
@ -342,13 +345,8 @@ public class PlotModelDataRequestJob extends Job {
&& generatorJob.isDone();
}
public void shutdown() {
public synchronized void shutdown() {
this.cancel();
try {
join();
} catch (InterruptedException e) {
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e);
}
this.generatorJob.shutdown();
}

View file

@ -32,7 +32,6 @@ import org.eclipse.core.runtime.jobs.Job;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.viz.core.IGraphicsTarget;
import com.raytheon.uf.viz.core.data.IRenderedImageCallback;
import com.raytheon.uf.viz.core.drawables.IImage;
@ -119,10 +118,15 @@ public class PlotModelGeneratorJob extends Job {
}
}
}
if (monitor.isCanceled()) {
break;
synchronized (this) {
if (monitor.isCanceled()) {
if(image != null){
image.dispose();
}
break;
}
caller.modelGenerated(infos, image);
}
caller.modelGenerated(infos, image);
} catch (Exception e) {
statusHandler.error("Error creating plot", e);
}
@ -153,14 +157,9 @@ public class PlotModelGeneratorJob extends Job {
return getState() != Job.RUNNING && getState() != Job.WAITING;
}
protected void shutdown() {
protected synchronized void shutdown() {
cancel();
taskQueue.clear();
try {
join();
} catch (InterruptedException e) {
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e);
}
clearImageCache();
}
}

View file

@ -402,11 +402,11 @@ public class PlotResource2 extends
@Override
protected void disposeInternal() {
resourceData.getPlotInfoRetriever().cancel();
progressiveDisclosure.shutdown();
if (generator != null) {
generator.shutdown();
}
resourceData.getPlotInfoRetriever().cancel();
progressiveDisclosure.shutdown();
clearImages();
}