corona
corona copied to clipboard
This causes a SIGEGV
I always store a refence to a graphic in a table. If the graphic is removed (but not nil) then solar handles it
local g = display.newGroup()
local t = {}
t.graphic = display.newRect(0,0,1,1)
g:insert(t.graphic)
//some time later
display.remove(t.graphic)
g:insert(t.graphic)
however, if you nil the graphic you will get a crash on device.
local t = {}
t.graphic = display.newRect(0,0,1,1)
g:insert(t.graphic)
//some time later
display.remove(t.graphic)
t.graphic = nil
g:insert(t.graphic)
Sim shows a trappable error which I would expect
But device simply crashes (even with a catch all error handler)
This is a normal crash check before if its nil
t.graphic = nil
if( t.graphic ~= nil) then
g:insert(t.graphic)
end
Or add in your Code:
local unhandledErrorListener = function( event )
print( "We have a problem: " .. event.errorMessage )
return true
end
Runtime:addEventListener( "unhandledError", unhandledErrorListener )
https://docs.coronalabs.com/api/event/unhandledError/index.html
This a a bug report for vlad. Inserting a nil graphic should NOT crash (framework is missing a nil check).
The crash is happening in the framework so uhandledError will not help.