Problem
If the
window property is omitted when a [Titanium.UI.Tab](
http://developer.appcelerator.com/apidoc/mobile/latest/Titanium.UI.Tab-object#properties) is created, despite setting it directly afterwards with the
setWindow() method, it will cause the app to crash.
The crash will occur when the
open method is called on the
TabGroup.
Test case
Ti.UI.setBackgroundColor('#000');
var tabGroup = Ti.UI.createTabGroup();
var win1 = Ti.UI.createWindow({
title:'Tab 1',
backgroundColor:'#fff'
});
var tab1 = Ti.UI.createTab({
icon:'KS_nav_views.png',
title:'Tab 1',
});
tab1.window = win1;
var win2 = Ti.UI.createWindow({
title:'Tab 2',
backgroundColor:'#fff'
});
var tab2 = Ti.UI.createTab({
icon:'KS_nav_ui.png',
title:'Tab 2',
});
tab2.setWindow(win2);
tabGroup.addTab(tab1);
tabGroup.addTab(tab2);
tabGroup.open();
Logs
01-05 17:59:57.370: ERROR/TiApplication(6157): (main) [1,4512] Sending event: exception on thread: main msg:java.lang.NullPointerException; Titanium 1.8.0.1,2011/12/22 13:09,fbdc96f
01-05 17:59:57.370: ERROR/TiApplication(6157): java.lang.NullPointerException
01-05 17:59:57.370: ERROR/TiApplication(6157): at ti.modules.titanium.ui.TabGroupProxy.addTabToGroup(TabGroupProxy.java:204)
01-05 17:59:57.370: ERROR/TiApplication(6157): at ti.modules.titanium.ui.TabGroupProxy.handlePostOpen(TabGroupProxy.java:314)
01-05 17:59:57.370: ERROR/TiApplication(6157): at ti.modules.titanium.ui.TabGroupProxy.handleMessage(TabGroupProxy.java:95)
01-05 17:59:57.370: ERROR/TiApplication(6157): at android.os.Handler.dispatchMessage(Handler.java:95)
01-05 17:59:57.370: ERROR/TiApplication(6157): at android.os.Looper.loop(Looper.java:123)
01-05 17:59:57.370: ERROR/TiApplication(6157): at android.app.ActivityThread.main(ActivityThread.java:3691)
01-05 17:59:57.370: ERROR/TiApplication(6157): at java.lang.reflect.Method.invokeNative(Native Method)
01-05 17:59:57.370: ERROR/TiApplication(6157): at java.lang.reflect.Method.invoke(Method.java:507)
01-05 17:59:57.370: ERROR/TiApplication(6157): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:847)
01-05 17:59:57.370: ERROR/TiApplication(6157): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:605)
01-05 17:59:57.370: ERROR/TiApplication(6157): at dalvik.system.NativeStart.main(Native Method)
01-05 17:59:57.400: ERROR/AndroidRuntime(6157): FATAL EXCEPTION: main
01-05 17:59:57.400: ERROR/AndroidRuntime(6157): java.lang.NullPointerException
01-05 17:59:57.400: ERROR/AndroidRuntime(6157): at ti.modules.titanium.ui.TabGroupProxy.addTabToGroup(TabGroupProxy.java:204)
01-05 17:59:57.400: ERROR/AndroidRuntime(6157): at ti.modules.titanium.ui.TabGroupProxy.handlePostOpen(TabGroupProxy.java:314)
01-05 17:59:57.400: ERROR/AndroidRuntime(6157): at ti.modules.titanium.ui.TabGroupProxy.handleMessage(TabGroupProxy.java:95)
01-05 17:59:57.400: ERROR/AndroidRuntime(6157): at android.os.Handler.dispatchMessage(Handler.java:95)
01-05 17:59:57.400: ERROR/AndroidRuntime(6157): at android.os.Looper.loop(Looper.java:123)
01-05 17:59:57.400: ERROR/AndroidRuntime(6157): at android.app.ActivityThread.main(ActivityThread.java:3691)
01-05 17:59:57.400: ERROR/AndroidRuntime(6157): at java.lang.reflect.Method.invokeNative(Native Method)
01-05 17:59:57.400: ERROR/AndroidRuntime(6157): at java.lang.reflect.Method.invoke(Method.java:507)
01-05 17:59:57.400: ERROR/AndroidRuntime(6157): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:847)
01-05 17:59:57.400: ERROR/AndroidRuntime(6157): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:605)
01-05 17:59:57.400: ERROR/AndroidRuntime(6157): at dalvik.system.NativeStart.main(Native Method)
This work on SDK 1.7.5, that's a regression.
Verified fixed with SDK 1.9.0.v20120119131634 on Nexus S (2.3.6) and Emulator.
updated labels
Anvil testcase PR https://github.com/appcelerator/titanium_mobile/pull/5074