[Resolved] Runtime error when using tableview widget and tabbar widget together?

I have a very strange problem that I can reliably reproduce, but I have been unable to find the cause.

I have an app with 5 tabs, and tabs 2 and 3 are tableviews. The tableview rows have the usual onEvent and onRender listeners, and the whole table also has a listener to check if event.type == “endedScroll” so that I can detect if the user has released after pulling the table down (i.e. it uses pull down to refresh).

These all work fine. However if I pull either one of the tableviews down slightly, and then change to any other tab before it has finished “springing back” to it’s default position, the app freezes and I get a stack traceback error.

The error doesn’t give me the lua.file and line it occurs on, but says that it happens in function ‘update_scrollbar’. I don’t have any function with that name so presumably it is a function built into Corona?

I’m not sure what to do about it, I tried removing my table listener but it still happens. I also tried removing my enterframe listeners in those classes in case the problem lay there, but it still persists.
It usually says “attempt to perform arithmetic on field ‘y’ (a nil value)” but occasionally it says “attempt to perform index field ‘target’ (a nil value)”

Has anyone else encountered the same problem?

I should add that multitouch is switched off in this app, but it is still common that this error occurs when changing tabs. [import]uid: 84115 topic_id: 33215 reply_id: 333215[/import]

My hunch is that the tableView is being destroyed while still trying to execute code. Are you using any code to destroy the tableView on storyboard exit (I’m presuming you use storyboard to switch tabs?)

Also, not that I have any experience with pulldowns (yet) but I’d assume there you’d want to use endedScroll as the trigger to refresh but movingToTopLimit to tell the app that a refresh is okay, else it would refresh every time you stop scrolling at all… [import]uid: 41884 topic_id: 33215 reply_id: 132092[/import]

My hunch is that the tableView is being destroyed while still trying to execute code. Are you using any code to destroy the tableView on storyboard exit (I’m presuming you use storyboard to switch tabs?)

Also, not that I have any experience with pulldowns (yet) but I’d assume there you’d want to use endedScroll as the trigger to refresh but movingToTopLimit to tell the app that a refresh is okay, else it would refresh every time you stop scrolling at all… [import]uid: 41884 topic_id: 33215 reply_id: 132092[/import]

You were correct, I was manually destroying the tableView on exit. Removing that fixed the problem.

With regards to the pull-down refresh, I am already using a separate bool + checking the scroll position so that already works - I just didn’t think that was worth mentioning in my first post :slight_smile: [import]uid: 84115 topic_id: 33215 reply_id: 132313[/import]

You were correct, I was manually destroying the tableView on exit. Removing that fixed the problem.

With regards to the pull-down refresh, I am already using a separate bool + checking the scroll position so that already works - I just didn’t think that was worth mentioning in my first post :slight_smile: [import]uid: 84115 topic_id: 33215 reply_id: 132313[/import]