[TIMOB-11415] Android: App crashes while trying to convert null to boolean
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | High |
Status | Closed |
Resolution | Won't Fix |
Resolution Date | 2012-10-13T02:28:51.000+0000 |
Affected Version/s | Release 3.0.0 |
Fix Version/s | 2012 Sprint 21 Core, 2012 Sprint 21 |
Components | Android |
Labels | core, qe-and100112 |
Reporter | Shyam Bhadauria |
Assignee | Ingo Muschenetz |
Created | 2012-10-12T12:33:42.000+0000 |
Updated | 2013-03-27T22:29:51.000+0000 |
Description
This is not a regression. It exists as far as 2.0.1.
Steps to reproduce:
1. Use the code below in app.js
var win = Ti.UI.createWindow();
var info = Ti.UI.createLabel();
win.add(info);
var switchButton = Ti.UI.createSwitch({
top:40,
value:Ti.App.Properties.getBool('test') // mandatory property for iOS
});
switchButton.addEventListener('change',function(_event){
Ti.App.Properties.setBool('test', _event.value);
});
win.add(switchButton);
function onPropertiesChange()
{
switchButton.value = Ti.App.Properties.getBool('test');
info.text = 'onPropertiesChange';
Ti.API.info('onPropertiesChange')
setTimeout(function(){info.text = '';}, 1000);
}
Ti.App.Properties.addEventListener('change',onPropertiesChange);
win.addEventListener('close', function() {
Ti.App.Properties.removeEventListener('change',onPropertiesChange);
});
win.open();
2. Run the app on android device.
Expected result:
1. A window with a button should be displayed.
Actual result:
1. App crashes and force closes.It gives message unable to convert null to boolean. Error logs attached.
Attachments
File | Date | Size |
---|---|---|
TIMOB-10314.rtf | 2012-10-12T12:33:42.000+0000 | 11419 |
This behavior has actually been there for a long time, and we actually throw an exception when the user passes in a null. We may not necessarily want to always assume null -> false. This will get complicated for other types like string or number. In the app, they should really set a default value themselves, like:
Going to mark this as won't fix until we decide we want to change this behavior for sure.