Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Combobox ConVar change callback deletion
Fixes #1068 We need to remove the callback in a timer, because otherwise the ConVar change callback code will throw an error while looping over the callbacks. This happens, because the callback is removed from the same table that is iterated over. Thus, the table size changes while iterating over it and leads to a nil callback as the last entry. See https://github.com/Facepunch/garrysmod/blob/1b512930d1f8fb1acf6235e584c4ec1ff84e9362/garrysmod/lua/includes/modules/cvars.lua#L44 and https://github.com/Facepunch/garrysmod/blob/1b512930d1f8fb1acf6235e584c4ec1ff84e9362/garrysmod/lua/includes/modules/cvars.lua#L97 here the code uses table.Remove, which causes the table to be reindexed and resized, this is the root cause for the problem. We should thus avoid removing callbacks in the callback itself.
- Loading branch information