Closed PiotrKaszuba closed 1 month ago
I've managed to reproduce a similar, but not exactly the same, issue.
The issue is with _on_unit_tree_exited()
callback which is supposed to clear references when creeps die. It's used for both selection and hovering. Selection code in set_selected_unit()
disconnects that callback, without considering whether it is still needed for hovering logic.
This issue is not exactly the same as the originally reported one, so there may be more deeper issues. For now, will fix the reproducible issue and add brute force check for valid references.
Thank you. The reproducible issue seems about the same without the first occurence of error that I've shown on the screenshot - the following occurences stopped at the exactly same point as the reproducible issue - when sorting, and with similar contents of _units_under_mouse_list
. The reason for that would be no sorting actually took place the first time as that Array had only 1 element.
I added a fix but need to double check the original issue. It might be different because my reproduced issue also had null SelectUnit._hovered_unit.
also had null SelectUnit._hovered_unit
I think the same was the case for me - I captured all local and member variables in the picture.
In your case, you had _hovered_unit == "true null"
.
In my case, _hovered_unit was a "previously freed reference", but displayed as "null" in editor.
I couldn't find any other issues which might cause dangling references in SelectUnit, so will close. The fix in dc36acf5c946e44b3ed5d5882729d424b85ab256 most likely solves both issues.
Thank you. I didn't know the difference between those null values nor I was able to spot it.
During one of the games I've had following situation happen:
_units_under_mouse_list
contains null. Not sure how that happened - not sure if it could be due to very rare occurence with memory being freed.. or some other bug that caused it._units_under_mouse_list
now contained 2 entries (screenshot shows initial occurence with only 1 entry) with null at 0 index and some probably valid object at index 1. The local code selects the 0th index and crashes again. My guess is the null at 0th index never goes away._units_under_mouse_list
contains null and remove it..