From 4febe2a87cacecbbf2aa51bbde6d64bca32d1806 Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Wed, 6 Apr 2016 16:29:08 +0300 Subject: [PATCH] =?UTF-8?q?FragmentClass=20instance=20is=20cached=20so=20t?= =?UTF-8?q?hat=20JS=20part=20does=20not=20die=20before=20=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * FragmentClass instance is cached so that JS part does not die before native counter part. * Fix tslint error. --- ui/frame/frame.android.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ui/frame/frame.android.ts b/ui/frame/frame.android.ts index a98c29a10..5393c585b 100644 --- a/ui/frame/frame.android.ts +++ b/ui/frame/frame.android.ts @@ -7,7 +7,6 @@ import {View} from "ui/core/view"; import {Observable} from "data/observable"; import * as application from "application"; import * as types from "utils/types"; -import * as utils from "utils/utils"; global.moduleMerge(frameCommon, exports); @@ -19,6 +18,7 @@ var IS_BACK = "_isBack"; var NAV_DEPTH = "_navDepth"; var CLEARING_HISTORY = "_clearingHistory"; var FRAMEID = "_frameId"; +var FRAGMENT = "_FRAGMENT"; var navDepth = -1; @@ -197,6 +197,9 @@ export class Frame extends frameCommon.Frame { newFragment.frame = this; newFragment.entry = backstackEntry; + // Cahce newFragment at backstackEntry instance so that it cannot die while backstackEntry is alive. + backstackEntry[FRAGMENT] = newFragment; + backstackEntry[BACKSTACK_TAG] = newFragmentTag; backstackEntry[NAV_DEPTH] = navDepth; @@ -664,7 +667,7 @@ class FragmentClass extends android.app.Fragment { public onDestroy(): void { trace.write(`${this.getTag()}.onDestroy()`, trace.categories.NativeLifecycle); super.onDestroy(); - utils.GC(); + this.entry[FRAGMENT] = undefined; } }