From 0f82960824f1110135888b1cc3ff7b904e4579c8 Mon Sep 17 00:00:00 2001 From: "bent.mozilla@gmail.com" Date: Wed, 3 Oct 2007 17:57:09 -0700 Subject: [PATCH] Bug 392493 - "Add forget() method to nsCOMPtr and nsRefPtr". r=dbaron. --- xpcom/tests/TestAutoPtr.cpp | 9 +++++++++ xpcom/tests/TestCOMPtr.cpp | 11 ++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/xpcom/tests/TestAutoPtr.cpp b/xpcom/tests/TestAutoPtr.cpp index 157048e7707..de866b5347a 100644 --- a/xpcom/tests/TestAutoPtr.cpp +++ b/xpcom/tests/TestAutoPtr.cpp @@ -404,6 +404,15 @@ int main() printf("Should destroy 3 |TestObject|s:\n"); } + { + printf("Should create one |TestRefObject|:\n"); + nsRefPtr pobj( new TestRefObject() ); + printf("Should do nothing:\n"); + nsRefPtr pobj2( pobj.forget() ); + printf("Should destroy one |TestRefObject|:\n"); + } + + printf("\nTesting construction.\n"); { diff --git a/xpcom/tests/TestCOMPtr.cpp b/xpcom/tests/TestCOMPtr.cpp index 8626c06dbee..0bb2a8bc1c3 100644 --- a/xpcom/tests/TestCOMPtr.cpp +++ b/xpcom/tests/TestCOMPtr.cpp @@ -626,6 +626,15 @@ main() printf("### End Test 23\n"); + { + printf("\n### setup for Test 24\n"); + nsCOMPtr fooP( do_QueryInterface(new IFoo) ); + + printf("### Test 24: does |forget| avoid an AddRef/Release when assigning to another nsCOMPtr?\n"); + nsCOMPtr fooP2( fooP.forget() ); + } + printf("### End Test 24\n"); + { nsCOMPtr fooP; @@ -643,7 +652,7 @@ main() } - printf("\n### Test 24: will a static |nsCOMPtr| |Release| before program termination?\n"); + printf("\n### Test 25: will a static |nsCOMPtr| |Release| before program termination?\n"); gFoop = do_QueryInterface(new IFoo); printf("<