Description
When calling setData on a table that has been populated with sections and rows, setting the data to just rows causes a crash.
Code to reproduce
var second = Ti.UI.createWindow();
var section = Ti.UI.createTableViewSection({
headerTitle : "Fruit"
});
var allNoteTypes = [{
title : 'Apple'
}, {
title : 'Orange'
}, {
title : 'Banana'
}, {
title : 'Pear'
}];
var searchBar = Ti.UI.createSearchBar({
hintText : "Type Here"
});
var table = Ti.UI.createTableView({
width : Ti.UI.FILL,
style : Titanium.UI.iPhone.TableViewStyle.GROUPED,
hideSearchOnSelection : false,
search : searchBar
});
for (var i = 0; i < 3; i++) {
var dataRow = Ti.UI.createTableViewRow({
height : 44
});
var lbl = Ti.UI.createLabel({
left : 10,
text : allNoteTypes[i].title
});
dataRow.add(lbl);
section.add(dataRow);
}
table.setData([section]);
function handleSearchBarFocus(_event) {
Ti.API.info("handleSearchBarFocus");
table.setData(null);
table.setData(allNoteTypes);
}
function handleSearchBarCancel(_event) {
Ti.API.info("handleSearchBarCancel");
table.setData([section]);
}
searchBar.addEventListener("focus", handleSearchBarFocus);
searchBar.addEventListener("cancel", handleSearchBarCancel);
second.add(table);
second.open();
Steps to reproduce
1. Tap on search bar and type 'a'.
2. Press search
3. Press cancel
4. Tap on search bar again
5. App should crash
Please see the attached crash log.
The issue does not occur in 2.1.4GA
https://github.com/appcelerator/titanium_mobile/pull/4640
backport to 3_1_X https://github.com/appcelerator/titanium_mobile/pull/4641
Vishal would you happen to know when can we expect a bug fix for this issue, will it make it to the nightly build ? Sid
[~sghosh] The 3.1.X PR is merged. Builds are kicked off as soon as there is new code to build, so it should be in a build already or if not, soon.
Verified the fixed with environment: Appc Studio: 3.1.3.201309072408 Sdk:3.1.3.v20130909192251 CLI version : 3.1.2 Alloy : 1.2.2-beta MAC OSX: 10.8.4 XCode : 5beta6 Device: Ipad3(v7) TableView now does not crash on calling setData after search.