From 801832b8a39aef224d55c892022b6f9008ffc894 Mon Sep 17 00:00:00 2001 From: Debao Zhang Date: Wed, 14 Mar 2012 14:39:02 -0700 Subject: [PATCH] QSharedPointer: remove two emtpy functions. As the comments says:they are broken by design, and replaced with other functions. The purpose of their existence is for BIC with Qt4.5. Change-Id: I9453f816a7b7c6812499b89b7c60f0fd99dea27c Reviewed-by: Olivier Goffart Reviewed-by: Thiago Macieira --- src/corelib/tools/qsharedpointer.cpp | 37 ++----------------------- src/corelib/tools/qsharedpointer_impl.h | 10 +++---- 2 files changed, 7 insertions(+), 40 deletions(-) diff --git a/src/corelib/tools/qsharedpointer.cpp b/src/corelib/tools/qsharedpointer.cpp index 77c3d1e2cb..58c62f0a3e 100644 --- a/src/corelib/tools/qsharedpointer.cpp +++ b/src/corelib/tools/qsharedpointer.cpp @@ -1380,47 +1380,14 @@ Q_GLOBAL_STATIC(KnownPointers, knownPointers) QT_BEGIN_NAMESPACE namespace QtSharedPointer { - Q_CORE_EXPORT void internalSafetyCheckAdd(const volatile void *); - Q_CORE_EXPORT void internalSafetyCheckRemove(const volatile void *); Q_AUTOTEST_EXPORT void internalSafetyCheckCleanCheck(); } /*! \internal */ -void QtSharedPointer::internalSafetyCheckAdd(const volatile void *) +void QtSharedPointer::internalSafetyCheckAdd(const void *d_ptr, const volatile void *ptr) { - // Qt 4.5 compatibility - // this function is broken by design, so it was replaced with internalSafetyCheckAdd2 - // - // it's broken because we tracked the pointers added and - // removed from QSharedPointer, converted to void*. - // That is, this is supposed to track the "top-of-object" pointer in - // case of multiple inheritance. - // - // However, it doesn't work well in some compilers: - // if you create an object with a class of type A and the last reference - // is dropped of type B, then the value passed to internalSafetyCheckRemove could - // be different than was added. That would leave dangling addresses. - // - // So instead, we track the pointer by the d-pointer instead. -} - -/*! - \internal -*/ -void QtSharedPointer::internalSafetyCheckRemove(const volatile void *) -{ - // Qt 4.5 compatibility - // see comments above -} - -/*! - \internal -*/ -void QtSharedPointer::internalSafetyCheckAdd2(const void *d_ptr, const volatile void *ptr) -{ - // see comments above for the rationale for this function KnownPointers *const kp = knownPointers(); if (!kp) return; // end-game: the application is being destroyed already @@ -1453,7 +1420,7 @@ void QtSharedPointer::internalSafetyCheckAdd2(const void *d_ptr, const volatile /*! \internal */ -void QtSharedPointer::internalSafetyCheckRemove2(const void *d_ptr) +void QtSharedPointer::internalSafetyCheckRemove(const void *d_ptr) { KnownPointers *const kp = knownPointers(); if (!kp) diff --git a/src/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h index 58010dd8d9..81ce17889e 100644 --- a/src/corelib/tools/qsharedpointer_impl.h +++ b/src/corelib/tools/qsharedpointer_impl.h @@ -105,8 +105,8 @@ namespace QtSharedPointer { template QSharedPointer copyAndSetPointer(X * ptr, const QSharedPointer &src); // used in debug mode to verify the reuse of pointers - Q_CORE_EXPORT void internalSafetyCheckAdd2(const void *, const volatile void *); - Q_CORE_EXPORT void internalSafetyCheckRemove2(const void *); + Q_CORE_EXPORT void internalSafetyCheckAdd(const void *, const volatile void *); + Q_CORE_EXPORT void internalSafetyCheckRemove(const void *); template inline void executeDeleter(T *t, RetVal (Klass:: *memberDeleter)()) @@ -247,7 +247,7 @@ namespace QtSharedPointer { } static void safetyCheckDeleter(ExternalRefCountData *self) { - internalSafetyCheckRemove2(self); + internalSafetyCheckRemove(self); deleter(self); } @@ -290,7 +290,7 @@ namespace QtSharedPointer { } static void safetyCheckDeleter(ExternalRefCountData *self) { - internalSafetyCheckRemove2(self); + internalSafetyCheckRemove(self); deleter(self); } @@ -374,7 +374,7 @@ namespace QtSharedPointer { Basic::internalConstruct(ptr); if (ptr) d->setQObjectShared(ptr, true); #ifdef QT_SHAREDPOINTER_TRACK_POINTERS - if (ptr) internalSafetyCheckAdd2(d, ptr); + if (ptr) internalSafetyCheckAdd(d, ptr); #endif }