qsharedpointer.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/corelib/tools/qsharedpointer.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7-
8-
9-
10-
11-
12-
13void QtSharedPointer::ExternalRefCountData::setQObjectShared(const QObject *, bool)-
14{}-
15void QtSharedPointer::ExternalRefCountData::checkQObjectShared(const QObject *)-
16{-
17 if (strongref.load() < 0
strongref.load() < 0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QSharedPointer
FALSEevaluated 60 times by 5 tests
Evaluated by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QSharedPointer
  • tst_Spdy
)
2-60
18 QMessageLogger(__FILE__, 1328, __PRETTY_FUNCTION__).warning("QSharedPointer: cannot create a QSharedPointer from a QObject-tracking QWeakPointer");
executed 2 times by 1 test: QMessageLogger(__FILE__, 1328, __PRETTY_FUNCTION__).warning("QSharedPointer: cannot create a QSharedPointer from a QObject-tracking QWeakPointer");
Executed by:
  • tst_QSharedPointer
2
19}
executed 62 times by 5 tests: end of block
Executed by:
  • tst_QAbstractNetworkCache
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkDiskCache
  • tst_QSharedPointer
  • tst_Spdy
62
20-
21QtSharedPointer::ExternalRefCountData *QtSharedPointer::ExternalRefCountData::getAndRef(const QObject *obj)-
22{-
23 ((!(obj)) ? qt_assert("obj",__FILE__,1333) : qt_noop());-
24 QObjectPrivate *d = QObjectPrivate::get(const_cast<QObject *>(obj));-
25 ((!(!d->wasDeleted)) ? qt_assert_x("QWeakPointer", "Detected QWeakPointer creation in a QObject being deleted",__FILE__,1335) : qt_noop());-
26-
27 ExternalRefCountData *that = d->sharedRefcount.load();-
28 if (that
thatDescription
TRUEevaluated 217414 times by 223 tests
Evaluated by:
  • tst_Gestures
  • tst_ModelTest
  • tst_NetworkSelfTest
  • tst_QAbstractAnimation
  • tst_QAbstractButton
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractScrollArea
  • tst_QAbstractSlider
  • tst_QAbstractSpinBox
  • tst_QAccessibility
  • tst_QAction
  • tst_QActionGroup
  • tst_QAnimationGroup
  • tst_QApplication
  • tst_QBackingStore
  • tst_QBoxLayout
  • tst_QBrush
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QCheckBox
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • ...
FALSEevaluated 68025 times by 243 tests
Evaluated by:
  • tst_Gestures
  • tst_ModelTest
  • tst_NetworkSelfTest
  • tst_QAbstractAnimation
  • tst_QAbstractButton
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractScrollArea
  • tst_QAbstractSlider
  • tst_QAbstractSpinBox
  • tst_QAbstractTextDocumentLayout
  • tst_QAccessibility
  • tst_QAction
  • tst_QActionGroup
  • tst_QAnimationGroup
  • tst_QApplication
  • tst_QBackingStore
  • tst_QBoxLayout
  • tst_QBrush
  • tst_QBuffer
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QCheckBox
  • tst_QColorDialog
  • ...
) {
68025-217414
29 that->weakref.ref();-
30 return
executed 217414 times by 223 tests: return that;
Executed by:
  • tst_Gestures
  • tst_ModelTest
  • tst_NetworkSelfTest
  • tst_QAbstractAnimation
  • tst_QAbstractButton
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractScrollArea
  • tst_QAbstractSlider
  • tst_QAbstractSpinBox
  • tst_QAccessibility
  • tst_QAction
  • tst_QActionGroup
  • tst_QAnimationGroup
  • tst_QApplication
  • tst_QBackingStore
  • tst_QBoxLayout
  • tst_QBrush
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QCheckBox
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • ...
that;
executed 217414 times by 223 tests: return that;
Executed by:
  • tst_Gestures
  • tst_ModelTest
  • tst_NetworkSelfTest
  • tst_QAbstractAnimation
  • tst_QAbstractButton
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractScrollArea
  • tst_QAbstractSlider
  • tst_QAbstractSpinBox
  • tst_QAccessibility
  • tst_QAction
  • tst_QActionGroup
  • tst_QAnimationGroup
  • tst_QApplication
  • tst_QBackingStore
  • tst_QBoxLayout
  • tst_QBrush
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QCheckBox
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • ...
217414
31 }-
32-
33-
34 ExternalRefCountData *x = new ExternalRefCountData(Qt::Uninitialized);-
35 x->strongref.store(-1);-
36 x->weakref.store(2);-
37 if (!d->sharedRefcount.testAndSetRelease(0, x)
!d->sharedRefc...tRelease(0, x)Description
TRUEnever evaluated
FALSEevaluated 68025 times by 243 tests
Evaluated by:
  • tst_Gestures
  • tst_ModelTest
  • tst_NetworkSelfTest
  • tst_QAbstractAnimation
  • tst_QAbstractButton
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractScrollArea
  • tst_QAbstractSlider
  • tst_QAbstractSpinBox
  • tst_QAbstractTextDocumentLayout
  • tst_QAccessibility
  • tst_QAction
  • tst_QActionGroup
  • tst_QAnimationGroup
  • tst_QApplication
  • tst_QBackingStore
  • tst_QBoxLayout
  • tst_QBrush
  • tst_QBuffer
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QCheckBox
  • tst_QColorDialog
  • ...
) {
0-68025
38 delete x;-
39 x = d->sharedRefcount.loadAcquire();-
40 x->weakref.ref();-
41 }
never executed: end of block
0
42 return
executed 68025 times by 243 tests: return x;
Executed by:
  • tst_Gestures
  • tst_ModelTest
  • tst_NetworkSelfTest
  • tst_QAbstractAnimation
  • tst_QAbstractButton
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractScrollArea
  • tst_QAbstractSlider
  • tst_QAbstractSpinBox
  • tst_QAbstractTextDocumentLayout
  • tst_QAccessibility
  • tst_QAction
  • tst_QActionGroup
  • tst_QAnimationGroup
  • tst_QApplication
  • tst_QBackingStore
  • tst_QBoxLayout
  • tst_QBrush
  • tst_QBuffer
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QCheckBox
  • tst_QColorDialog
  • ...
x;
executed 68025 times by 243 tests: return x;
Executed by:
  • tst_Gestures
  • tst_ModelTest
  • tst_NetworkSelfTest
  • tst_QAbstractAnimation
  • tst_QAbstractButton
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractScrollArea
  • tst_QAbstractSlider
  • tst_QAbstractSpinBox
  • tst_QAbstractTextDocumentLayout
  • tst_QAccessibility
  • tst_QAction
  • tst_QActionGroup
  • tst_QAnimationGroup
  • tst_QApplication
  • tst_QBackingStore
  • tst_QBoxLayout
  • tst_QBrush
  • tst_QBuffer
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QCheckBox
  • tst_QColorDialog
  • ...
68025
43}-
44-
45-
46-
47-
48-
49-
50QSharedPointer<QObject> QtSharedPointer::sharedPointerFromVariant_internal(const QVariant &variant)-
51{-
52 ((!(QMetaType::typeFlags(variant.userType()) & QMetaType::SharedPointerToQObject)) ? qt_assert("QMetaType::typeFlags(variant.userType()) & QMetaType::SharedPointerToQObject",__FILE__,1362) : qt_noop());-
53 return
executed 8 times by 2 tests: return *reinterpret_cast<const QSharedPointer<QObject>*>(variant.constData());
Executed by:
  • tst_QMetaType
  • tst_QSharedPointer
*reinterpret_cast<const QSharedPointer<QObject>*>(variant.constData());
executed 8 times by 2 tests: return *reinterpret_cast<const QSharedPointer<QObject>*>(variant.constData());
Executed by:
  • tst_QMetaType
  • tst_QSharedPointer
8
54}-
55-
56-
57-
58-
59-
60-
61QWeakPointer<QObject> QtSharedPointer::weakPointerFromVariant_internal(const QVariant &variant)-
62{-
63 ((!(QMetaType::typeFlags(variant.userType()) & QMetaType::WeakPointerToQObject || QMetaType::typeFlags(variant.userType()) & QMetaType::TrackingPointerToQObject)) ? qt_assert("QMetaType::typeFlags(variant.userType()) & QMetaType::WeakPointerToQObject || QMetaType::typeFlags(variant.userType()) & QMetaType::TrackingPointerToQObject",__FILE__,1373) : qt_noop());-
64 return
executed 21 times by 3 tests: return *reinterpret_cast<const QWeakPointer<QObject>*>(variant.constData());
Executed by:
  • tst_QMetaType
  • tst_QPointer
  • tst_QSharedPointer
*reinterpret_cast<const QWeakPointer<QObject>*>(variant.constData());
executed 21 times by 3 tests: return *reinterpret_cast<const QWeakPointer<QObject>*>(variant.constData());
Executed by:
  • tst_QMetaType
  • tst_QPointer
  • tst_QSharedPointer
21
65}-
66-
67-
68namespace {-
69 -
70 struct Data {-
71 const volatile void *pointer;-
72-
73-
74-
75 };-
76-
77 class KnownPointers-
78 {-
79 public:-
80 QMutex mutex;-
81 QHash<const void *, Data> dPointers;-
82 QHash<const volatile void *, const void *> dataPointers;-
83 };-
84}-
85-
86namespace { namespace Q_QGS_knownPointers { typedef KnownPointers Type; QBasicAtomicInt guard = { QtGlobalStatic::Uninitialized }; __attribute__((visibility("hidden"))) inline Type *innerFunction() { struct HolderBase { ~HolderBase() noexcept { if (guard.load() == QtGlobalStatic::Initialized
guard.load() =...c::InitializedDescription
TRUEevaluated 2 times by 2 tests
Evaluated by:
  • tst_qsharedpointer - unknown status
  • tst_qsharedpointer_and_qwidget - unknown status
FALSEnever evaluated
) guard.store(QtGlobalStatic::Destroyed);
executed 2 times by 2 tests: guard.store(QtGlobalStatic::Destroyed);
Executed by:
  • tst_qsharedpointer - unknown status
  • tst_qsharedpointer_and_qwidget - unknown status
}
executed 2 times by 2 tests: end of block
Executed by:
  • tst_qsharedpointer - unknown status
  • tst_qsharedpointer_and_qwidget - unknown status
}; static struct Holder : public HolderBase { Type value; Holder() noexcept(noexcept(Type ())) : value () { guard.store(QtGlobalStatic::Initialized); } } holder; return
executed 387 times by 2 tests: return &holder.value;
Executed by:
  • tst_QSharedPointer
  • tst_QSharedPointer_and_QWidget
&holder.value;
executed 387 times by 2 tests: return &holder.value;
Executed by:
  • tst_QSharedPointer
  • tst_QSharedPointer_and_QWidget
} } } static QGlobalStatic<KnownPointers, Q_QGS_knownPointers::innerFunction, Q_QGS_knownPointers::guard> knownPointers;
0-387
87-
88-
89-
90namespace QtSharedPointer {-
91 __attribute__((visibility("default"))) void internalSafetyCheckCleanCheck();-
92}-
93-
94-
95-
96-
97void QtSharedPointer::internalSafetyCheckAdd(const void *d_ptr, const volatile void *ptr)-
98{-
99 KnownPointers *const kp = knownPointers();-
100 if (!kp
!kpDescription
TRUEnever evaluated
FALSEevaluated 133 times by 1 test
Evaluated by:
  • tst_QSharedPointer
)
0-133
101 return;
never executed: return;
0
102-
103 QMutexLocker lock(&kp->mutex);-
104 ((!(!kp->dPointers.contains(d_ptr))) ? qt_assert("!kp->dPointers.contains(d_ptr)",__FILE__,1502) : qt_noop());-
105-
106-
107-
108 const void *other_d_ptr = kp->dataPointers.value(ptr, 0);-
109 if (__builtin_expect(!!(other_d_ptr), false)
__builtin_expe...d_ptr), false)Description
TRUEnever evaluated
FALSEevaluated 133 times by 1 test
Evaluated by:
  • tst_QSharedPointer
) {
0-133
110-
111-
112-
113 QMessageLogger(__FILE__, 1511, __PRETTY_FUNCTION__).fatal("QSharedPointer: internal self-check failed: pointer %p was already tracked "-
114 "by another QSharedPointer object %p", ptr, other_d_ptr);-
115 }
never executed: end of block
0
116-
117 Data data;-
118 data.pointer = ptr;-
119-
120-
121-
122-
123 kp->dPointers.insert(d_ptr, data);-
124 kp->dataPointers.insert(ptr, d_ptr);-
125 ((!(kp->dPointers.size() == kp->dataPointers.size())) ? qt_assert("kp->dPointers.size() == kp->dataPointers.size()",__FILE__,1523) : qt_noop());-
126}
executed 133 times by 1 test: end of block
Executed by:
  • tst_QSharedPointer
