mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-17 21:01:34 +08:00
Merge pull request #658 from NativeScript/tab-view-fix
Fixed a null reference exception.
This commit is contained in:
@ -445,13 +445,23 @@ export class TabView extends common.TabView {
|
|||||||
trace.write("TabView._removeTabs(" + oldItems + ");", common.traceCategory);
|
trace.write("TabView._removeTabs(" + oldItems + ");", common.traceCategory);
|
||||||
super._removeTabs(oldItems);
|
super._removeTabs(oldItems);
|
||||||
|
|
||||||
|
var i = 0;
|
||||||
|
if (oldItems && oldItems.length) {
|
||||||
|
var item: TabViewItem;
|
||||||
|
for (; i < oldItems.length; i++) {
|
||||||
|
item = <TabViewItem>oldItems[i];
|
||||||
|
item._tab = null;
|
||||||
|
item._parent = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var actionBar = this._getActionBar();
|
var actionBar = this._getActionBar();
|
||||||
if (!actionBar) {
|
if (!actionBar) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove all the existing tabs added by this instance
|
// 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 tab: android.app.ActionBar.Tab;
|
||||||
var index;
|
var index;
|
||||||
for (; i >= 0; i--) {
|
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 = <TabViewItem>this.items[i];
|
|
||||||
item._tab = null;
|
|
||||||
item._parent = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this._tabsAddedByMe.length > 0) {
|
if (this._tabsAddedByMe.length > 0) {
|
||||||
throw new Error("TabView did not remove all of its tabs from the ActionBar.");
|
throw new Error("TabView did not remove all of its tabs from the ActionBar.");
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user