summaryrefslogtreecommitdiffstats
path: root/include/utils
diff options
context:
space:
mode:
authorMathias Agopian <mathias@google.com>2011-02-24 18:12:34 -0800
committerMathias Agopian <mathias@google.com>2011-02-24 18:12:34 -0800
commit49862c3630632303c40ca37f1791ed4b092ce063 (patch)
treecb7d2a8d7d615664a206243557f82abb7c03f3c3 /include/utils
parentec122eb46b6ce8f6e8bb3e08c34e575de666cd3e (diff)
downloadframeworks_base-49862c3630632303c40ca37f1791ed4b092ce063.zip
frameworks_base-49862c3630632303c40ca37f1791ed4b092ce063.tar.gz
frameworks_base-49862c3630632303c40ca37f1791ed4b092ce063.tar.bz2
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
Diffstat (limited to 'include/utils')
-rw-r--r--include/utils/RefBase.h7
-rw-r--r--include/utils/StrongPointer.h14
2 files changed, 10 insertions, 11 deletions
diff --git a/include/utils/RefBase.h b/include/utils/RefBase.h
index 9b0e7d8..f355087 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 5daccf4..a8c9897 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)