summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMathias Agopian2013-03-19 00:27:41 -0500
committerAlex Ray2013-07-30 15:57:01 -0500
commit6cd548c7154c1633a0ed318c31dd22c50a5f5d02 (patch)
treece9928ccfb45dac23ead4ddae0da0253b0cdd2fe /libs/utils/RefBase.cpp
parent6d4419d9b130719dd2355861907dc8f87368a51c (diff)
downloadplatform-system-core-6cd548c7154c1633a0ed318c31dd22c50a5f5d02.tar.gz
platform-system-core-6cd548c7154c1633a0ed318c31dd22c50a5f5d02.tar.xz
platform-system-core-6cd548c7154c1633a0ed318c31dd22c50a5f5d02.zip
Fix a crasher with RefBase debugging and vectors of wp<>
background: we have some code to fix-up the IDs of references when using RefBase's DEBUG_REFS when those refs are managed by arrays wp<> or sp<> (this is because wp<> / sp<> don't have a trivial ctor when DEBUG_REFS is enabled, and Vector treats them as trivial for obvious performance reasons) this is complicated by the fact that we don't want to have to recompile everything when enabling DEBUG_REFs (i.e.: the Vector code cannot know wheter it's enabled or not for its template stuff). problem: there was a bug in the fix-up code for wp<> which was trying to access the weakref_impl from the RefBase* however, this was moronic since RefBase could have been destroyed if there wasn't any more strong refs -- and this happned. Instead we need to get the weakref_impl directly from the wp<> Change-Id: Ie16e334204205fdbff142acb9faff8479a78450b
Diffstat (limited to 'libs/utils/RefBase.cpp')
-rw-r--r--libs/utils/RefBase.cpp24
1 files changed, 15 insertions, 9 deletions
diff --git a/libs/utils/RefBase.cpp b/libs/utils/RefBase.cpp
index ef87131ad..abaf3c0ca 100644
--- a/libs/utils/RefBase.cpp
+++ b/libs/utils/RefBase.cpp
@@ -631,21 +631,27 @@ void RefBase::onLastWeakRef(const void* /*id*/)
631 631
632// --------------------------------------------------------------------------- 632// ---------------------------------------------------------------------------
633 633
634void RefBase::moveReferences(void* dst, void const* src, size_t n, 634void RefBase::renameRefs(size_t n, const ReferenceRenamer& renamer) {
635 const ReferenceConverterBase& caster)
636{
637#if DEBUG_REFS 635#if DEBUG_REFS
638 const size_t itemSize = caster.getReferenceTypeSize();
639 for (size_t i=0 ; i<n ; i++) { 636 for (size_t i=0 ; i<n ; i++) {
640 void* d = reinterpret_cast<void *>(intptr_t(dst) + i*itemSize); 637 renamer(i);
641 void const* s = reinterpret_cast<void const*>(intptr_t(src) + i*itemSize);
642 RefBase* ref(reinterpret_cast<RefBase*>(caster.getReferenceBase(d)));
643 ref->mRefs->renameStrongRefId(s, d);
644 ref->mRefs->renameWeakRefId(s, d);
645 } 638 }
646#endif 639#endif
647} 640}
648 641
642void RefBase::renameRefId(weakref_type* ref,
643 const void* old_id, const void* new_id) {
644 weakref_impl* const impl = static_cast<weakref_impl*>(ref);
645 impl->renameStrongRefId(old_id, new_id);
646 impl->renameWeakRefId(old_id, new_id);
647}
648
649void RefBase::renameRefId(RefBase* ref,
650 const void* old_id, const void* new_id) {
651 ref->mRefs->renameStrongRefId(old_id, new_id);
652 ref->mRefs->renameWeakRefId(old_id, new_id);
653}
654
649// --------------------------------------------------------------------------- 655// ---------------------------------------------------------------------------
650 656
651TextOutput& printStrongPointer(TextOutput& to, const void* val) 657TextOutput& printStrongPointer(TextOutput& to, const void* val)