diff --git a/src/base-object.h b/src/base-object.h index 3a18a4fde4e..0e0df3e938b 100644 --- a/src/base-object.h +++ b/src/base-object.h @@ -32,10 +32,15 @@ class BaseObject { BaseObject(Environment* env, v8::Local handle); ~BaseObject(); - // Returns the wrapped object. Illegal to call in your destructor. + // Returns the wrapped object. Returns an empty handle when + // persistent.IsEmpty() is true. inline v8::Local object(); - // Parent class is responsible to Dispose. + // The parent class is responsible for calling .Reset() on destruction + // when the persistent handle is strong because there is no way for + // BaseObject to know when the handle goes out of scope. + // Weak handles have been reset by the time the destructor runs but + // calling .Reset() again is harmless. inline v8::Persistent& persistent(); inline Environment* env() const;