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

Change-Id: I6011a5fedc155ab8d515d3c6eb5d368f582c59bd

Former-commit-id: 9aa0da6f76 [formerly 6f178a9150] [formerly 603a9c90e4] [formerly 559efb19fb [formerly 603a9c90e4 [formerly aece671b35405e1f278439c9a1a8230dad5cf4c2]]]
Former-commit-id: 559efb19fb
Former-commit-id: cd531c27c5b206f5bdac1fdd9f11e0273f8cfa3b [formerly 3f258a2bf8]
Former-commit-id: d52dd42ab2
This commit is contained in:
Ben Steffensmeier 2012-08-10 16:22:45 -05:00
parent 400324692e
commit 3df0e4d6e8
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 // TODO need to determine if this type of plot is a combination or
// not // not
combineData(stationQuery); combineData(stationQuery);
if (monitor.isCanceled()) { synchronized (this) {
break; if (monitor.isCanceled()) {
} break;
}
for (PlotInfo[] infos : stationQuery) { for (PlotInfo[] infos : stationQuery) {
// schedule next work for other jobs // schedule next work for other jobs
// TODO investigate further, shouldn't be possible to get a null // TODO investigate further, shouldn't be possible to get a
// here, but somehow we do // null
if (infos[0].pdv != null) { // here, but somehow we do
switch (task.getRequestType()) { if (infos[0].pdv != null) {
case PLOT_ONLY: switch (task.getRequestType()) {
this.generatorJob.enqueue(infos); case PLOT_ONLY:
break; this.generatorJob.enqueue(infos);
case SAMPLE_ONLY: break;
this.sampleJob.enqueue(infos); case SAMPLE_ONLY:
break; this.sampleJob.enqueue(infos);
case PLOT_AND_SAMPLE: break;
this.generatorJob.enqueue(infos); case PLOT_AND_SAMPLE:
this.sampleJob.enqueue(infos); this.generatorJob.enqueue(infos);
break; this.sampleJob.enqueue(infos);
break;
}
} }
} }
} }
@ -342,13 +345,8 @@ public class PlotModelDataRequestJob extends Job {
&& generatorJob.isDone(); && generatorJob.isDone();
} }
public void shutdown() { public synchronized void shutdown() {
this.cancel(); this.cancel();
try {
join();
} catch (InterruptedException e) {
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e);
}
this.generatorJob.shutdown(); 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.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus; 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.IGraphicsTarget;
import com.raytheon.uf.viz.core.data.IRenderedImageCallback; import com.raytheon.uf.viz.core.data.IRenderedImageCallback;
import com.raytheon.uf.viz.core.drawables.IImage; import com.raytheon.uf.viz.core.drawables.IImage;
@ -119,10 +118,15 @@ public class PlotModelGeneratorJob extends Job {
} }
} }
} }
if (monitor.isCanceled()) { synchronized (this) {
break; if (monitor.isCanceled()) {
if(image != null){
image.dispose();
}
break;
}
caller.modelGenerated(infos, image);
} }
caller.modelGenerated(infos, image);
} catch (Exception e) { } catch (Exception e) {
statusHandler.error("Error creating plot", e); statusHandler.error("Error creating plot", e);
} }
@ -153,14 +157,9 @@ public class PlotModelGeneratorJob extends Job {
return getState() != Job.RUNNING && getState() != Job.WAITING; return getState() != Job.RUNNING && getState() != Job.WAITING;
} }
protected void shutdown() { protected synchronized void shutdown() {
cancel(); cancel();
taskQueue.clear(); taskQueue.clear();
try {
join();
} catch (InterruptedException e) {
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e);
}
clearImageCache(); clearImageCache();
} }
} }

View file

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