133
127-
128-
129-
130-
131void QtSharedPointer::internalSafetyCheckRemove(const void *d_ptr)-
132{-
133 KnownPointers *const kp = knownPointers();-
134 if (!kp
!kpDescription
TRUEnever evaluated
FALSEevaluated 133 times by 1 test
Evaluated by:
  • tst_QSharedPointer
)
0-133
135 return;
never executed: return;
0
136-
137 QMutexLocker lock(&kp->mutex);-
138-
139 const auto it = kp->dPointers.constFind(d_ptr);-
140 if (__builtin_expect(!!(it == kp->dPointers.cend()), false)
__builtin_expe...end()), false)Description
TRUEnever evaluated
FALSEevaluated 133 times by 1 test
Evaluated by:
  • tst_QSharedPointer
) {
0-133
141 QMessageLogger(__FILE__, 1539, __PRETTY_FUNCTION__).fatal("QSharedPointer: internal self-check inconsistency: pointer %p was not tracked. "-
142 "To use QT_SHAREDPOINTER_TRACK_POINTERS, you have to enable it throughout "-
143 "in your code.", d_ptr);-
144 }
never executed: end of block
0
145-
146 const auto it2 = kp->dataPointers.constFind(it->pointer);-
147 ((!(it2 != kp->dataPointers.cend())) ? qt_assert("it2 != kp->dataPointers.cend()",__FILE__,1545) : qt_noop());-
148-
149-
150-
151-
152 kp->dataPointers.erase(it2);-
153 kp->dPointers.erase(it);-
154 ((!(kp->dPointers.size() == kp->dataPointers.size())) ? qt_assert("kp->dPointers.size() == kp->dataPointers.size()",__FILE__,1552) : qt_noop());-
155}
executed 133 times by 1 test: end of block
Executed by:
  • tst_QSharedPointer
