From 35c3d273bbf1bd8c9c41ac1c3d91f150df0eb280 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 18 Aug 2011 11:38:40 +0200 Subject: Fix custom recursive loading in post_load callback Before we called the callback while holding the statements locked. As a result, if the callback tried to load another object of this type, it failed. Now we unlock the statements (since we have completely loaded the object from ODB's point of view) and then call the callback. The callback test has been updated to test this situation. --- odb/sqlite/object-statements.hxx | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'odb/sqlite/object-statements.hxx') diff --git a/odb/sqlite/object-statements.hxx b/odb/sqlite/object-statements.hxx index c181b17..c9c101d 100644 --- a/odb/sqlite/object-statements.hxx +++ b/odb/sqlite/object-statements.hxx @@ -72,6 +72,22 @@ namespace odb { } + struct auto_unlock + { + // Unlocks the statement on construction and re-locks it on + // destruction. + // + auto_unlock (object_statements_base&); + ~auto_unlock (); + + private: + auto_unlock (const auto_unlock&); + auto_unlock& operator= (const auto_unlock&); + + private: + object_statements_base& s_; + }; + protected: connection_type& conn_; bool locked_; -- cgit v1.1