Skip to content

Commit

Permalink
Bug 1034921 - Remove dangerous public destructor of nsFoo in TestThre…
Browse files Browse the repository at this point in the history
…adUtils.cpp. r=nfroyd
  • Loading branch information
threebee committed Sep 4, 2014
1 parent 6b7ffc4 commit 09aa891
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions xpcom/tests/TestThreadUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,10 @@ class nsFoo : public nsISupports {
*aBool = true;
return NS_OK;
}
virtual ~nsFoo() {}
};

namespace mozilla {
template<>
struct HasDangerousPublicDestructor<nsFoo>
{
static const bool value = true;
private:
virtual ~nsFoo() {}
};
}

NS_IMPL_ISUPPORTS0(nsFoo)

Expand Down Expand Up @@ -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<nsFoo> rawFoo = new nsFoo();

// Read only string. Dereferencing in runnable method to check this works.
char* message = (char*)"Test message";
Expand All @@ -152,8 +146,6 @@ int main(int argc, char** argv)
NS_DispatchToMainThread(NS_NewRunnableMethodWithArg<nsFoo*>(bar, &nsBar::DoBar5std, rawFoo));
NS_DispatchToMainThread(NS_NewRunnableMethodWithArg<char*>(bar, &nsBar::DoBar6std, message));
#endif

delete rawFoo;
}

// Spin the event loop
Expand Down

0 comments on commit 09aa891

Please sign in to comment.