From 5eef234bb48827258cef08d1477f33f495839760 Mon Sep 17 00:00:00 2001 From: "dbaron%dbaron.org" Date: Sat, 22 Feb 2003 03:57:32 +0000 Subject: [PATCH] Some compilers insist that AddRef and Release return |nsrefcnt| in order to get along with nsDerivedSafe. Hopefully fixing gcc 2.95 bustage. git-svn-id: svn://10.0.0.236/trunk@138147 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/xpcom/tests/TestAutoPtr.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/mozilla/xpcom/tests/TestAutoPtr.cpp b/mozilla/xpcom/tests/TestAutoPtr.cpp index 7f4f25b3b80..cf23de594fc 100644 --- a/mozilla/xpcom/tests/TestAutoPtr.cpp +++ b/mozilla/xpcom/tests/TestAutoPtr.cpp @@ -55,15 +55,16 @@ class TestObject : public TestObjectBaseA, public TestObjectBaseB { class TestRefObjectBaseA { public: int fooA; - virtual void AddRef() = 0; - virtual void Release() = 0; + // Must return |nsrefcnt| to keep |nsDerivedSafe| happy. + virtual nsrefcnt AddRef() = 0; + virtual nsrefcnt Release() = 0; }; class TestRefObjectBaseB { public: int fooB; - virtual void AddRef() = 0; - virtual void Release() = 0; + virtual nsrefcnt AddRef() = 0; + virtual nsrefcnt Release() = 0; }; class TestRefObject : public TestRefObjectBaseA, public TestRefObjectBaseB { @@ -81,20 +82,24 @@ class TestRefObject : public TestRefObjectBaseA, public TestRefObjectBaseB { NS_STATIC_CAST(void*, this)); } - void AddRef() + nsrefcnt AddRef() { ++mRefCount; printf(" AddRef to %d on TestRefObject %p.\n", mRefCount, NS_STATIC_CAST(void*, this)); + return mRefCount; } - void Release() + nsrefcnt Release() { --mRefCount; printf(" Release to %d on TestRefObject %p.\n", mRefCount, NS_STATIC_CAST(void*, this)); - if (mRefCount == 0) + if (mRefCount == 0) { delete NS_CONST_CAST(TestRefObject*, this); + return 0; + } + return mRefCount; } protected: