From e92394519c5c9621784908120d12f06ad693a9b5 Mon Sep 17 00:00:00 2001 From: randomdan Date: Wed, 1 Sep 2010 20:10:43 +0000 Subject: Add some missing virtual destructors Unregister VariableParent row use when destroyed --- project2/perRowValues.cpp | 19 ++++++++++++++----- project2/perRowValues.h | 5 +++-- project2/variables.cpp | 13 +++++++++++++ project2/variables.h | 2 ++ 4 files changed, 32 insertions(+), 7 deletions(-) diff --git a/project2/perRowValues.cpp b/project2/perRowValues.cpp index f5cd2e7..9f80924 100644 --- a/project2/perRowValues.cpp +++ b/project2/perRowValues.cpp @@ -1,6 +1,7 @@ #include "perRowValues.h" #include #include +#include PerRowValues::RowValuesStack PerRowValues::stack; @@ -12,6 +13,18 @@ PerRowValues::~PerRowValues() { } +void +PerRowValues::use(const RowUser * r) const +{ + rowUsers.insert(r); +} + +void +PerRowValues::finish(const RowUser * r) const +{ + rowUsers.erase(r); +} + void PerRowValues::beginRow(const PerRowValues * r) { @@ -22,6 +35,7 @@ void PerRowValues::endRow(const PerRowValues * r) { if ((*stack.rbegin()) != r) { + syslog(LOG_ERR, "PerRowValues::endRow: stack is corrupted"); std::abort(); } stack.pop_back(); @@ -38,8 +52,3 @@ RowUser::~RowUser() { } -void -RowUser::rowChanged() const -{ -} - diff --git a/project2/perRowValues.h b/project2/perRowValues.h index 46445ee..9d4e7a8 100644 --- a/project2/perRowValues.h +++ b/project2/perRowValues.h @@ -8,7 +8,7 @@ class RowUser { public: RowUser(); - ~RowUser(); + virtual ~RowUser() = 0; virtual void rowChanged() const = 0; }; @@ -25,7 +25,8 @@ class PerRowValues { virtual const Glib::ustring & getColumnName(unsigned int col) const = 0; virtual const Glib::ustring & getCurrentValue(const Glib::ustring & id) const = 0; virtual const Glib::ustring & getCurrentValue(unsigned int col) const = 0; - void use(const RowUser * r) const { rowUsers.insert(r); } + void use(const RowUser * r) const; + void finish(const RowUser * r) const; static const RowValuesStack & Stack() { return stack; } static void beginRow(const PerRowValues * r); diff --git a/project2/variables.cpp b/project2/variables.cpp index 1a16c4b..3c27d44 100644 --- a/project2/variables.cpp +++ b/project2/variables.cpp @@ -94,6 +94,15 @@ class VariableParent : public VariableImplDyn, public RowUser { dep(d) { } + ~VariableParent() + { + if (row) { + row->finish(this); + if (dep) { + row->finish(dep); + } + } + } const Glib::ustring & value() const { if (!cacheValid) { @@ -227,3 +236,7 @@ VariableImpl::VariableImpl(const Glib::ustring & src) : } } +VariableImpl::~VariableImpl() +{ +} + diff --git a/project2/variables.h b/project2/variables.h index 1d4b4ba..c927ae6 100644 --- a/project2/variables.h +++ b/project2/variables.h @@ -16,6 +16,8 @@ class VariableImpl : public virtual IntrusivePtrBase { protected: VariableImpl(const Glib::ustring & src); + virtual ~VariableImpl() = 0; + const Glib::ustring source; Glib::ustring name; boost::optional defaultValue; -- cgit v1.2.3