I did not know of a way to add the functionality to the rest of the event handlers.
In practice I have a struct with a constructor and destructor that gets stored with the Script* pointer. The constructor calls CaptureLambdaVariables and the destructor calls UncaptureLambdaVariables. So when a callback gets removed from a data collection (along with the script), it'll uncapture the variable list for the potential lambda as the destructor gets called.
…pCallback
I did not know of a way to add the functionality to the rest of the event handlers.
In practice I have a struct with a constructor and destructor that gets stored with the Script* pointer. The constructor calls CaptureLambdaVariables and the destructor calls UncaptureLambdaVariables. So when a callback gets removed from a data collection (along with the script), it'll uncapture the variable list for the potential lambda as the destructor gets called.