diff options
author | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2012-08-16 17:06:16 +0100 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-08-27 12:14:39 +0200 |
commit | 1b3a74e74237d004527c3f296b7ec65365be0f25 (patch) | |
tree | ac3e60c021c8cdf838f8d0abe52c1bcf46fb0174 /src/corelib/tools | |
parent | 7982f6ad2703e13edbf80d55e537871bf1cd548d (diff) |
QSharedPointer: make QT_SHAREDPOINTER_TRACK_POINTERS work with QObjects
If setQObjectShared crashes because a QObject is tracked by two
different QSharedPointers, we lose the debug feature offered by #defining
QT_SHAREDPOINTER_TRACK_POINTERS, as the check done by this define
happens after the setQObjectShared call.
Therefore, move setQObjectShared after the internalSafetyCheckAdd2 call.
This way, the error raised by QSharedPointer created changes from f.i.
QSharedPointer: pointer 0xa10010 already has reference counting
to the more "debuggable" (and consistent with non-QObjects)
QSharedPointer: internal self-check failed: pointer 0x1dd90e0 was already tracked by another QSharedPointer object 0x1dd9330
"Backport" of change-id I71340d0f878828354537762d01c46d441efc918c from
qtbase (although, as of commit 609b0a9c2e69180ceff5d89c42e0d9468491d7e3,
this issue is not present there, as setQObjectShared does nothing).
Change-Id: I4cea83d705795eae0e05da128a3f189aea36f5ce
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/tools')
-rw-r--r-- | src/corelib/tools/qsharedpointer_impl.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h index 4216456c1c..95864a1cc6 100644 --- a/src/corelib/tools/qsharedpointer_impl.h +++ b/src/corelib/tools/qsharedpointer_impl.h @@ -378,10 +378,10 @@ namespace QtSharedPointer { inline void internalFinishConstruction(T *ptr) { Basic<T>::internalConstruct(ptr); - if (ptr) d->setQObjectShared(ptr, true); #ifdef QT_SHAREDPOINTER_TRACK_POINTERS if (ptr) internalSafetyCheckAdd2(d, ptr); #endif + if (ptr) d->setQObjectShared(ptr, true); } inline ExternalRefCount() : d(0) { } |