From 9377a3c9bbfafb4f1ba751849991e597ad51319f Mon Sep 17 00:00:00 2001 From: Rossen Hristov Date: Wed, 2 Sep 2015 09:09:00 +0300 Subject: [PATCH] Fixed a null reference exception. --- ui/tab-view/tab-view.android.ts | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/ui/tab-view/tab-view.android.ts b/ui/tab-view/tab-view.android.ts index d80d94266..23316831b 100644 --- a/ui/tab-view/tab-view.android.ts +++ b/ui/tab-view/tab-view.android.ts @@ -445,13 +445,23 @@ export class TabView extends common.TabView { trace.write("TabView._removeTabs(" + oldItems + ");", common.traceCategory); super._removeTabs(oldItems); + var i = 0; + if (oldItems && oldItems.length) { + var item: TabViewItem; + for (; i < oldItems.length; i++) { + item = oldItems[i]; + item._tab = null; + item._parent = null; + } + } + var actionBar = this._getActionBar(); if (!actionBar) { return; } // Remove all the existing tabs added by this instance - var i: number = actionBar.getTabCount() - 1; + i = actionBar.getTabCount() - 1; var tab: android.app.ActionBar.Tab; var index; for (; i >= 0; i--) { @@ -465,15 +475,6 @@ export class TabView extends common.TabView { } } - i = 0; - var length = this.items.length; - var item: TabViewItem; - for (; i < length; i++) { - item = this.items[i]; - item._tab = null; - item._parent = null; - } - if (this._tabsAddedByMe.length > 0) { throw new Error("TabView did not remove all of its tabs from the ActionBar."); }