From: reed Date: Mon, 24 Nov 2014 22:13:55 +0000 (-0800) Subject: restore old convention of asserting refcnt==1 in destructor X-Git-Tag: accepted/tizen/5.0/unified/20181102.025319~4721 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3c850c561fcad1ac35bff4ec2875a40ef2309148;p=platform%2Fupstream%2FlibSkiaSharp.git restore old convention of asserting refcnt==1 in destructor BUG=skia: Review URL: https://codereview.chromium.org/757563003 --- diff --git a/include/core/SkRefCnt.h b/include/core/SkRefCnt.h index 9360878..c718987 100644 --- a/include/core/SkRefCnt.h +++ b/include/core/SkRefCnt.h @@ -255,6 +255,7 @@ template class SkNVRefCnt : SkNoncopyable { public: SkNVRefCnt() : fRefCnt(1) {} + ~SkNVRefCnt() { SkASSERTF(1 == fRefCnt, "NVRefCnt was %d", fRefCnt); } // Implementation is pretty much the same as SkRefCntBase. All required barriers are the same: // - unique() needs acquire when it returns true, and no barrier if it returns false; @@ -267,18 +268,12 @@ public: int32_t prevValue = sk_atomic_dec(&fRefCnt); SkASSERT(prevValue >= 1); if (1 == prevValue) { + SkDEBUGCODE(fRefCnt = 1;) // restore the 1 for our destructor's assert SkDELETE((const Derived*)this); } } void deref() const { this->unref(); } // Chrome prefers to call deref(). -protected: -#ifdef SK_DEBUG - ~SkNVRefCnt() { - SkASSERTF(0 == fRefCnt, "NVRefCnt was %d", fRefCnt); - } -#endif - private: mutable int32_t fRefCnt; };