Project: titanium
Issue TIMOB-17141: iOS: Application crashes during a numeric search on a ListView
h1. Problem if you change the position of the listView during a search the app crashes h1. Reproduction Drop the following in an app.js. 1) Run it 2) put 555 in the textField and do a search 3) press the button ("change top of listview") twice and it will crash. (values like 555 or 100 crash the application) warning!: we noticed that if the searched values are less than the listview's height the application will crash. As a matter of fact, if we put values like '78' or '0' the application does not crash. {code:title=App.js | borderStyle=solid} var win = Ti.UI.createWindow({}); var search = Ti.UI.createSearchBar({}); var items = []; for (var i = 0; i<1000; i++) {	items.push({	properties: {	title: 'item: ' + i,	searchableText: 'item: ' + i	}	}); } var button = Ti.UI.createButton({	title : 'Change top of listView',	top:50, }); button.addEventListener('click', function() {	listView.top === 100 ? listView.top = 150 : listView.top = 100; }); var listView = Titanium.UI.createListView({	top: 100,	sections: [ Ti.UI.createListSection({items: items}) ],	searchView: search, }); win.add(button); win.add(listView); win.open(); {code} h1. Console Log {code:title=Console Log | borderStyle=solid} [ERROR] : The application has crashed with an uncaught exception 'NSRangeException'. [ERROR] : Reason: [ERROR] : *** -[__NSArrayM objectAtIndex:]: index 19 beyond bounds [0 .. 0] [ERROR] : Stack trace: [ERROR] : 0 CoreFoundation 0x044081c8 __exceptionPreprocess + 152 [ERROR] : 1 libobjc.A.dylib 0x040c48e5 objc_exception_throw + 44 [ERROR] : 2 CoreFoundation 0x043a93f6 -[__NSArrayM objectAtIndex:] + 246 [ERROR] : 3 test 0x00291768 -[TiUIListView pathForSearchPath:] + 184 [ERROR] : 4 test 0x00297b19 -[TiUIListView tableView:cellForRowAtIndexPath:] + 73 [ERROR] : 5 UIKit 0x00ade11f -[UITableView _createPreparedCellForGlobalRow:withIndexPath:] + 412 [ERROR] : 6 UIKit 0x00ade1f3 -[UITableView _createPreparedCellForGlobalRow:] + 69 [ERROR] : 7 UIKit 0x00abfece -[UITableView _updateVisibleCellsNow:] + 2428 [ERROR] : 8 UIKit 0x00ad46a5 -[UITableView layoutSubviews] + 213 [ERROR] : 9 UIKit 0x00a54964 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 355 [ERROR] : 10 libobjc.A.dylib 0x040d682b -[NSObject performSelector:withObject:] + 70 [ERROR] : 11 QuartzCore 0x0301a45a -[CALayer layoutSublayers] + 148 [ERROR] : 12 QuartzCore 0x0300e244 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380 [ERROR] : 13 QuartzCore 0x0300e0b0 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 26 [ERROR] : 14 QuartzCore 0x02f747fa _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 294 [ERROR] : 15 QuartzCore 0x02f75b85 _ZN2CA11Transaction6commitEv + 393 [ERROR] : 16 QuartzCore 0x02f76258 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 92 [ERROR] : 17 CoreFoundation 0x043d036e __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 30 [ERROR] : 18 CoreFoundation 0x043d02bf __CFRunLoopDoObservers + 399 [ERROR] : 19 CoreFoundation 0x043ae254 __CFRunLoopRun + 1076 [ERROR] : 20 CoreFoundation 0x043ad9d3 CFRunLoopRunSpecific + 467 [ERROR] : 21 CoreFoundation 0x043ad7eb CFRunLoopRunInMode + 123 [ERROR] : 22 GraphicsServices 0x05e795ee GSEventRunModal + 192 [ERROR] : 23 GraphicsServices 0x05e7942b GSEventRun + 104 [ERROR] : 24 UIKit 0x009e5f9b UIApplicationMain + 1225 [ERROR] : 25 test 0x00005a58 main + 456 [ERROR] : 26 libdyld.dylib 0x04a3b701 start + 1 [ERROR] : 2014-05-23 11:46:27.329 test[85362:70b] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 19 beyond bounds [0 .. 0]' [ERROR] : *** First throw call stack: [ERROR] : ( [ERROR] :	0 CoreFoundation 0x044081e4 __exceptionPreprocess + 180 [ERROR] :	1 libobjc.A.dylib 0x040c48e5 objc_exception_throw + 44 [ERROR] :	2 CoreFoundation 0x043a93f6 -[__NSArrayM objectAtIndex:] + 246 [ERROR] :	3 test 0x00291768 -[TiUIListView pathForSearchPath:] + 184 [ERROR] :	4 test 0x00297b19 -[TiUIListView tableView:cellForRowAtIndexPath:] + 73 [ERROR] :	5 UIKit 0x00ade11f -[UITableView _createPreparedCellForGlobalRow:withIndexPath:] + 412 [ERROR] :	6 UIKit 0x00ade1f3 -[UITableView _createPreparedCellForGlobalRow:] + 69 [ERROR] :	7 UIKit 0x00abfece -[UITableView _updateVisibleCellsNow:] + 2428 [ERROR] :	8 UIKit 0x00ad46a5 -[UITableView layoutSubviews] + 213 [ERROR] :	9 UIKit 0x00a54964 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 355 [ERROR] :	10 libobjc.A.dylib 0x040d682b -[NSObject performSelector:withObject:] + 70 [ERROR] :	11 QuartzCore 0x0301a45a -[CALayer layoutSublayers] + 148 [ERROR] :	12 QuartzCore 0x0300e244 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380 [ERROR] :	13 QuartzCore 0x0300e0b0 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 26 [ERROR] :	14 QuartzCore 0x02f747fa _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 294 [ERROR] :	15 QuartzCore 0x02f75b85 _ZN2CA11Transaction6commitEv + 393 [ERROR] :	16 QuartzCore 0x02f76258 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 92 [ERROR] :	17 CoreFoundation 0x043d036e __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 30 [ERROR] :	18 CoreFoundation 0x043d02bf __CFRunLoopDoObservers + 399 [ERROR] :	19 CoreFoundation 0x043ae254 __CFRunLoopRun + 1076 [ERROR] :	20 CoreFoundation 0x043ad9d3 CFRunLoopRunSpecific + 467 [ERROR] :	21 CoreFoundation 0x043ad7eb CFRunLoopRunInMode + 123 [ERROR] :	22 GraphicsServices 0x05e795ee GSEventRunModal + 192 [ERROR] :	23 GraphicsServices 0x05e7942b GSEventRun + 104 [ERROR] :	24 UIKit 0x009e5f9b UIApplicationMain + 1225 [ERROR] :	25 test 0x00005a58 main + 456 [ERROR] :	26 libdyld.dylib 0x04a3b701 start + 1 [ERROR] : ) [ERROR] : libc++abi.dylib: terminating with uncaught exception of type NSException {code}
Story points: 3