From 3f258a2bf82e1d0e8931f52181416766c4c72704 Mon Sep 17 00:00:00 2001 From: Ben Steffensmeier Date: Fri, 10 Aug 2012 16:22:45 -0500 Subject: [PATCH] Issue #1004 change plots to synchronize with dispose instead of joining since join allows paint to happen Change-Id: I6011a5fedc155ab8d515d3c6eb5d368f582c59bd Former-commit-id: 603a9c90e4ed9dbd422fbfb9d77456d799a9e550 [formerly aece671b35405e1f278439c9a1a8230dad5cf4c2] Former-commit-id: 559efb19fbd9db5cb5dcc6ce0bbf65835afa4f0e --- .../pointdata/PlotModelDataRequestJob.java | 48 +++++++++---------- .../viz/pointdata/PlotModelGeneratorJob.java | 19 ++++---- .../viz/pointdata/rsc/PlotResource2.java | 4 +- 3 files changed, 34 insertions(+), 37 deletions(-) diff --git a/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/PlotModelDataRequestJob.java b/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/PlotModelDataRequestJob.java index c2311a4884..3e51d6ed2c 100644 --- a/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/PlotModelDataRequestJob.java +++ b/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/PlotModelDataRequestJob.java @@ -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(); } diff --git a/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/PlotModelGeneratorJob.java b/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/PlotModelGeneratorJob.java index 8402b8440a..705fdb9947 100644 --- a/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/PlotModelGeneratorJob.java +++ b/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/PlotModelGeneratorJob.java @@ -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(); } } diff --git a/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/rsc/PlotResource2.java b/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/rsc/PlotResource2.java index ed79eeb323..a52e970be5 100644 --- a/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/rsc/PlotResource2.java +++ b/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/rsc/PlotResource2.java @@ -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(); }