From 09aa8919f57b0abedde1179ba6deed285f11fb81 Mon Sep 17 00:00:00 2001 From: Anuj Agarwal Date: Thu, 4 Sep 2014 07:07:00 +0200 Subject: [PATCH] Bug 1034921 - Remove dangerous public destructor of nsFoo in TestThreadUtils.cpp. r=nfroyd --- xpcom/tests/TestThreadUtils.cpp | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/xpcom/tests/TestThreadUtils.cpp b/xpcom/tests/TestThreadUtils.cpp index 98ad43ebcef1..e358cade73f8 100644 --- a/xpcom/tests/TestThreadUtils.cpp +++ b/xpcom/tests/TestThreadUtils.cpp @@ -31,17 +31,11 @@ class nsFoo : public nsISupports { *aBool = true; return NS_OK; } + +private: virtual ~nsFoo() {} }; -namespace mozilla { -template<> -struct HasDangerousPublicDestructor -{ - static const bool value = true; -}; -} - NS_IMPL_ISUPPORTS0(nsFoo) class TestSuicide : public nsRunnable { @@ -129,7 +123,7 @@ int main(int argc, char** argv) // This pointer will be freed at the end of the block // Do not dereference this pointer in the runnable method! - nsFoo * rawFoo = new nsFoo(); + nsRefPtr rawFoo = new nsFoo(); // Read only string. Dereferencing in runnable method to check this works. char* message = (char*)"Test message"; @@ -152,8 +146,6 @@ int main(int argc, char** argv) NS_DispatchToMainThread(NS_NewRunnableMethodWithArg(bar, &nsBar::DoBar5std, rawFoo)); NS_DispatchToMainThread(NS_NewRunnableMethodWithArg(bar, &nsBar::DoBar6std, message)); #endif - - delete rawFoo; } // Spin the event loop