Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(22)

Unified Diff: include/core/SkRefCnt.h

Issue 757563003: restore old convention of asserting refcnt==1 in destructor (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkRefCnt.h
diff --git a/include/core/SkRefCnt.h b/include/core/SkRefCnt.h
index 93608783d688bd21b6f63eef49e4eb1482878eb0..c718987b517ab4726943f235a9531568489f3ebf 100644
--- a/include/core/SkRefCnt.h
+++ b/include/core/SkRefCnt.h
@@ -255,6 +255,7 @@ template <typename Derived>
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;
};
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698