Skip to content

Commit

Permalink
src: turn inspector raw pointer into unique_ptr
Browse files Browse the repository at this point in the history
Use a unique pointer to make ownership clear.

PR-URL: #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>
  • Loading branch information
fhinkel committed Nov 14, 2017
1 parent 8101042 commit c07d127
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/env-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/env.h
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,7 @@ class Environment {

#if HAVE_INSPECTOR
inline inspector::Agent* inspector_agent() const {
return inspector_agent_;
return inspector_agent_.get();
}
#endif

Expand Down Expand Up @@ -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_;
Expand Down

0 comments on commit c07d127

Please sign in to comment.