Code

make refcount logging a little more useful by including the relevent class name
authormental <mental@users.sourceforge.net>
Sat, 29 Apr 2006 03:59:24 +0000 (03:59 +0000)
committermental <mental@users.sourceforge.net>
Sat, 29 Apr 2006 03:59:24 +0000 (03:59 +0000)
ChangeLog
src/sp-object.cpp

index 015854f39d5d52836dd69e3ca05d9efb5c6fff87..d49bec139d2857047df85a9cb7998fb7d007a316 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2006-04-28  MenTaLguY  <mental@rydia.net>
+
+    * src/sp-object.cpp: make refcount logging a little more useful
+         by including the relevent class name
+
 2006-04-28  Jon A. Cruz  <jon@joncruz.org>
 
        * src/Makefile_insert, src/Makefile.am, src/dir-util-test.h,
index 9068c4ba2ae0e0b2bdf19f6e65739df32077db58..e7778dd081fb46fb1fb8c1b5bb73d9839b967117 100644 (file)
@@ -246,7 +246,9 @@ public:
     enum Type { REF, UNREF };
 
     RefEvent(SPObject *object, Type type)
-        : _object(stringify(object)), _refcount(G_OBJECT(object)->ref_count),
+        : _object(stringify(object)),
+          _class_name(Inkscape::Util::share_static_string(g_type_name(G_TYPE_FROM_INSTANCE(object)))),
+          _refcount(G_OBJECT(object)->ref_count),
           _type(type)
     {}
 
@@ -259,13 +261,15 @@ public:
             return Inkscape::Util::share_static_string("sp-object-unref");
         }
     }
-    unsigned propertyCount() const { return 2; }
+    unsigned propertyCount() const { return 3; }
     PropertyPair property(unsigned index) const {
         switch (index) {
             case 0:
                 return PropertyPair("object", _object);
             case 1:
-                return PropertyPair("refcount", stringify( _type == REF ? _refcount + 1 : _refcount - 1 ));
+                return PropertyPair("class", _class_name);
+            case 2:
+                return PropertyPair("new-refcount", stringify( _type == REF ? _refcount + 1 : _refcount - 1 ));
             default:
                 return PropertyPair();
         }
@@ -273,6 +277,7 @@ public:
 
 private:
     Inkscape::Util::ptr_shared<char> _object;
+    Inkscape::Util::ptr_shared<char> _class_name;
     unsigned _refcount;
     Type _type;
 };
@@ -293,11 +298,8 @@ sp_object_ref(SPObject *object, SPObject *owner)
     g_return_val_if_fail(SP_IS_OBJECT(object), NULL);
     g_return_val_if_fail(!owner || SP_IS_OBJECT(owner), NULL);
 
-    Inkscape::Debug::EventTracker<> tracker;
-    tracker.set<RefEvent>(object, RefEvent::REF);
-
+    Inkscape::Debug::EventTracker<RefEvent> tracker(object, RefEvent::REF);
     g_object_ref(G_OBJECT(object));
-
     return object;
 }
 
@@ -316,11 +318,8 @@ sp_object_unref(SPObject *object, SPObject *owner)
     g_return_val_if_fail(SP_IS_OBJECT(object), NULL);
     g_return_val_if_fail(!owner || SP_IS_OBJECT(owner), NULL);
 
-    Inkscape::Debug::EventTracker<> tracker;
-    tracker.set<RefEvent>(object, RefEvent::UNREF);
-
+    Inkscape::Debug::EventTracker<RefEvent> tracker(object, RefEvent::UNREF);
     g_object_unref(G_OBJECT(object));
-
     return NULL;
 }