Clear up BaseRenderer.disable

- Call onDisabled last. onDisabled really shouldn't be doing
  anything with the stream, so pretty sure this is fine (and
  guarantees the stream is cleared properly even if onDisabled
  throws a RTE).
- Remove super.onDisabled calls from Text/Metadata renderers.
  This is just for consistency; we don't make such calls in
  other direct descendants of BaseRenderer.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=156130640
This commit is contained in:
olly 2017-05-15 18:06:20 -07:00 committed by Oliver Woodman
parent 84875bbe7b
commit 72ba736a7f
3 changed files with 1 additions and 5 deletions

View File

@ -142,9 +142,9 @@ public abstract class BaseRenderer implements Renderer, RendererCapabilities {
public final void disable() { public final void disable() {
Assertions.checkState(state == STATE_ENABLED); Assertions.checkState(state == STATE_ENABLED);
state = STATE_DISABLED; state = STATE_DISABLED;
onDisabled();
stream = null; stream = null;
streamIsFinal = false; streamIsFinal = false;
onDisabled();
} }
// RendererCapabilities implementation. // RendererCapabilities implementation.
@ -300,8 +300,6 @@ public abstract class BaseRenderer implements Renderer, RendererCapabilities {
/** /**
* Returns whether the upstream source is ready. * Returns whether the upstream source is ready.
*
* @return Whether the source is ready.
*/ */
protected final boolean isSourceReady() { protected final boolean isSourceReady() {
return readEndOfStream ? streamIsFinal : stream.isReady(); return readEndOfStream ? streamIsFinal : stream.isReady();

View File

@ -153,7 +153,6 @@ public final class MetadataRenderer extends BaseRenderer implements Callback {
protected void onDisabled() { protected void onDisabled() {
flushPendingMetadata(); flushPendingMetadata();
decoder = null; decoder = null;
super.onDisabled();
} }
@Override @Override

View File

@ -254,7 +254,6 @@ public final class TextRenderer extends BaseRenderer implements Callback {
streamFormat = null; streamFormat = null;
clearOutput(); clearOutput();
releaseDecoder(); releaseDecoder();
super.onDisabled();
} }
@Override @Override