Reviewers: Sven Panne,

Description:
restore persistent dtor

[email protected]
BUG=

Please review this at https://codereview.chromium.org/23581010/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files (+9, -1 lines):
  M include/v8.h
  M test/cctest/test-api.cc


Index: include/v8.h
diff --git a/include/v8.h b/include/v8.h
index 88c81ae36e184d92c61efff65f4cce601ccc2fed..5410334df57a25862861a81b386e2eafd9409244 100644
--- a/include/v8.h
+++ b/include/v8.h
@@ -544,6 +544,14 @@ template <class T, class M> class Persistent {
     Copy(that);
     return *this;
   }
+  /**
+   * The destructor will dispose the Persistent based on the
+ * kResetInDestructor flags in the traits class. Since not calling dispose + * can result in a memory leak, it is recommended to always set this flag.
+   */
+  V8_INLINE(~Persistent()) {
+    if (M::kResetInDestructor) Reset();
+  }

   /**
    * If non-empty, destroy the underlying storage cell
Index: test/cctest/test-api.cc
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
index aaac4866324777940b3c7c920be68ec35382e3ee..19f33095ffd41b0968d85c1cd31ab8f5a7d03628 100644
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -12700,7 +12700,7 @@ TEST(CopyablePersistent) {
     CHECK_EQ(initial_handles + 3, globals->global_handles_count());
   }
   // Verify autodispose
-//  CHECK_EQ(initial_handles, globals->global_handles_count());
+  CHECK_EQ(initial_handles, globals->global_handles_count());
 }




--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to