i have a window that has a tableview, and the data is populated from the local database. it works great. however, i can cause it to throw an exception (and subsequent forceclose since I'm not catching it right now until I solve this) by going back, then opening the window again, then forcing a data refresh.
To open the window, you click from the previous window. The click code is:
var superWin = Titanium.UI.createWindow({ url: 'user/super.js', title: 'Super', fullscreen: false, p: win.p, tl: rowdata }); superWin.close(); superWin.open();The superWin opens and has this code:
// // create table view ( // Titanium.API.info('creating tableview'); tableView = Titanium.UI.createTableView({ search: search, filterAttribute: 'filter', backgroundColor:'white' }); var populateTable = function() { Titanium.API.info('getting supers'); var db = Titanium.Database.open('super.db'); var rows = db.execute(sql); if (rows == null || rows.rowCount == 0) { Titanium.API.info("tl rowcnt = 0"); win.add(lblNone); } else { Titanium.API.info("t rowcnt = " + rows.rowCount); var data = []; var j = 0; Titanium.API.info("entering whileloop 99"); var slTime = new Date(); while (rows.isValidRow()) { var row = Ti.UI.createTableViewRow(); row.height = 100; [code to build row] data.push(row); rows.next(); } var elTime = new Date(); Titanium.API.info('loop took: ' + (elTime - slTime)); Titanium.API.info("done with forloop:"); Titanium.App.fireEvent('hide_indicator'); Ti.API.info('~287'); Ti.API.info(data); Ti.API.info(data.length); Titanium.API.info('setting data with full array'); tableView.setData(data); Titanium.API.info('search!'); Titanium.API.info(search); Ti.API.info('~291'); tableView.search = search; Ti.API.info('~293'); tableView.filterAttribute = 'filter'; win.add(tableView); } } populateTable(); [code to show menu option that, when clicked, will run populateTable()]When superWin is loaded for the first time, you can click the menu button then the option to run populateTable() as many times as you want - it works each time.
If you go back [back button] then click to open the superWin, it loads as expected. But, if you click to populateTable() through the menu, populateTV() runs until it gets to tableView.setData(data), which causes: http://pastie.org/1379960
I've also tried putting the code to create the tableview within the populateTable() function. When I do this, it works for the first load, but ANYTIME I click the refresh menu button that fires populateTable(), it crashes at the same spot.