Attempt to index field 'parent' (a nil value)

I don’t have any idea what triggers this.

File: ?

Attempt to index field ‘parent’ (a nil value)

stack traceback:

?: in function ‘createScrollBar’

?: in function ‘_listener’

?: in function <?:141>

?: in function <?:218>

 

 

kindly explain why is this error triggered? what are the conditions to make this error appear

Have you searched your code for all calls to ‘createScrollBar’, then once you locate the file or files, that call make the call, look for a listener function that accesses something .parent  ?  Or you could search all code in your game/app folder for the phrase " .parent".  

I’m not saying this will find the issue with 100% certainty, since you didn’t mention looking for it I have am asking if you tried these things. 

As far as the cause, well if you’ve included any external code (not written by you) and it has this problem, you could be getting this (generic) error message from that code.  I do know that hunting down generic errors like this where the source file is not explicitly spelled out is annoying, but the error message should be giving you enough data to narrow down the listener that caused the issue.

Just to elaborate, you know the following from the error message:

  1. The function ‘createScrollBar()’ was called and passed a listener function.  This listener is causing the issue.

  2. In whatever file that listener lives in, it starts on line 141.

  3. The offending code in the listener is on line 218 of the same file.

Good luck on this.

Are you using either a widget.newTableView or widget.newScrollView?

Rob

Hi, 

I’m also having this issue. Happens when I remove a scrollView using removeSelf or display.remove. The scrollView is completely stationary when I’m trying to remove it. The screen is literally just a scrollView and a button, which are both inserted into a group.

2014-09-05 16:23:24.440 Corona Simulator[8542:507] Runtime error

?:0: attempt to index field ‘parent’ (a nil value)

stack traceback:

?: in function <?:497>

?: in function <?:221>

Is the button in the scrollView?  You might want to use the “timer trick” used when you’re trying to remove something you’re still using.  Try:

timer.performWithDelay(10, function() scrollView:removeSelf(); scrollView = nil; end)

And see if that helps.

Rob

I actually figured it out. Instead of just removing my group that contained the button and scrollView, I had to *first* remove the scrollView. Have no idea why, but it works on 6 different menus in my game that all had this issue. Trying to remove the group directly caused the error. So now I manually remove the scrollView and then I remove the group normally.

Have you searched your code for all calls to ‘createScrollBar’, then once you locate the file or files, that call make the call, look for a listener function that accesses something .parent  ?  Or you could search all code in your game/app folder for the phrase " .parent".  

I’m not saying this will find the issue with 100% certainty, since you didn’t mention looking for it I have am asking if you tried these things. 

As far as the cause, well if you’ve included any external code (not written by you) and it has this problem, you could be getting this (generic) error message from that code.  I do know that hunting down generic errors like this where the source file is not explicitly spelled out is annoying, but the error message should be giving you enough data to narrow down the listener that caused the issue.

Just to elaborate, you know the following from the error message:

  1. The function ‘createScrollBar()’ was called and passed a listener function.  This listener is causing the issue.

  2. In whatever file that listener lives in, it starts on line 141.

  3. The offending code in the listener is on line 218 of the same file.

Good luck on this.

Are you using either a widget.newTableView or widget.newScrollView?

Rob

Hi, 

I’m also having this issue. Happens when I remove a scrollView using removeSelf or display.remove. The scrollView is completely stationary when I’m trying to remove it. The screen is literally just a scrollView and a button, which are both inserted into a group.

2014-09-05 16:23:24.440 Corona Simulator[8542:507] Runtime error

?:0: attempt to index field ‘parent’ (a nil value)

stack traceback:

?: in function <?:497>

?: in function <?:221>

Is the button in the scrollView?  You might want to use the “timer trick” used when you’re trying to remove something you’re still using.  Try:

timer.performWithDelay(10, function() scrollView:removeSelf(); scrollView = nil; end)

And see if that helps.

Rob

I actually figured it out. Instead of just removing my group that contained the button and scrollView, I had to *first* remove the scrollView. Have no idea why, but it works on 6 different menus in my game that all had this issue. Trying to remove the group directly caused the error. So now I manually remove the scrollView and then I remove the group normally.