[TIMOB-16594] iOS: Editable ListView with RefreshControl + tintColor crashes swipe-delete event.
| GitHub Issue | n/a |
|---|---|
| Type | Bug |
| Priority | n/a |
| Status | Closed |
| Resolution | Fixed |
| Resolution Date | 2014-03-17T19:59:05.000+0000 |
| Affected Version/s | n/a |
| Fix Version/s | 2014 Sprint 06, 2014 Sprint 06 SDK, Release 3.2.3, Release 3.3.0 |
| Components | iOS |
| Labels | crash, delete, event, ios, listview, qe-closed-3.2.3, qe-testadded, tintColor |
| Reporter | Ed |
| Assignee | Vishal Duggal |
| Created | 2014-03-06T04:39:34.000+0000 |
| Updated | 2014-03-18T21:08:48.000+0000 |
Description
An editable ListView with a RefreshControl crashes if tintColor is defined for the RefreshControl AND one tries to JSON.stringify() the delete event object.
Expected behavior: JSON.strigify(e) should work on the delete event, regardless of the RefreshControl and its tintColor property.
Test with code below. Swipe delete one row and the following error gets logged:
bq. alloyblank[56590:320b] -[UIDeviceRGBColor boundBridge:withKrollObject:]: unrecognized selector sent to instance 0xcc53e30
Swipe delete another one, and the app crashes with:
bq. [ valueForUndefinedKey:]: this class is not key value coding-compliant for the key toJSON.
<Alloy>
<Window class="container">
<ListView id="lv" onDelete="lv_delete">
<ListSection id="ls" />
</ListView>
</Window>
</Alloy>
var refresh = Ti.UI.createRefreshControl({
// DEFINING THIS WILL CRASH DELETE EVENT
tintColor: '#ff0000'
});
$.lv.applyProperties({
refreshControl: refresh
});
var rows = [];
for (var i = 0; i < 50; i++) {
rows.push({ properties: { title: 'Row '+ i, canEdit: true }});
}
$.ls.setItems(rows);
$.index.open();
function lv_delete(e) {
Ti.API.info('this works: ' + e.itemIndex);
// JSON.stringify(e) WILL CRASH IF tintColor IS DEFINED ABOVE
Ti.API.info('stringify: ' + JSON.stringify(e));
}
Classic test code
var win = Ti.UI.createWindow({backgroundColor:'white',fullscreen:true}) var refresh = Ti.UI.createRefreshControl({ // DEFINING THIS WILL CRASH DELETE EVENT tintColor: '#ff0000' }); var listView = Ti.UI.createListView({refreshControl: refresh}); var fruitSection = Ti.UI.createListSection({ headerTitle: 'Fruits'}); var rows = []; for (var i = 0; i < 50; i++) { rows.push({ properties: { title: 'Row '+ i, canEdit: true }}); } fruitSection.setItems(rows); listView.setSections([fruitSection]); win.add(listView); win.open(); function lv_delete(e) { Ti.API.info('this works: ' + e.itemIndex); // JSON.stringify(e) WILL CRASH IF tintColor IS DEFINED ABOVE Ti.API.info('stringify: ' + JSON.stringify(e)); } listView.addEventListener('delete',lv_delete);Pull pending master - https://github.com/appcelerator/titanium_mobile/pull/5442 3_2_X - https://github.com/appcelerator/titanium_mobile/pull/5482
Tested and verified the fix with: Appcelerator Studio, build: 3.2.3.201403171239 Titanium SDK, build: 3.2.3.v20140317142455 Node.JS Version: v0.10.13 NPM Version: 1.3.2 ├── acs@1.0.14 ├── alloy@1.3.1 ├── npm@1.3.2 ├── titanium@3.2.1 └── titanium-code-processor@1.1.0