jazzisparis / JIP-LN-NVSE

An extension for the New Vegas Script Extender (NVSE)
GNU General Public License v3.0
50 stars 14 forks source link

Capture lambda variable context in MessageBoxAltEx and SetGameMainLoo… #7

Closed korri123 closed 3 years ago

korri123 commented 3 years ago

…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.