problem
When setting the *visible* property of a Ti.UI.View to *null* it causes a runtime exception on android. On iOS and Mobileweb the view would simply become invisible. I'm not certain whether it should be visible or invisible, but they should be the same behavior regardless of platform.
expected
When I set the the *visible* property of a Ti.UI.Label to *null*, I expect the behavior, whether it makes the view visible or invisible, to be the same on all platforms. It should not cause a runtime exception
test case
app.js
var win = Ti.UI.createWindow({
backgroundColor: '#fff',
modal: false,
exitOnClose: true
});
var label = Ti.UI.createLabel({
text: 'just a test label'
});
label.addEventListener('click', function(e) {
label.visible = null;
});
win.add(label);
win.open();
error log (adb)
W/dalvikvm( 486): threadid=1: thread exiting with uncaught exception (group=0x40015560)
E/TiApplication( 486): (main) [1415,31700] Sending event: exception on thread: main msg:java.lang.IllegalArgumentException: Unable to convert null to boolean.; Titanium 3.1.1,2013/06/15 16:10,f7592c1
E/TiApplication( 486): java.lang.IllegalArgumentException: Unable to convert null to boolean.
E/TiApplication( 486): at org.appcelerator.titanium.util.TiConvert.toBoolean(TiConvert.java:356)
E/TiApplication( 486): at org.appcelerator.titanium.view.TiUIView.propertyChanged(TiUIView.java:543)
E/TiApplication( 486): at ti.modules.titanium.ui.widget.TiUILabel.propertyChanged(TiUILabel.java:168)
E/TiApplication( 486): at org.appcelerator.kroll.KrollPropertyChange.fireEvent(KrollPropertyChange.java:21)
E/TiApplication( 486): at org.appcelerator.kroll.KrollProxy.handleMessage(KrollProxy.java:1011)
E/TiApplication( 486): at org.appcelerator.titanium.proxy.TiViewProxy.handleMessage(TiViewProxy.java:316)
E/TiApplication( 486): at android.os.Handler.dispatchMessage(Handler.java:95)
E/TiApplication( 486): at android.os.Looper.loop(Looper.java:130)
E/TiApplication( 486): at android.app.ActivityThread.main(ActivityThread.java:3683)
E/TiApplication( 486): at java.lang.reflect.Method.invokeNative(Native Method)
E/TiApplication( 486): at java.lang.reflect.Method.invoke(Method.java:507)
E/TiApplication( 486): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
E/TiApplication( 486): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
E/TiApplication( 486): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 486): FATAL EXCEPTION: main
E/AndroidRuntime( 486): java.lang.IllegalArgumentException: Unable to convert null to boolean.
E/AndroidRuntime( 486): at org.appcelerator.titanium.util.TiConvert.toBoolean(TiConvert.java:356)
E/AndroidRuntime( 486): at org.appcelerator.titanium.view.TiUIView.propertyChanged(TiUIView.java:543)
E/AndroidRuntime( 486): at ti.modules.titanium.ui.widget.TiUILabel.propertyChanged(TiUILabel.java:168)
E/AndroidRuntime( 486): at org.appcelerator.kroll.KrollPropertyChange.fireEvent(KrollPropertyChange.java:21)
E/AndroidRuntime( 486): at org.appcelerator.kroll.KrollProxy.handleMessage(KrollProxy.java:1011)
E/AndroidRuntime( 486): at org.appcelerator.titanium.proxy.TiViewProxy.handleMessage(TiViewProxy.java:316)
E/AndroidRuntime( 486): at android.os.Handler.dispatchMessage(Handler.java:95)
E/AndroidRuntime( 486): at android.os.Looper.loop(Looper.java:130)
E/AndroidRuntime( 486): at android.app.ActivityThread.main(ActivityThread.java:3683)
E/AndroidRuntime( 486): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 486): at java.lang.reflect.Method.invoke(Method.java:507)
E/AndroidRuntime( 486): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
E/AndroidRuntime( 486): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
E/AndroidRuntime( 486): at dalvik.system.NativeStart.main(Native Method)
PR: https://github.com/appcelerator/titanium_mobile/pull/4459
Verified the fix with: Appc-Studio: 3.2.0.201310100354 Sdk:3.2.0.v20131009134844 alloy:1.2.2 npm:1.3.2 titanium:3.2.0 titanium-code-processor:1.0.3 Device:Google Nexus 7(v4.3),ipodTouch1(v7.0) Xcode: 5 Setting visible to null on view does not cause exception now. Works fine on both iOS and Android. Have checked with view as well as label.