TableView error question

ERROR: Runtime error ?:0: attempt to index field '\_view' (a nil value) stack traceback: ?: in function 'touch' ?: in function \<?:949\> ?: in function \<?:205\>

I have this problem too . Please share me about how to solve this problem . Thank you

Is there more to the error?

It looks like it’s coming from a touch event handler. Perhaps your onRowTouch() function or a button inside of the row created in onRowRender()?

We will need to see some code around those areas. And more from  your console log, like the few lines above it.

Rob

Rob,

Just checking in to see if there is an update on this.

Thank you!

No one provided me any additional information.

Rob,

In re-reading your response it is not clear whether you are referring to the bug report above (Case #45528), or to shohoku-boy post.

Thank you.

When you drag off a row in the tableview it’s setting the fill colour on the now unselected row back to the default.
It then turns the separator line back on on the row it’s just uncoloured and the one above

If however the row you’ve just unselected is right at the top of the tableview then the row above it could well have just been culled.
 

if view.\_rows[self.\_targetRow.index - 1] then if view.\_rows[self.\_targetRow.index - 1].\_view.\_separator then view.\_rows[self.\_targetRow.index - 1].\_view.\_separator.isVisible = true end end

Probably ought to say

-- the row above might have been culled and so not have a view, we ought to care about that if view.\_rows[self.\_targetRow.index - 1] and view.\_rows[self.\_targetRow.index - 1].\_view then if view.\_rows[self.\_targetRow.index - 1].\_view.\_separator then view.\_rows[self.\_targetRow.index - 1].\_view.\_separator.isVisible = true end end

at line 387 in widget_tabelview.lua

(edited my suggested fix after looking for other places it might do the same thing, thought I ought to make it check the same way it does EVERYWHERE else in tableview)

Steve,

Where does one find the widget_tableview.lua file to make the changes you mention? I am not wise to the innerworkings of Corona and a long search of my hard drive did not turn up any results. There were some mentions on the forum of “overriding” the built-in widget library - without any examples of how to go about performing such witchery.

Thank you!

Ed

There are probably proper instructions written by people who know how to do stuff somewhere. I suspect I read them once upon a time when I did it myself and didn’t just guess.

My “don’t really remember and don’t particularly use github” version is something like this

go to https://github.com/coronalabs/framework-widget and press the “download zip” button, that’ll give you a copy of the open sourced version of widget2

copy the widgetLibrary folder from the downloaded zip into your project

Change all the

-- Require needed widget files local \_widget = require( "widget" ) local \_momentumScrolling = require( "widget\_momentumScrolling" )

shaped lines at the top of the files in there to require widgetLibrary.WhateverItsRequiring or you’ll have bits of your widget library and bits of the standard corona one I think.

change the line mentioned in my previous post in widget_tableview.lua,

change wherever you’re requiring widget in your code to require widgetLibrary.widget instead

I don’t think you need any of the other stuff in your downloaded file to make it work, just to override the art assets and themes

Hopefully someone who knows what they’re doing will come along and point out whatever is completely wrong in this post or I’ll look harder at what I’ve actually done with anything else from that download when I’m in the office.

eta: https://forums.coronalabs.com/topic/34183-widgets-20-open-source/ is I think the original instructions but that says to read the readme which seems to not have anything in it.

Rob - any update as to whether this has moved any closer to a fix?

UPDATE:

After flicking the TableView up and down a bit in the simulator, I have been able to recreate a very similar Runtime Error:

[lua]10:28:55.169 ERROR: Runtime error
10:28:55.169 ?:0: attempt to index field ‘_view’ (a nil value)
10:28:55.169 stack traceback:
10:28:55.169 ?: in function ‘touch’
10:28:55.169 ?: in function
10:28:55.169 ?: in function [/lua]

Anyone, any thoughts where I can start to track this down??

Thank you!

UPDATE 2:

I added a print statement to onRowTouch that prints event.target.index if phase == “press”. The print statement indicates that the row index is 12, yet the error message indicates that a nil value was passed. Anyway, here is the simulator output screen (ORT is print statement within onRowTouch and TVL is print statement in tableViewListener):

[lua]10:47:43.233 ORT: press
10:47:43.233 ORT: press
10:47:43.233 Pressed row: 12
10:47:43.233 ID: 416072
10:47:43.263 TVL Phase: began
10:47:43.263 TVL Content Pos: -1590.9401855469
10:47:43.263 TVL Phase: began
10:47:43.263 TVL Content Pos: -1590.9401855469
10:47:43.273 ERROR: Runtime error
10:47:43.273 ?:0: attempt to index field ‘_view’ (a nil value)
10:47:43.273 stack traceback:
10:47:43.273 ?: in function ‘touch’
10:47:43.273 ?: in function
10:47:43.273 ?: in function [/lua]

Here is onRowTouch:

[lua]local onRowTouch = function(event)
local phase = event.phase
print ("ORT: " … phase)
if (phase == “press”) then
print ("ORT: " … phase)
print("Pressed row: ", event.target.index)
print("ID: ", event.target.id)
end
if (phase == “tap”) then
print ("ORT: " … phase)
print("Tapped row: ", event.target.index)
print("ID: ", event.target.id)
end
if (phase == “release”) then
print("Released row: ", event.target.index)
print("ID: ", event.target.id)
if(event.target.index % 2 == 0) then
– hide the calendar selection button
_G.GUI.GetHandle(“MY_BUTTON”):show(false)
– get the current screen ratio
Globals.TVRatio = display.contentHeight / display.contentWidth
– 3 steps: destory the tableView
Globals.tableView:deleteAllRows()
display.remove( Globals.tableView )
–Globals.tableView:removeSelf()
Globals.tableView = nil
– unhide back button
Globals.btnBack.alpha = 1
– hide app name
Globals.appName.alpha = 0

– create the away/home buttons
Z.createAwayHome( event )

else
print(“Nothing to do here, this tap must be on a header.”)
end
end – end if phase == “release”
return true
end – end local function
Z.onRowTouch = onRowTouch[/lua]

Link to a screen capture of the above error message:

https://youtu.be/hVw6fZrkJ8k

Thank you! 

Ed

P.S. is there a way to post code to main indenting?

Hi @reallyrottens_98,

At an initial glance, shouldn’t your conditional phase checks inside the “onRowTouch()” function be structured in the following format to avoid potential duplicate responses?

if then elseif then elseif then (else) end

Here, you have it:

if then end if then end if then end

I would suggest doing the first one, unless you have a very specific reasoning for using the conditional setup where you may get multiple true conditions.

Brent

Hi Brent,

Thank you for the response!

I put in the multiple if’s while trying different ways to troubleshoot this - I was checking to see if perhaps multiple touch/tap/other phases were somehow being fired simultaneously. I had not cleaned it up yet. The things you do when you start running out of ideas!

I added some code to print the event table and subtables right before the Runtime Error. Here is the output:

[lua]16:46:13.013 ORT: press

16:46:13.013 table: 0A981C10 {
16:46:13.013 [phase] => “press”
16:46:13.013 [row] => table: 0A981C10 {
16:46:13.013 [index] => 4
16:46:13.013 [_label] => “”
16:46:13.013 [id] => “416077”
16:46:13.013 [_cannotTap] => false
16:46:13.013 [setRowColor] => function: 0A71D798
16:46:13.013 [isCategory] => false
16:46:13.013 [_functionListeners] => table: 0A8EFC48 {
16:46:13.013 [tap] => table: 0A8ECA48 {
16:46:13.013 [1] => function: 0A97AA00
16:46:13.013 }
16:46:13.013 [touch] => table: 0A8ECA48 {
16:46:13.013 [1] => function: 0A97A9E0
16:46:13.013 }
16:46:13.013 }
16:46:13.013 [_class] => table: 0A8EFC48 {
16:46:13.013 [removeEventListener] => function: 0699EB80
16:46:13.013 [addEventListener] => function: 0699EB60
16:46:13.013 [__index] => table: 0699FCF0 {
16:46:13.013 *table: 0699FCF0
16:46:13.013 }
16:46:13.013 }
16:46:13.013 [params] => table: 0A8EFC48 {
16:46:13.013 [home_team_id] => “144”
16:46:13.013 [away_probable_pitcher_first] => “Lance”
16:46:13.013 [away_team_id] => “138”
16:46:13.013 [home_team_city] => “Atlanta”
16:46:13.013 [away_probable_pitcher_losses] => “10”
16:46:13.013 [away_team_city] => “STL C”
16:46:13.013 [home_probable_pitcher_losses] => “8”
16:46:13.013 [home_probable_pitcher_wins] => “7”
16:46:13.013 [away_probable_pitcher_era] => “3.06”
16:46:13.013 [home_probable_pitcher_era] => “5.11”
16:46:13.013 [away_probable_pitcher_wins] => “12”
16:46:13.013 [home_probable_pitcher_last] => “Wisler”
16:46:13.013 [away_probable_pitcher_id] => “458681”
16:46:13.013 [away_probable_pitcher_last] => “Lynn”
16:46:13.013 [home_probable_pitcher_first] => “Matt”
16:46:13.013 [home_probable_pitcher_id] => “605538”
16:46:13.013 }
16:46:13.013 [removeSelf] => function: 0A71D738
16:46:13.013 [_rowColor] => table: 0A8EFC48 {
16:46:13.013 [default] => table: 0ACE14C8 {
16:46:13.013 [1] => 1
16:46:13.013 [2] => 1
16:46:13.013 [3] => 1
16:46:13.013 }
16:46:13.013 [over] => table: 0ACE14C8 {
16:46:13.013 [1] => 0.89411764705882
16:46:13.013 [2] => 0.89411764705882
16:46:13.013 [3] => 0.89411764705882
16:46:13.013 }
16:46:13.013 }
16:46:13.013 [_proxy] => userdata: 0A8EFA30
16:46:13.013 [_cell] => table: 0A8EFC48 {
16:46:13.013 [_class] => table: 0A8ECB60 {
16:46:13.013 *table: 0699FCF0
16:46:13.013 }
16:46:13.013 [_proxy] => userdata: 0A8EFBE8
16:46:13.013 }
16:46:13.013 [_separator] => table: 0A8EFC48 {
16:46:13.013 [_class] => table: 0A8ECB10 {
16:46:13.013 *table: 0699FCF0
16:46:13.013 }
16:46:13.013 [_proxy] => userdata: 0A8ECB50
16:46:13.013 }
16:46:13.013 }
16:46:13.013 [target] => table: 0A981C10 {
16:46:13.013 *table: 0A8EFC48
16:46:13.013 }
16:46:13.013 }
16:46:13.013 ORT: press
16:46:13.013 Pressed row: 4
16:46:13.013 ID: 416077
16:46:13.063 ERROR: Runtime error
16:46:13.063 ?:0: attempt to index field ‘_view’ (a nil value)
16:46:13.063 stack traceback:
16:46:13.063 ?: in function ‘touch’
16:46:13.063 ?: in function
16:46:13.063 ?: in function [/lua]

Again, thank you for looking at this!

Ed

Can you post the code that shows the actual creation of the TableView?

Brent,

I will gladly post my creation code, but first I wanted to share some additional info I’ve discovered about this issue. (I used the Widget Demo code as a template for the creation of the TableView.)

The TableView will generate this Runtime Error when a row is partially off the top of the screen and then the user attempts to scroll the TableView by pressing on the partially exposed row and scrolling the TableView. Here is an example of the error occurring on the Widget Demo code included with the Corona SDK simulator:

https://youtu.be/4ujFHOqUczo

Please advise on how I should proceed ( do you want me to post my tableView creation code? ).

Thank you!

Ed

Brent,

I submitted a bug report on this issue. The system did not provide an id for the submission, is there a way to track it?

Thank you!

Hi,

Can you carefully check your spam email folder to make sure it didn’t get allocated there?

Thanks,

Brent

Checked Inbox, Spam, Trash. Nowhere to be found.

Brent,

Should I re-submit the Bug Report? I still have not received a notification.

Ed

It looks like your bug failed to submit. There is nothing in the bug tracker with your email address other than an account renewal case from 2014.  Try it again and capture the screen after you press the submit button for me and post it here. And to verify you used an email that starts with reallyrottens_98@

Thanks

Rob