Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-15019] iOS: Tableview crash when calling setData after search

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2013-09-03T20:56:58.000+0000
Affected Version/sRelease 3.1.0, Release 3.1.1, Release 3.1.2
Fix Version/s2013 Sprint 18, 2013 Sprint 18 API, Release 3.1.3, Release 3.2.0
ComponentsAndroid
Labelsregression
ReporterBetty Tran
AssigneeVishal Duggal
Created2013-08-30T21:12:10.000+0000
Updated2013-09-10T06:52:33.000+0000

Description

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

Attachments

FileDateSize
crashlog2013-08-30T21:12:11.000+00006270

Comments

  1. Vishal Duggal 2013-09-03

    https://github.com/appcelerator/titanium_mobile/pull/4640
  2. Vishal Duggal 2013-09-03

    backport to 3_1_X https://github.com/appcelerator/titanium_mobile/pull/4641
  3. Sid Ghosh 2013-09-04

    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
  4. Ingo Muschenetz 2013-09-04

    [~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.
  5. Priya Agarwal 2013-09-10

    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.

JSON Source