From 6c666b0dfa38cf1f6407817261a829645e86d855 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 21 May 2013 18:50:32 -0400 Subject: Ignore requests to load transient objects in lazy pointers --- odb/lazy-ptr.ixx | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'odb/lazy-ptr.ixx') diff --git a/odb/lazy-ptr.ixx b/odb/lazy-ptr.ixx index 38fcf1a..724142a 100644 --- a/odb/lazy-ptr.ixx +++ b/odb/lazy-ptr.ixx @@ -115,7 +115,7 @@ namespace odb inline T* lazy_ptr:: load () const { - if (!loaded ()) + if (p_ == 0 && i_) p_ = i_.template load (true); // Reset id. return p_; @@ -371,7 +371,7 @@ namespace odb inline std::auto_ptr& lazy_auto_ptr:: load () const { - if (!loaded ()) + if (p_.get () == 0 && i_) { std::auto_ptr tmp (i_.template load (true)); // Reset id. p_ = tmp; @@ -645,7 +645,7 @@ namespace odb inline std::unique_ptr& lazy_unique_ptr:: load () const { - if (!loaded ()) + if (!p_ && i_) p_ = std::unique_ptr (i_.template load (true)); // Reset id. return p_; @@ -1128,7 +1128,7 @@ namespace odb inline std::shared_ptr lazy_shared_ptr:: load () const { - if (!loaded ()) + if (!p_ && i_) p_ = i_.template load (true); // Reset id. return p_; @@ -1517,11 +1517,12 @@ namespace odb { std::shared_ptr r (p_.lock ()); - if (r || !i_) - return r; + if (!r && i_) + { + r = i_.template load (false); // Keep id. + p_ = r; + } - r = i_.template load (false); // Keep id. - p_ = r; return r; } -- cgit v1.1