From cc2ea1310ade30832640b55a94e7fc14c483f63a Mon Sep 17 00:00:00 2001 From: "scc%netscape.com" Date: Sun, 6 Feb 2000 21:17:51 +0000 Subject: [PATCH] enable the |ASSERT_NO_QUERY_NEEDED| tests for the |getter_AddRefs()| case as well. bug #26420, r=dougt git-svn-id: svn://10.0.0.236/trunk@59952 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/xpcom/base/nsCOMPtr.cpp | 7 ++++++- mozilla/xpcom/base/nsCOMPtr.h | 6 ++---- mozilla/xpcom/glue/nsCOMPtr.cpp | 7 ++++++- mozilla/xpcom/glue/nsCOMPtr.h | 6 ++---- 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/mozilla/xpcom/base/nsCOMPtr.cpp b/mozilla/xpcom/base/nsCOMPtr.cpp index c95f17579e0..16dbed86038 100644 --- a/mozilla/xpcom/base/nsCOMPtr.cpp +++ b/mozilla/xpcom/base/nsCOMPtr.cpp @@ -28,7 +28,12 @@ nsQueryInterface::operator()( const nsIID& aIID, void** answer ) const { nsresult status; if ( mRawPtr ) - status = mRawPtr->QueryInterface(aIID, answer); + { + status = mRawPtr->QueryInterface(aIID, answer); +#ifdef NSCAP_FEATURE_TEST_NONNULL_QUERY_SUCCEEDS + NS_WARN_IF_FALSE(NS_SUCCEEDED(status), "interface not found---were you expecting that?"); +#endif + } else status = NS_ERROR_NULL_POINTER; diff --git a/mozilla/xpcom/base/nsCOMPtr.h b/mozilla/xpcom/base/nsCOMPtr.h index bcd04aa0984..5f3487251bb 100644 --- a/mozilla/xpcom/base/nsCOMPtr.h +++ b/mozilla/xpcom/base/nsCOMPtr.h @@ -98,7 +98,7 @@ #ifdef NS_DEBUG #define NSCAP_FEATURE_TEST_DONTQUERY_CASES #define NSCAP_FEATURE_DEBUG_PTR_TYPES - #define NSCAP_FEATURE_TEST_NONNULL_QUERY_SUCCEEDS +//#define NSCAP_FEATURE_TEST_NONNULL_QUERY_SUCCEEDS #endif /* @@ -185,7 +185,7 @@ class nsDerivedSafe : public T /* Compiler warnings and errors: nsDerivedSafe operator=() hides inherited operator=(). - If you see that, that means somebody checked in a (XP)COM interface class that declares an + If you see that, that means somebody checked in a [XP]COM interface class that declares an |operator=()|, and that's _bad_. So bad, in fact, that this declaration exists explicitly to stop people from doing it. */ @@ -835,13 +835,11 @@ class nsGetterAddRefs // nothing else to do } -#if 0 #ifdef NSCAP_FEATURE_TEST_DONTQUERY_CASES ~nsGetterAddRefs() { mTargetSmartPtr.Assert_NoQueryNeeded(); } -#endif #endif operator void**() diff --git a/mozilla/xpcom/glue/nsCOMPtr.cpp b/mozilla/xpcom/glue/nsCOMPtr.cpp index c95f17579e0..16dbed86038 100644 --- a/mozilla/xpcom/glue/nsCOMPtr.cpp +++ b/mozilla/xpcom/glue/nsCOMPtr.cpp @@ -28,7 +28,12 @@ nsQueryInterface::operator()( const nsIID& aIID, void** answer ) const { nsresult status; if ( mRawPtr ) - status = mRawPtr->QueryInterface(aIID, answer); + { + status = mRawPtr->QueryInterface(aIID, answer); +#ifdef NSCAP_FEATURE_TEST_NONNULL_QUERY_SUCCEEDS + NS_WARN_IF_FALSE(NS_SUCCEEDED(status), "interface not found---were you expecting that?"); +#endif + } else status = NS_ERROR_NULL_POINTER; diff --git a/mozilla/xpcom/glue/nsCOMPtr.h b/mozilla/xpcom/glue/nsCOMPtr.h index bcd04aa0984..5f3487251bb 100644 --- a/mozilla/xpcom/glue/nsCOMPtr.h +++ b/mozilla/xpcom/glue/nsCOMPtr.h @@ -98,7 +98,7 @@ #ifdef NS_DEBUG #define NSCAP_FEATURE_TEST_DONTQUERY_CASES #define NSCAP_FEATURE_DEBUG_PTR_TYPES - #define NSCAP_FEATURE_TEST_NONNULL_QUERY_SUCCEEDS +//#define NSCAP_FEATURE_TEST_NONNULL_QUERY_SUCCEEDS #endif /* @@ -185,7 +185,7 @@ class nsDerivedSafe : public T /* Compiler warnings and errors: nsDerivedSafe operator=() hides inherited operator=(). - If you see that, that means somebody checked in a (XP)COM interface class that declares an + If you see that, that means somebody checked in a [XP]COM interface class that declares an |operator=()|, and that's _bad_. So bad, in fact, that this declaration exists explicitly to stop people from doing it. */ @@ -835,13 +835,11 @@ class nsGetterAddRefs // nothing else to do } -#if 0 #ifdef NSCAP_FEATURE_TEST_DONTQUERY_CASES ~nsGetterAddRefs() { mTargetSmartPtr.Assert_NoQueryNeeded(); } -#endif #endif operator void**()