When a C++ object that is exposed to v8 is deleted, how can I invalidate handles that may pointed to this object.
I'm using v8 as a scripting interface to a larger application. Objects in the larger application are wrapped and accessed in v8 using node's ObjectWrap class.
The issue is, the lifetime of the wrapped objects is limited. If, in javascript, I execute something like:
var win = app.getWindow();
win.close(); // The C++ object that win references goes away
console.log(win.width()); // This should fail.
I want it to behave just like the comments say. After win.close() (or some other event maybe outside JS control), any access to win or duplicated handle needs to fail.
Currently, I have to mark the wrapped C++ object to be invalid and check the validity on every method call. Is this the only way to do it, or is there a way to mark a handle as no longer valid?