show # of unknown subclasses in dump
authorreed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Tue, 26 Jun 2012 18:58:03 +0000 (18:58 +0000)
committerreed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Tue, 26 Jun 2012 18:58:03 +0000 (18:58 +0000)
git-svn-id: http://skia.googlecode.com/svn/trunk@4347 2bbb7eff-a529-9590-31e7-b0007b416f81

include/core/SkInstCnt.h

index 087d5a7..ff9a19f 100644 (file)
@@ -31,7 +31,7 @@
 #define SK_DECLARE_INST_COUNT_INTERNAL(className, initStep)                 \
     class SkInstanceCountHelper {                                           \
     public:                                                                 \
-        typedef void (*PFCheckInstCnt)(int level);                          \
+        typedef int (*PFCheckInstCnt)(int level);                           \
         SkInstanceCountHelper() {                                           \
             if (!gInited) {                                                 \
                 initStep                                                    \
         return SkInstanceCountHelper::gInstanceCount;                       \
     }                                                                       \
                                                                             \
-    static void CheckInstanceCount(int level = 0) {                         \
+    static int CheckInstanceCount(int level = 0) {                          \
         if (0 != SkInstanceCountHelper::gInstanceCount) {                   \
-            SkDebugf("%*c Leaked %s objects: %d\n",                         \
+            SkDebugf("%*c Leaked %s: %d\n",                                 \
                      4*level, ' ', #className,                              \
                      SkInstanceCountHelper::gInstanceCount);                \
         }                                                                   \
-        for (int i = 0; i < SkInstanceCountHelper::gChildren.count(); ++i) {\
-            (*SkInstanceCountHelper::gChildren[i])(level+1);                \
+        int childCount = SkInstanceCountHelper::gChildren.count();          \
+        int count = SkInstanceCountHelper::gInstanceCount;                  \
+        for (int i = 0; i < childCount; ++i) {                              \
+            count -= (*SkInstanceCountHelper::gChildren[i])(level+1);       \
         }                                                                   \
+        SkASSERT(count >= 0);                                               \
+        if (childCount > 0 && count > 0) {                                  \
+            SkDebugf("%*c Leaked ???: %d\n", 4*(level + 1), ' ', count);    \
+        }                                                                   \
+        return SkInstanceCountHelper::gInstanceCount;                       \
     }                                                                       \
                                                                             \
     static void AddInstChild(SkInstanceCountHelper::PFCheckInstCnt          \