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 <ogoffart@woboq.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Debao Zhang 2012-03-14 14:39:02 -07:00 committed by Qt by Nokia
parent e640c3bcfe
commit 801832b8a3
2 changed files with 7 additions and 40 deletions

View File

@ -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)

View File

@ -105,8 +105,8 @@ namespace QtSharedPointer {
template <class X, class Y> QSharedPointer<X> copyAndSetPointer(X * ptr, const QSharedPointer<Y> &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 <class T, typename Klass, typename RetVal>
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<T>::internalConstruct(ptr);
if (ptr) d->setQObjectShared(ptr, true);
#ifdef QT_SHAREDPOINTER_TRACK_POINTERS
if (ptr) internalSafetyCheckAdd2(d, ptr);
if (ptr) internalSafetyCheckAdd(d, ptr);
#endif
}