diff options
author | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2012-08-16 16:06:16 (GMT) |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-08-27 10:14:39 (GMT) |
commit | 1b3a74e74237d004527c3f296b7ec65365be0f25 (patch) | |
tree | ac3e60c021c8cdf838f8d0abe52c1bcf46fb0174 /tests/auto/qsharedpointer | |
parent | 7982f6ad2703e13edbf80d55e537871bf1cd548d (diff) | |
download | Qt-1b3a74e74237d004527c3f296b7ec65365be0f25.zip Qt-1b3a74e74237d004527c3f296b7ec65365be0f25.tar.gz Qt-1b3a74e74237d004527c3f296b7ec65365be0f25.tar.bz2 |
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 'tests/auto/qsharedpointer')
-rw-r--r-- | tests/auto/qsharedpointer/tst_qsharedpointer.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/tests/auto/qsharedpointer/tst_qsharedpointer.cpp b/tests/auto/qsharedpointer/tst_qsharedpointer.cpp index 452e658..54fe65e 100644 --- a/tests/auto/qsharedpointer/tst_qsharedpointer.cpp +++ b/tests/auto/qsharedpointer/tst_qsharedpointer.cpp @@ -1755,6 +1755,13 @@ void tst_QSharedPointer::invalidConstructs_data() "QSharedPointer<Data> ptr1 = QSharedPointer<Data>(aData);\n" "QSharedPointer<Data> ptr2 = QSharedPointer<Data>(aData);\n"; + // two QObjects with the same pointer + QTest::newRow("same-pointer-to-qobject") + << &QTest::QExternalTest::tryRunFail + << "QObject *anObj = new QObject;\n" + "QSharedPointer<QObject> ptr1 = QSharedPointer<QObject>(anObj);\n" + "QSharedPointer<QObject> ptr2 = QSharedPointer<QObject>(anObj);\n"; + // re-creation: QTest::newRow("re-creation") << &QTest::QExternalTest::tryRunFail |