diff options
-rw-r--r-- | odb/sqlite/connection.cxx | 16 | ||||
-rw-r--r-- | odb/sqlite/connection.hxx | 6 |
2 files changed, 16 insertions, 6 deletions
diff --git a/odb/sqlite/connection.cxx b/odb/sqlite/connection.cxx index c9e5d75..cdd4c20 100644 --- a/odb/sqlite/connection.cxx +++ b/odb/sqlite/connection.cxx @@ -187,11 +187,19 @@ namespace odb { invalidate_results (); - // The current first active_object will remove itself from the list - // and make the second object (if any) the new first. + // The current first active_object may remove itself from the list and + // make the second object (if any) the new first. // - while (active_objects_ != 0) - active_objects_->clear (); + for (active_object** pp (&active_objects_); *pp != nullptr; ) + { + active_object* p (*pp); + p->clear (); + + // Move to the next object if this one decided to stay on the list. + // + if (*pp == p) + pp = &p->next_; + } } // connection_factory diff --git a/odb/sqlite/connection.hxx b/odb/sqlite/connection.hxx index 783ef5b..254a002 100644 --- a/odb/sqlite/connection.hxx +++ b/odb/sqlite/connection.hxx @@ -41,8 +41,8 @@ namespace odb class LIBODB_SQLITE_EXPORT active_object { public: - // This function should remove the object from the list, since - // it shall no longer be "active". + // This function may remove the object from the list since it may no + // longer be "active". // virtual void clear () = 0; @@ -57,6 +57,8 @@ namespace odb list_remove (); protected: + friend class connection; + // prev_ == 0 means we are the first element. // next_ == 0 means we are the last element. // next_ == this means we are not on the list (prev_ should be 0). |