Issue #2544 Fix recycling issues with Satellite resources.

Former-commit-id: 9ff1751f4e [formerly 166957a22c3447fa2407b13362eece24943675c9]
Former-commit-id: e392185d78
This commit is contained in:
Ben Steffensmeier 2013-11-18 11:44:56 -06:00
parent 542a0946f2
commit 15ae95075d
3 changed files with 49 additions and 20 deletions

View file

@ -45,11 +45,14 @@ import com.raytheon.uf.viz.core.rsc.capabilities.AbstractCapability;
* *
* SOFTWARE HISTORY * SOFTWARE HISTORY
* *
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------- ---------- ----------- --------------------------
* Dec 21, 2011 mschenke Initial creation * Dec 21, 2011 mschenke Initial creation
* Jun 24, 2013 2122 mschenke Made use built in resource data changed listener * Jun 24, 2013 2122 mschenke Made use built in resource data changed
* updates will not be lost from construction to initInternal * listener updates will not be lost from
* construction to initInternal
* Nov 18, 2013 2544 bsteffen Clear dataTimes in disposeInternal to
* fix recycle.
* *
* </pre> * </pre>
* *
@ -354,6 +357,11 @@ public abstract class AbstractPluginDataObjectResource<T extends AbstractResourc
// Copy Frames and clear member // Copy Frames and clear member
frames = new HashMap<DataTime, Frame>(this.frames); frames = new HashMap<DataTime, Frame>(this.frames);
this.frames.clear(); this.frames.clear();
/* Must clear dataTimes for recycle to work correctly. */
if (!dataTimes.isEmpty()) {
dataTimes.clear();
}
} }
// Dispose frame one by one // Dispose frame one by one

View file

@ -62,12 +62,14 @@ import com.raytheon.uf.viz.core.rsc.capabilities.Capabilities;
* <pre> * <pre>
* *
* SOFTWARE HISTORY * SOFTWARE HISTORY
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------- -------- ----------- --------------------------
* Feb 4, 2009 chammack Initial creation from original IVizResource * Feb 04, 2009 chammack Initial creation from original IVizResource
* Mar 3, 2009 2032 jsanchez Added getDescriptor and paintProps. * Mar 03, 2009 2032 jsanchez Added getDescriptor and paintProps.
* Mar 29, 2013 1638 mschenke Fixed leak of data change listener * Mar 29, 2013 1638 mschenke Fixed leak of data change listener
* Jun 24, 2013 2140 randerso Added getSafeName method * Jun 24, 2013 2140 randerso Added getSafeName method
* Nov 18, 2013 2544 bsteffen Add recycleInternal so IResourceGroups
* can recycle better.
* *
* </pre> * </pre>
* *
@ -754,7 +756,7 @@ public abstract class AbstractVizResource<T extends AbstractResourceData, D exte
*/ */
public final void recycle() { public final void recycle() {
if (status == ResourceStatus.INITIALIZED) { if (status == ResourceStatus.INITIALIZED) {
disposeInternal(); recycleInternal();
} }
status = ResourceStatus.NEW; status = ResourceStatus.NEW;
initJob = null; initJob = null;
@ -763,6 +765,16 @@ public abstract class AbstractVizResource<T extends AbstractResourceData, D exte
} }
} }
/**
* Internally recycle all the graphics objects used by the resource. The
* default implementation will simply call disposeInternal to remove
* graphics resources and allow init to recreate them. Complex resources may
* need more sophisticated behavior.
*/
protected void recycleInternal() {
disposeInternal();
}
public ResourceOrder getResourceOrder() { public ResourceOrder getResourceOrder() {
return RenderingOrderFactory.getRenderingOrder(this); return RenderingOrderFactory.getRenderingOrder(this);
} }

View file

@ -55,14 +55,15 @@ import com.vividsolutions.jts.geom.Coordinate;
* *
* <pre> * <pre>
* SOFTWARE HISTORY * SOFTWARE HISTORY
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------- -------- ----------- --------------------------
* Feb 18, 2009 2032 jsanchez Initial Creation. * Feb 18, 2009 2032 jsanchez Initial Creation.
* Updated inspect to display a single value. * Updated inspect to display a single value.
* Mar 17, 2009 800 jsanchez Avoided displaying unnecessary 0.0. * Mar 17, 2009 800 jsanchez Avoided displaying unnecessary 0.0.
* Jul 31, 2013 2190 mschenke Removed arbitrary check for 0.0 and instead * Jul 31, 2013 2190 mschenke Removed arbitrary check for 0.0 and instead
* only check for NaN. SatResource handles fill * only check for NaN. SatResource handles fill
* values and returns NaN now * values and returns NaN now
* Nov 18, 2013 2544 bsteffen Override recycleInternal
* *
* </pre> * </pre>
* *
@ -101,6 +102,14 @@ public class SatBlendedResource extends
resourceData.removeChangeListener(this); resourceData.removeChangeListener(this);
} }
@Override
protected void recycleInternal() {
for (ResourcePair rp : this.resourceData.getResourceList()) {
rp.getResource().recycle();
}
disposeImage();
}
/* /*
* (non-Javadoc) * (non-Javadoc)
* *