diff options
| author | 2011-02-24 18:27:40 -0800 | |
|---|---|---|
| committer | 2011-02-24 18:27:40 -0800 | |
| commit | d4e5832b694614990f24ab107df65ff2d17a0292 (patch) | |
| tree | cc2461238e706d03a7db7b8e4b1974f56191ffc2 /include/utils | |
| parent | f92ab1c8b03d5161bb06fafb73cc986e783c5671 (diff) | |
| parent | d005004f1419e51680ea69a78e6835a7d1b71aac (diff) | |
Merge "Fix a wp<> bug where the owner ID would be wrong"
Diffstat (limited to 'include/utils')
| -rw-r--r-- | include/utils/RefBase.h | 7 | ||||
| -rw-r--r-- | 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 9b0e7d8a44..f355087713 100644 --- a/include/utils/RefBase.h +++ b/include/utils/RefBase.h @@ -425,8 +425,11 @@ void wp<T>::set_object_and_refs(T* other, weakref_type* refs) template<typename T> sp<T> wp<T>::promote() const { - T* p = (m_ptr && m_refs->attemptIncStrong(this)) ? m_ptr : 0; - return sp<T>(p, true); + sp<T> result; + if (m_ptr && m_refs->attemptIncStrong(&result)) { + result.set_pointer(m_ptr); + } + return result; } template<typename T> diff --git a/include/utils/StrongPointer.h b/include/utils/StrongPointer.h index 5daccf4f09..a8c989749b 100644 --- a/include/utils/StrongPointer.h +++ b/include/utils/StrongPointer.h @@ -104,11 +104,8 @@ public: private: template<typename Y> friend class sp; template<typename Y> 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<T>::clear() } template<typename T> -sp<T>::sp(T* p, bool) -: m_ptr(p) - { - } +void sp<T>::set_pointer(T* ptr) { + m_ptr = ptr; +} template <typename T> inline TextOutput& operator<<(TextOutput& to, const sp<T>& val) |