From aaa94a950ed48b71587c77cd3a10415a601a05e3 Mon Sep 17 00:00:00 2001 From: Myk Melez Date: Tue, 28 Oct 2014 17:26:49 -0700 Subject: [PATCH] explain why we attach/detach native impl. in setParent --- java/custom/com/nokia/mid/ui/CanvasItem.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/java/custom/com/nokia/mid/ui/CanvasItem.java b/java/custom/com/nokia/mid/ui/CanvasItem.java index d47da6ce..e0ef3d97 100644 --- a/java/custom/com/nokia/mid/ui/CanvasItem.java +++ b/java/custom/com/nokia/mid/ui/CanvasItem.java @@ -18,6 +18,12 @@ public abstract class CanvasItem { parent = theParent; + // We need to attach/detach the native implementation at some point. + // We initially considered init/finalize, but our VM doesn't appear + // to ever call finalize. So we do it here, attaching the native impl. + // when setParent is called with an object reference, then detaching it + // when setParent is called with a null value; which appears to be + // expected usage when creating/destroying CanvasItem objects. if (parent != null) { attachNativeImpl(); } else {