From d005004f1419e51680ea69a78e6835a7d1b71aac Mon Sep 17 00:00:00 2001 From: Mathias Agopian Date: Thu, 24 Feb 2011 18:12:34 -0800 Subject: [PATCH] Fix a wp<> bug where the owner ID would be wrong this was introduced recently. we make sure to use the correct owner id (the sp) instead of the wp. Change-Id: I78fdc6ec0c2d3e687278b70442d74d1924b512a2 --- include/utils/RefBase.h | 7 +++++-- include/utils/StrongPointer.h | 14 +++++--------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/include/utils/RefBase.h b/include/utils/RefBase.h index 9b0e7d8a4..f35508771 100644 --- a/include/utils/RefBase.h +++ b/include/utils/RefBase.h @@ -425,8 +425,11 @@ void wp::set_object_and_refs(T* other, weakref_type* refs) template sp wp::promote() const { - T* p = (m_ptr && m_refs->attemptIncStrong(this)) ? m_ptr : 0; - return sp(p, true); + sp result; + if (m_ptr && m_refs->attemptIncStrong(&result)) { + result.set_pointer(m_ptr); + } + return result; } template diff --git a/include/utils/StrongPointer.h b/include/utils/StrongPointer.h index 5daccf4f0..a8c989749 100644 --- a/include/utils/StrongPointer.h +++ b/include/utils/StrongPointer.h @@ -104,11 +104,8 @@ public: private: template friend class sp; template friend class wp; - - // Optimization for wp::promote(). - sp(T* p, bool); - - T* m_ptr; + void set_pointer(T* ptr); + T* m_ptr; }; #undef COMPARE @@ -206,10 +203,9 @@ void sp::clear() } template -sp::sp(T* p, bool) -: m_ptr(p) - { - } +void sp::set_pointer(T* ptr) { + m_ptr = ptr; +} template inline TextOutput& operator<<(TextOutput& to, const sp& val)