diff options
author | Yang Ni <yangni@google.com> | 2016-04-20 21:26:24 -0700 |
---|---|---|
committer | Yang Ni <yangni@google.com> | 2016-04-22 10:21:18 -0700 |
commit | 1b4df1697f0d9b5dadfa1aca6c50d845d701ed2c (patch) | |
tree | f664276d9f50f6b5d5c40134c8c13cf2d151890f /rs/java/android/renderscript/ScriptGroup.java | |
parent | 54d056ed6d75083ce166eb003fb93efc53cefea5 (diff) |
Fixed BaseObj finalizer and destroy()
Bug: 28242626
Bug: 27972184
Bug: 27973681
This is resolving issues in ScriptGroup (V1) again.
In ScriptGroup.destroy(), we also need to consider the old API where
mClosures is not initialized.
Also cleaned up the finalizer for ScriptGroup and Allocation:
Since BaseObj.finalize() calls BaseObj.helpDestroy(), instead of
BaseObj.destroy(), there is no possibility that the finalizers of
child objects may race their parents finalizers. Note that
helpDestroy() does not try to recurse on child objects.
Change-Id: I9dbb2b60f8478f656f8a418c2b5fc8d6848aeef0
Diffstat (limited to 'rs/java/android/renderscript/ScriptGroup.java')
-rw-r--r-- | rs/java/android/renderscript/ScriptGroup.java | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/rs/java/android/renderscript/ScriptGroup.java b/rs/java/android/renderscript/ScriptGroup.java index 0d10c6d9dc50..e0bdbfcdfed5 100644 --- a/rs/java/android/renderscript/ScriptGroup.java +++ b/rs/java/android/renderscript/ScriptGroup.java @@ -1066,19 +1066,12 @@ public final class ScriptGroup extends BaseObj { */ public void destroy() { super.destroy(); - for(Closure c : mClosures) { - c.destroy(); - } - } - - protected void finalize() throws Throwable { - // Clear out the list mClosures to avoid double-destroying the closures, - // in case their finalizers race ahead. + // ScriptGroup created using the old Builder class does not + // initialize the field mClosures if (mClosures != null) { - // ScriptGroup created using the old Builder class does not - // initialize the field mClosures - mClosures.clear(); + for (Closure c : mClosures) { + c.destroy(); + } } - super.finalize(); } } |