133
156-
157-
158-
159-
160-
161void QtSharedPointer::internalSafetyCheckCleanCheck()-
162{-
163-
164 KnownPointers *const kp = knownPointers();-
165 ((!(kp)) ? qt_assert_x("internalSafetyCheckSelfCheck()", "Called after global statics deletion!",__FILE__,1563) : qt_noop());-
166-
167 if (__builtin_expect(!!(kp->dPointers.size() != kp->dataPointers.size()), false)
__builtin_expe...ize()), false)Description
TRUEnever evaluated
FALSEevaluated 121 times by 2 tests
Evaluated by:
  • tst_QSharedPointer
  • tst_QSharedPointer_and_QWidget
)
0-121
168 QMessageLogger(__FILE__, 1566, __PRETTY_FUNCTION__).fatal("Internal consistency error: the number of pointers is not equal!");
never executed: QMessageLogger(__FILE__, 1566, __PRETTY_FUNCTION__).fatal("Internal consistency error: the number of pointers is not equal!");
0
169-
170 if (__builtin_expect(!!(!kp->dPointers.isEmpty()), false)
__builtin_expe...pty()), false)Description
TRUEnever evaluated
FALSEevaluated 121 times by 2 tests
Evaluated by:
  • tst_QSharedPointer
  • tst_QSharedPointer_and_QWidget
)
0-121
171 QMessageLogger(__FILE__, 1569, __PRETTY_FUNCTION__).fatal("Pointer cleaning failed: %d entries remaining", kp->dPointers.size());
never executed: QMessageLogger(__FILE__, 1569, __PRETTY_FUNCTION__).fatal("Pointer cleaning failed: %d entries remaining", kp->dPointers.size());
0
172-
173}
executed 121 times by 2 tests: end of block
Executed by:
  • tst_QSharedPointer
  • tst_QSharedPointer_and_QWidget
121
174-
175-
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9