changeset 7850:56254a8d4d59

Smarter reference counting in base_property.
author Michael Goffioul <michael.goffioul@gmail.com>
date Fri, 29 Feb 2008 17:49:00 +0100
parents 3249f64f69b2
children 002b1d8460d2
files src/ChangeLog src/graphics.h.in
diffstat 2 files changed, 10 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Fri Feb 29 17:38:32 2008 +0100
+++ b/src/ChangeLog	Fri Feb 29 17:49:00 2008 +0100
@@ -27,6 +27,11 @@
 
 2008-06-04  Michael Goffioul <michael.goffioul@gmail.com>
 
+	* graphics.h.in (base_property::base_property): Set internal counter
+	to 1 by default.
+	(property::property): Adapt constructors to default counter value in
+	base_property.
+
 	* graphics.h.in (base_properties::get_property): Make virtual and
 	remove const modifier.
 	* graphics.cc (base_properties::get_property): Can return built-in
--- a/src/graphics.h.in	Fri Feb 29 17:38:32 2008 +0100
+++ b/src/graphics.h.in	Fri Feb 29 17:49:00 2008 +0100
@@ -347,13 +347,13 @@
   friend class property;
 
 public:
-  base_property (void) : count (0) { }
+  base_property (void) : count (1) { }
 
   base_property (const std::string& s, const graphics_handle& h)
-    : count (0), name (s), parent (h), hidden (false) { }
+    : count (1), name (s), parent (h), hidden (false) { }
 
   base_property (const base_property& p)
-    : count (0), name (p.name), parent (p.parent), hidden (p.hidden) { }
+    : count (1), name (p.name), parent (p.parent), hidden (p.hidden) { }
 
   virtual ~base_property (void) { }
 
@@ -1089,10 +1089,10 @@
 {
 public:
   property (void) : rep (new base_property ("", graphics_handle ()))
-    { rep->count++; }
+    { }
 
   property (base_property *bp, bool persist = false) : rep (bp)
-    { rep->count++; if (persist) rep->count++; }
+    { if (persist) rep->count++; }
 
   property (const property& p)
     {