Hello,
I migrated from v2017.3073 to v2018.3204, and a lot of runtime errors appears in my app.
I isolated the problem and tried to reproduce the issue in the sample “Widget” Corona (I reduce the code to a minimum).
It looks like the runtime error is related to the asynchronous image loading I do in the onRowRender function of the TableView.
When I manipulate quickly the tableView up and down, the runtime error occure.
ERROR: Runtime error
main.lua:40: bad argument #-1 to ‘newImage’ (Proxy expected, got nil)
It seems that sometimes the var “row” (event.row) used to attach image is not defined, i don’t know why. I didn’t find any solution.
am i doing something wrong? is it a bug i have to report?
In advance thank you to the person who will take the time to read my post and will bring me a beginning of solution.
PS: sorry for my bad english.
Here is the code of my main.lua
Have a nice day!
local widget = require( "widget" ) -- Forward reference for the tableView local tableView -- Listen for tableView events local function tableViewListener( event ) local phase = event.phase --print( "Event.phase is:", event.phase ) end -- Handle row rendering local function onRowRender( event ) local phase = event.phase local row = event.row local groupContentHeight = row.contentHeight local rowTitle = display.newText( row, "Row " .. row.index, 0, 0, nil, 14 ) rowTitle.x = 10 rowTitle.anchorX = 0 rowTitle.y = groupContentHeight \* 0.5 if ( row.isCategory ) then rowTitle:setFillColor( 1 ) rowTitle.text = rowTitle.text.." (category)" else rowTitle:setFillColor( 0 ) --[[ASYNC DOWLOAD IMAGE]] --[[CODE FROM THE SAMPLE AsynchImageDownload]] local myImage local function networkListener( event ) if ( event.isError ) then print ( "Network error - download failed" ) else myImage = display.newImage(row, event.response.filename, event.response.baseDirectory, 20, 20) myImage.alpha = 0 myImage.x = display.contentWidth - 50 myImage.y = 75 myImage.width = 120 myImage.height = 120 transition.to( myImage, { alpha = 1.0 } ) print ( "RESPONSE: ", event.response.filename ) end end network.download( "https://developer.coronalabs.com/demo/hello.png", "GET", networkListener, "helloCopy.png", system.TemporaryDirectory ) end --[[/ ADD BY ME]] end -- Handle row updates local function onRowUpdate( event ) local phase = event.phase local row = event.row --print( row.index, ": is now onscreen" ) end -- Handle touches on the row local function onRowTouch( event ) local phase = event.phase local row = event.target if ( "release" == phase ) then end end -- Create a tableView tableView = widget.newTableView { top = 0, left = 0, width = display.contentWidth, height = display.contentHeight, hideBackground = true, listener = tableViewListener, onRowRender = onRowRender, onRowUpdate = onRowUpdate, onRowTouch = onRowTouch, } -- Create 75 rows for i = 1,75 do local isCategory = false local rowHeight = 150 local rowColor = { default = { 1 }, over = { 1 } } -- Make some rows categories if i == 20 or i == 40 or i == 60 then isCategory = true rowHeight = 32 rowColor = { default = { 0.5 }, over = { 0.5 } } end -- Insert the row into the tableView tableView:insertRow { isCategory = isCategory, rowHeight = rowHeight, rowColor = rowColor, lineColor = { 0.5 }, params = { } } end