framework-widget icon indicating copy to clipboard operation
framework-widget copied to clipboard

Button: prevent crashes caused by _isWithinBounds

Open XeduR opened this issue 3 years ago • 1 comments

There's currently a chance that the button's touch event is still called after the button's view.parent has already been removed and set to nil. This will result in a runtime error within function widget._isWithinBounds( object, event ) when it attempts to index a nil value (i.e. object.contentBounds within object as it isn't a table anymore).

https://github.com/coronalabs/framework-widget/blob/d425ae72f47b29a3da5880eebcb1111f2cdf6cd2/widgetLibrary/widget.lua#L245-L257

The safest and easiest way to fix this issue is to just check that the button's view.parent exists and is still a display object at the start of the touch listener.

As a part of these changes, there's no need for further checks to see if the parent view exists given that the function won't get past the new initial check if it doesn't.

XeduR avatar Nov 24 '22 03:11 XeduR

Could you take a look at this PR @Shchvova?

XeduR avatar Dec 07 '22 17:12 XeduR