Add SkASSERTF.
Example failure: fRefCnt was 3 ../../../usr/local/google/home/mtklein/skia/include/core/SkRefCnt.h:40: failed assertion "(fRefCnt == 1) || (SkDebugf("fRefCnt was %d""\n", fRefCnt), false)" Command terminated by signal 11 Not pretty, but everything's there. Perhaps we'll think of ways to make it nicer later. BUG=skia: R=bsalomon@google.com, reed@google.com, mtklein@google.com Author: mtklein@chromium.org Review URL: https://codereview.chromium.org/337243004
This commit is contained in:
parent
12c2198535
commit
b59161f000
@ -37,7 +37,7 @@ public:
|
||||
*/
|
||||
virtual ~SkRefCntBase() {
|
||||
#ifdef SK_DEBUG
|
||||
SkASSERT(fRefCnt == 1);
|
||||
SkASSERTF(fRefCnt == 1, "fRefCnt was %d", fRefCnt);
|
||||
fRefCnt = 0; // illegal value, to catch us if we reuse after delete
|
||||
#endif
|
||||
}
|
||||
|
@ -115,6 +115,11 @@ inline void operator delete(void* p) {
|
||||
|
||||
#define SkFAIL(message) SK_ALWAYSBREAK(false && message)
|
||||
|
||||
// We want to evaluate cond only once, and inside the SkASSERT somewhere so we see its string form.
|
||||
// So we use the comma operator to make an SkDebugf that always returns false: we'll evaluate cond,
|
||||
// and if it's true the assert passes; if it's false, we'll print the message and the assert fails.
|
||||
#define SkASSERTF(cond, fmt, ...) SkASSERT((cond) || (SkDebugf(fmt"\n", __VA_ARGS__), false))
|
||||
|
||||
#ifdef SK_DEVELOPER
|
||||
#define SkDEVCODE(code) code
|
||||
#else
|
||||
|
Loading…
Reference in New Issue
Block a user