src: turn inspector raw pointer into unique_ptr

Use a unique pointer to make ownership clear.

PR-URL: https://github.com/nodejs/node/pull/16974
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Eugene Ostroukhov <eostroukhov@google.com>
This commit is contained in:
Franziska Hinkelmann 2017-11-12 19:52:13 +01:00
parent 81010421c5
commit c07d1279b2
2 changed files with 5 additions and 4 deletions

View File

@ -326,8 +326,9 @@ inline Environment::~Environment() {
v8::HandleScope handle_scope(isolate());
#if HAVE_INSPECTOR
// Destroy inspector agent before erasing the context.
delete inspector_agent_;
// Destroy inspector agent before erasing the context. The inspector
// destructor depends on the context still being accessible.
inspector_agent_.reset(nullptr);
#endif
context()->SetAlignedPointerInEmbedderData(kContextEmbedderDataIndex,

View File

@ -689,7 +689,7 @@ class Environment {
#if HAVE_INSPECTOR
inline inspector::Agent* inspector_agent() const {
return inspector_agent_;
return inspector_agent_.get();
}
#endif
@ -734,7 +734,7 @@ class Environment {
std::map<std::string, uint64_t> performance_marks_;
#if HAVE_INSPECTOR
inspector::Agent* const inspector_agent_;
std::unique_ptr<inspector::Agent> inspector_agent_;
#endif
HandleWrapQueue handle_wrap_queue_;