kernel/qobject.cpp

Source codeSwitch to Preprocessed file
LineSource CodeCoverage
1/**************************************************************************** -
2** -
3** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -
4** Contact: http://www.qt-project.org/legal -
5** -
6** This file is part of the QtCore module of the Qt Toolkit. -
7** -
8** $QT_BEGIN_LICENSE:LGPL$ -
9** Commercial License Usage -
10** Licensees holding valid commercial Qt licenses may use this file in -
11** accordance with the commercial license agreement provided with the -
12** Software or, alternatively, in accordance with the terms contained in -
13** a written agreement between you and Digia. For licensing terms and -
14** conditions see http://qt.digia.com/licensing. For further information -
15** use the contact form at http://qt.digia.com/contact-us. -
16** -
17** GNU Lesser General Public License Usage -
18** Alternatively, this file may be used under the terms of the GNU Lesser -
19** General Public License version 2.1 as published by the Free Software -
20** Foundation and appearing in the file LICENSE.LGPL included in the -
21** packaging of this file. Please review the following information to -
22** ensure the GNU Lesser General Public License version 2.1 requirements -
23** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -
24** -
25** In addition, as a special exception, Digia gives you certain additional -
26** rights. These rights are described in the Digia Qt LGPL Exception -
27** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -
28** -
29** GNU General Public License Usage -
30** Alternatively, this file may be used under the terms of the GNU -
31** General Public License version 3.0 as published by the Free Software -
32** Foundation and appearing in the file LICENSE.GPL included in the -
33** packaging of this file. Please review the following information to -
34** ensure the GNU General Public License version 3.0 requirements will be -
35** met: http://www.gnu.org/copyleft/gpl.html. -
36** -
37** -
38** $QT_END_LICENSE$ -
39** -
40****************************************************************************/ -
41 -
42#include "qobject.h" -
43#include "qobject_p.h" -
44#include "qmetaobject_p.h" -
45 -
46#include "qabstracteventdispatcher.h" -
47#include "qabstracteventdispatcher_p.h" -
48#include "qcoreapplication.h" -
49#include "qcoreapplication_p.h" -
50#include "qvariant.h" -
51#include "qmetaobject.h" -
52#include <qregexp.h> -
53#include <qregularexpression.h> -
54#include <qthread.h> -
55#include <private/qthread_p.h> -
56#include <qdebug.h> -
57#include <qhash.h> -
58#include <qpair.h> -
59#include <qvarlengtharray.h> -
60#include <qset.h> -
61#include <qsemaphore.h> -
62#include <qsharedpointer.h> -
63 -
64#include <private/qorderedmutexlocker_p.h> -
65 -
66#include <new> -
67 -
68#include <ctype.h> -
69#include <limits.h> -
70 -
71QT_BEGIN_NAMESPACE -
72 -
73static int DIRECT_CONNECTION_ONLY = 0; -
74 -
75struct QSlotObjectBaseDeleter { // for use with QScopedPointer<QSlotObjectBase,...> -
76 static void cleanup(QtPrivate::QSlotObjectBase *slot) { -
77 if (slot) slot->destroyIfLastRef();
executed: slot->destroyIfLastRef();
Execution Count:334
partially evaluated: slot
TRUEFALSE
yes
Evaluation Count:334
no
Evaluation Count:0
0-334
78 }
executed: }
Execution Count:334
334
79}; -
80static int *queuedConnectionTypes(const QList<QByteArray> &typeNames) -
81{ -
82 int *types = new int [typeNames.count() + 1];
executed (the execution status of this line is deduced): int *types = new int [typeNames.count() + 1];
-
83 Q_CHECK_PTR(types);
never executed: qBadAlloc();
executed: }
Execution Count:1711
partially evaluated: !(types)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1711
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1711
0-1711
84 for (int i = 0; i < typeNames.count(); ++i) {
evaluated: i < typeNames.count()
TRUEFALSE
yes
Evaluation Count:1349
yes
Evaluation Count:1711
1349-1711
85 const QByteArray typeName = typeNames.at(i);
executed (the execution status of this line is deduced): const QByteArray typeName = typeNames.at(i);
-
86 if (typeName.endsWith('*'))
partially evaluated: typeName.endsWith('*')
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1349
0-1349
87 types[i] = QMetaType::VoidStar;
never executed: types[i] = QMetaType::VoidStar;
0
88 else -
89 types[i] = QMetaType::type(typeName);
executed: types[i] = QMetaType::type(typeName);
Execution Count:1349
1349
90 -
91 if (!types[i]) {
partially evaluated: !types[i]
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1349
0-1349
92 qWarning("QObject::connect: Cannot queue arguments of type '%s'\n"
never executed (the execution status of this line is deduced): QMessageLogger("kernel/qobject.cpp", 92, __PRETTY_FUNCTION__).warning("QObject::connect: Cannot queue arguments of type '%s'\n"
-
93 "(Make sure '%s' is registered using qRegisterMetaType().)",
never executed (the execution status of this line is deduced): "(Make sure '%s' is registered using qRegisterMetaType().)",
-
94 typeName.constData(), typeName.constData());
never executed (the execution status of this line is deduced): typeName.constData(), typeName.constData());
-
95 delete [] types;
never executed (the execution status of this line is deduced): delete [] types;
-
96 return 0;
never executed: return 0;
0
97 } -
98 }
executed: }
Execution Count:1349
1349
99 types[typeNames.count()] = 0;
executed (the execution status of this line is deduced): types[typeNames.count()] = 0;
-
100 -
101 return types;
executed: return types;
Execution Count:1711
1711
102} -
103 -
104static int *queuedConnectionTypes(const QArgumentType *argumentTypes, int argc) -
105{ -
106 QScopedArrayPointer<int> types(new int [argc + 1]);
executed (the execution status of this line is deduced): QScopedArrayPointer<int> types(new int [argc + 1]);
-
107 for (int i = 0; i < argc; ++i) {
evaluated: i < argc
TRUEFALSE
yes
Evaluation Count:28507
yes
Evaluation Count:17839
17839-28507
108 const QArgumentType &type = argumentTypes[i];
executed (the execution status of this line is deduced): const QArgumentType &type = argumentTypes[i];
-
109 if (type.type())
evaluated: type.type()
TRUEFALSE
yes
Evaluation Count:28506
yes
Evaluation Count:1
1-28506
110 types[i] = type.type();
executed: types[i] = type.type();
Execution Count:28506
28506
111 else if (type.name().endsWith('*'))
partially evaluated: type.name().endsWith('*')
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
112 types[i] = QMetaType::VoidStar;
executed: types[i] = QMetaType::VoidStar;
Execution Count:1
1
113 else -
114 types[i] = QMetaType::type(type.name());
never executed: types[i] = QMetaType::type(type.name());
0
115 -
116 if (!types[i]) {
partially evaluated: !types[i]
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:28507
0-28507
117 qWarning("QObject::connect: Cannot queue arguments of type '%s'\n"
never executed (the execution status of this line is deduced): QMessageLogger("kernel/qobject.cpp", 117, __PRETTY_FUNCTION__).warning("QObject::connect: Cannot queue arguments of type '%s'\n"
-
118 "(Make sure '%s' is registered using qRegisterMetaType().)",
never executed (the execution status of this line is deduced): "(Make sure '%s' is registered using qRegisterMetaType().)",
-
119 type.name().constData(), type.name().constData());
never executed (the execution status of this line is deduced): type.name().constData(), type.name().constData());
-
120 return 0;
never executed: return 0;
0
121 } -
122 }
executed: }
Execution Count:28507
28507
123 types[argc] = 0;
executed (the execution status of this line is deduced): types[argc] = 0;
-
124 -
125 return types.take();
executed: return types.take();
Execution Count:17839
17839
126} -
127 -
128static QBasicMutex _q_ObjectMutexPool[131]; -
129 -
130/** -
131 * \internal -
132 * mutex to be locked when accessing the connectionlists or the senders list -
133 */ -
134static inline QMutex *signalSlotLock(const QObject *o) -
135{ -
136 return static_cast<QMutex *>(&_q_ObjectMutexPool[
executed: return static_cast<QMutex *>(&_q_ObjectMutexPool[ uint(quintptr(o)) % sizeof(_q_ObjectMutexPool)/sizeof(QBasicMutex)]);
Execution Count:3680026
3680026
137 uint(quintptr(o)) % sizeof(_q_ObjectMutexPool)/sizeof(QBasicMutex)]);
executed: return static_cast<QMutex *>(&_q_ObjectMutexPool[ uint(quintptr(o)) % sizeof(_q_ObjectMutexPool)/sizeof(QBasicMutex)]);
Execution Count:3680026
3680026
138} -
139 -
140extern "C" Q_CORE_EXPORT void qt_addObject(QObject *) -
141{} -
142 -
143extern "C" Q_CORE_EXPORT void qt_removeObject(QObject *) -
144{} -
145 -
146struct QConnectionSenderSwitcher { -
147 QObject *receiver; -
148 QObjectPrivate::Sender *previousSender; -
149 QObjectPrivate::Sender currentSender; -
150 bool switched; -
151 -
152 inline QConnectionSenderSwitcher() : switched(false) {}
executed: }
Execution Count:2758947
2758947
153 -
154 inline QConnectionSenderSwitcher(QObject *receiver, QObject *sender, int signal_absolute_id) -
155 { -
156 switchSender(receiver, sender, signal_absolute_id);
executed (the execution status of this line is deduced): switchSender(receiver, sender, signal_absolute_id);
-
157 }
executed: }
Execution Count:85024
85024
158 -
159 inline void switchSender(QObject *receiver, QObject *sender, int signal_absolute_id) -
160 { -
161 this->receiver = receiver;
executed (the execution status of this line is deduced): this->receiver = receiver;
-
162 currentSender.sender = sender;
executed (the execution status of this line is deduced): currentSender.sender = sender;
-
163 currentSender.signal = signal_absolute_id;
executed (the execution status of this line is deduced): currentSender.signal = signal_absolute_id;
-
164 currentSender.ref = 1;
executed (the execution status of this line is deduced): currentSender.ref = 1;
-
165 previousSender = QObjectPrivate::setCurrentSender(receiver, &currentSender);
executed (the execution status of this line is deduced): previousSender = QObjectPrivate::setCurrentSender(receiver, &currentSender);
-
166 switched = true;
executed (the execution status of this line is deduced): switched = true;
-
167 }
executed: }
Execution Count:2843846
2843846
168 -
169 inline ~QConnectionSenderSwitcher() -
170 { -
171 if (switched)
evaluated: switched
TRUEFALSE
yes
Evaluation Count:2843909
yes
Evaluation Count:105
105-2843909
172 QObjectPrivate::resetCurrentSender(receiver, &currentSender, previousSender);
executed: QObjectPrivate::resetCurrentSender(receiver, &currentSender, previousSender);
Execution Count:2843918
2843918
173 }
executed: }
Execution Count:2843973
2843973
174private: -
175 Q_DISABLE_COPY(QConnectionSenderSwitcher) -
176}; -
177 -
178 -
179void (*QAbstractDeclarativeData::destroyed)(QAbstractDeclarativeData *, QObject *) = 0; -
180void (*QAbstractDeclarativeData::parentChanged)(QAbstractDeclarativeData *, QObject *, QObject *) = 0; -
181void (*QAbstractDeclarativeData::signalEmitted)(QAbstractDeclarativeData *, QObject *, int, void **) = 0; -
182int (*QAbstractDeclarativeData::receivers)(QAbstractDeclarativeData *, const QObject *, int) = 0; -
183bool (*QAbstractDeclarativeData::isSignalConnected)(QAbstractDeclarativeData *, const QObject *, int) = 0; -
184 -
185QObjectData::~QObjectData() {} -
186 -
187QMetaObject *QObjectData::dynamicMetaObject() const -
188{ -
189 return metaObject->toDynamicMetaObject(q_ptr);
never executed: return metaObject->toDynamicMetaObject(q_ptr);
0
190} -
191 -
192QObjectPrivate::QObjectPrivate(int version) -
193 : threadData(0), connectionLists(0), senders(0), currentSender(0), currentChildBeingDeleted(0) -
194{ -
195 if (version != QObjectPrivateVersion)
partially evaluated: version != QObjectPrivateVersion
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3603234
0-3603234
196 qFatal("Cannot mix incompatible Qt library (version 0x%x) with this library (version 0x%x)",
never executed: QMessageLogger("kernel/qobject.cpp", 196, __PRETTY_FUNCTION__).fatal("Cannot mix incompatible Qt library (version 0x%x) with this library (version 0x%x)", version, QObjectPrivateVersion);
0
197 version, QObjectPrivateVersion);
never executed: QMessageLogger("kernel/qobject.cpp", 196, __PRETTY_FUNCTION__).fatal("Cannot mix incompatible Qt library (version 0x%x) with this library (version 0x%x)", version, QObjectPrivateVersion);
0
198 -
199 // QObjectData initialization -
200 q_ptr = 0;
executed (the execution status of this line is deduced): q_ptr = 0;
-
201 parent = 0; // no parent yet. It is set by setParent()
executed (the execution status of this line is deduced): parent = 0;
-
202 isWidget = false; // assume not a widget object
executed (the execution status of this line is deduced): isWidget = false;
-
203 blockSig = false; // not blocking signals
executed (the execution status of this line is deduced): blockSig = false;
-
204 wasDeleted = false; // double-delete catcher
executed (the execution status of this line is deduced): wasDeleted = false;
-
205 isDeletingChildren = false; // set by deleteChildren()
executed (the execution status of this line is deduced): isDeletingChildren = false;
-
206 sendChildEvents = true; // if we should send ChildInsert and ChildRemove events to parent
executed (the execution status of this line is deduced): sendChildEvents = true;
-
207 receiveChildEvents = true;
executed (the execution status of this line is deduced): receiveChildEvents = true;
-
208 postedEvents = 0;
executed (the execution status of this line is deduced): postedEvents = 0;
-
209 extraData = 0;
executed (the execution status of this line is deduced): extraData = 0;
-
210 connectedSignals[0] = connectedSignals[1] = 0;
executed (the execution status of this line is deduced): connectedSignals[0] = connectedSignals[1] = 0;
-
211 metaObject = 0;
executed (the execution status of this line is deduced): metaObject = 0;
-
212 isWindow = false;
executed (the execution status of this line is deduced): isWindow = false;
-
213}
executed: }
Execution Count:3603234
3603234
214 -
215QObjectPrivate::~QObjectPrivate() -
216{ -
217 if (extraData && !extraData->runningTimers.isEmpty()) {
evaluated: extraData
TRUEFALSE
yes
Evaluation Count:44067
yes
Evaluation Count:3556836
evaluated: !extraData->runningTimers.isEmpty()
TRUEFALSE
yes
Evaluation Count:738
yes
Evaluation Count:43329
738-3556836
218 // unregister pending timers -
219 if (threadData->eventDispatcher)
evaluated: threadData->eventDispatcher
TRUEFALSE
yes
Evaluation Count:680
yes
Evaluation Count:58
58-680
220 threadData->eventDispatcher->unregisterTimers(q_ptr);
executed: threadData->eventDispatcher->unregisterTimers(q_ptr);
Execution Count:680
680
221 -
222 // release the timer ids back to the pool -
223 for (int i = 0; i < extraData->runningTimers.size(); ++i)
evaluated: i < extraData->runningTimers.size()
TRUEFALSE
yes
Evaluation Count:775
yes
Evaluation Count:738
738-775
224 QAbstractEventDispatcherPrivate::releaseTimerId(extraData->runningTimers.at(i));
executed: QAbstractEventDispatcherPrivate::releaseTimerId(extraData->runningTimers.at(i));
Execution Count:775
775
225 }
executed: }
Execution Count:738
738
226 -
227 if (postedEvents)
evaluated: postedEvents
TRUEFALSE
yes
Evaluation Count:6443
yes
Evaluation Count:3594451
6443-3594451
228 QCoreApplication::removePostedEvents(q_ptr, 0);
executed: QCoreApplication::removePostedEvents(q_ptr, 0);
Execution Count:6443
6443
229 -
230 threadData->deref();
executed (the execution status of this line is deduced): threadData->deref();
-
231 -
232 if (metaObject) metaObject->objectDestroyed(q_ptr);
never executed: metaObject->objectDestroyed(q_ptr);
partially evaluated: metaObject
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3600895
0-3600895
233 -
234#ifndef QT_NO_USERDATA -
235 if (extraData)
evaluated: extraData
TRUEFALSE
yes
Evaluation Count:44067
yes
Evaluation Count:3556863
44067-3556863
236 qDeleteAll(extraData->userData);
executed: qDeleteAll(extraData->userData);
Execution Count:44067
44067
237#endif -
238 delete extraData;
executed (the execution status of this line is deduced): delete extraData;
-
239}
executed: }
Execution Count:3600894
3600894
240 -
241/*! -
242 \internal -
243 For a given metaobject, compute the signal offset, and the method offset (including signals) -
244*/ -
245static void computeOffsets(const QMetaObject *metaobject, int *signalOffset, int *methodOffset) -
246{ -
247 *signalOffset = *methodOffset = 0;
executed (the execution status of this line is deduced): *signalOffset = *methodOffset = 0;
-
248 const QMetaObject *m = metaobject->d.superdata;
executed (the execution status of this line is deduced): const QMetaObject *m = metaobject->d.superdata;
-
249 while (m) {
evaluated: m
TRUEFALSE
yes
Evaluation Count:9243
yes
Evaluation Count:206893
9243-206893
250 const QMetaObjectPrivate *d = QMetaObjectPrivate::get(m);
executed (the execution status of this line is deduced): const QMetaObjectPrivate *d = QMetaObjectPrivate::get(m);
-
251 *methodOffset += d->methodCount;
executed (the execution status of this line is deduced): *methodOffset += d->methodCount;
-
252 Q_ASSERT(d->revision >= 4);
executed (the execution status of this line is deduced): qt_noop();
-
253 *signalOffset += d->signalCount;
executed (the execution status of this line is deduced): *signalOffset += d->signalCount;
-
254 m = m->d.superdata;
executed (the execution status of this line is deduced): m = m->d.superdata;
-
255 }
executed: }
Execution Count:9243
9243
256}
executed: }
Execution Count:206893
206893
257 -
258/* -
259 This vector contains the all connections from an object. -
260 -
261 Each object may have one vector containing the lists of -
262 connections for a given signal. The index in the vector correspond -
263 to the signal index. The signal index is the one returned by -
264 QObjectPrivate::signalIndex (not QMetaObject::indexOfSignal). -
265 Negative index means connections to all signals. -
266 -
267 This vector is protected by the object mutex (signalSlotMutexes()) -
268 -
269 Each Connection is also part of a 'senders' linked list. The mutex -
270 of the receiver must be locked when touching the pointers of this -
271 linked list. -
272*/ -
273class QObjectConnectionListVector : public QVector<QObjectPrivate::ConnectionList> -
274{ -
275public: -
276 bool orphaned; //the QObject owner of this vector has been destroyed while the vector was inUse -
277 bool dirty; //some Connection have been disconnected (their receiver is 0) but not removed from the list yet -
278 int inUse; //number of functions that are currently accessing this object or its connections -
279 QObjectPrivate::ConnectionList allsignals; -
280 -
281 QObjectConnectionListVector() -
282 : QVector<QObjectPrivate::ConnectionList>(), orphaned(false), dirty(false), inUse(0) -
283 { }
executed: }
Execution Count:67047
67047
284 -
285 QObjectPrivate::ConnectionList &operator[](int at) -
286 { -
287 if (at < 0)
evaluated: at < 0
TRUEFALSE
yes
Evaluation Count:173944
yes
Evaluation Count:1427457
173944-1427457
288 return allsignals;
executed: return allsignals;
Execution Count:173944
173944
289 return QVector<QObjectPrivate::ConnectionList>::operator[](at);
executed: return QVector<QObjectPrivate::ConnectionList>::operator[](at);
Execution Count:1427458
1427458
290 } -
291}; -
292 -
293// Used by QAccessibleWidget -
294bool QObjectPrivate::isSender(const QObject *receiver, const char *signal) const -
295{ -
296 Q_Q(const QObject);
never executed (the execution status of this line is deduced): const QObject * const q = q_func();
-
297 int signal_index = signalIndex(signal);
never executed (the execution status of this line is deduced): int signal_index = signalIndex(signal);
-
298 if (signal_index < 0)
never evaluated: signal_index < 0
0
299 return false;
never executed: return false;
0
300 QMutexLocker locker(signalSlotLock(q));
never executed (the execution status of this line is deduced): QMutexLocker locker(signalSlotLock(q));
-
301 if (connectionLists) {
never evaluated: connectionLists
0
302 if (signal_index < connectionLists->count()) {
never evaluated: signal_index < connectionLists->count()
0
303 const QObjectPrivate::Connection *c =
never executed (the execution status of this line is deduced): const QObjectPrivate::Connection *c =
-
304 connectionLists->at(signal_index).first;
never executed (the execution status of this line is deduced): connectionLists->at(signal_index).first;
-
305 -
306 while (c) {
never evaluated: c
0
307 if (c->receiver == receiver)
never evaluated: c->receiver == receiver
0
308 return true;
never executed: return true;
0
309 c = c->nextConnectionList;
never executed (the execution status of this line is deduced): c = c->nextConnectionList;
-
310 }
never executed: }
0
311 }
never executed: }
0
312 }
never executed: }
0
313 return false;
never executed: return false;
0
314} -
315 -
316// Used by QAccessibleWidget -
317QObjectList QObjectPrivate::receiverList(const char *signal) const -
318{ -
319 Q_Q(const QObject);
never executed (the execution status of this line is deduced): const QObject * const q = q_func();
-
320 QObjectList returnValue;
never executed (the execution status of this line is deduced): QObjectList returnValue;
-
321 int signal_index = signalIndex(signal);
never executed (the execution status of this line is deduced): int signal_index = signalIndex(signal);
-
322 if (signal_index < 0)
never evaluated: signal_index < 0
0
323 return returnValue;
never executed: return returnValue;
0
324 QMutexLocker locker(signalSlotLock(q));
never executed (the execution status of this line is deduced): QMutexLocker locker(signalSlotLock(q));
-
325 if (connectionLists) {
never evaluated: connectionLists
0
326 if (signal_index < connectionLists->count()) {
never evaluated: signal_index < connectionLists->count()
0
327 const QObjectPrivate::Connection *c = connectionLists->at(signal_index).first;
never executed (the execution status of this line is deduced): const QObjectPrivate::Connection *c = connectionLists->at(signal_index).first;
-
328 -
329 while (c) {
never evaluated: c
0
330 if (c->receiver)
never evaluated: c->receiver
0
331 returnValue << c->receiver;
never executed: returnValue << c->receiver;
0
332 c = c->nextConnectionList;
never executed (the execution status of this line is deduced): c = c->nextConnectionList;
-
333 }
never executed: }
0
334 }
never executed: }
0
335 }
never executed: }
0
336 return returnValue;
never executed: return returnValue;
0
337} -
338 -
339// Used by QAccessibleWidget -
340QObjectList QObjectPrivate::senderList() const -
341{ -
342 QObjectList returnValue;
never executed (the execution status of this line is deduced): QObjectList returnValue;
-
343 QMutexLocker locker(signalSlotLock(q_func()));
never executed (the execution status of this line is deduced): QMutexLocker locker(signalSlotLock(q_func()));
-
344 for (Connection *c = senders; c; c = c->next)
never evaluated: c
0
345 returnValue << c->sender;
never executed: returnValue << c->sender;
0
346 return returnValue;
never executed: return returnValue;
0
347} -
348 -
349/*! -
350 \internal -
351 Add the connection \a c to the list of connections of the sender's object -
352 for the specified \a signal -
353 -
354 The signalSlotLock() of the sender and receiver must be locked while calling -
355 this function -
356 -
357 Will also add the connection in the sender's list of the receiver. -
358 */ -
359void QObjectPrivate::addConnection(int signal, Connection *c) -
360{ -
361 Q_ASSERT(c->sender == q_ptr);
executed (the execution status of this line is deduced): qt_noop();
-
362 if (!connectionLists)
evaluated: !connectionLists
TRUEFALSE
yes
Evaluation Count:67045
yes
Evaluation Count:375159
67045-375159
363 connectionLists = new QObjectConnectionListVector();
executed: connectionLists = new QObjectConnectionListVector();
Execution Count:67046
67046
364 if (signal >= connectionLists->count())
evaluated: signal >= connectionLists->count()
TRUEFALSE
yes
Evaluation Count:136394
yes
Evaluation Count:305814
136394-305814
365 connectionLists->resize(signal + 1);
executed: connectionLists->resize(signal + 1);
Execution Count:136394
136394
366 -
367 ConnectionList &connectionList = (*connectionLists)[signal];
executed (the execution status of this line is deduced): ConnectionList &connectionList = (*connectionLists)[signal];
-
368 if (connectionList.last) {
evaluated: connectionList.last
TRUEFALSE
yes
Evaluation Count:247837
yes
Evaluation Count:194367
194367-247837
369 connectionList.last->nextConnectionList = c;
executed (the execution status of this line is deduced): connectionList.last->nextConnectionList = c;
-
370 } else {
executed: }
Execution Count:247837
247837
371 connectionList.first = c;
executed (the execution status of this line is deduced): connectionList.first = c;
-
372 }
executed: }
Execution Count:194366
194366
373 connectionList.last = c;
executed (the execution status of this line is deduced): connectionList.last = c;
-
374 -
375 cleanConnectionLists();
executed (the execution status of this line is deduced): cleanConnectionLists();
-
376 -
377 c->prev = &(QObjectPrivate::get(c->receiver)->senders);
executed (the execution status of this line is deduced): c->prev = &(QObjectPrivate::get(c->receiver)->senders);
-
378 c->next = *c->prev;
executed (the execution status of this line is deduced): c->next = *c->prev;
-
379 *c->prev = c;
executed (the execution status of this line is deduced): *c->prev = c;
-
380 if (c->next)
evaluated: c->next
TRUEFALSE
yes
Evaluation Count:278291
yes
Evaluation Count:163913
163913-278291
381 c->next->prev = &c->next;
executed: c->next->prev = &c->next;
Execution Count:278291
278291
382 -
383 if (signal < 0) {
evaluated: signal < 0
TRUEFALSE
yes
Evaluation Count:319
yes
Evaluation Count:441883
319-441883
384 connectedSignals[0] = connectedSignals[1] = ~0;
executed (the execution status of this line is deduced): connectedSignals[0] = connectedSignals[1] = ~0;
-
385 } else if (signal < (int)sizeof(connectedSignals) * 8) {
executed: }
Execution Count:319
evaluated: signal < (int)sizeof(connectedSignals) * 8
TRUEFALSE
yes
Evaluation Count:441880
yes
Evaluation Count:2
2-441880
386 connectedSignals[signal >> 5] |= (1 << (signal & 0x1f));
executed (the execution status of this line is deduced): connectedSignals[signal >> 5] |= (1 << (signal & 0x1f));
-
387 }
executed: }
Execution Count:441881
441881
388} -
389 -
390void QObjectPrivate::cleanConnectionLists() -
391{ -
392 if (connectionLists->dirty && !connectionLists->inUse) {
evaluated: connectionLists->dirty
TRUEFALSE
yes
Evaluation Count:105701
yes
Evaluation Count:336502
evaluated: !connectionLists->inUse
TRUEFALSE
yes
Evaluation Count:105527
yes
Evaluation Count:174
174-336502
393 // remove broken connections -
394 for (int signal = -1; signal < connectionLists->count(); ++signal) {
evaluated: signal < connectionLists->count()
TRUEFALSE
yes
Evaluation Count:457597
yes
Evaluation Count:105527
105527-457597
395 QObjectPrivate::ConnectionList &connectionList =
executed (the execution status of this line is deduced): QObjectPrivate::ConnectionList &connectionList =
-
396 (*connectionLists)[signal];
executed (the execution status of this line is deduced): (*connectionLists)[signal];
-
397 -
398 // Set to the last entry in the connection list that was *not* -
399 // deleted. This is needed to update the list's last pointer -
400 // at the end of the cleanup. -
401 QObjectPrivate::Connection *last = 0;
executed (the execution status of this line is deduced): QObjectPrivate::Connection *last = 0;
-
402 -
403 QObjectPrivate::Connection **prev = &connectionList.first;
executed (the execution status of this line is deduced): QObjectPrivate::Connection **prev = &connectionList.first;
-
404 QObjectPrivate::Connection *c = *prev;
executed (the execution status of this line is deduced): QObjectPrivate::Connection *c = *prev;
-
405 while (c) {
evaluated: c
TRUEFALSE
yes
Evaluation Count:304553
yes
Evaluation Count:457597
304553-457597
406 if (c->receiver) {
evaluated: c->receiver
TRUEFALSE
yes
Evaluation Count:171401
yes
Evaluation Count:133152
133152-171401
407 last = c;
executed (the execution status of this line is deduced): last = c;
-
408 prev = &c->nextConnectionList;
executed (the execution status of this line is deduced): prev = &c->nextConnectionList;
-
409 c = *prev;
executed (the execution status of this line is deduced): c = *prev;
-
410 } else {
executed: }
Execution Count:171401
171401
411 QObjectPrivate::Connection *next = c->nextConnectionList;
executed (the execution status of this line is deduced): QObjectPrivate::Connection *next = c->nextConnectionList;
-
412 *prev = next;
executed (the execution status of this line is deduced): *prev = next;
-
413 c->deref();
executed (the execution status of this line is deduced): c->deref();
-
414 c = next;
executed (the execution status of this line is deduced): c = next;
-
415 }
executed: }
Execution Count:133152
133152
416 } -
417 -
418 // Correct the connection list's last pointer. -
419 // As conectionList.last could equal last, this could be a noop -
420 connectionList.last = last;
executed (the execution status of this line is deduced): connectionList.last = last;
-
421 }
executed: }
Execution Count:457597
457597
422 connectionLists->dirty = false;
executed (the execution status of this line is deduced): connectionLists->dirty = false;
-
423 }
executed: }
Execution Count:105527
105527
424}
executed: }
Execution Count:442203
442203
425 -
426/*! -
427 \internal -
428 */ -
429QMetaCallEvent::QMetaCallEvent(ushort method_offset, ushort method_relative, QObjectPrivate::StaticMetaCallFunction callFunction, -
430 const QObject *sender, int signalId, -
431 int nargs, int *types, void **args, QSemaphore *semaphore) -
432 : QEvent(MetaCall), slotObj_(0), sender_(sender), signalId_(signalId), -
433 nargs_(nargs), types_(types), args_(args), semaphore_(semaphore), -
434 callFunction_(callFunction), method_offset_(method_offset), method_relative_(method_relative) -
435{ }
executed: }
Execution Count:90148
90148
436 -
437/*! -
438 \internal -
439 */ -
440QMetaCallEvent::QMetaCallEvent(QtPrivate::QSlotObjectBase *slotO, const QObject *sender, int signalId, -
441 int nargs, int *types, void **args, QSemaphore *semaphore) -
442 : QEvent(MetaCall), slotObj_(slotO), sender_(sender), signalId_(signalId), -
443 nargs_(nargs), types_(types), args_(args), semaphore_(semaphore), -
444 callFunction_(0), method_offset_(0), method_relative_(ushort(-1)) -
445{ -
446 if (slotObj_)
partially evaluated: slotObj_
TRUEFALSE
yes
Evaluation Count:67
no
Evaluation Count:0
0-67
447 slotObj_->ref();
executed: slotObj_->ref();
Execution Count:67
67
448}
executed: }
Execution Count:67
67
449 -
450/*! -
451 \internal -
452 */ -
453QMetaCallEvent::~QMetaCallEvent() -
454{ -
455 if (types_) {
evaluated: types_
TRUEFALSE
yes
Evaluation Count:90172
yes
Evaluation Count:737
737-90172
456 for (int i = 0; i < nargs_; ++i) {
evaluated: i < nargs_
TRUEFALSE
yes
Evaluation Count:139988
yes
Evaluation Count:90183
90183-139988
457 if (types_[i] && args_[i])
evaluated: types_[i]
TRUEFALSE
yes
Evaluation Count:49834
yes
Evaluation Count:90173
partially evaluated: args_[i]
TRUEFALSE
yes
Evaluation Count:49837
no
Evaluation Count:0
0-90173
458 QMetaType::destroy(types_[i], args_[i]);
executed: QMetaType::destroy(types_[i], args_[i]);
Execution Count:49837
49837
459 }
executed: }
Execution Count:140008
140008
460 free(types_);
executed (the execution status of this line is deduced): free(types_);
-
461 free(args_);
executed (the execution status of this line is deduced): free(args_);
-
462 }
executed: }
Execution Count:90196
90196
463#ifndef QT_NO_THREAD -
464 if (semaphore_)
evaluated: semaphore_
TRUEFALSE
yes
Evaluation Count:574
yes
Evaluation Count:90359
574-90359
465 semaphore_->release();
executed: semaphore_->release();
Execution Count:574
574
466#endif -
467 if (slotObj_)
evaluated: slotObj_
TRUEFALSE
yes
Evaluation Count:67
yes
Evaluation Count:90866
67-90866
468 slotObj_->destroyIfLastRef();
executed: slotObj_->destroyIfLastRef();
Execution Count:67
67
469}
executed: }
Execution Count:90932
90932
470 -
471/*! -
472 \internal -
473 */ -
474void QMetaCallEvent::placeMetaCall(QObject *object) -
475{ -
476 if (slotObj_) {
evaluated: slotObj_
TRUEFALSE
yes
Evaluation Count:67
yes
Evaluation Count:84794
67-84794
477 slotObj_->call(object, args_);
executed (the execution status of this line is deduced): slotObj_->call(object, args_);
-
478 } else if (callFunction_ && method_offset_ <= object->metaObject()->methodOffset()) {
executed: }
Execution Count:67
evaluated: callFunction_
TRUEFALSE
yes
Evaluation Count:84789
yes
Evaluation Count:7
evaluated: method_offset_ <= object->metaObject()->methodOffset()
TRUEFALSE
yes
Evaluation Count:84801
yes
Evaluation Count:1
1-84801
479 callFunction_(object, QMetaObject::InvokeMetaMethod, method_relative_, args_);
executed (the execution status of this line is deduced): callFunction_(object, QMetaObject::InvokeMetaMethod, method_relative_, args_);
-
480 } else {
executed: }
Execution Count:84820
84820
481 QMetaObject::metacall(object, QMetaObject::InvokeMetaMethod, method_offset_ + method_relative_, args_);
executed (the execution status of this line is deduced): QMetaObject::metacall(object, QMetaObject::InvokeMetaMethod, method_offset_ + method_relative_, args_);
-
482 }
executed: }
Execution Count:8
8
483} -
484 -
485/*! -
486 \class QObject -
487 \inmodule QtCore -
488 \brief The QObject class is the base class of all Qt objects. -
489 -
490 \ingroup objectmodel -
491 -
492 \reentrant -
493 -
494 QObject is the heart of the Qt \l{Object Model}. The central -
495 feature in this model is a very powerful mechanism for seamless -
496 object communication called \l{signals and slots}. You can -
497 connect a signal to a slot with connect() and destroy the -
498 connection with disconnect(). To avoid never ending notification -
499 loops you can temporarily block signals with blockSignals(). The -
500 protected functions connectNotify() and disconnectNotify() make -
501 it possible to track connections. -
502 -
503 QObjects organize themselves in \l {Object Trees & Ownership} -
504 {object trees}. When you create a QObject with another object as -
505 parent, the object will automatically add itself to the parent's -
506 children() list. The parent takes ownership of the object; i.e., -
507 it will automatically delete its children in its destructor. You -
508 can look for an object by name and optionally type using -
509 findChild() or findChildren(). -
510 -
511 Every object has an objectName() and its class name can be found -
512 via the corresponding metaObject() (see QMetaObject::className()). -
513 You can determine whether the object's class inherits another -
514 class in the QObject inheritance hierarchy by using the -
515 inherits() function. -
516 -
517 When an object is deleted, it emits a destroyed() signal. You can -
518 catch this signal to avoid dangling references to QObjects. -
519 -
520 QObjects can receive events through event() and filter the events -
521 of other objects. See installEventFilter() and eventFilter() for -
522 details. A convenience handler, childEvent(), can be reimplemented -
523 to catch child events. -
524 -
525 Events are delivered in the thread in which the object was -
526 created; see \l{Thread Support in Qt} and thread() for details. -
527 Note that event processing is not done at all for QObjects with no -
528 thread affinity (thread() returns zero). Use the moveToThread() -
529 function to change the thread affinity for an object and its -
530 children (the object cannot be moved if it has a parent). -
531 -
532 Last but not least, QObject provides the basic timer support in -
533 Qt; see QTimer for high-level support for timers. -
534 -
535 Notice that the Q_OBJECT macro is mandatory for any object that -
536 implements signals, slots or properties. You also need to run the -
537 \l{moc}{Meta Object Compiler} on the source file. We strongly -
538 recommend the use of this macro in all subclasses of QObject -
539 regardless of whether or not they actually use signals, slots and -
540 properties, since failure to do so may lead certain functions to -
541 exhibit strange behavior. -
542 -
543 All Qt widgets inherit QObject. The convenience function -
544 isWidgetType() returns whether an object is actually a widget. It -
545 is much faster than -
546 \l{qobject_cast()}{qobject_cast}<QWidget *>(\e{obj}) or -
547 \e{obj}->\l{inherits()}{inherits}("QWidget"). -
548 -
549 Some QObject functions, e.g. children(), return a QObjectList. -
550 QObjectList is a typedef for QList<QObject *>. -
551 -
552 \target No copy constructor -
553 \section1 No copy constructor or assignment operator -
554 -
555 QObject has neither a copy constructor nor an assignment operator. -
556 This is by design. Actually, they are declared, but in a -
557 \c{private} section with the macro Q_DISABLE_COPY(). In fact, all -
558 Qt classes derived from QObject (direct or indirect) use this -
559 macro to declare their copy constructor and assignment operator to -
560 be private. The reasoning is found in the discussion on -
561 \l{Identity vs Value} {Identity vs Value} on the Qt \l{Object -
562 Model} page. -
563 -
564 The main consequence is that you should use pointers to QObject -
565 (or to your QObject subclass) where you might otherwise be tempted -
566 to use your QObject subclass as a value. For example, without a -
567 copy constructor, you can't use a subclass of QObject as the value -
568 to be stored in one of the container classes. You must store -
569 pointers. -
570 -
571 \section1 Auto-Connection -
572 -
573 Qt's meta-object system provides a mechanism to automatically connect -
574 signals and slots between QObject subclasses and their children. As long -
575 as objects are defined with suitable object names, and slots follow a -
576 simple naming convention, this connection can be performed at run-time -
577 by the QMetaObject::connectSlotsByName() function. -
578 -
579 \l uic generates code that invokes this function to enable -
580 auto-connection to be performed between widgets on forms created -
581 with \e{Qt Designer}. More information about using auto-connection with \e{Qt Designer} is -
582 given in the \l{Using a Designer UI File in Your Application} section of -
583 the \e{Qt Designer} manual. -
584 -
585 \section1 Dynamic Properties -
586 -
587 From Qt 4.2, dynamic properties can be added to and removed from QObject -
588 instances at run-time. Dynamic properties do not need to be declared at -
589 compile-time, yet they provide the same advantages as static properties -
590 and are manipulated using the same API - using property() to read them -
591 and setProperty() to write them. -
592 -
593 From Qt 4.3, dynamic properties are supported by -
594 \l{Qt Designer's Widget Editing Mode#The Property Editor}{Qt Designer}, -
595 and both standard Qt widgets and user-created forms can be given dynamic -
596 properties. -
597 -
598 \section1 Internationalization (i18n) -
599 -
600 All QObject subclasses support Qt's translation features, making it possible -
601 to translate an application's user interface into different languages. -
602 -
603 To make user-visible text translatable, it must be wrapped in calls to -
604 the tr() function. This is explained in detail in the -
605 \l{Writing Source Code for Translation} document. -
606 -
607 \sa QMetaObject, QPointer, QObjectCleanupHandler, Q_DISABLE_COPY() -
608 \sa {Object Trees & Ownership} -
609*/ -
610 -
611/*! -
612 \relates QObject -
613 -
614 Returns a pointer to the object named \a name that inherits \a -
615 type and with a given \a parent. -
616 -
617 Returns 0 if there is no such child. -
618 -
619 \snippet code/src_corelib_kernel_qobject.cpp 0 -
620*/ -
621 -
622void *qt_find_obj_child(QObject *parent, const char *type, const QString &name) -
623{ -
624 QObjectList list = parent->children();
never executed (the execution status of this line is deduced): QObjectList list = parent->children();
-
625 if (list.size() == 0) return 0;
never executed: return 0;
never evaluated: list.size() == 0
0
626 for (int i = 0; i < list.size(); ++i) {
never evaluated: i < list.size()
0
627 QObject *obj = list.at(i);
never executed (the execution status of this line is deduced): QObject *obj = list.at(i);
-
628 if (name == obj->objectName() && obj->inherits(type))
never evaluated: name == obj->objectName()
never evaluated: obj->inherits(type)
0
629 return obj;
never executed: return obj;
0
630 }
never executed: }
0
631 return 0;
never executed: return 0;
0
632} -
633 -
634 -
635/***************************************************************************** -
636 QObject member functions -
637 *****************************************************************************/ -
638 -
639// check the constructor's parent thread argument -
640static bool check_parent_thread(QObject *parent, -
641 QThreadData *parentThreadData, -
642 QThreadData *currentThreadData) -
643{ -
644 if (parent && parentThreadData != currentThreadData) {
partially evaluated: parent
TRUEFALSE
yes
Evaluation Count:49403
no
Evaluation Count:0
partially evaluated: parentThreadData != currentThreadData
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:49404
0-49404
645 QThread *parentThread = parentThreadData->thread;
never executed (the execution status of this line is deduced): QThread *parentThread = parentThreadData->thread;
-
646 QThread *currentThread = currentThreadData->thread;
never executed (the execution status of this line is deduced): QThread *currentThread = currentThreadData->thread;
-
647 qWarning("QObject: Cannot create children for a parent that is in a different thread.\n"
never executed (the execution status of this line is deduced): QMessageLogger("kernel/qobject.cpp", 647, __PRETTY_FUNCTION__).warning("QObject: Cannot create children for a parent that is in a different thread.\n"
-
648 "(Parent is %s(%p), parent's thread is %s(%p), current thread is %s(%p)",
never executed (the execution status of this line is deduced): "(Parent is %s(%p), parent's thread is %s(%p), current thread is %s(%p)",
-
649 parent->metaObject()->className(),
never executed (the execution status of this line is deduced): parent->metaObject()->className(),
-
650 parent,
never executed (the execution status of this line is deduced): parent,
-
651 parentThread ? parentThread->metaObject()->className() : "QThread",
never executed (the execution status of this line is deduced): parentThread ? parentThread->metaObject()->className() : "QThread",
-
652 parentThread,
never executed (the execution status of this line is deduced): parentThread,
-
653 currentThread ? currentThread->metaObject()->className() : "QThread",
never executed (the execution status of this line is deduced): currentThread ? currentThread->metaObject()->className() : "QThread",
-
654 currentThread);
never executed (the execution status of this line is deduced): currentThread);
-
655 return false;
never executed: return false;
0
656 } -
657 return true;
executed: return true;
Execution Count:49403
49403
658} -
659 -
660/*! -
661 Constructs an object with parent object \a parent. -
662 -
663 The parent of an object may be viewed as the object's owner. For -
664 instance, a \l{QDialog}{dialog box} is the parent of the \uicontrol{OK} -
665 and \uicontrol{Cancel} buttons it contains. -
666 -
667 The destructor of a parent object destroys all child objects. -
668 -
669 Setting \a parent to 0 constructs an object with no parent. If the -
670 object is a widget, it will become a top-level window. -
671 -
672 \sa parent(), findChild(), findChildren() -
673*/ -
674 -
675QObject::QObject(QObject *parent) -
676 : d_ptr(new QObjectPrivate) -
677{ -
678 Q_D(QObject);
executed (the execution status of this line is deduced): QObjectPrivate * const d = d_func();
-
679 d_ptr->q_ptr = this;
executed (the execution status of this line is deduced): d_ptr->q_ptr = this;
-
680 d->threadData = (parent && !parent->thread()) ? parent->d_func()->threadData : QThreadData::current();
evaluated: parent
TRUEFALSE
yes
Evaluation Count:5260
yes
Evaluation Count:74467
evaluated: !parent->thread()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:5259
1-74467
681 d->threadData->ref();
executed (the execution status of this line is deduced): d->threadData->ref();
-
682 if (parent) {
evaluated: parent
TRUEFALSE
yes
Evaluation Count:5260
yes
Evaluation Count:74475
5260-74475
683 QT_TRY { -
684 if (!check_parent_thread(parent, parent ? parent->d_func()->threadData : 0, d->threadData))
partially evaluated: !check_parent_thread(parent, parent ? parent->d_func()->threadData : 0, d->threadData)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5260
0-5260
685 parent = 0;
never executed: parent = 0;
0
686 setParent(parent);
executed (the execution status of this line is deduced): setParent(parent);
-
687 } QT_CATCH(...) {
executed: }
Execution Count:5260
5260
688 d->threadData->deref();
never executed (the execution status of this line is deduced): d->threadData->deref();
-
689 QT_RETHROW;
never executed: throw;
0
690 } -
691 }
executed: }
Execution Count:5260
5260
692 qt_addObject(this);
executed (the execution status of this line is deduced): qt_addObject(this);
-
693}
executed: }
Execution Count:79730
79730
694 -
695/*! -
696 \internal -
697 */ -
698QObject::QObject(QObjectPrivate &dd, QObject *parent) -
699 : d_ptr(&dd) -
700{ -
701 Q_D(QObject);
executed (the execution status of this line is deduced): QObjectPrivate * const d = d_func();
-
702 d_ptr->q_ptr = this;
executed (the execution status of this line is deduced): d_ptr->q_ptr = this;
-
703 d->threadData = (parent && !parent->thread()) ? parent->d_func()->threadData : QThreadData::current();
evaluated: parent
TRUEFALSE
yes
Evaluation Count:44140
yes
Evaluation Count:3479364
partially evaluated: !parent->thread()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:44141
0-3479364
704 d->threadData->ref();
executed (the execution status of this line is deduced): d->threadData->ref();
-
705 if (parent) {
evaluated: parent
TRUEFALSE
yes
Evaluation Count:44143
yes
Evaluation Count:3479370
44143-3479370
706 QT_TRY { -
707 if (!check_parent_thread(parent, parent ? parent->d_func()->threadData : 0, d->threadData))
partially evaluated: !check_parent_thread(parent, parent ? parent->d_func()->threadData : 0, d->threadData)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:44143
0-44143
708 parent = 0;
never executed: parent = 0;
0
709 if (d->isWidget) {
partially evaluated: d->isWidget
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:44143
0-44143
710 if (parent) {
never evaluated: parent
0
711 d->parent = parent;
never executed (the execution status of this line is deduced): d->parent = parent;
-
712 d->parent->d_func()->children.append(this);
never executed (the execution status of this line is deduced): d->parent->d_func()->children.append(this);
-
713 }
never executed: }
0
714 // no events sent here, this is done at the end of the QWidget constructor -
715 } else {
never executed: }
0
716 setParent(parent);
executed (the execution status of this line is deduced): setParent(parent);
-
717 }
executed: }
Execution Count:44139
44139
718 } QT_CATCH(...) { -
719 d->threadData->deref();
never executed (the execution status of this line is deduced): d->threadData->deref();
-
720 QT_RETHROW;
never executed: throw;
0
721 } -
722 }
executed: }
Execution Count:44139
44139
723 qt_addObject(this);
executed (the execution status of this line is deduced): qt_addObject(this);
-
724}
executed: }
Execution Count:3523506
3523506
725 -
726/*! -
727 Destroys the object, deleting all its child objects. -
728 -
729 All signals to and from the object are automatically disconnected, and -
730 any pending posted events for the object are removed from the event -
731 queue. However, it is often safer to use deleteLater() rather than -
732 deleting a QObject subclass directly. -
733 -
734 \warning All child objects are deleted. If any of these objects -
735 are on the stack or global, sooner or later your program will -
736 crash. We do not recommend holding pointers to child objects from -
737 outside the parent. If you still do, the destroyed() signal gives -
738 you an opportunity to detect when an object is destroyed. -
739 -
740 \warning Deleting a QObject while pending events are waiting to -
741 be delivered can cause a crash. You must not delete the QObject -
742 directly if it exists in a different thread than the one currently -
743 executing. Use deleteLater() instead, which will cause the event -
744 loop to delete the object after all pending events have been -
745 delivered to it. -
746 -
747 \sa deleteLater() -
748*/ -
749 -
750QObject::~QObject() -
751{ -
752 Q_D(QObject);
executed (the execution status of this line is deduced): QObjectPrivate * const d = d_func();
-
753 d->wasDeleted = true;
executed (the execution status of this line is deduced): d->wasDeleted = true;
-
754 d->blockSig = 0; // unblock signals so we always emit destroyed()
executed (the execution status of this line is deduced): d->blockSig = 0;
-
755 -
756 QtSharedPointer::ExternalRefCountData *sharedRefcount = d->sharedRefcount.load();
executed (the execution status of this line is deduced): QtSharedPointer::ExternalRefCountData *sharedRefcount = d->sharedRefcount.load();
-
757 if (sharedRefcount) {
evaluated: sharedRefcount
TRUEFALSE
yes
Evaluation Count:28683
yes
Evaluation Count:3572315
28683-3572315
758 if (sharedRefcount->strongref.load() > 0) {
partially evaluated: sharedRefcount->strongref.load() > 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:28682
0-28682
759 qWarning("QObject: shared QObject was deleted directly. The program is malformed and may crash.");
never executed (the execution status of this line is deduced): QMessageLogger("kernel/qobject.cpp", 759, __PRETTY_FUNCTION__).warning("QObject: shared QObject was deleted directly. The program is malformed and may crash.");
-
760 // but continue deleting, it's too late to stop anyway -
761 }
never executed: }
0
762 -
763 // indicate to all QWeakPointers that this QObject has now been deleted -
764 sharedRefcount->strongref.store(0);
executed (the execution status of this line is deduced): sharedRefcount->strongref.store(0);
-
765 if (!sharedRefcount->weakref.deref())
evaluated: !sharedRefcount->weakref.deref()
TRUEFALSE
yes
Evaluation Count:13250
yes
Evaluation Count:15433
13250-15433
766 delete sharedRefcount;
executed: delete sharedRefcount;
Execution Count:13249
13249
767 }
executed: }
Execution Count:28682
28682
768 -
769 if (!d->isWidget && d->isSignalConnected(0)) {
evaluated: !d->isWidget
TRUEFALSE
yes
Evaluation Count:3568884
yes
Evaluation Count:32099
evaluated: d->isSignalConnected(0)
TRUEFALSE
yes
Evaluation Count:5009
yes
Evaluation Count:3563894
5009-3568884
770 QT_TRY { -
771 emit destroyed(this);
executed (the execution status of this line is deduced): destroyed(this);
-
772 } QT_CATCH(...) {
executed: }
Execution Count:5009
5009
773 // all the signal/slots connections are still in place - if we don't -
774 // quit now, we will crash pretty soon. -
775 qWarning("Detected an unexpected exception in ~QObject while emitting destroyed().");
never executed (the execution status of this line is deduced): QMessageLogger("kernel/qobject.cpp", 775, __PRETTY_FUNCTION__).warning("Detected an unexpected exception in ~QObject while emitting destroyed().");
-
776 QT_RETHROW;
never executed: throw;
0
777 } -
778 }
executed: }
Execution Count:5009
5009
779 -
780 if (d->declarativeData)
partially evaluated: d->declarativeData
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3601006
0-3601006
781 QAbstractDeclarativeData::destroyed(d->declarativeData, this);
never executed: QAbstractDeclarativeData::destroyed(d->declarativeData, this);
0
782 -
783 // set ref to zero to indicate that this object has been deleted -
784 if (d->currentSender != 0)
evaluated: d->currentSender != 0
TRUEFALSE
yes
Evaluation Count:30
yes
Evaluation Count:3600957
30-3600957
785 d->currentSender->ref = 0;
executed: d->currentSender->ref = 0;
Execution Count:30
30
786 d->currentSender = 0;
executed (the execution status of this line is deduced): d->currentSender = 0;
-
787 -
788 if (d->connectionLists || d->senders) {
evaluated: d->connectionLists
TRUEFALSE
yes
Evaluation Count:66072
yes
Evaluation Count:3534915
evaluated: d->senders
TRUEFALSE
yes
Evaluation Count:52783
yes
Evaluation Count:3482131
52783-3534915
789 QMutex *signalSlotMutex = signalSlotLock(this);
executed (the execution status of this line is deduced): QMutex *signalSlotMutex = signalSlotLock(this);
-
790 QMutexLocker locker(signalSlotMutex);
executed (the execution status of this line is deduced): QMutexLocker locker(signalSlotMutex);
-
791 -
792 // disconnect all receivers -
793 if (d->connectionLists) {
evaluated: d->connectionLists
TRUEFALSE
yes
Evaluation Count:66072
yes
Evaluation Count:52783
52783-66072
794 ++d->connectionLists->inUse;
executed (the execution status of this line is deduced): ++d->connectionLists->inUse;
-
795 int connectionListsCount = d->connectionLists->count();
executed (the execution status of this line is deduced): int connectionListsCount = d->connectionLists->count();
-
796 for (int signal = -1; signal < connectionListsCount; ++signal) {
evaluated: signal < connectionListsCount
TRUEFALSE
yes
Evaluation Count:567107
yes
Evaluation Count:66072
66072-567107
797 QObjectPrivate::ConnectionList &connectionList =
executed (the execution status of this line is deduced): QObjectPrivate::ConnectionList &connectionList =
-
798 (*d->connectionLists)[signal];
executed (the execution status of this line is deduced): (*d->connectionLists)[signal];
-
799 -
800 while (QObjectPrivate::Connection *c = connectionList.first) {
evaluated: QObjectPrivate::Connection *c = connectionList.first
TRUEFALSE
yes
Evaluation Count:294632
yes
Evaluation Count:567110
294632-567110
801 if (!c->receiver) {
evaluated: !c->receiver
TRUEFALSE
yes
Evaluation Count:107392
yes
Evaluation Count:187244
107392-187244
802 connectionList.first = c->nextConnectionList;
executed (the execution status of this line is deduced): connectionList.first = c->nextConnectionList;
-
803 c->deref();
executed (the execution status of this line is deduced): c->deref();
-
804 continue;
executed: continue;
Execution Count:107394
107394
805 } -
806 -
807 QMutex *m = signalSlotLock(c->receiver);
executed (the execution status of this line is deduced): QMutex *m = signalSlotLock(c->receiver);
-
808 bool needToUnlock = QOrderedMutexLocker::relock(signalSlotMutex, m);
executed (the execution status of this line is deduced): bool needToUnlock = QOrderedMutexLocker::relock(signalSlotMutex, m);
-
809 -
810 if (c->receiver) {
evaluated: c->receiver
TRUEFALSE
yes
Evaluation Count:187206
yes
Evaluation Count:38
38-187206
811 *c->prev = c->next;
executed (the execution status of this line is deduced): *c->prev = c->next;
-
812 if (c->next) c->next->prev = c->prev;
executed: c->next->prev = c->prev;
Execution Count:114428
evaluated: c->next
TRUEFALSE
yes
Evaluation Count:114428
yes
Evaluation Count:72778
72778-114428
813 }
executed: }
Execution Count:187206
187206
814 c->receiver = 0;
executed (the execution status of this line is deduced): c->receiver = 0;
-
815 if (needToUnlock)
evaluated: needToUnlock
TRUEFALSE
yes
Evaluation Count:179475
yes
Evaluation Count:7770
7770-179475
816 m->unlock();
executed: m->unlock();
Execution Count:179475
179475
817 -
818 connectionList.first = c->nextConnectionList;
executed (the execution status of this line is deduced): connectionList.first = c->nextConnectionList;
-
819 c->deref();
executed (the execution status of this line is deduced): c->deref();
-
820 }
executed: }
Execution Count:187245
187245
821 }
executed: }
Execution Count:567108
567108
822 -
823 if (!--d->connectionLists->inUse) {
evaluated: !--d->connectionLists->inUse
TRUEFALSE
yes
Evaluation Count:65998
yes
Evaluation Count:74
74-65998
824 delete d->connectionLists;
executed (the execution status of this line is deduced): delete d->connectionLists;
-
825 } else {
executed: }
Execution Count:65998
65998
826 d->connectionLists->orphaned = true;
executed (the execution status of this line is deduced): d->connectionLists->orphaned = true;
-
827 }
executed: }
Execution Count:74
74
828 d->connectionLists = 0;
executed (the execution status of this line is deduced): d->connectionLists = 0;
-
829 }
executed: }
Execution Count:66072
66072
830 -
831 // disconnect all senders -
832 QObjectPrivate::Connection *node = d->senders;
executed (the execution status of this line is deduced): QObjectPrivate::Connection *node = d->senders;
-
833 while (node) {
evaluated: node
TRUEFALSE
yes
Evaluation Count:125160
yes
Evaluation Count:118853
118853-125160
834 QObject *sender = node->sender;
executed (the execution status of this line is deduced): QObject *sender = node->sender;
-
835 QMutex *m = signalSlotLock(sender);
executed (the execution status of this line is deduced): QMutex *m = signalSlotLock(sender);
-
836 node->prev = &node;
executed (the execution status of this line is deduced): node->prev = &node;
-
837 bool needToUnlock = QOrderedMutexLocker::relock(signalSlotMutex, m);
executed (the execution status of this line is deduced): bool needToUnlock = QOrderedMutexLocker::relock(signalSlotMutex, m);
-
838 //the node has maybe been removed while the mutex was unlocked in relock? -
839 if (!node || node->sender != sender) {
evaluated: !node
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:125155
evaluated: node->sender != sender
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:125153
2-125155
840 m->unlock();
executed (the execution status of this line is deduced): m->unlock();
-
841 continue;
executed: continue;
Execution Count:9
9
842 } -
843 node->receiver = 0;
executed (the execution status of this line is deduced): node->receiver = 0;
-
844 QObjectConnectionListVector *senderLists = sender->d_func()->connectionLists;
executed (the execution status of this line is deduced): QObjectConnectionListVector *senderLists = sender->d_func()->connectionLists;
-
845 if (senderLists)
partially evaluated: senderLists
TRUEFALSE
yes
Evaluation Count:125153
no
Evaluation Count:0
0-125153
846 senderLists->dirty = true;
executed: senderLists->dirty = true;
Execution Count:125153
125153
847 -
848 int signal_index = node->signal_index;
executed (the execution status of this line is deduced): int signal_index = node->signal_index;
-
849 node = node->next;
executed (the execution status of this line is deduced): node = node->next;
-
850 if (needToUnlock)
evaluated: needToUnlock
TRUEFALSE
yes
Evaluation Count:124404
yes
Evaluation Count:749
749-124404
851 m->unlock();
executed: m->unlock();
Execution Count:124403
124403
852 sender->disconnectNotify(QMetaObjectPrivate::signal(sender->metaObject(), signal_index));
executed (the execution status of this line is deduced): sender->disconnectNotify(QMetaObjectPrivate::signal(sender->metaObject(), signal_index));
-
853 }
executed: }
Execution Count:125151
125151
854 }
executed: }
Execution Count:118853
118853
855 -
856 if (!d->children.isEmpty())
evaluated: !d->children.isEmpty()
TRUEFALSE
yes
Evaluation Count:8747
yes
Evaluation Count:3592234
8747-3592234
857 d->deleteChildren();
executed: d->deleteChildren();
Execution Count:8747
8747
858 -
859 qt_removeObject(this);
executed (the execution status of this line is deduced): qt_removeObject(this);
-
860 -
861 if (d->parent) // remove it from parent object
evaluated: d->parent
TRUEFALSE
yes
Evaluation Count:94109
yes
Evaluation Count:3506857
94109-3506857
862 d->setParent_helper(0);
executed: d->setParent_helper(0);
Execution Count:94109
94109
863}
executed: }
Execution Count:3600967
3600967
864 -
865QObjectPrivate::Connection::~Connection() -
866{ -
867 if (ownArgumentTypes) {
evaluated: ownArgumentTypes
TRUEFALSE
yes
Evaluation Count:427754
yes
Evaluation Count:35
35-427754
868 const int *v = argumentTypes.load();
executed (the execution status of this line is deduced): const int *v = argumentTypes.load();
-
869 if (v != &DIRECT_CONNECTION_ONLY)
partially evaluated: v != &DIRECT_CONNECTION_ONLY
TRUEFALSE
yes
Evaluation Count:427754
no
Evaluation Count:0
0-427754
870 delete [] v;
executed: delete [] v;
Execution Count:427753
427753
871 }
executed: }
Execution Count:427753
427753
872 if (isSlotObject)
evaluated: isSlotObject
TRUEFALSE
yes
Evaluation Count:2475
yes
Evaluation Count:425312
2475-425312
873 slotObj->destroyIfLastRef();
executed: slotObj->destroyIfLastRef();
Execution Count:2475
2475
874}
executed: }
Execution Count:427787
427787
875 -
876 -
877/*! -
878 \fn QMetaObject *QObject::metaObject() const -
879 -
880 Returns a pointer to the meta-object of this object. -
881 -
882 A meta-object contains information about a class that inherits -
883 QObject, e.g. class name, superclass name, properties, signals and -
884 slots. Every QObject subclass that contains the Q_OBJECT macro will have a -
885 meta-object. -
886 -
887 The meta-object information is required by the signal/slot -
888 connection mechanism and the property system. The inherits() -
889 function also makes use of the meta-object. -
890 -
891 If you have no pointer to an actual object instance but still -
892 want to access the meta-object of a class, you can use \l -
893 staticMetaObject. -
894 -
895 Example: -
896 -
897 \snippet code/src_corelib_kernel_qobject.cpp 1 -
898 -
899 \sa staticMetaObject -
900*/ -
901 -
902/*! -
903 \variable QObject::staticMetaObject -
904 -
905 This variable stores the meta-object for the class. -
906 -
907 A meta-object contains information about a class that inherits -
908 QObject, e.g. class name, superclass name, properties, signals and -
909 slots. Every class that contains the Q_OBJECT macro will also have -
910 a meta-object. -
911 -
912 The meta-object information is required by the signal/slot -
913 connection mechanism and the property system. The inherits() -
914 function also makes use of the meta-object. -
915 -
916 If you have a pointer to an object, you can use metaObject() to -
917 retrieve the meta-object associated with that object. -
918 -
919 Example: -
920 -
921 \snippet code/src_corelib_kernel_qobject.cpp 2 -
922 -
923 \sa metaObject() -
924*/ -
925 -
926/*! \fn T *qobject_cast<T *>(QObject *object) -
927 \relates QObject -
928 -
929 Returns the given \a object cast to type T if the object is of type -
930 T (or of a subclass); otherwise returns 0. If \a object is 0 then -
931 it will also return 0. -
932 -
933 The class T must inherit (directly or indirectly) QObject and be -
934 declared with the \l Q_OBJECT macro. -
935 -
936 A class is considered to inherit itself. -
937 -
938 Example: -
939 -
940 \snippet code/src_corelib_kernel_qobject.cpp 3 -
941 -
942 The qobject_cast() function behaves similarly to the standard C++ -
943 \c dynamic_cast(), with the advantages that it doesn't require -
944 RTTI support and it works across dynamic library boundaries. -
945 -
946 qobject_cast() can also be used in conjunction with interfaces; -
947 see the \l{tools/plugandpaint}{Plug & Paint} example for details. -
948 -
949 \warning If T isn't declared with the Q_OBJECT macro, this -
950 function's return value is undefined. -
951 -
952 \sa QObject::inherits() -
953*/ -
954 -
955/*! -
956 \fn bool QObject::inherits(const char *className) const -
957 -
958 Returns true if this object is an instance of a class that -
959 inherits \a className or a QObject subclass that inherits \a -
960 className; otherwise returns false. -
961 -
962 A class is considered to inherit itself. -
963 -
964 Example: -
965 -
966 \snippet code/src_corelib_kernel_qobject.cpp 4 -
967 -
968 If you need to determine whether an object is an instance of a particular -
969 class for the purpose of casting it, consider using qobject_cast<Type *>(object) -
970 instead. -
971 -
972 \sa metaObject(), qobject_cast() -
973*/ -
974 -
975/*! -
976 \property QObject::objectName -
977 -
978 \brief the name of this object -
979 -
980 You can find an object by name (and type) using findChild(). -
981 You can find a set of objects with findChildren(). -
982 -
983 \snippet code/src_corelib_kernel_qobject.cpp 5 -
984 -
985 By default, this property contains an empty string. -
986 -
987 \sa metaObject(), QMetaObject::className() -
988*/ -
989 -
990QString QObject::objectName() const -
991{ -
992 Q_D(const QObject);
executed (the execution status of this line is deduced): const QObjectPrivate * const d = d_func();
-
993 return d->extraData ? d->extraData->objectName : QString();
executed: return d->extraData ? d->extraData->objectName : QString();
Execution Count:1736049
1736049
994} -
995 -
996/* -
997 Sets the object's name to \a name. -
998*/ -
999void QObject::setObjectName(const QString &name) -
1000{ -
1001 Q_D(QObject);
executed (the execution status of this line is deduced): QObjectPrivate * const d = d_func();
-
1002 if (!d->extraData)
evaluated: !d->extraData
TRUEFALSE
yes
Evaluation Count:30293
yes
Evaluation Count:181
181-30293
1003 d->extraData = new QObjectPrivate::ExtraData;
executed: d->extraData = new QObjectPrivate::ExtraData;
Execution Count:30293
30293
1004 -
1005 if (d->extraData->objectName != name) {
evaluated: d->extraData->objectName != name
TRUEFALSE
yes
Evaluation Count:30462
yes
Evaluation Count:12
12-30462
1006 d->extraData->objectName = name;
executed (the execution status of this line is deduced): d->extraData->objectName = name;
-
1007 emit objectNameChanged(d->extraData->objectName, QPrivateSignal());
executed (the execution status of this line is deduced): objectNameChanged(d->extraData->objectName, QPrivateSignal());
-
1008 }
executed: }
Execution Count:30462
30462
1009}
executed: }
Execution Count:30474
30474
1010 -
1011/*! \fn void QObject::objectNameChanged(const QString &objectName) -
1012 -
1013 This signal is emitted after the object's name has been changed. The new object name is passed as \a objectName. -
1014 -
1015 \sa QObject::objectName -
1016*/ -
1017 -
1018/*! -
1019 \fn bool QObject::isWidgetType() const -
1020 -
1021 Returns true if the object is a widget; otherwise returns false. -
1022 -
1023 Calling this function is equivalent to calling -
1024 \c{inherits("QWidget")}, except that it is much faster. -
1025*/ -
1026 -
1027/*! -
1028 \fn bool QObject::isWindowType() const -
1029 -
1030 Returns true if the object is a window; otherwise returns false. -
1031 -
1032 Calling this function is equivalent to calling -
1033 \c{inherits("QWindow")}, except that it is much faster. -
1034*/ -
1035 -
1036/*! -
1037 This virtual function receives events to an object and should -
1038 return true if the event \a e was recognized and processed. -
1039 -
1040 The event() function can be reimplemented to customize the -
1041 behavior of an object. -
1042 -
1043 \sa installEventFilter(), timerEvent(), QCoreApplication::sendEvent(), -
1044 QCoreApplication::postEvent() -
1045*/ -
1046 -
1047bool QObject::event(QEvent *e) -
1048{ -
1049 switch (e->type()) { -
1050 case QEvent::Timer: -
1051 timerEvent((QTimerEvent*)e);
executed (the execution status of this line is deduced): timerEvent((QTimerEvent*)e);
-
1052 break;
executed: break;
Execution Count:40639
40639
1053 -
1054 case QEvent::ChildAdded: -
1055 case QEvent::ChildPolished: -
1056 case QEvent::ChildRemoved: -
1057 childEvent((QChildEvent*)e);
executed (the execution status of this line is deduced): childEvent((QChildEvent*)e);
-
1058 break;
executed: break;
Execution Count:169741
169741
1059 -
1060 case QEvent::DeferredDelete: -
1061 qDeleteInEventHandler(this);
executed (the execution status of this line is deduced): qDeleteInEventHandler(this);
-
1062 break;
executed: break;
Execution Count:2606
2606
1063 -
1064 case QEvent::MetaCall: -
1065 { -
1066 QMetaCallEvent *mce = static_cast<QMetaCallEvent*>(e);
executed (the execution status of this line is deduced): QMetaCallEvent *mce = static_cast<QMetaCallEvent*>(e);
-
1067 -
1068 QConnectionSenderSwitcher sw(this, const_cast<QObject*>(mce->sender()), mce->signalId());
executed (the execution status of this line is deduced): QConnectionSenderSwitcher sw(this, const_cast<QObject*>(mce->sender()), mce->signalId());
-
1069 -
1070 mce->placeMetaCall(this);
executed (the execution status of this line is deduced): mce->placeMetaCall(this);
-
1071 break;
executed: break;
Execution Count:85065
85065
1072 } -
1073 -
1074 case QEvent::ThreadChange: { -
1075 Q_D(QObject);
executed (the execution status of this line is deduced): QObjectPrivate * const d = d_func();
-
1076 QThreadData *threadData = d->threadData;
executed (the execution status of this line is deduced): QThreadData *threadData = d->threadData;
-
1077 QAbstractEventDispatcher *eventDispatcher = threadData->eventDispatcher;
executed (the execution status of this line is deduced): QAbstractEventDispatcher *eventDispatcher = threadData->eventDispatcher;
-
1078 if (eventDispatcher) {
evaluated: eventDispatcher
TRUEFALSE
yes
Evaluation Count:23263
yes
Evaluation Count:7
7-23263
1079 QList<QAbstractEventDispatcher::TimerInfo> timers = eventDispatcher->registeredTimers(this);
executed (the execution status of this line is deduced): QList<QAbstractEventDispatcher::TimerInfo> timers = eventDispatcher->registeredTimers(this);
-
1080 if (!timers.isEmpty()) {
evaluated: !timers.isEmpty()
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:23259
3-23259
1081 // do not to release our timer ids back to the pool (since the timer ids are moving to a new thread). -
1082 eventDispatcher->unregisterTimers(this);
executed (the execution status of this line is deduced): eventDispatcher->unregisterTimers(this);
-
1083 QMetaObject::invokeMethod(this, "_q_reregisterTimers", Qt::QueuedConnection,
executed (the execution status of this line is deduced): QMetaObject::invokeMethod(this, "_q_reregisterTimers", Qt::QueuedConnection,
-
1084 Q_ARG(void*, (new QList<QAbstractEventDispatcher::TimerInfo>(timers))));
executed (the execution status of this line is deduced): QArgument<void* >("void*", (new QList<QAbstractEventDispatcher::TimerInfo>(timers))));
-
1085 }
executed: }
Execution Count:3
3
1086 }
executed: }
Execution Count:23259
23259
1087 break;
executed: break;
Execution Count:23274
23274
1088 } -
1089 -
1090 default: -
1091 if (e->type() >= QEvent::User) {
evaluated: e->type() >= QEvent::User
TRUEFALSE
yes
Evaluation Count:259670
yes
Evaluation Count:139032
139032-259670
1092 customEvent(e);
executed (the execution status of this line is deduced): customEvent(e);
-
1093 break;
executed: break;
Execution Count:259636
259636
1094 } -
1095 return false;
executed: return false;
Execution Count:139032
139032
1096 } -
1097 return true;
executed: return true;
Execution Count:580871
580871
1098} -
1099 -
1100/*! -
1101 \fn void QObject::timerEvent(QTimerEvent *event) -
1102 -
1103 This event handler can be reimplemented in a subclass to receive -
1104 timer events for the object. -
1105 -
1106 QTimer provides a higher-level interface to the timer -
1107 functionality, and also more general information about timers. The -
1108 timer event is passed in the \a event parameter. -
1109 -
1110 \sa startTimer(), killTimer(), event() -
1111*/ -
1112 -
1113void QObject::timerEvent(QTimerEvent *) -
1114{ -
1115} -
1116 -
1117 -
1118/*! -
1119 This event handler can be reimplemented in a subclass to receive -
1120 child events. The event is passed in the \a event parameter. -
1121 -
1122 QEvent::ChildAdded and QEvent::ChildRemoved events are sent to -
1123 objects when children are added or removed. In both cases you can -
1124 only rely on the child being a QObject, or if isWidgetType() -
1125 returns true, a QWidget. (This is because, in the -
1126 \l{QEvent::ChildAdded}{ChildAdded} case, the child is not yet -
1127 fully constructed, and in the \l{QEvent::ChildRemoved}{ChildRemoved} -
1128 case it might have been destructed already). -
1129 -
1130 QEvent::ChildPolished events are sent to widgets when children -
1131 are polished, or when polished children are added. If you receive -
1132 a child polished event, the child's construction is usually -
1133 completed. However, this is not guaranteed, and multiple polish -
1134 events may be delivered during the execution of a widget's -
1135 constructor. -
1136 -
1137 For every child widget, you receive one -
1138 \l{QEvent::ChildAdded}{ChildAdded} event, zero or more -
1139 \l{QEvent::ChildPolished}{ChildPolished} events, and one -
1140 \l{QEvent::ChildRemoved}{ChildRemoved} event. -
1141 -
1142 The \l{QEvent::ChildPolished}{ChildPolished} event is omitted if -
1143 a child is removed immediately after it is added. If a child is -
1144 polished several times during construction and destruction, you -
1145 may receive several child polished events for the same child, -
1146 each time with a different virtual table. -
1147 -
1148 \sa event() -
1149*/ -
1150 -
1151void QObject::childEvent(QChildEvent * /* event */) -
1152{ -
1153} -
1154 -
1155 -
1156/*! -
1157 This event handler can be reimplemented in a subclass to receive -
1158 custom events. Custom events are user-defined events with a type -
1159 value at least as large as the QEvent::User item of the -
1160 QEvent::Type enum, and is typically a QEvent subclass. The event -
1161 is passed in the \a event parameter. -
1162 -
1163 \sa event(), QEvent -
1164*/ -
1165void QObject::customEvent(QEvent * /* event */) -
1166{ -
1167} -
1168 -
1169 -
1170 -
1171/*! -
1172 Filters events if this object has been installed as an event -
1173 filter for the \a watched object. -
1174 -
1175 In your reimplementation of this function, if you want to filter -
1176 the \a event out, i.e. stop it being handled further, return -
1177 true; otherwise return false. -
1178 -
1179 Example: -
1180 \snippet code/src_corelib_kernel_qobject.cpp 6 -
1181 -
1182 Notice in the example above that unhandled events are passed to -
1183 the base class's eventFilter() function, since the base class -
1184 might have reimplemented eventFilter() for its own internal -
1185 purposes. -
1186 -
1187 \warning If you delete the receiver object in this function, be -
1188 sure to return true. Otherwise, Qt will forward the event to the -
1189 deleted object and the program might crash. -
1190 -
1191 \sa installEventFilter() -
1192*/ -
1193 -
1194bool QObject::eventFilter(QObject * /* watched */, QEvent * /* event */) -
1195{ -
1196 return false;
executed: return false;
Execution Count:114675
114675
1197} -
1198 -
1199/*! -
1200 \fn bool QObject::signalsBlocked() const -
1201 -
1202 Returns true if signals are blocked; otherwise returns false. -
1203 -
1204 Signals are not blocked by default. -
1205 -
1206 \sa blockSignals() -
1207*/ -
1208 -
1209/*! -
1210 If \a block is true, signals emitted by this object are blocked -
1211 (i.e., emitting a signal will not invoke anything connected to it). -
1212 If \a block is false, no such blocking will occur. -
1213 -
1214 The return value is the previous value of signalsBlocked(). -
1215 -
1216 Note that the destroyed() signal will be emitted even if the signals -
1217 for this object have been blocked. -
1218 -
1219 \sa signalsBlocked() -
1220*/ -
1221 -
1222bool QObject::blockSignals(bool block) -
1223{ -
1224 Q_D(QObject);
executed (the execution status of this line is deduced): QObjectPrivate * const d = d_func();
-
1225 bool previous = d->blockSig;
executed (the execution status of this line is deduced): bool previous = d->blockSig;
-
1226 d->blockSig = block;
executed (the execution status of this line is deduced): d->blockSig = block;
-
1227 return previous;
executed: return previous;
Execution Count:24693
24693
1228} -
1229 -
1230/*! -
1231 Returns the thread in which the object lives. -
1232 -
1233 \sa moveToThread() -
1234*/ -
1235QThread *QObject::thread() const -
1236{ -
1237 return d_func()->threadData->thread;
executed: return d_func()->threadData->thread;
Execution Count:2116939
2116939
1238} -
1239 -
1240/*! -
1241 Changes the thread affinity for this object and its children. The -
1242 object cannot be moved if it has a parent. Event processing will -
1243 continue in the \a targetThread. -
1244 -
1245 To move an object to the main thread, use QApplication::instance() -
1246 to retrieve a pointer to the current application, and then use -
1247 QApplication::thread() to retrieve the thread in which the -
1248 application lives. For example: -
1249 -
1250 \snippet code/src_corelib_kernel_qobject.cpp 7 -
1251 -
1252 If \a targetThread is zero, all event processing for this object -
1253 and its children stops. -
1254 -
1255 Note that all active timers for the object will be reset. The -
1256 timers are first stopped in the current thread and restarted (with -
1257 the same interval) in the \a targetThread. As a result, constantly -
1258 moving an object between threads can postpone timer events -
1259 indefinitely. -
1260 -
1261 A QEvent::ThreadChange event is sent to this object just before -
1262 the thread affinity is changed. You can handle this event to -
1263 perform any special processing. Note that any new events that are -
1264 posted to this object will be handled in the \a targetThread. -
1265 -
1266 \warning This function is \e not thread-safe; the current thread -
1267 must be same as the current thread affinity. In other words, this -
1268 function can only "push" an object from the current thread to -
1269 another thread, it cannot "pull" an object from any arbitrary -
1270 thread to the current thread. -
1271 -
1272 \sa thread() -
1273 */ -
1274void QObject::moveToThread(QThread *targetThread) -
1275{ -
1276 Q_D(QObject);
executed (the execution status of this line is deduced): QObjectPrivate * const d = d_func();
-
1277 -
1278 if (d->threadData->thread == targetThread) {
evaluated: d->threadData->thread == targetThread
TRUEFALSE
yes
Evaluation Count:8732
yes
Evaluation Count:23133
8732-23133
1279 // object is already in this thread -
1280 return;
executed: return;
Execution Count:8732
8732
1281 } -
1282 -
1283 if (d->parent != 0) {
partially evaluated: d->parent != 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:23137
0-23137
1284 qWarning("QObject::moveToThread: Cannot move objects with a parent");
never executed (the execution status of this line is deduced): QMessageLogger("kernel/qobject.cpp", 1284, __PRETTY_FUNCTION__).warning("QObject::moveToThread: Cannot move objects with a parent");
-
1285 return;
never executed: return;
0
1286 } -
1287 if (d->isWidget) {
partially evaluated: d->isWidget
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:23131
0-23131
1288 qWarning("QObject::moveToThread: Widgets cannot be moved to a new thread");
never executed (the execution status of this line is deduced): QMessageLogger("kernel/qobject.cpp", 1288, __PRETTY_FUNCTION__).warning("QObject::moveToThread: Widgets cannot be moved to a new thread");
-
1289 return;
never executed: return;
0
1290 } -
1291 -
1292 QThreadData *currentData = QThreadData::current();
executed (the execution status of this line is deduced): QThreadData *currentData = QThreadData::current();
-
1293 QThreadData *targetData = targetThread ? QThreadData::get2(targetThread) : new QThreadData(0);
evaluated: targetThread
TRUEFALSE
yes
Evaluation Count:23123
yes
Evaluation Count:5
5-23123
1294 if (d->threadData->thread == 0 && currentData == targetData) {
evaluated: d->threadData->thread == 0
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:23131
partially evaluated: currentData == targetData
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-23131
1295 // one exception to the rule: we allow moving objects with no thread affinity to the current thread -
1296 currentData = d->threadData;
executed (the execution status of this line is deduced): currentData = d->threadData;
-
1297 } else if (d->threadData != currentData) {
executed: }
Execution Count:3
partially evaluated: d->threadData != currentData
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:23129
0-23129
1298 qWarning("QObject::moveToThread: Current thread (%p) is not the object's thread (%p).\n"
never executed (the execution status of this line is deduced): QMessageLogger("kernel/qobject.cpp", 1298, __PRETTY_FUNCTION__).warning("QObject::moveToThread: Current thread (%p) is not the object's thread (%p).\n"
-
1299 "Cannot move to target thread (%p)\n",
never executed (the execution status of this line is deduced): "Cannot move to target thread (%p)\n",
-
1300 currentData->thread, d->threadData->thread, targetData->thread);
never executed (the execution status of this line is deduced): currentData->thread, d->threadData->thread, targetData->thread);
-
1301 -
1302#ifdef Q_OS_MAC -
1303 qWarning("On Mac OS X, you might be loading two sets of Qt binaries into the same process. " -
1304 "Check that all plugins are compiled against the right Qt binaries. Export " -
1305 "DYLD_PRINT_LIBRARIES=1 and check that only one set of binaries are being loaded."); -
1306#endif -
1307 -
1308 return;
never executed: return;
0
1309 } -
1310 -
1311 // prepare to move -
1312 d->moveToThread_helper();
executed (the execution status of this line is deduced): d->moveToThread_helper();
-
1313 -
1314 QOrderedMutexLocker locker(&currentData->postEventList.mutex,
executed (the execution status of this line is deduced): QOrderedMutexLocker locker(&currentData->postEventList.mutex,
-
1315 &targetData->postEventList.mutex);
executed (the execution status of this line is deduced): &targetData->postEventList.mutex);
-
1316 -
1317 // keep currentData alive (since we've got it locked) -
1318 currentData->ref();
executed (the execution status of this line is deduced): currentData->ref();
-
1319 -
1320 // move the object -
1321 d_func()->setThreadData_helper(currentData, targetData);
executed (the execution status of this line is deduced): d_func()->setThreadData_helper(currentData, targetData);
-
1322 -
1323 locker.unlock();
executed (the execution status of this line is deduced): locker.unlock();
-
1324 -
1325 // now currentData can commit suicide if it wants to -
1326 currentData->deref();
executed (the execution status of this line is deduced): currentData->deref();
-
1327}
executed: }
Execution Count:23150
23150
1328 -
1329void QObjectPrivate::moveToThread_helper() -
1330{ -
1331 Q_Q(QObject);
executed (the execution status of this line is deduced): QObject * const q = q_func();
-
1332 QEvent e(QEvent::ThreadChange);
executed (the execution status of this line is deduced): QEvent e(QEvent::ThreadChange);
-
1333 QCoreApplication::sendEvent(q, &e);
executed (the execution status of this line is deduced): QCoreApplication::sendEvent(q, &e);
-
1334 for (int i = 0; i < children.size(); ++i) {
evaluated: i < children.size()
TRUEFALSE
yes
Evaluation Count:141
yes
Evaluation Count:23257
141-23257
1335 QObject *child = children.at(i);
executed (the execution status of this line is deduced): QObject *child = children.at(i);
-
1336 child->d_func()->moveToThread_helper();
executed (the execution status of this line is deduced): child->d_func()->moveToThread_helper();
-
1337 }
executed: }
Execution Count:141
141
1338}
executed: }
Execution Count:23254
23254
1339 -
1340void QObjectPrivate::setThreadData_helper(QThreadData *currentData, QThreadData *targetData) -
1341{ -
1342 Q_Q(QObject);
executed (the execution status of this line is deduced): QObject * const q = q_func();
-
1343 -
1344 // move posted events -
1345 int eventsMoved = 0;
executed (the execution status of this line is deduced): int eventsMoved = 0;
-
1346 for (int i = 0; i < currentData->postEventList.size(); ++i) {
evaluated: i < currentData->postEventList.size()
TRUEFALSE
yes
Evaluation Count:857624
yes
Evaluation Count:23293
23293-857624
1347 const QPostEvent &pe = currentData->postEventList.at(i);
executed (the execution status of this line is deduced): const QPostEvent &pe = currentData->postEventList.at(i);
-
1348 if (!pe.event)
evaluated: !pe.event
TRUEFALSE
yes
Evaluation Count:245785
yes
Evaluation Count:611839
245785-611839
1349 continue;
executed: continue;
Execution Count:245785
245785
1350 if (pe.receiver == q) {
evaluated: pe.receiver == q
TRUEFALSE
yes
Evaluation Count:349063
yes
Evaluation Count:262776
262776-349063
1351 // move this post event to the targetList -
1352 targetData->postEventList.addEvent(pe);
executed (the execution status of this line is deduced): targetData->postEventList.addEvent(pe);
-
1353 const_cast<QPostEvent &>(pe).event = 0;
executed (the execution status of this line is deduced): const_cast<QPostEvent &>(pe).event = 0;
-
1354 ++eventsMoved;
executed (the execution status of this line is deduced): ++eventsMoved;
-
1355 }
executed: }
Execution Count:349063
349063
1356 }
executed: }
Execution Count:611839
611839
1357 if (eventsMoved > 0 && targetData->eventDispatcher) {
evaluated: eventsMoved > 0
TRUEFALSE
yes
Evaluation Count:20463
yes
Evaluation Count:2830
evaluated: targetData->eventDispatcher
TRUEFALSE
yes
Evaluation Count:20459
yes
Evaluation Count:4
4-20463
1358 targetData->canWait = false;
executed (the execution status of this line is deduced): targetData->canWait = false;
-
1359 targetData->eventDispatcher->wakeUp();
executed (the execution status of this line is deduced): targetData->eventDispatcher->wakeUp();
-
1360 }
executed: }
Execution Count:20459
20459
1361 -
1362 // the current emitting thread shouldn't restore currentSender after calling moveToThread() -
1363 if (currentSender)
evaluated: currentSender
TRUEFALSE
yes
Evaluation Count:21001
yes
Evaluation Count:2292
2292-21001
1364 currentSender->ref = 0;
executed: currentSender->ref = 0;
Execution Count:21001
21001
1365 currentSender = 0;
executed (the execution status of this line is deduced): currentSender = 0;
-
1366 -
1367 // set new thread data -
1368 targetData->ref();
executed (the execution status of this line is deduced): targetData->ref();
-
1369 threadData->deref();
executed (the execution status of this line is deduced): threadData->deref();
-
1370 threadData = targetData;
executed (the execution status of this line is deduced): threadData = targetData;
-
1371 -
1372 for (int i = 0; i < children.size(); ++i) {
evaluated: i < children.size()
TRUEFALSE
yes
Evaluation Count:141
yes
Evaluation Count:23293
141-23293
1373 QObject *child = children.at(i);
executed (the execution status of this line is deduced): QObject *child = children.at(i);
-
1374 child->d_func()->setThreadData_helper(currentData, targetData);
executed (the execution status of this line is deduced): child->d_func()->setThreadData_helper(currentData, targetData);
-
1375 }
executed: }
Execution Count:141
141
1376}
executed: }
Execution Count:23293
23293
1377 -
1378void QObjectPrivate::_q_reregisterTimers(void *pointer) -
1379{ -
1380 Q_Q(QObject);
executed (the execution status of this line is deduced): QObject * const q = q_func();
-
1381 QList<QAbstractEventDispatcher::TimerInfo> *timerList = reinterpret_cast<QList<QAbstractEventDispatcher::TimerInfo> *>(pointer);
executed (the execution status of this line is deduced): QList<QAbstractEventDispatcher::TimerInfo> *timerList = reinterpret_cast<QList<QAbstractEventDispatcher::TimerInfo> *>(pointer);
-
1382 QAbstractEventDispatcher *eventDispatcher = threadData->eventDispatcher;
executed (the execution status of this line is deduced): QAbstractEventDispatcher *eventDispatcher = threadData->eventDispatcher;
-
1383 for (int i = 0; i < timerList->size(); ++i) {
evaluated: i < timerList->size()
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:3
3
1384 const QAbstractEventDispatcher::TimerInfo &ti = timerList->at(i);
executed (the execution status of this line is deduced): const QAbstractEventDispatcher::TimerInfo &ti = timerList->at(i);
-
1385 eventDispatcher->registerTimer(ti.timerId, ti.interval, ti.timerType, q);
executed (the execution status of this line is deduced): eventDispatcher->registerTimer(ti.timerId, ti.interval, ti.timerType, q);
-
1386 }
executed: }
Execution Count:3
3
1387 delete timerList;
executed (the execution status of this line is deduced): delete timerList;
-
1388}
executed: }
Execution Count:3
3
1389 -
1390 -
1391// -
1392// The timer flag hasTimer is set when startTimer is called. -
1393// It is not reset when killing the timer because more than -
1394// one timer might be active. -
1395// -
1396 -
1397/*! -
1398 Starts a timer and returns a timer identifier, or returns zero if -
1399 it could not start a timer. -
1400 -
1401 A timer event will occur every \a interval milliseconds until -
1402 killTimer() is called. If \a interval is 0, then the timer event -
1403 occurs once every time there are no more window system events to -
1404 process. -
1405 -
1406 The virtual timerEvent() function is called with the QTimerEvent -
1407 event parameter class when a timer event occurs. Reimplement this -
1408 function to get timer events. -
1409 -
1410 If multiple timers are running, the QTimerEvent::timerId() can be -
1411 used to find out which timer was activated. -
1412 -
1413 Example: -
1414 -
1415 \snippet code/src_corelib_kernel_qobject.cpp 8 -
1416 -
1417 Note that QTimer's accuracy depends on the underlying operating system and -
1418 hardware. The \a timerType argument allows you to customize the accuracy of -
1419 the timer. See Qt::TimerType for information on the different timer types. -
1420 Most platforms support an accuracy of 20 milliseconds; some provide more. -
1421 If Qt is unable to deliver the requested number of timer events, it will -
1422 silently discard some. -
1423 -
1424 The QTimer class provides a high-level programming interface with -
1425 single-shot timers and timer signals instead of events. There is -
1426 also a QBasicTimer class that is more lightweight than QTimer and -
1427 less clumsy than using timer IDs directly. -
1428 -
1429 \sa timerEvent(), killTimer(), QTimer::singleShot() -
1430*/ -
1431 -
1432int QObject::startTimer(int interval, Qt::TimerType timerType) -
1433{ -
1434 Q_D(QObject);
executed (the execution status of this line is deduced): QObjectPrivate * const d = d_func();
-
1435 -
1436 if (interval < 0) {
partially evaluated: interval < 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:9428
0-9428
1437 qWarning("QObject::startTimer: QTimer cannot have a negative interval");
never executed (the execution status of this line is deduced): QMessageLogger("kernel/qobject.cpp", 1437, __PRETTY_FUNCTION__).warning("QObject::startTimer: QTimer cannot have a negative interval");
-
1438 return 0;
never executed: return 0;
0
1439 } -
1440 -
1441 if (!d->threadData->eventDispatcher) {
partially evaluated: !d->threadData->eventDispatcher
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:9428
0-9428
1442 qWarning("QObject::startTimer: QTimer can only be used with threads started with QThread");
never executed (the execution status of this line is deduced): QMessageLogger("kernel/qobject.cpp", 1442, __PRETTY_FUNCTION__).warning("QObject::startTimer: QTimer can only be used with threads started with QThread");
-
1443 return 0;
never executed: return 0;
0
1444 } -
1445 int timerId = d->threadData->eventDispatcher->registerTimer(interval, timerType, this);
executed (the execution status of this line is deduced): int timerId = d->threadData->eventDispatcher->registerTimer(interval, timerType, this);
-
1446 if (!d->extraData)
evaluated: !d->extraData
TRUEFALSE
yes
Evaluation Count:4373
yes
Evaluation Count:5055
4373-5055
1447 d->extraData = new QObjectPrivate::ExtraData;
executed: d->extraData = new QObjectPrivate::ExtraData;
Execution Count:4373
4373
1448 d->extraData->runningTimers.append(timerId);
executed (the execution status of this line is deduced): d->extraData->runningTimers.append(timerId);
-
1449 return timerId;
executed: return timerId;
Execution Count:9428
9428
1450} -
1451 -
1452/*! -
1453 Kills the timer with timer identifier, \a id. -
1454 -
1455 The timer identifier is returned by startTimer() when a timer -
1456 event is started. -
1457 -
1458 \sa timerEvent(), startTimer() -
1459*/ -
1460 -
1461void QObject::killTimer(int id) -
1462{ -
1463 Q_D(QObject);
executed (the execution status of this line is deduced): QObjectPrivate * const d = d_func();
-
1464 if (id) {
partially evaluated: id
TRUEFALSE
yes
Evaluation Count:8640
no
Evaluation Count:0
0-8640
1465 int at = d->extraData ? d->extraData->runningTimers.indexOf(id) : -1;
partially evaluated: d->extraData
TRUEFALSE
yes
Evaluation Count:8640
no
Evaluation Count:0
0-8640
1466 if (at == -1) {
partially evaluated: at == -1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:8640
0-8640
1467 // timer isn't owned by this object -
1468 qWarning("QObject::killTimer(): Error: timer id %d is not valid for object %p (%s), timer has not been killed",
never executed (the execution status of this line is deduced): QMessageLogger("kernel/qobject.cpp", 1468, __PRETTY_FUNCTION__).warning("QObject::killTimer(): Error: timer id %d is not valid for object %p (%s), timer has not been killed",
-
1469 id,
never executed (the execution status of this line is deduced): id,
-
1470 this,
never executed (the execution status of this line is deduced): this,
-
1471 qPrintable(objectName()));
never executed (the execution status of this line is deduced): QString(objectName()).toLocal8Bit().constData());
-
1472 return;
never executed: return;
0
1473 } -
1474 -
1475 if (d->threadData->eventDispatcher)
evaluated: d->threadData->eventDispatcher
TRUEFALSE
yes
Evaluation Count:8544
yes
Evaluation Count:96
96-8544
1476 d->threadData->eventDispatcher->unregisterTimer(id);
executed: d->threadData->eventDispatcher->unregisterTimer(id);
Execution Count:8544
8544
1477 -
1478 d->extraData->runningTimers.remove(at);
executed (the execution status of this line is deduced): d->extraData->runningTimers.remove(at);
-
1479 QAbstractEventDispatcherPrivate::releaseTimerId(id);
executed (the execution status of this line is deduced): QAbstractEventDispatcherPrivate::releaseTimerId(id);
-
1480 }
executed: }
Execution Count:8640
8640
1481}
executed: }
Execution Count:8640
8640
1482 -
1483 -
1484/*! -
1485 \fn QObject *QObject::parent() const -
1486 -
1487 Returns a pointer to the parent object. -
1488 -
1489 \sa children() -
1490*/ -
1491 -
1492/*! -
1493 \fn const QObjectList &QObject::children() const -
1494 -
1495 Returns a list of child objects. -
1496 The QObjectList class is defined in the \c{<QObject>} header -
1497 file as the following: -
1498 -
1499 \quotefromfile kernel/qobject.h -
1500 \skipto /typedef .*QObjectList/ -
1501 \printuntil QObjectList -
1502 -
1503 The first child added is the \l{QList::first()}{first} object in -
1504 the list and the last child added is the \l{QList::last()}{last} -
1505 object in the list, i.e. new children are appended at the end. -
1506 -
1507 Note that the list order changes when QWidget children are -
1508 \l{QWidget::raise()}{raised} or \l{QWidget::lower()}{lowered}. A -
1509 widget that is raised becomes the last object in the list, and a -
1510 widget that is lowered becomes the first object in the list. -
1511 -
1512 \sa findChild(), findChildren(), parent(), setParent() -
1513*/ -
1514 -
1515 -
1516/*! -
1517 \fn T *QObject::findChild(const QString &name, Qt::FindChildOptions options) const -
1518 -
1519 Returns the child of this object that can be cast into type T and -
1520 that is called \a name, or 0 if there is no such object. -
1521 Omitting the \a name argument causes all object names to be matched. -
1522 The search is performed recursively, unless \a options specifies the -
1523 option FindDirectChildrenOnly. -
1524 -
1525 If there is more than one child matching the search, the most -
1526 direct ancestor is returned. If there are several direct -
1527 ancestors, it is undefined which one will be returned. In that -
1528 case, findChildren() should be used. -
1529 -
1530 This example returns a child \c{QPushButton} of \c{parentWidget} -
1531 named \c{"button1"}, even if the button isn't a direct child of -
1532 the parent: -
1533 -
1534 \snippet code/src_corelib_kernel_qobject.cpp 10 -
1535 -
1536 This example returns a \c{QListWidget} child of \c{parentWidget}: -
1537 -
1538 \snippet code/src_corelib_kernel_qobject.cpp 11 -
1539 -
1540 This example returns a child \c{QPushButton} of \c{parentWidget} -
1541 (its direct parent) named \c{"button1"}: -
1542 -
1543 \snippet code/src_corelib_kernel_qobject.cpp 41 -
1544 -
1545 This example returns a \c{QListWidget} child of \c{parentWidget}, -
1546 its direct parent: -
1547 -
1548 \snippet code/src_corelib_kernel_qobject.cpp 42 -
1549 -
1550 \sa findChildren() -
1551*/ -
1552 -
1553/*! -
1554 \fn QList<T> QObject::findChildren(const QString &name, Qt::FindChildOptions options) const -
1555 -
1556 Returns all children of this object with the given \a name that can be -
1557 cast to type T, or an empty list if there are no such objects. -
1558 Omitting the \a name argument causes all object names to be matched. -
1559 The search is performed recursively, unless \a options specifies the -
1560 option FindDirectChildrenOnly. -
1561 -
1562 The following example shows how to find a list of child \c{QWidget}s of -
1563 the specified \c{parentWidget} named \c{widgetname}: -
1564 -
1565 \snippet code/src_corelib_kernel_qobject.cpp 12 -
1566 -
1567 This example returns all \c{QPushButton}s that are children of \c{parentWidget}: -
1568 -
1569 \snippet code/src_corelib_kernel_qobject.cpp 13 -
1570 -
1571 This example returns all \c{QPushButton}s that are immediate children of \c{parentWidget}: -
1572 -
1573 \snippet code/src_corelib_kernel_qobject.cpp 43 -
1574 -
1575 \sa findChild() -
1576*/ -
1577 -
1578/*! -
1579 \fn QList<T> QObject::findChildren(const QRegExp &regExp, Qt::FindChildOptions options) const -
1580 \overload findChildren() -
1581 -
1582 Returns the children of this object that can be cast to type T -
1583 and that have names matching the regular expression \a regExp, -
1584 or an empty list if there are no such objects. -
1585 The search is performed recursively, unless \a options specifies the -
1586 option FindDirectChildrenOnly. -
1587*/ -
1588 -
1589/*! -
1590 \fn QList<T> QObject::findChildren(const QRegularExpression &re, Qt::FindChildOptions options) const -
1591 \overload findChildren() -
1592 -
1593 \since 5.0 -
1594 -
1595 Returns the children of this object that can be cast to type T -
1596 and that have names matching the regular expression \a re, -
1597 or an empty list if there are no such objects. -
1598 The search is performed recursively, unless \a options specifies the -
1599 option FindDirectChildrenOnly. -
1600*/ -
1601 -
1602/*! -
1603 \fn T qFindChild(const QObject *obj, const QString &name) -
1604 \relates QObject -
1605 \overload qFindChildren() -
1606 \obsolete -
1607 -
1608 This function is equivalent to -
1609 \a{obj}->\l{QObject::findChild()}{findChild}<T>(\a name). -
1610 -
1611 \note This function was provided as a workaround for MSVC 6 -
1612 which did not support member template functions. It is advised -
1613 to use the other form in new code. -
1614 -
1615 \sa QObject::findChild() -
1616*/ -
1617 -
1618/*! -
1619 \fn QList<T> qFindChildren(const QObject *obj, const QString &name) -
1620 \relates QObject -
1621 \overload qFindChildren() -
1622 \obsolete -
1623 -
1624 This function is equivalent to -
1625 \a{obj}->\l{QObject::findChildren()}{findChildren}<T>(\a name). -
1626 -
1627 \note This function was provided as a workaround for MSVC 6 -
1628 which did not support member template functions. It is advised -
1629 to use the other form in new code. -
1630 -
1631 \sa QObject::findChildren() -
1632*/ -
1633 -
1634/*! -
1635 \fn QList<T> qFindChildren(const QObject *obj, const QRegExp &regExp) -
1636 \relates QObject -
1637 \overload qFindChildren() -
1638 -
1639 This function is equivalent to -
1640 \a{obj}->\l{QObject::findChildren()}{findChildren}<T>(\a regExp). -
1641 -
1642 \note This function was provided as a workaround for MSVC 6 -
1643 which did not support member template functions. It is advised -
1644 to use the other form in new code. -
1645 -
1646 \sa QObject::findChildren() -
1647*/ -
1648 -
1649/*! -
1650 \internal -
1651*/ -
1652void qt_qFindChildren_helper(const QObject *parent, const QString &name, -
1653 const QMetaObject &mo, QList<void*> *list, Qt::FindChildOptions options) -
1654{ -
1655 if (!parent || !list)
evaluated: !parent
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:33800
partially evaluated: !list
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:33800
0-33800
1656 return;
executed: return;
Execution Count:12
12
1657 const QObjectList &children = parent->children();
executed (the execution status of this line is deduced): const QObjectList &children = parent->children();
-
1658 QObject *obj;
executed (the execution status of this line is deduced): QObject *obj;
-
1659 for (int i = 0; i < children.size(); ++i) {
evaluated: i < children.size()
TRUEFALSE
yes
Evaluation Count:32072
yes
Evaluation Count:33800
32072-33800
1660 obj = children.at(i);
executed (the execution status of this line is deduced): obj = children.at(i);
-
1661 if (mo.cast(obj)) {
evaluated: mo.cast(obj)
TRUEFALSE
yes
Evaluation Count:14972
yes
Evaluation Count:17100
14972-17100
1662 if (name.isNull() || obj->objectName() == name)
evaluated: name.isNull()
TRUEFALSE
yes
Evaluation Count:14709
yes
Evaluation Count:263
evaluated: obj->objectName() == name
TRUEFALSE
yes
Evaluation Count:28
yes
Evaluation Count:235
28-14709
1663 list->append(obj);
executed: list->append(obj);
Execution Count:14737
14737
1664 }
executed: }
Execution Count:14972
14972
1665 if (options & Qt::FindChildrenRecursively)
evaluated: options & Qt::FindChildrenRecursively
TRUEFALSE
yes
Evaluation Count:31987
yes
Evaluation Count:85
85-31987
1666 qt_qFindChildren_helper(obj, name, mo, list, options);
executed: qt_qFindChildren_helper(obj, name, mo, list, options);
Execution Count:31987
31987
1667 }
executed: }
Execution Count:32072
32072
1668}
executed: }
Execution Count:33800
33800
1669 -
1670#ifndef QT_NO_REGEXP -
1671/*! -
1672 \internal -
1673*/ -
1674void qt_qFindChildren_helper(const QObject *parent, const QRegExp &re, -
1675 const QMetaObject &mo, QList<void*> *list, Qt::FindChildOptions options) -
1676{ -
1677 if (!parent || !list)
partially evaluated: !parent
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:55
partially evaluated: !list
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:55
0-55
1678 return;
never executed: return;
0
1679 const QObjectList &children = parent->children();
executed (the execution status of this line is deduced): const QObjectList &children = parent->children();
-
1680 QRegExp reCopy = re;
executed (the execution status of this line is deduced): QRegExp reCopy = re;
-
1681 QObject *obj;
executed (the execution status of this line is deduced): QObject *obj;
-
1682 for (int i = 0; i < children.size(); ++i) {
evaluated: i < children.size()
TRUEFALSE
yes
Evaluation Count:70
yes
Evaluation Count:55
55-70
1683 obj = children.at(i);
executed (the execution status of this line is deduced): obj = children.at(i);
-
1684 if (mo.cast(obj) && reCopy.indexIn(obj->objectName()) != -1)
evaluated: mo.cast(obj)
TRUEFALSE
yes
Evaluation Count:52
yes
Evaluation Count:18
evaluated: reCopy.indexIn(obj->objectName()) != -1
TRUEFALSE
yes
Evaluation Count:15
yes
Evaluation Count:37
15-52
1685 list->append(obj);
executed: list->append(obj);
Execution Count:15
15
1686 -
1687 if (options & Qt::FindChildrenRecursively)
evaluated: options & Qt::FindChildrenRecursively
TRUEFALSE
yes
Evaluation Count:45
yes
Evaluation Count:25
25-45
1688 qt_qFindChildren_helper(obj, re, mo, list, options);
executed: qt_qFindChildren_helper(obj, re, mo, list, options);
Execution Count:45
45
1689 }
executed: }
Execution Count:70
70
1690}
executed: }
Execution Count:55
55
1691#endif // QT_NO_REGEXP -
1692 -
1693#ifndef QT_NO_REGEXP -
1694/*! -
1695 \internal -
1696*/ -
1697void qt_qFindChildren_helper(const QObject *parent, const QRegularExpression &re, -
1698 const QMetaObject &mo, QList<void*> *list, Qt::FindChildOptions options) -
1699{ -
1700 if (!parent || !list)
partially evaluated: !parent
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:50
partially evaluated: !list
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:50
0-50
1701 return;
never executed: return;
0
1702 const QObjectList &children = parent->children();
executed (the execution status of this line is deduced): const QObjectList &children = parent->children();
-
1703 QObject *obj;
executed (the execution status of this line is deduced): QObject *obj;
-
1704 for (int i = 0; i < children.size(); ++i) {
evaluated: i < children.size()
TRUEFALSE
yes
Evaluation Count:45
yes
Evaluation Count:50
45-50
1705 obj = children.at(i);
executed (the execution status of this line is deduced): obj = children.at(i);
-
1706 if (mo.cast(obj)) {
evaluated: mo.cast(obj)
TRUEFALSE
yes
Evaluation Count:33
yes
Evaluation Count:12
12-33
1707 QRegularExpressionMatch m = re.match(obj->objectName());
executed (the execution status of this line is deduced): QRegularExpressionMatch m = re.match(obj->objectName());
-
1708 if (m.hasMatch())
evaluated: m.hasMatch()
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:23
10-23
1709 list->append(obj);
executed: list->append(obj);
Execution Count:10
10
1710 }
executed: }
Execution Count:33
33
1711 if (options & Qt::FindChildrenRecursively)
partially evaluated: options & Qt::FindChildrenRecursively
TRUEFALSE
yes
Evaluation Count:45
no
Evaluation Count:0
0-45
1712 qt_qFindChildren_helper(obj, re, mo, list, options);
executed: qt_qFindChildren_helper(obj, re, mo, list, options);
Execution Count:45
45
1713 }
executed: }
Execution Count:45
45
1714}
executed: }
Execution Count:50
50
1715#endif // QT_NO_REGEXP -
1716 -
1717/*! -
1718 \internal -
1719 */ -
1720QObject *qt_qFindChild_helper(const QObject *parent, const QString &name, const QMetaObject &mo, Qt::FindChildOptions options) -
1721{ -
1722 if (!parent)
partially evaluated: !parent
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4209
0-4209
1723 return 0;
never executed: return 0;
0
1724 const QObjectList &children = parent->children();
executed (the execution status of this line is deduced): const QObjectList &children = parent->children();
-
1725 QObject *obj;
executed (the execution status of this line is deduced): QObject *obj;
-
1726 int i;
executed (the execution status of this line is deduced): int i;
-
1727 for (i = 0; i < children.size(); ++i) {
evaluated: i < children.size()
TRUEFALSE
yes
Evaluation Count:5428
yes
Evaluation Count:3887
3887-5428
1728 obj = children.at(i);
executed (the execution status of this line is deduced): obj = children.at(i);
-
1729 if (mo.cast(obj) && (name.isNull() || obj->objectName() == name))
evaluated: mo.cast(obj)
TRUEFALSE
yes
Evaluation Count:476
yes
Evaluation Count:4952
evaluated: name.isNull()
TRUEFALSE
yes
Evaluation Count:197
yes
Evaluation Count:279
evaluated: obj->objectName() == name
TRUEFALSE
yes
Evaluation Count:125
yes
Evaluation Count:154
125-4952
1730 return obj;
executed: return obj;
Execution Count:322
322
1731 }
executed: }
Execution Count:5106
5106
1732 if (options & Qt::FindChildrenRecursively) {
evaluated: options & Qt::FindChildrenRecursively
TRUEFALSE
yes
Evaluation Count:3878
yes
Evaluation Count:9
9-3878
1733 for (i = 0; i < children.size(); ++i) {
evaluated: i < children.size()
TRUEFALSE
yes
Evaluation Count:3643
yes
Evaluation Count:3738
3643-3738
1734 obj = qt_qFindChild_helper(children.at(i), name, mo, options);
executed (the execution status of this line is deduced): obj = qt_qFindChild_helper(children.at(i), name, mo, options);
-
1735 if (obj)
evaluated: obj
TRUEFALSE
yes
Evaluation Count:140
yes
Evaluation Count:3503
140-3503
1736 return obj;
executed: return obj;
Execution Count:140
140
1737 }
executed: }
Execution Count:3503
3503
1738 }
executed: }
Execution Count:3738
3738
1739 return 0;
executed: return 0;
Execution Count:3747
3747
1740} -
1741 -
1742/*! -
1743 Makes the object a child of \a parent. -
1744 -
1745 \sa parent(), children() -
1746*/ -
1747void QObject::setParent(QObject *parent) -
1748{ -
1749 Q_D(QObject);
executed (the execution status of this line is deduced): QObjectPrivate * const d = d_func();
-
1750 Q_ASSERT(!d->isWidget);
executed (the execution status of this line is deduced): qt_noop();
-
1751 d->setParent_helper(parent);
executed (the execution status of this line is deduced): d->setParent_helper(parent);
-
1752}
executed: }
Execution Count:68036
68036
1753 -
1754void QObjectPrivate::deleteChildren() -
1755{ -
1756 Q_ASSERT_X(!isDeletingChildren, "QObjectPrivate::deleteChildren()", "isDeletingChildren already set, did this function recurse?");
executed (the execution status of this line is deduced): qt_noop();
-
1757 isDeletingChildren = true;
executed (the execution status of this line is deduced): isDeletingChildren = true;
-
1758 // delete children objects -
1759 // don't use qDeleteAll as the destructor of the child might -
1760 // delete siblings -
1761 for (int i = 0; i < children.count(); ++i) {
evaluated: i < children.count()
TRUEFALSE
yes
Evaluation Count:51813
yes
Evaluation Count:23396
23396-51813
1762 currentChildBeingDeleted = children.at(i);
executed (the execution status of this line is deduced): currentChildBeingDeleted = children.at(i);
-
1763 children[i] = 0;
executed (the execution status of this line is deduced): children[i] = 0;
-
1764 delete currentChildBeingDeleted;
executed (the execution status of this line is deduced): delete currentChildBeingDeleted;
-
1765 }
executed: }
Execution Count:51813
51813
1766 children.clear();
executed (the execution status of this line is deduced): children.clear();
-
1767 currentChildBeingDeleted = 0;
executed (the execution status of this line is deduced): currentChildBeingDeleted = 0;
-
1768 isDeletingChildren = false;
executed (the execution status of this line is deduced): isDeletingChildren = false;
-
1769}
executed: }
Execution Count:23396
23396
1770 -
1771void QObjectPrivate::setParent_helper(QObject *o) -
1772{ -
1773 Q_Q(QObject);
executed (the execution status of this line is deduced): QObject * const q = q_func();
-
1774 if (o == parent)
evaluated: o == parent
TRUEFALSE
yes
Evaluation Count:1527
yes
Evaluation Count:193896
1527-193896
1775 return;
executed: return;
Execution Count:1527
1527
1776 if (parent) {
evaluated: parent
TRUEFALSE
yes
Evaluation Count:95373
yes
Evaluation Count:98523
95373-98523
1777 QObjectPrivate *parentD = parent->d_func();
executed (the execution status of this line is deduced): QObjectPrivate *parentD = parent->d_func();
-
1778 if (parentD->isDeletingChildren && wasDeleted
evaluated: parentD->isDeletingChildren
TRUEFALSE
yes
Evaluation Count:51813
yes
Evaluation Count:43560
partially evaluated: wasDeleted
TRUEFALSE
yes
Evaluation Count:51813
no
Evaluation Count:0
0-51813
1779 && parentD->currentChildBeingDeleted == q) {
evaluated: parentD->currentChildBeingDeleted == q
TRUEFALSE
yes
Evaluation Count:51812
yes
Evaluation Count:1
1-51812
1780 // don't do anything since QObjectPrivate::deleteChildren() already -
1781 // cleared our entry in parentD->children. -
1782 } else {
executed: }
Execution Count:51812
51812
1783 const int index = parentD->children.indexOf(q);
executed (the execution status of this line is deduced): const int index = parentD->children.indexOf(q);
-
1784 if (parentD->isDeletingChildren) {
evaluated: parentD->isDeletingChildren
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:43560
1-43560
1785 parentD->children[index] = 0;
executed (the execution status of this line is deduced): parentD->children[index] = 0;
-
1786 } else {
executed: }
Execution Count:1
1
1787 parentD->children.removeAt(index);
executed (the execution status of this line is deduced): parentD->children.removeAt(index);
-
1788 if (sendChildEvents && parentD->receiveChildEvents) {
evaluated: sendChildEvents
TRUEFALSE
yes
Evaluation Count:43559
yes
Evaluation Count:1
partially evaluated: parentD->receiveChildEvents
TRUEFALSE
yes
Evaluation Count:43559
no
Evaluation Count:0
0-43559
1789 QChildEvent e(QEvent::ChildRemoved, q);
executed (the execution status of this line is deduced): QChildEvent e(QEvent::ChildRemoved, q);
-
1790 QCoreApplication::sendEvent(parent, &e);
executed (the execution status of this line is deduced): QCoreApplication::sendEvent(parent, &e);
-
1791 }
executed: }
Execution Count:43559
43559
1792 }
executed: }
Execution Count:43560
43560
1793 } -
1794 } -
1795 parent = o;
executed (the execution status of this line is deduced): parent = o;
-
1796 if (parent) {
evaluated: parent
TRUEFALSE
yes
Evaluation Count:99241
yes
Evaluation Count:94655
94655-99241
1797 // object hierarchies are constrained to a single thread -
1798 if (threadData != parent->d_func()->threadData) {
partially evaluated: threadData != parent->d_func()->threadData
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:99240
0-99240
1799 qWarning("QObject::setParent: Cannot set parent, new parent is in a different thread");
never executed (the execution status of this line is deduced): QMessageLogger("kernel/qobject.cpp", 1799, __PRETTY_FUNCTION__).warning("QObject::setParent: Cannot set parent, new parent is in a different thread");
-
1800 parent = 0;
never executed (the execution status of this line is deduced): parent = 0;
-
1801 return;
never executed: return;
0
1802 } -
1803 parent->d_func()->children.append(q);
executed (the execution status of this line is deduced): parent->d_func()->children.append(q);
-
1804 if(sendChildEvents && parent->d_func()->receiveChildEvents) {
evaluated: sendChildEvents
TRUEFALSE
yes
Evaluation Count:99240
yes
Evaluation Count:1
partially evaluated: parent->d_func()->receiveChildEvents
TRUEFALSE
yes
Evaluation Count:99240
no
Evaluation Count:0
0-99240
1805 if (!isWidget) {
evaluated: !isWidget
TRUEFALSE
yes
Evaluation Count:66072
yes
Evaluation Count:33168
33168-66072
1806 QChildEvent e(QEvent::ChildAdded, q);
executed (the execution status of this line is deduced): QChildEvent e(QEvent::ChildAdded, q);
-
1807 QCoreApplication::sendEvent(parent, &e);
executed (the execution status of this line is deduced): QCoreApplication::sendEvent(parent, &e);
-
1808 }
executed: }
Execution Count:66068
66068
1809 }
executed: }
Execution Count:99237
99237
1810 }
executed: }
Execution Count:99238
99238
1811 if (!isDeletingChildren && declarativeData)
partially evaluated: !isDeletingChildren
TRUEFALSE
yes
Evaluation Count:193893
no
Evaluation Count:0
partially evaluated: declarativeData
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:193892
0-193893
1812 QAbstractDeclarativeData::parentChanged(declarativeData, q, o);
never executed: QAbstractDeclarativeData::parentChanged(declarativeData, q, o);
0
1813}
executed: }
Execution Count:193890
193890
1814 -
1815/*! -
1816 \fn void QObject::installEventFilter(QObject *filterObj) -
1817 -
1818 Installs an event filter \a filterObj on this object. For example: -
1819 \snippet code/src_corelib_kernel_qobject.cpp 14 -
1820 -
1821 An event filter is an object that receives all events that are -
1822 sent to this object. The filter can either stop the event or -
1823 forward it to this object. The event filter \a filterObj receives -
1824 events via its eventFilter() function. The eventFilter() function -
1825 must return true if the event should be filtered, (i.e. stopped); -
1826 otherwise it must return false. -
1827 -
1828 If multiple event filters are installed on a single object, the -
1829 filter that was installed last is activated first. -
1830 -
1831 Here's a \c KeyPressEater class that eats the key presses of its -
1832 monitored objects: -
1833 -
1834 \snippet code/src_corelib_kernel_qobject.cpp 15 -
1835 -
1836 And here's how to install it on two widgets: -
1837 -
1838 \snippet code/src_corelib_kernel_qobject.cpp 16 -
1839 -
1840 The QShortcut class, for example, uses this technique to intercept -
1841 shortcut key presses. -
1842 -
1843 \warning If you delete the receiver object in your eventFilter() -
1844 function, be sure to return true. If you return false, Qt sends -
1845 the event to the deleted object and the program will crash. -
1846 -
1847 Note that the filtering object must be in the same thread as this -
1848 object. If \a filterObj is in a different thread, this function does -
1849 nothing. If either \a filterObj or this object are moved to a different -
1850 thread after calling this function, the event filter will not be -
1851 called until both objects have the same thread affinity again (it -
1852 is \e not removed). -
1853 -
1854 \sa removeEventFilter(), eventFilter(), event() -
1855*/ -
1856 -
1857void QObject::installEventFilter(QObject *obj) -
1858{ -
1859 Q_D(QObject);
executed (the execution status of this line is deduced): QObjectPrivate * const d = d_func();
-
1860 if (!obj)
partially evaluated: !obj
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:14355
0-14355
1861 return;
never executed: return;
0
1862 if (d->threadData != obj->d_func()->threadData) {
evaluated: d->threadData != obj->d_func()->threadData
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:14354
1-14354
1863 qWarning("QObject::installEventFilter(): Cannot filter events for objects in a different thread.");
executed (the execution status of this line is deduced): QMessageLogger("kernel/qobject.cpp", 1863, __PRETTY_FUNCTION__).warning("QObject::installEventFilter(): Cannot filter events for objects in a different thread.");
-
1864 return;
executed: return;
Execution Count:1
1
1865 } -
1866 -
1867 if (!d->extraData)
evaluated: !d->extraData
TRUEFALSE
yes
Evaluation Count:9411
yes
Evaluation Count:4943
4943-9411
1868 d->extraData = new QObjectPrivate::ExtraData;
executed: d->extraData = new QObjectPrivate::ExtraData;
Execution Count:9411
9411
1869 -
1870 // clean up unused items in the list -
1871 d->extraData->eventFilters.removeAll((QObject*)0);
executed (the execution status of this line is deduced): d->extraData->eventFilters.removeAll((QObject*)0);
-
1872 d->extraData->eventFilters.removeAll(obj);
executed (the execution status of this line is deduced): d->extraData->eventFilters.removeAll(obj);
-
1873 d->extraData->eventFilters.prepend(obj);
executed (the execution status of this line is deduced): d->extraData->eventFilters.prepend(obj);
-
1874}
executed: }
Execution Count:14354
14354
1875 -
1876/*! -
1877 Removes an event filter object \a obj from this object. The -
1878 request is ignored if such an event filter has not been installed. -
1879 -
1880 All event filters for this object are automatically removed when -
1881 this object is destroyed. -
1882 -
1883 It is always safe to remove an event filter, even during event -
1884 filter activation (i.e. from the eventFilter() function). -
1885 -
1886 \sa installEventFilter(), eventFilter(), event() -
1887*/ -
1888 -
1889void QObject::removeEventFilter(QObject *obj) -
1890{ -
1891 Q_D(QObject);
executed (the execution status of this line is deduced): QObjectPrivate * const d = d_func();
-
1892 if (d->extraData) {
evaluated: d->extraData
TRUEFALSE
yes
Evaluation Count:713
yes
Evaluation Count:354
354-713
1893 for (int i = 0; i < d->extraData->eventFilters.count(); ++i) {
evaluated: i < d->extraData->eventFilters.count()
TRUEFALSE
yes
Evaluation Count:921
yes
Evaluation Count:713
713-921
1894 if (d->extraData->eventFilters.at(i) == obj)
evaluated: d->extraData->eventFilters.at(i) == obj
TRUEFALSE
yes
Evaluation Count:452
yes
Evaluation Count:469
452-469
1895 d->extraData->eventFilters[i] = 0;
executed: d->extraData->eventFilters[i] = 0;
Execution Count:452
452
1896 }
executed: }
Execution Count:921
921
1897 }
executed: }
Execution Count:713
713
1898}
executed: }
Execution Count:1067
1067
1899 -
1900 -
1901/*! -
1902 \fn QObject::destroyed(QObject *obj) -
1903 -
1904 This signal is emitted immediately before the object \a obj is -
1905 destroyed, and can not be blocked. -
1906 -
1907 All the objects's children are destroyed immediately after this -
1908 signal is emitted. -
1909 -
1910 \sa deleteLater(), QPointer -
1911*/ -
1912 -
1913/*! -
1914 Schedules this object for deletion. -
1915 -
1916 The object will be deleted when control returns to the event -
1917 loop. If the event loop is not running when this function is -
1918 called (e.g. deleteLater() is called on an object before -
1919 QCoreApplication::exec()), the object will be deleted once the -
1920 event loop is started. -
1921 -
1922 Note that entering and leaving a new event loop (e.g., by opening a modal -
1923 dialog) will \e not perform the deferred deletion; for the object to be -
1924 deleted, the control must return to the event loop from which -
1925 deleteLater() was called. -
1926 -
1927 \b{Note:} It is safe to call this function more than once; when the -
1928 first deferred deletion event is delivered, any pending events for the -
1929 object are removed from the event queue. -
1930 -
1931 \sa destroyed(), QPointer -
1932*/ -
1933void QObject::deleteLater() -
1934{ -
1935 QCoreApplication::postEvent(this, new QDeferredDeleteEvent());
executed (the execution status of this line is deduced): QCoreApplication::postEvent(this, new QDeferredDeleteEvent());
-
1936}
executed: }
Execution Count:7971
7971
1937 -
1938/*! -
1939 \fn QString QObject::tr(const char *sourceText, const char *disambiguation, int n) -
1940 \reentrant -
1941 -
1942 Returns a translated version of \a sourceText, optionally based on a -
1943 \a disambiguation string and value of \a n for strings containing plurals; -
1944 otherwise returns \a sourceText itself if no appropriate translated string -
1945 is available. -
1946 -
1947 Example: -
1948 \snippet ../widgets/mainwindows/sdi/mainwindow.cpp implicit tr context -
1949 \dots -
1950 -
1951 If the same \a sourceText is used in different roles within the -
1952 same context, an additional identifying string may be passed in -
1953 \a disambiguation (0 by default). In Qt 4.4 and earlier, this was -
1954 the preferred way to pass comments to translators. -
1955 -
1956 Example: -
1957 -
1958 \snippet code/src_corelib_kernel_qobject.cpp 17 -
1959 \dots -
1960 -
1961 See \l{Writing Source Code for Translation} for a detailed description of -
1962 Qt's translation mechanisms in general, and the -
1963 \l{Writing Source Code for Translation#Disambiguation}{Disambiguation} -
1964 section for information on disambiguation. -
1965 -
1966 \warning This method is reentrant only if all translators are -
1967 installed \e before calling this method. Installing or removing -
1968 translators while performing translations is not supported. Doing -
1969 so will probably result in crashes or other undesirable behavior. -
1970 -
1971 \sa trUtf8(), QCoreApplication::translate(), {Internationalization with Qt} -
1972*/ -
1973 -
1974/*! -
1975 \fn QString QObject::trUtf8(const char *sourceText, const char *disambiguation, int n) -
1976 \reentrant -
1977 \obsolete -
1978 -
1979 Returns a translated version of \a sourceText, or -
1980 QString::fromUtf8(\a sourceText) if there is no appropriate -
1981 version. It is otherwise identical to tr(\a sourceText, \a -
1982 disambiguation, \a n). -
1983 -
1984 \warning This method is reentrant only if all translators are -
1985 installed \e before calling this method. Installing or removing -
1986 translators while performing translations is not supported. Doing -
1987 so will probably result in crashes or other undesirable behavior. -
1988 -
1989 \warning For portability reasons, we recommend that you use -
1990 escape sequences for specifying non-ASCII characters in string -
1991 literals to trUtf8(). For example: -
1992 -
1993 \snippet code/src_corelib_kernel_qobject.cpp 20 -
1994 -
1995 \sa tr(), QCoreApplication::translate(), {Internationalization with Qt} -
1996*/ -
1997 -
1998 -
1999 -
2000 -
2001/***************************************************************************** -
2002 Signals and slots -
2003 *****************************************************************************/ -
2004 -
2005 -
2006const int flagged_locations_count = 2; -
2007static const char* flagged_locations[flagged_locations_count] = {0}; -
2008 -
2009const char *qFlagLocation(const char *method) -
2010{ -
2011 static int idx = 0; -
2012 flagged_locations[idx] = method;
never executed (the execution status of this line is deduced): flagged_locations[idx] = method;
-
2013 idx = (idx+1) % flagged_locations_count;
never executed (the execution status of this line is deduced): idx = (idx+1) % flagged_locations_count;
-
2014 return method;
never executed: return method;
0
2015} -
2016 -
2017static int extract_code(const char *member) -
2018{ -
2019 // extract code, ensure QMETHOD_CODE <= code <= QSIGNAL_CODE -
2020 return (((int)(*member) - '0') & 0x3);
executed: return (((int)(*member) - '0') & 0x3);
Execution Count:714866
714866
2021} -
2022 -
2023static const char * extract_location(const char *member) -
2024{ -
2025 for (int i = 0; i < flagged_locations_count; ++i) {
never evaluated: i < flagged_locations_count
0
2026 if (member == flagged_locations[i]) {
never evaluated: member == flagged_locations[i]
0
2027 // signature includes location information after the first null-terminator -
2028 const char *location = member + qstrlen(member) + 1;
never executed (the execution status of this line is deduced): const char *location = member + qstrlen(member) + 1;
-
2029 if (*location != '\0')
never evaluated: *location != '\0'
0
2030 return location;
never executed: return location;
0
2031 return 0;
never executed: return 0;
0
2032 } -
2033 }
never executed: }
0
2034 return 0;
never executed: return 0;
0
2035} -
2036 -
2037static bool check_signal_macro(const QObject *sender, const char *signal, -
2038 const char *func, const char *op) -
2039{ -
2040 int sigcode = extract_code(signal);
executed (the execution status of this line is deduced): int sigcode = extract_code(signal);
-
2041 if (sigcode != QSIGNAL_CODE) {
partially evaluated: sigcode != 2
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:359019
0-359019
2042 if (sigcode == QSLOT_CODE)
never evaluated: sigcode == 1
0
2043 qWarning("QObject::%s: Attempt to %s non-signal %s::%s",
never executed: QMessageLogger("kernel/qobject.cpp", 2043, __PRETTY_FUNCTION__).warning("QObject::%s: Attempt to %s non-signal %s::%s", func, op, sender->metaObject()->className(), signal+1);
0
2044 func, op, sender->metaObject()->className(), signal+1);
never executed: QMessageLogger("kernel/qobject.cpp", 2043, __PRETTY_FUNCTION__).warning("QObject::%s: Attempt to %s non-signal %s::%s", func, op, sender->metaObject()->className(), signal+1);
0
2045 else -
2046 qWarning("QObject::%s: Use the SIGNAL macro to %s %s::%s",
never executed: QMessageLogger("kernel/qobject.cpp", 2046, __PRETTY_FUNCTION__).warning("QObject::%s: Use the SIGNAL macro to %s %s::%s", func, op, sender->metaObject()->className(), signal);
0
2047 func, op, sender->metaObject()->className(), signal);
never executed: QMessageLogger("kernel/qobject.cpp", 2046, __PRETTY_FUNCTION__).warning("QObject::%s: Use the SIGNAL macro to %s %s::%s", func, op, sender->metaObject()->className(), signal);
0
2048 return false;
never executed: return false;
0
2049 } -
2050 return true;
executed: return true;
Execution Count:359019
359019
2051} -
2052 -
2053static bool check_method_code(int code, const QObject *object, -
2054 const char *method, const char *func) -
2055{ -
2056 if (code != QSLOT_CODE && code != QSIGNAL_CODE) {
evaluated: code != 1
TRUEFALSE
yes
Evaluation Count:9837
yes
Evaluation Count:346020
partially evaluated: code != 2
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:9837
0-346020
2057 qWarning("QObject::%s: Use the SLOT or SIGNAL macro to "
never executed (the execution status of this line is deduced): QMessageLogger("kernel/qobject.cpp", 2057, __PRETTY_FUNCTION__).warning("QObject::%s: Use the SLOT or SIGNAL macro to "
-
2058 "%s %s::%s", func, func, object->metaObject()->className(), method);
never executed (the execution status of this line is deduced): "%s %s::%s", func, func, object->metaObject()->className(), method);
-
2059 return false;
never executed: return false;
0
2060 } -
2061 return true;
executed: return true;
Execution Count:355855
355855
2062} -
2063 -
2064static void err_method_notfound(const QObject *object, -
2065 const char *method, const char *func) -
2066{ -
2067 const char *type = "method";
never executed (the execution status of this line is deduced): const char *type = "method";
-
2068 switch (extract_code(method)) { -
2069 case QSLOT_CODE: type = "slot"; break;
never executed: break;
0
2070 case QSIGNAL_CODE: type = "signal"; break;
never executed: break;
0
2071 } -
2072 const char *loc = extract_location(method);
never executed (the execution status of this line is deduced): const char *loc = extract_location(method);
-
2073 if (strchr(method,')') == 0) // common typing mistake
never evaluated: strchr(method,')') == 0
0
2074 qWarning("QObject::%s: Parentheses expected, %s %s::%s%s%s",
never executed: QMessageLogger("kernel/qobject.cpp", 2074, __PRETTY_FUNCTION__).warning("QObject::%s: Parentheses expected, %s %s::%s%s%s", func, type, object->metaObject()->className(), method+1, loc ? " in ": "", loc ? loc : "");
0
2075 func, type, object->metaObject()->className(), method+1,
never executed: QMessageLogger("kernel/qobject.cpp", 2074, __PRETTY_FUNCTION__).warning("QObject::%s: Parentheses expected, %s %s::%s%s%s", func, type, object->metaObject()->className(), method+1, loc ? " in ": "", loc ? loc : "");
0
2076 loc ? " in ": "", loc ? loc : "");
never executed: QMessageLogger("kernel/qobject.cpp", 2074, __PRETTY_FUNCTION__).warning("QObject::%s: Parentheses expected, %s %s::%s%s%s", func, type, object->metaObject()->className(), method+1, loc ? " in ": "", loc ? loc : "");
0
2077 else -
2078 qWarning("QObject::%s: No such %s %s::%s%s%s",
never executed: QMessageLogger("kernel/qobject.cpp", 2078, __PRETTY_FUNCTION__).warning("QObject::%s: No such %s %s::%s%s%s", func, type, object->metaObject()->className(), method+1, loc ? " in ": "", loc ? loc : "");
0
2079 func, type, object->metaObject()->className(), method+1,
never executed: QMessageLogger("kernel/qobject.cpp", 2078, __PRETTY_FUNCTION__).warning("QObject::%s: No such %s %s::%s%s%s", func, type, object->metaObject()->className(), method+1, loc ? " in ": "", loc ? loc : "");
0
2080 loc ? " in ": "", loc ? loc : "");
never executed: QMessageLogger("kernel/qobject.cpp", 2078, __PRETTY_FUNCTION__).warning("QObject::%s: No such %s %s::%s%s%s", func, type, object->metaObject()->className(), method+1, loc ? " in ": "", loc ? loc : "");
0
2081 -
2082} -
2083 -
2084 -
2085static void err_info_about_objects(const char * func, -
2086 const QObject * sender, -
2087 const QObject * receiver) -
2088{ -
2089 QString a = sender ? sender->objectName() : QString();
never evaluated: sender
0
2090 QString b = receiver ? receiver->objectName() : QString();
never evaluated: receiver
0
2091 if (!a.isEmpty())
never evaluated: !a.isEmpty()
0
2092 qWarning("QObject::%s: (sender name: '%s')", func, a.toLocal8Bit().data());
never executed: QMessageLogger("kernel/qobject.cpp", 2092, __PRETTY_FUNCTION__).warning("QObject::%s: (sender name: '%s')", func, a.toLocal8Bit().data());
0
2093 if (!b.isEmpty())
never evaluated: !b.isEmpty()
0
2094 qWarning("QObject::%s: (receiver name: '%s')", func, b.toLocal8Bit().data());
never executed: QMessageLogger("kernel/qobject.cpp", 2094, __PRETTY_FUNCTION__).warning("QObject::%s: (receiver name: '%s')", func, b.toLocal8Bit().data());
0
2095}
never executed: }
0
2096 -
2097/*! -
2098 Returns a pointer to the object that sent the signal, if called in -
2099 a slot activated by a signal; otherwise it returns 0. The pointer -
2100 is valid only during the execution of the slot that calls this -
2101 function from this object's thread context. -
2102 -
2103 The pointer returned by this function becomes invalid if the -
2104 sender is destroyed, or if the slot is disconnected from the -
2105 sender's signal. -
2106 -
2107 \warning This function violates the object-oriented principle of -
2108 modularity. However, getting access to the sender might be useful -
2109 when many signals are connected to a single slot. -
2110 -
2111 \warning As mentioned above, the return value of this function is -
2112 not valid when the slot is called via a Qt::DirectConnection from -
2113 a thread different from this object's thread. Do not use this -
2114 function in this type of scenario. -
2115 -
2116 \sa senderSignalIndex(), QSignalMapper -
2117*/ -
2118 -
2119QObject *QObject::sender() const -
2120{ -
2121 Q_D(const QObject);
executed (the execution status of this line is deduced): const QObjectPrivate * const d = d_func();
-
2122 -
2123 QMutexLocker locker(signalSlotLock(this));
executed (the execution status of this line is deduced): QMutexLocker locker(signalSlotLock(this));
-
2124 if (!d->currentSender)
evaluated: !d->currentSender
TRUEFALSE
yes
Evaluation Count:35
yes
Evaluation Count:6048
35-6048
2125 return 0;
executed: return 0;
Execution Count:35
35
2126 -
2127 for (QObjectPrivate::Connection *c = d->senders; c; c = c->next) {
evaluated: c
TRUEFALSE
yes
Evaluation Count:22840
yes
Evaluation Count:3
3-22840
2128 if (c->sender == d->currentSender->sender)
evaluated: c->sender == d->currentSender->sender
TRUEFALSE
yes
Evaluation Count:6045
yes
Evaluation Count:16795
6045-16795
2129 return d->currentSender->sender;
executed: return d->currentSender->sender;
Execution Count:6045
6045
2130 }
executed: }
Execution Count:16795
16795
2131 -
2132 return 0;
executed: return 0;
Execution Count:3
3
2133} -
2134 -
2135/*! -
2136 \since 4.8 -
2137 -
2138 Returns the meta-method index of the signal that called the currently -
2139 executing slot, which is a member of the class returned by sender(). -
2140 If called outside of a slot activated by a signal, -1 is returned. -
2141 -
2142 For signals with default parameters, this function will always return -
2143 the index with all parameters, regardless of which was used with -
2144 connect(). For example, the signal \c {destroyed(QObject *obj = 0)} -
2145 will have two different indexes (with and without the parameter), but -
2146 this function will always return the index with a parameter. This does -
2147 not apply when overloading signals with different parameters. -
2148 -
2149 \warning This function violates the object-oriented principle of -
2150 modularity. However, getting access to the signal index might be useful -
2151 when many signals are connected to a single slot. -
2152 -
2153 \warning The return value of this function is not valid when the slot -
2154 is called via a Qt::DirectConnection from a thread different from this -
2155 object's thread. Do not use this function in this type of scenario. -
2156 -
2157 \sa sender(), QMetaObject::indexOfSignal(), QMetaObject::method() -
2158*/ -
2159 -
2160int QObject::senderSignalIndex() const -
2161{ -
2162 Q_D(const QObject);
executed (the execution status of this line is deduced): const QObjectPrivate * const d = d_func();
-
2163 int signal_index = d->senderSignalIndex();
executed (the execution status of this line is deduced): int signal_index = d->senderSignalIndex();
-
2164 if (signal_index < 0)
evaluated: signal_index < 0
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:742
7-742
2165 return signal_index;
executed: return signal_index;
Execution Count:7
7
2166 // Convert from signal range to method range -
2167 return QMetaObjectPrivate::signal(sender()->metaObject(), signal_index).methodIndex();
executed: return QMetaObjectPrivate::signal(sender()->metaObject(), signal_index).methodIndex();
Execution Count:742
742
2168} -
2169 -
2170/*! -
2171 Returns the number of receivers connected to the \a signal. -
2172 -
2173 Since both slots and signals can be used as receivers for signals, -
2174 and the same connections can be made many times, the number of -
2175 receivers is the same as the number of connections made from this -
2176 signal. -
2177 -
2178 When calling this function, you can use the \c SIGNAL() macro to -
2179 pass a specific signal: -
2180 -
2181 \snippet code/src_corelib_kernel_qobject.cpp 21 -
2182 -
2183 \warning This function violates the object-oriented principle of -
2184 modularity. However, it might be useful when you need to perform -
2185 expensive initialization only if something is connected to a -
2186 signal. -
2187 -
2188 \sa isSignalConnected() -
2189*/ -
2190 -
2191int QObject::receivers(const char *signal) const -
2192{ -
2193 Q_D(const QObject);
executed (the execution status of this line is deduced): const QObjectPrivate * const d = d_func();
-
2194 int receivers = 0;
executed (the execution status of this line is deduced): int receivers = 0;
-
2195 if (signal) {
partially evaluated: signal
TRUEFALSE
yes
Evaluation Count:6
no
Evaluation Count:0
0-6
2196 QByteArray signal_name = QMetaObject::normalizedSignature(signal);
executed (the execution status of this line is deduced): QByteArray signal_name = QMetaObject::normalizedSignature(signal);
-
2197 signal = signal_name;
executed (the execution status of this line is deduced): signal = signal_name;
-
2198#ifndef QT_NO_DEBUG -
2199 if (!check_signal_macro(this, signal, "receivers", "bind")) -
2200 return 0; -
2201#endif -
2202 signal++; // skip code
executed (the execution status of this line is deduced): signal++;
-
2203 int signal_index = d->signalIndex(signal);
executed (the execution status of this line is deduced): int signal_index = d->signalIndex(signal);
-
2204 if (signal_index < 0) {
partially evaluated: signal_index < 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6
0-6
2205#ifndef QT_NO_DEBUG -
2206 err_method_notfound(this, signal-1, "receivers"); -
2207#endif -
2208 return 0;
never executed: return 0;
0
2209 } -
2210 -
2211 if (!d->isSignalConnected(signal_index))
evaluated: !d->isSignalConnected(signal_index)
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:3
3
2212 return receivers;
executed: return receivers;
Execution Count:3
3
2213 -
2214 if (d->declarativeData && QAbstractDeclarativeData::receivers) {
partially evaluated: d->declarativeData
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
never evaluated: QAbstractDeclarativeData::receivers
0-3
2215 receivers += QAbstractDeclarativeData::receivers(d->declarativeData, this,
never executed (the execution status of this line is deduced): receivers += QAbstractDeclarativeData::receivers(d->declarativeData, this,
-
2216 signal_index);
never executed (the execution status of this line is deduced): signal_index);
-
2217 }
never executed: }
0
2218 -
2219 QMutexLocker locker(signalSlotLock(this));
executed (the execution status of this line is deduced): QMutexLocker locker(signalSlotLock(this));
-
2220 if (d->connectionLists) {
partially evaluated: d->connectionLists
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-3
2221 if (signal_index < d->connectionLists->count()) {
partially evaluated: signal_index < d->connectionLists->count()
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-3
2222 const QObjectPrivate::Connection *c =
executed (the execution status of this line is deduced): const QObjectPrivate::Connection *c =
-
2223 d->connectionLists->at(signal_index).first;
executed (the execution status of this line is deduced): d->connectionLists->at(signal_index).first;
-
2224 while (c) {
evaluated: c
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:3
3-5
2225 receivers += c->receiver ? 1 : 0;
evaluated: c->receiver
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:2
2-3
2226 c = c->nextConnectionList;
executed (the execution status of this line is deduced): c = c->nextConnectionList;
-
2227 }
executed: }
Execution Count:5
5
2228 }
executed: }
Execution Count:3
3
2229 }
executed: }
Execution Count:3
3
2230 }
executed: }
Execution Count:3
3
2231 return receivers;
executed: return receivers;
Execution Count:3
3
2232} -
2233 -
2234/*! -
2235 \since 5.0 -
2236 Returns true if the \a signal is connected to at least one receiver, -
2237 otherwise returns false. -
2238 -
2239 \a signal must be a signal member of this object, otherwise the behaviour -
2240 is undefined. -
2241 -
2242 \snippet code/src_corelib_kernel_qobject.cpp 49 -
2243 -
2244 As the code snippet above illustrates, you can use this function -
2245 to avoid emitting a signal that nobody listens to. -
2246 -
2247 \warning This function violates the object-oriented principle of -
2248 modularity. However, it might be useful when you need to perform -
2249 expensive initialization only if something is connected to a -
2250 signal. -
2251*/ -
2252bool QObject::isSignalConnected(const QMetaMethod &signal) const -
2253{ -
2254 Q_D(const QObject);
executed (the execution status of this line is deduced): const QObjectPrivate * const d = d_func();
-
2255 if (!signal.mobj)
evaluated: !signal.mobj
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:24
1-24
2256 return false;
executed: return false;
Execution Count:1
1
2257 -
2258 Q_ASSERT_X(signal.mobj->cast(this) && signal.methodType() == QMetaMethod::Signal,
executed (the execution status of this line is deduced): qt_noop();
-
2259 "QObject::isSignalConnected" , "the parameter must be a signal member of the object"); -
2260 uint signalIndex = (signal.handle - QMetaObjectPrivate::get(signal.mobj)->methodData)/5;
executed (the execution status of this line is deduced): uint signalIndex = (signal.handle - QMetaObjectPrivate::get(signal.mobj)->methodData)/5;
-
2261 -
2262 if (signal.mobj->d.data[signal.handle + 4] & MethodCloned)
evaluated: signal.mobj->d.data[signal.handle + 4] & MethodCloned
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:21
3-21
2263 signalIndex = QMetaObjectPrivate::originalClone(signal.mobj, signalIndex);
executed: signalIndex = QMetaObjectPrivate::originalClone(signal.mobj, signalIndex);
Execution Count:3
3
2264 -
2265 signalIndex += QMetaObjectPrivate::signalOffset(signal.mobj);
executed (the execution status of this line is deduced): signalIndex += QMetaObjectPrivate::signalOffset(signal.mobj);
-
2266 -
2267 if (signalIndex < sizeof(d->connectedSignals) * 8)
evaluated: signalIndex < sizeof(d->connectedSignals) * 8
TRUEFALSE
yes
Evaluation Count:20
yes
Evaluation Count:4
4-20
2268 return d->isSignalConnected(signalIndex);
executed: return d->isSignalConnected(signalIndex);
Execution Count:20
20
2269 -
2270 QMutexLocker locker(signalSlotLock(this));
executed (the execution status of this line is deduced): QMutexLocker locker(signalSlotLock(this));
-
2271 if (d->connectionLists) {
evaluated: d->connectionLists
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:1
1-3
2272 if (signalIndex < uint(d->connectionLists->count())) {
partially evaluated: signalIndex < uint(d->connectionLists->count())
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-3
2273 const QObjectPrivate::Connection *c =
executed (the execution status of this line is deduced): const QObjectPrivate::Connection *c =
-
2274 d->connectionLists->at(signalIndex).first;
executed (the execution status of this line is deduced): d->connectionLists->at(signalIndex).first;
-
2275 while (c) {
partially evaluated: c
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-3
2276 if (c->receiver)
partially evaluated: c->receiver
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-3
2277 return true;
executed: return true;
Execution Count:3
3
2278 c = c->nextConnectionList;
never executed (the execution status of this line is deduced): c = c->nextConnectionList;
-
2279 }
never executed: }
0
2280 }
never executed: }
0
2281 }
never executed: }
0
2282 return false;
executed: return false;
Execution Count:1
1
2283} -
2284 -
2285/*! -
2286 \internal -
2287 -
2288 This helper function calculates signal and method index for the given -
2289 member in the specified class. -
2290 -
2291 \list -
2292 \li If member.mobj is 0 then both signalIndex and methodIndex are set to -1. -
2293 -
2294 \li If specified member is not a member of obj instance class (or one of -
2295 its parent classes) then both signalIndex and methodIndex are set to -1. -
2296 \endlist -
2297 -
2298 This function is used by QObject::connect and QObject::disconnect which -
2299 are working with QMetaMethod. -
2300 -
2301 \a signalIndex is set to the signal index of member. If the member -
2302 specified is not signal this variable is set to -1. -
2303 -
2304 \a methodIndex is set to the method index of the member. If the -
2305 member is not a method of the object specified by the \a obj argument this -
2306 variable is set to -1. -
2307*/ -
2308void QMetaObjectPrivate::memberIndexes(const QObject *obj, -
2309 const QMetaMethod &member, -
2310 int *signalIndex, int *methodIndex) -
2311{ -
2312 *signalIndex = -1;
executed (the execution status of this line is deduced): *signalIndex = -1;
-
2313 *methodIndex = -1;
executed (the execution status of this line is deduced): *methodIndex = -1;
-
2314 if (!obj || !member.mobj)
evaluated: !obj
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:80
evaluated: !member.mobj
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:71
8-80
2315 return;
executed: return;
Execution Count:17
17
2316 const QMetaObject *m = obj->metaObject();
executed (the execution status of this line is deduced): const QMetaObject *m = obj->metaObject();
-
2317 // Check that member is member of obj class -
2318 while (m != 0 && m != member.mobj)
partially evaluated: m != 0
TRUEFALSE
yes
Evaluation Count:73
no
Evaluation Count:0
evaluated: m != member.mobj
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:71
0-73
2319 m = m->d.superdata;
executed: m = m->d.superdata;
Execution Count:2
2
2320 if (!m)
partially evaluated: !m
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:71
0-71
2321 return;
never executed: return;
0
2322 *signalIndex = *methodIndex = (member.handle - get(member.mobj)->methodData)/5;
executed (the execution status of this line is deduced): *signalIndex = *methodIndex = (member.handle - get(member.mobj)->methodData)/5;
-
2323 -
2324 int signalOffset;
executed (the execution status of this line is deduced): int signalOffset;
-
2325 int methodOffset;
executed (the execution status of this line is deduced): int methodOffset;
-
2326 computeOffsets(m, &signalOffset, &methodOffset);
executed (the execution status of this line is deduced): computeOffsets(m, &signalOffset, &methodOffset);
-
2327 -
2328 *methodIndex += methodOffset;
executed (the execution status of this line is deduced): *methodIndex += methodOffset;
-
2329 if (member.methodType() == QMetaMethod::Signal) {
evaluated: member.methodType() == QMetaMethod::Signal
TRUEFALSE
yes
Evaluation Count:36
yes
Evaluation Count:35
35-36
2330 *signalIndex = originalClone(m, *signalIndex);
executed (the execution status of this line is deduced): *signalIndex = originalClone(m, *signalIndex);
-
2331 *signalIndex += signalOffset;
executed (the execution status of this line is deduced): *signalIndex += signalOffset;
-
2332 } else {
executed: }
Execution Count:36
36
2333 *signalIndex = -1;
executed (the execution status of this line is deduced): *signalIndex = -1;
-
2334 }
executed: }
Execution Count:35
35
2335} -
2336 -
2337static inline void check_and_warn_compat(const QMetaObject *sender, const QMetaMethod &signal, -
2338 const QMetaObject *receiver, const QMetaMethod &method) -
2339{ -
2340 if (signal.attributes() & QMetaMethod::Compatibility) {
never evaluated: signal.attributes() & QMetaMethod::Compatibility
0
2341 if (!(method.attributes() & QMetaMethod::Compatibility))
never evaluated: !(method.attributes() & QMetaMethod::Compatibility)
0
2342 qWarning("QObject::connect: Connecting from COMPAT signal (%s::%s)",
never executed: QMessageLogger("kernel/qobject.cpp", 2342, __PRETTY_FUNCTION__).warning("QObject::connect: Connecting from COMPAT signal (%s::%s)", sender->className(), signal.methodSignature().constData());
0
2343 sender->className(), signal.methodSignature().constData());
never executed: QMessageLogger("kernel/qobject.cpp", 2342, __PRETTY_FUNCTION__).warning("QObject::connect: Connecting from COMPAT signal (%s::%s)", sender->className(), signal.methodSignature().constData());
0
2344 } else if ((method.attributes() & QMetaMethod::Compatibility) &&
never executed: }
never evaluated: (method.attributes() & QMetaMethod::Compatibility)
0
2345 method.methodType() == QMetaMethod::Signal) {
never evaluated: method.methodType() == QMetaMethod::Signal
0
2346 qWarning("QObject::connect: Connecting from %s::%s to COMPAT slot (%s::%s)",
never executed (the execution status of this line is deduced): QMessageLogger("kernel/qobject.cpp", 2346, __PRETTY_FUNCTION__).warning("QObject::connect: Connecting from %s::%s to COMPAT slot (%s::%s)",
-
2347 sender->className(), signal.methodSignature().constData(),
never executed (the execution status of this line is deduced): sender->className(), signal.methodSignature().constData(),
-
2348 receiver->className(), method.methodSignature().constData());
never executed (the execution status of this line is deduced): receiver->className(), method.methodSignature().constData());
-
2349 }
never executed: }
0
2350} -
2351 -
2352/*! -
2353 \threadsafe -
2354 -
2355 Creates a connection of the given \a type from the \a signal in -
2356 the \a sender object to the \a method in the \a receiver object. -
2357 Returns a handle to the connection that can be used to disconnect -
2358 it later. -
2359 -
2360 You must use the \c SIGNAL() and \c SLOT() macros when specifying -
2361 the \a signal and the \a method, for example: -
2362 -
2363 \snippet code/src_corelib_kernel_qobject.cpp 22 -
2364 -
2365 This example ensures that the label always displays the current -
2366 scroll bar value. Note that the signal and slots parameters must not -
2367 contain any variable names, only the type. E.g. the following would -
2368 not work and return false: -
2369 -
2370 \snippet code/src_corelib_kernel_qobject.cpp 23 -
2371 -
2372 A signal can also be connected to another signal: -
2373 -
2374 \snippet code/src_corelib_kernel_qobject.cpp 24 -
2375 -
2376 In this example, the \c MyWidget constructor relays a signal from -
2377 a private member variable, and makes it available under a name -
2378 that relates to \c MyWidget. -
2379 -
2380 A signal can be connected to many slots and signals. Many signals -
2381 can be connected to one slot. -
2382 -
2383 If a signal is connected to several slots, the slots are activated -
2384 in the same order in which the connections were made, when the -
2385 signal is emitted. -
2386 -
2387 The function returns a QMetaObject::Connection that represents -
2388 a handle to a connection if it successfully -
2389 connects the signal to the slot. The connection handle will be invalid -
2390 if it cannot create the connection, for example, if QObject is unable -
2391 to verify the existence of either \a signal or \a method, or if their -
2392 signatures aren't compatible. -
2393 You can check if the handle is valid by casting it to a bool. -
2394 -
2395 By default, a signal is emitted for every connection you make; -
2396 two signals are emitted for duplicate connections. You can break -
2397 all of these connections with a single disconnect() call. -
2398 If you pass the Qt::UniqueConnection \a type, the connection will only -
2399 be made if it is not a duplicate. If there is already a duplicate -
2400 (exact same signal to the exact same slot on the same objects), -
2401 the connection will fail and connect will return an invalid QMetaObject::Connection. -
2402 -
2403 The optional \a type parameter describes the type of connection -
2404 to establish. In particular, it determines whether a particular -
2405 signal is delivered to a slot immediately or queued for delivery -
2406 at a later time. If the signal is queued, the parameters must be -
2407 of types that are known to Qt's meta-object system, because Qt -
2408 needs to copy the arguments to store them in an event behind the -
2409 scenes. If you try to use a queued connection and get the error -
2410 message -
2411 -
2412 \snippet code/src_corelib_kernel_qobject.cpp 25 -
2413 -
2414 call qRegisterMetaType() to register the data type before you -
2415 establish the connection. -
2416 -
2417 \sa disconnect(), sender(), qRegisterMetaType(), Q_DECLARE_METATYPE() -
2418*/ -
2419QMetaObject::Connection QObject::connect(const QObject *sender, const char *signal, -
2420 const QObject *receiver, const char *method, -
2421 Qt::ConnectionType type) -
2422{ -
2423 if (sender == 0 || receiver == 0 || signal == 0 || method == 0) {
partially evaluated: sender == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:333894
partially evaluated: receiver == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:333894
partially evaluated: signal == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:333895
partially evaluated: method == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:333896
0-333896
2424 qWarning("QObject::connect: Cannot connect %s::%s to %s::%s",
never executed (the execution status of this line is deduced): QMessageLogger("kernel/qobject.cpp", 2424, __PRETTY_FUNCTION__).warning("QObject::connect: Cannot connect %s::%s to %s::%s",
-
2425 sender ? sender->metaObject()->className() : "(null)",
never executed (the execution status of this line is deduced): sender ? sender->metaObject()->className() : "(null)",
-
2426 (signal && *signal) ? signal+1 : "(null)",
never executed (the execution status of this line is deduced): (signal && *signal) ? signal+1 : "(null)",
-
2427 receiver ? receiver->metaObject()->className() : "(null)",
never executed (the execution status of this line is deduced): receiver ? receiver->metaObject()->className() : "(null)",
-
2428 (method && *method) ? method+1 : "(null)");
never executed (the execution status of this line is deduced): (method && *method) ? method+1 : "(null)");
-
2429 return QMetaObject::Connection(0);
never executed: return QMetaObject::Connection(0);
0
2430 } -
2431 QByteArray tmp_signal_name;
executed (the execution status of this line is deduced): QByteArray tmp_signal_name;
-
2432 -
2433 if (!check_signal_macro(sender, signal, "connect", "bind"))
partially evaluated: !check_signal_macro(sender, signal, "connect", "bind")
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:333894
0-333894
2434 return QMetaObject::Connection(0);
never executed: return QMetaObject::Connection(0);
0
2435 const QMetaObject *smeta = sender->metaObject();
executed (the execution status of this line is deduced): const QMetaObject *smeta = sender->metaObject();
-
2436 const char *signal_arg = signal;
executed (the execution status of this line is deduced): const char *signal_arg = signal;
-
2437 ++signal; //skip code
executed (the execution status of this line is deduced): ++signal;
-
2438 QArgumentTypeArray signalTypes;
executed (the execution status of this line is deduced): QArgumentTypeArray signalTypes;
-
2439 Q_ASSERT(QMetaObjectPrivate::get(smeta)->revision >= 7);
executed (the execution status of this line is deduced): qt_noop();
-
2440 QByteArray signalName = QMetaObjectPrivate::decodeMethodSignature(signal, signalTypes);
executed (the execution status of this line is deduced): QByteArray signalName = QMetaObjectPrivate::decodeMethodSignature(signal, signalTypes);
-
2441 int signal_index = QMetaObjectPrivate::indexOfSignalRelative(
executed (the execution status of this line is deduced): int signal_index = QMetaObjectPrivate::indexOfSignalRelative(
-
2442 &smeta, signalName, signalTypes.size(), signalTypes.constData());
executed (the execution status of this line is deduced): &smeta, signalName, signalTypes.size(), signalTypes.constData());
-
2443 if (signal_index < 0) {
evaluated: signal_index < 0
TRUEFALSE
yes
Evaluation Count:110
yes
Evaluation Count:333771
110-333771
2444 // check for normalized signatures -
2445 tmp_signal_name = QMetaObject::normalizedSignature(signal - 1);
executed (the execution status of this line is deduced): tmp_signal_name = QMetaObject::normalizedSignature(signal - 1);
-
2446 signal = tmp_signal_name.constData() + 1;
executed (the execution status of this line is deduced): signal = tmp_signal_name.constData() + 1;
-
2447 -
2448 signalTypes.clear();
executed (the execution status of this line is deduced): signalTypes.clear();
-
2449 signalName = QMetaObjectPrivate::decodeMethodSignature(signal, signalTypes);
executed (the execution status of this line is deduced): signalName = QMetaObjectPrivate::decodeMethodSignature(signal, signalTypes);
-
2450 smeta = sender->metaObject();
executed (the execution status of this line is deduced): smeta = sender->metaObject();
-
2451 signal_index = QMetaObjectPrivate::indexOfSignalRelative(
executed (the execution status of this line is deduced): signal_index = QMetaObjectPrivate::indexOfSignalRelative(
-
2452 &smeta, signalName, signalTypes.size(), signalTypes.constData());
executed (the execution status of this line is deduced): &smeta, signalName, signalTypes.size(), signalTypes.constData());
-
2453 }
executed: }
Execution Count:110
110
2454 if (signal_index < 0) {
partially evaluated: signal_index < 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:333881
0-333881
2455 err_method_notfound(sender, signal_arg, "connect");
never executed (the execution status of this line is deduced): err_method_notfound(sender, signal_arg, "connect");
-
2456 err_info_about_objects("connect", sender, receiver);
never executed (the execution status of this line is deduced): err_info_about_objects("connect", sender, receiver);
-
2457 return QMetaObject::Connection(0);
never executed: return QMetaObject::Connection(0);
0
2458 } -
2459 signal_index = QMetaObjectPrivate::originalClone(smeta, signal_index);
executed (the execution status of this line is deduced): signal_index = QMetaObjectPrivate::originalClone(smeta, signal_index);
-
2460 signal_index += QMetaObjectPrivate::signalOffset(smeta);
executed (the execution status of this line is deduced): signal_index += QMetaObjectPrivate::signalOffset(smeta);
-
2461 -
2462 QByteArray tmp_method_name;
executed (the execution status of this line is deduced): QByteArray tmp_method_name;
-
2463 int membcode = extract_code(method);
executed (the execution status of this line is deduced): int membcode = extract_code(method);
-
2464 -
2465 if (!check_method_code(membcode, receiver, method, "connect"))
partially evaluated: !check_method_code(membcode, receiver, method, "connect")
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:333882
0-333882
2466 return QMetaObject::Connection(0);
never executed: return QMetaObject::Connection(0);
0
2467 const char *method_arg = method;
executed (the execution status of this line is deduced): const char *method_arg = method;
-
2468 ++method; // skip code
executed (the execution status of this line is deduced): ++method;
-
2469 -
2470 QByteArray methodName;
executed (the execution status of this line is deduced): QByteArray methodName;
-
2471 QArgumentTypeArray methodTypes;
executed (the execution status of this line is deduced): QArgumentTypeArray methodTypes;
-
2472 const QMetaObject *rmeta = receiver->metaObject();
executed (the execution status of this line is deduced): const QMetaObject *rmeta = receiver->metaObject();
-
2473 int method_index_relative = -1;
executed (the execution status of this line is deduced): int method_index_relative = -1;
-
2474 Q_ASSERT(QMetaObjectPrivate::get(rmeta)->revision >= 7);
executed (the execution status of this line is deduced): qt_noop();
-
2475 switch (membcode) { -
2476 case QSLOT_CODE: -
2477 method_index_relative = QMetaObjectPrivate::indexOfSlotRelative(
executed (the execution status of this line is deduced): method_index_relative = QMetaObjectPrivate::indexOfSlotRelative(
-
2478 &rmeta, methodName, methodTypes.size(), methodTypes.constData());
executed (the execution status of this line is deduced): &rmeta, methodName, methodTypes.size(), methodTypes.constData());
-
2479 break;
executed: break;
Execution Count:324268
324268
2480 case QSIGNAL_CODE: -
2481 method_index_relative = QMetaObjectPrivate::indexOfSignalRelative(
executed (the execution status of this line is deduced): method_index_relative = QMetaObjectPrivate::indexOfSignalRelative(
-
2482 &rmeta, methodName, methodTypes.size(), methodTypes.constData());
executed (the execution status of this line is deduced): &rmeta, methodName, methodTypes.size(), methodTypes.constData());
-
2483 break;
executed: break;
Execution Count:9609
9609
2484 } -
2485 if (method_index_relative < 0) {
partially evaluated: method_index_relative < 0
TRUEFALSE
yes
Evaluation Count:333873
no
Evaluation Count:0
0-333873
2486 // check for normalized methods -
2487 tmp_method_name = QMetaObject::normalizedSignature(method);
executed (the execution status of this line is deduced): tmp_method_name = QMetaObject::normalizedSignature(method);
-
2488 method = tmp_method_name.constData();
executed (the execution status of this line is deduced): method = tmp_method_name.constData();
-
2489 -
2490 methodTypes.clear();
executed (the execution status of this line is deduced): methodTypes.clear();
-
2491 methodName = QMetaObjectPrivate::decodeMethodSignature(method, methodTypes);
executed (the execution status of this line is deduced): methodName = QMetaObjectPrivate::decodeMethodSignature(method, methodTypes);
-
2492 // rmeta may have been modified above -
2493 rmeta = receiver->metaObject();
executed (the execution status of this line is deduced): rmeta = receiver->metaObject();
-
2494 switch (membcode) { -
2495 case QSLOT_CODE: -
2496 method_index_relative = QMetaObjectPrivate::indexOfSlotRelative(
executed (the execution status of this line is deduced): method_index_relative = QMetaObjectPrivate::indexOfSlotRelative(
-
2497 &rmeta, methodName, methodTypes.size(), methodTypes.constData());
executed (the execution status of this line is deduced): &rmeta, methodName, methodTypes.size(), methodTypes.constData());
-
2498 break;
executed: break;
Execution Count:324274
324274
2499 case QSIGNAL_CODE: -
2500 method_index_relative = QMetaObjectPrivate::indexOfSignalRelative(
executed (the execution status of this line is deduced): method_index_relative = QMetaObjectPrivate::indexOfSignalRelative(
-
2501 &rmeta, methodName, methodTypes.size(), methodTypes.constData());
executed (the execution status of this line is deduced): &rmeta, methodName, methodTypes.size(), methodTypes.constData());
-
2502 break;
executed: break;
Execution Count:9608
9608
2503 } -
2504 }
executed: }
Execution Count:333880
333880
2505 -
2506 if (method_index_relative < 0) {
partially evaluated: method_index_relative < 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:333880
0-333880
2507 err_method_notfound(receiver, method_arg, "connect");
never executed (the execution status of this line is deduced): err_method_notfound(receiver, method_arg, "connect");
-
2508 err_info_about_objects("connect", sender, receiver);
never executed (the execution status of this line is deduced): err_info_about_objects("connect", sender, receiver);
-
2509 return QMetaObject::Connection(0);
never executed: return QMetaObject::Connection(0);
0
2510 } -
2511 -
2512 if (!QMetaObjectPrivate::checkConnectArgs(signalTypes.size(), signalTypes.constData(),
evaluated: !QMetaObjectPrivate::checkConnectArgs(signalTypes.size(), signalTypes.constData(), methodTypes.size(), methodTypes.constData())
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:333876
1-333876
2513 methodTypes.size(), methodTypes.constData())) {
evaluated: !QMetaObjectPrivate::checkConnectArgs(signalTypes.size(), signalTypes.constData(), methodTypes.size(), methodTypes.constData())
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:333876
1-333876
2514 qWarning("QObject::connect: Incompatible sender/receiver arguments"
executed (the execution status of this line is deduced): QMessageLogger("kernel/qobject.cpp", 2514, __PRETTY_FUNCTION__).warning("QObject::connect: Incompatible sender/receiver arguments"
-
2515 "\n %s::%s --> %s::%s",
executed (the execution status of this line is deduced): "\n %s::%s --> %s::%s",
-
2516 sender->metaObject()->className(), signal,
executed (the execution status of this line is deduced): sender->metaObject()->className(), signal,
-
2517 receiver->metaObject()->className(), method);
executed (the execution status of this line is deduced): receiver->metaObject()->className(), method);
-
2518 return QMetaObject::Connection(0);
executed: return QMetaObject::Connection(0);
Execution Count:1
1
2519 } -
2520 -
2521 int *types = 0;
executed (the execution status of this line is deduced): int *types = 0;
-
2522 if ((type == Qt::QueuedConnection)
evaluated: (type == Qt::QueuedConnection)
TRUEFALSE
yes
Evaluation Count:17839
yes
Evaluation Count:316035
17839-316035
2523 && !(types = queuedConnectionTypes(signalTypes.constData(), signalTypes.size()))) {
partially evaluated: !(types = queuedConnectionTypes(signalTypes.constData(), signalTypes.size()))
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:17839
0-17839
2524 return QMetaObject::Connection(0);
never executed: return QMetaObject::Connection(0);
0
2525 } -
2526 -
2527#ifndef QT_NO_DEBUG -
2528 QMetaMethod smethod = QMetaObjectPrivate::signal(smeta, signal_index); -
2529 QMetaMethod rmethod = rmeta->method(method_index_relative + rmeta->methodOffset()); -
2530 check_and_warn_compat(smeta, smethod, rmeta, rmethod); -
2531#endif -
2532 QMetaObject::Connection handle = QMetaObject::Connection(QMetaObjectPrivate::connect(
executed (the execution status of this line is deduced): QMetaObject::Connection handle = QMetaObject::Connection(QMetaObjectPrivate::connect(
-
2533 sender, signal_index, smeta, receiver, method_index_relative, rmeta ,type, types));
executed (the execution status of this line is deduced): sender, signal_index, smeta, receiver, method_index_relative, rmeta ,type, types));
-
2534 return handle;
executed: return handle;
Execution Count:333884
333884
2535} -
2536 -
2537/*! -
2538 \since 4.8 -
2539 -
2540 Creates a connection of the given \a type from the \a signal in -
2541 the \a sender object to the \a method in the \a receiver object. -
2542 Returns a handle to the connection that can be used to disconnect -
2543 it later. -
2544 -
2545 The Connection handle will be invalid if it cannot create the -
2546 connection, for example, the parameters were invalid. -
2547 You can check if the QMetaObject::Connection is valid by casting it to a bool. -
2548 -
2549 This function works in the same way as -
2550 connect(const QObject *sender, const char *signal, -
2551 const QObject *receiver, const char *method, -
2552 Qt::ConnectionType type) -
2553 but it uses QMetaMethod to specify signal and method. -
2554 -
2555 \sa connect(const QObject *sender, const char *signal, -
2556 const QObject *receiver, const char *method, -
2557 Qt::ConnectionType type) -
2558 */ -
2559QMetaObject::Connection QObject::connect(const QObject *sender, const QMetaMethod &signal, -
2560 const QObject *receiver, const QMetaMethod &method, -
2561 Qt::ConnectionType type) -
2562{ -
2563 if (sender == 0
partially evaluated: sender == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:27
0-27
2564 || receiver == 0
partially evaluated: receiver == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:27
0-27
2565 || signal.methodType() != QMetaMethod::Signal
evaluated: signal.methodType() != QMetaMethod::Signal
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:24
3-24
2566 || method.methodType() == QMetaMethod::Constructor) {
evaluated: method.methodType() == QMetaMethod::Constructor
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:23
1-23
2567 qWarning("QObject::connect: Cannot connect %s::%s to %s::%s",
executed (the execution status of this line is deduced): QMessageLogger("kernel/qobject.cpp", 2567, __PRETTY_FUNCTION__).warning("QObject::connect: Cannot connect %s::%s to %s::%s",
-
2568 sender ? sender->metaObject()->className() : "(null)",
executed (the execution status of this line is deduced): sender ? sender->metaObject()->className() : "(null)",
-
2569 signal.methodSignature().constData(),
executed (the execution status of this line is deduced): signal.methodSignature().constData(),
-
2570 receiver ? receiver->metaObject()->className() : "(null)",
executed (the execution status of this line is deduced): receiver ? receiver->metaObject()->className() : "(null)",
-
2571 method.methodSignature().constData() );
executed (the execution status of this line is deduced): method.methodSignature().constData() );
-
2572 return QMetaObject::Connection(0);
executed: return QMetaObject::Connection(0);
Execution Count:4
4
2573 } -
2574 -
2575 int signal_index;
executed (the execution status of this line is deduced): int signal_index;
-
2576 int method_index;
executed (the execution status of this line is deduced): int method_index;
-
2577 { -
2578 int dummy;
executed (the execution status of this line is deduced): int dummy;
-
2579 QMetaObjectPrivate::memberIndexes(sender, signal, &signal_index, &dummy);
executed (the execution status of this line is deduced): QMetaObjectPrivate::memberIndexes(sender, signal, &signal_index, &dummy);
-
2580 QMetaObjectPrivate::memberIndexes(receiver, method, &dummy, &method_index);
executed (the execution status of this line is deduced): QMetaObjectPrivate::memberIndexes(receiver, method, &dummy, &method_index);
-
2581 } -
2582 -
2583 const QMetaObject *smeta = sender->metaObject();
executed (the execution status of this line is deduced): const QMetaObject *smeta = sender->metaObject();
-
2584 const QMetaObject *rmeta = receiver->metaObject();
executed (the execution status of this line is deduced): const QMetaObject *rmeta = receiver->metaObject();
-
2585 if (signal_index == -1) {
partially evaluated: signal_index == -1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:23
0-23
2586 qWarning("QObject::connect: Can't find signal %s on instance of class %s",
never executed (the execution status of this line is deduced): QMessageLogger("kernel/qobject.cpp", 2586, __PRETTY_FUNCTION__).warning("QObject::connect: Can't find signal %s on instance of class %s",
-
2587 signal.methodSignature().constData(), smeta->className());
never executed (the execution status of this line is deduced): signal.methodSignature().constData(), smeta->className());
-
2588 return QMetaObject::Connection(0);
never executed: return QMetaObject::Connection(0);
0
2589 } -
2590 if (method_index == -1) {
partially evaluated: method_index == -1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:23
0-23
2591 qWarning("QObject::connect: Can't find method %s on instance of class %s",
never executed (the execution status of this line is deduced): QMessageLogger("kernel/qobject.cpp", 2591, __PRETTY_FUNCTION__).warning("QObject::connect: Can't find method %s on instance of class %s",
-
2592 method.methodSignature().constData(), rmeta->className());
never executed (the execution status of this line is deduced): method.methodSignature().constData(), rmeta->className());
-
2593 return QMetaObject::Connection(0);
never executed: return QMetaObject::Connection(0);
0
2594 } -
2595 -
2596 if (!QMetaObject::checkConnectArgs(signal.methodSignature().constData(), method.methodSignature().constData())) {
partially evaluated: !QMetaObject::checkConnectArgs(signal.methodSignature().constData(), method.methodSignature().constData())
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:23
0-23
2597 qWarning("QObject::connect: Incompatible sender/receiver arguments"
never executed (the execution status of this line is deduced): QMessageLogger("kernel/qobject.cpp", 2597, __PRETTY_FUNCTION__).warning("QObject::connect: Incompatible sender/receiver arguments"
-
2598 "\n %s::%s --> %s::%s",
never executed (the execution status of this line is deduced): "\n %s::%s --> %s::%s",
-
2599 smeta->className(), signal.methodSignature().constData(),
never executed (the execution status of this line is deduced): smeta->className(), signal.methodSignature().constData(),
-
2600 rmeta->className(), method.methodSignature().constData());
never executed (the execution status of this line is deduced): rmeta->className(), method.methodSignature().constData());
-
2601 return QMetaObject::Connection(0);
never executed: return QMetaObject::Connection(0);
0
2602 } -
2603 -
2604 int *types = 0;
executed (the execution status of this line is deduced): int *types = 0;
-
2605 if ((type == Qt::QueuedConnection)
partially evaluated: (type == Qt::QueuedConnection)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:23
0-23
2606 && !(types = queuedConnectionTypes(signal.parameterTypes())))
never evaluated: !(types = queuedConnectionTypes(signal.parameterTypes()))
0
2607 return QMetaObject::Connection(0);
never executed: return QMetaObject::Connection(0);
0
2608 -
2609#ifndef QT_NO_DEBUG -
2610 check_and_warn_compat(smeta, signal, rmeta, method); -
2611#endif -
2612 QMetaObject::Connection handle = QMetaObject::Connection(QMetaObjectPrivate::connect(
executed (the execution status of this line is deduced): QMetaObject::Connection handle = QMetaObject::Connection(QMetaObjectPrivate::connect(
-
2613 sender, signal_index, signal.enclosingMetaObject(), receiver, method_index, 0, type, types));
executed (the execution status of this line is deduced): sender, signal_index, signal.enclosingMetaObject(), receiver, method_index, 0, type, types));
-
2614 return handle;
executed: return handle;
Execution Count:23
23
2615} -
2616 -
2617/*! -
2618 \fn bool QObject::connect(const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const -
2619 \overload connect() -
2620 \threadsafe -
2621 -
2622 Connects \a signal from the \a sender object to this object's \a -
2623 method. -
2624 -
2625 Equivalent to connect(\a sender, \a signal, \c this, \a method, \a type). -
2626 -
2627 Every connection you make emits a signal, so duplicate connections emit -
2628 two signals. You can break a connection using disconnect(). -
2629 -
2630 \sa disconnect() -
2631*/ -
2632 -
2633/*! -
2634 \threadsafe -
2635 -
2636 Disconnects \a signal in object \a sender from \a method in object -
2637 \a receiver. Returns true if the connection is successfully broken; -
2638 otherwise returns false. -
2639 -
2640 A signal-slot connection is removed when either of the objects -
2641 involved are destroyed. -
2642 -
2643 disconnect() is typically used in three ways, as the following -
2644 examples demonstrate. -
2645 \list 1 -
2646 \li Disconnect everything connected to an object's signals: -
2647 -
2648 \snippet code/src_corelib_kernel_qobject.cpp 26 -
2649 -
2650 equivalent to the non-static overloaded function -
2651 -
2652 \snippet code/src_corelib_kernel_qobject.cpp 27 -
2653 -
2654 \li Disconnect everything connected to a specific signal: -
2655 -
2656 \snippet code/src_corelib_kernel_qobject.cpp 28 -
2657 -
2658 equivalent to the non-static overloaded function -
2659 -
2660 \snippet code/src_corelib_kernel_qobject.cpp 29 -
2661 -
2662 \li Disconnect a specific receiver: -
2663 -
2664 \snippet code/src_corelib_kernel_qobject.cpp 30 -
2665 -
2666 equivalent to the non-static overloaded function -
2667 -
2668 \snippet code/src_corelib_kernel_qobject.cpp 31 -
2669 -
2670 \endlist -
2671 -
2672 0 may be used as a wildcard, meaning "any signal", "any receiving -
2673 object", or "any slot in the receiving object", respectively. -
2674 -
2675 The \a sender may never be 0. (You cannot disconnect signals from -
2676 more than one object in a single call.) -
2677 -
2678 If \a signal is 0, it disconnects \a receiver and \a method from -
2679 any signal. If not, only the specified signal is disconnected. -
2680 -
2681 If \a receiver is 0, it disconnects anything connected to \a -
2682 signal. If not, slots in objects other than \a receiver are not -
2683 disconnected. -
2684 -
2685 If \a method is 0, it disconnects anything that is connected to \a -
2686 receiver. If not, only slots named \a method will be disconnected, -
2687 and all other slots are left alone. The \a method must be 0 if \a -
2688 receiver is left out, so you cannot disconnect a -
2689 specifically-named slot on all objects. -
2690 -
2691 \sa connect() -
2692*/ -
2693bool QObject::disconnect(const QObject *sender, const char *signal, -
2694 const QObject *receiver, const char *method) -
2695{ -
2696 if (sender == 0 || (receiver == 0 && method != 0)) {
partially evaluated: sender == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:33751
evaluated: receiver == 0
TRUEFALSE
yes
Evaluation Count:9731
yes
Evaluation Count:24020
partially evaluated: method != 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:9731
0-33751
2697 qWarning("QObject::disconnect: Unexpected null parameter");
never executed (the execution status of this line is deduced): QMessageLogger("kernel/qobject.cpp", 2697, __PRETTY_FUNCTION__).warning("QObject::disconnect: Unexpected null parameter");
-
2698 return false;
never executed: return false;
0
2699 } -
2700 -
2701 const char *signal_arg = signal;
executed (the execution status of this line is deduced): const char *signal_arg = signal;
-
2702 QByteArray signal_name;
executed (the execution status of this line is deduced): QByteArray signal_name;
-
2703 bool signal_found = false;
executed (the execution status of this line is deduced): bool signal_found = false;
-
2704 if (signal) {
evaluated: signal
TRUEFALSE
yes
Evaluation Count:25124
yes
Evaluation Count:8627
8627-25124
2705 QT_TRY { -
2706 signal_name = QMetaObject::normalizedSignature(signal);
executed (the execution status of this line is deduced): signal_name = QMetaObject::normalizedSignature(signal);
-
2707 signal = signal_name.constData();
executed (the execution status of this line is deduced): signal = signal_name.constData();
-
2708 } QT_CATCH (const std::bad_alloc &) {
executed: }
Execution Count:25124
25124
2709 // if the signal is already normalized, we can continue. -
2710 if (sender->metaObject()->indexOfSignal(signal + 1) == -1)
never evaluated: sender->metaObject()->indexOfSignal(signal + 1) == -1
0
2711 QT_RETHROW;
never executed: throw;
0
2712 }
never executed: }
0
2713 -
2714 if (!check_signal_macro(sender, signal, "disconnect", "unbind"))
partially evaluated: !check_signal_macro(sender, signal, "disconnect", "unbind")
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:25124
0-25124
2715 return false;
never executed: return false;
0
2716 signal++; // skip code
executed (the execution status of this line is deduced): signal++;
-
2717 }
executed: }
Execution Count:25124
25124
2718 -
2719 QByteArray method_name;
executed (the execution status of this line is deduced): QByteArray method_name;
-
2720 const char *method_arg = method;
executed (the execution status of this line is deduced): const char *method_arg = method;
-
2721 int membcode = -1;
executed (the execution status of this line is deduced): int membcode = -1;
-
2722 bool method_found = false;
executed (the execution status of this line is deduced): bool method_found = false;
-
2723 if (method) {
evaluated: method
TRUEFALSE
yes
Evaluation Count:21972
yes
Evaluation Count:11779
11779-21972
2724 QT_TRY { -
2725 method_name = QMetaObject::normalizedSignature(method);
executed (the execution status of this line is deduced): method_name = QMetaObject::normalizedSignature(method);
-
2726 method = method_name.constData();
executed (the execution status of this line is deduced): method = method_name.constData();
-
2727 } QT_CATCH(const std::bad_alloc &) {
executed: }
Execution Count:21972
21972
2728 // if the method is already normalized, we can continue. -
2729 if (receiver->metaObject()->indexOfMethod(method + 1) == -1)
never evaluated: receiver->metaObject()->indexOfMethod(method + 1) == -1
0
2730 QT_RETHROW;
never executed: throw;
0
2731 }
never executed: }
0
2732 -
2733 membcode = extract_code(method);
executed (the execution status of this line is deduced): membcode = extract_code(method);
-
2734 if (!check_method_code(membcode, receiver, method, "disconnect"))
partially evaluated: !check_method_code(membcode, receiver, method, "disconnect")
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:21972
0-21972
2735 return false;
never executed: return false;
0
2736 method++; // skip code
executed (the execution status of this line is deduced): method++;
-
2737 }
executed: }
Execution Count:21972
21972
2738 -
2739 /* We now iterate through all the sender's and receiver's meta -
2740 * objects in order to also disconnect possibly shadowed signals -
2741 * and slots with the same signature. -
2742 */ -
2743 bool res = false;
executed (the execution status of this line is deduced): bool res = false;
-
2744 const QMetaObject *smeta = sender->metaObject();
executed (the execution status of this line is deduced): const QMetaObject *smeta = sender->metaObject();
-
2745 QByteArray signalName;
executed (the execution status of this line is deduced): QByteArray signalName;
-
2746 QArgumentTypeArray signalTypes;
executed (the execution status of this line is deduced): QArgumentTypeArray signalTypes;
-
2747 Q_ASSERT(QMetaObjectPrivate::get(smeta)->revision >= 7);
executed (the execution status of this line is deduced): qt_noop();
-
2748 if (signal)
evaluated: signal
TRUEFALSE
yes
Evaluation Count:25124
yes
Evaluation Count:8627
8627-25124
2749 signalName = QMetaObjectPrivate::decodeMethodSignature(signal, signalTypes);
executed: signalName = QMetaObjectPrivate::decodeMethodSignature(signal, signalTypes);
Execution Count:25124
25124
2750 QByteArray methodName;
executed (the execution status of this line is deduced): QByteArray methodName;
-
2751 QArgumentTypeArray methodTypes;
executed (the execution status of this line is deduced): QArgumentTypeArray methodTypes;
-
2752 Q_ASSERT(!receiver || QMetaObjectPrivate::get(receiver->metaObject())->revision >= 7);
executed (the execution status of this line is deduced): qt_noop();
-
2753 if (method)
evaluated: method
TRUEFALSE
yes
Evaluation Count:21972
yes
Evaluation Count:11779
11779-21972
2754 methodName = QMetaObjectPrivate::decodeMethodSignature(method, methodTypes);
executed: methodName = QMetaObjectPrivate::decodeMethodSignature(method, methodTypes);
Execution Count:21972
21972
2755 do { -
2756 int signal_index = -1;
executed (the execution status of this line is deduced): int signal_index = -1;
-
2757 if (signal) {
evaluated: signal
TRUEFALSE
yes
Evaluation Count:48367
yes
Evaluation Count:8627
8627-48367
2758 signal_index = QMetaObjectPrivate::indexOfSignalRelative(
executed (the execution status of this line is deduced): signal_index = QMetaObjectPrivate::indexOfSignalRelative(
-
2759 &smeta, signalName, signalTypes.size(), signalTypes.constData());
executed (the execution status of this line is deduced): &smeta, signalName, signalTypes.size(), signalTypes.constData());
-
2760 if (signal_index < 0)
evaluated: signal_index < 0
TRUEFALSE
yes
Evaluation Count:23242
yes
Evaluation Count:25125
23242-25125
2761 break;
executed: break;
Execution Count:23242
23242
2762 signal_index = QMetaObjectPrivate::originalClone(smeta, signal_index);
executed (the execution status of this line is deduced): signal_index = QMetaObjectPrivate::originalClone(smeta, signal_index);
-
2763 signal_index += QMetaObjectPrivate::signalOffset(smeta);
executed (the execution status of this line is deduced): signal_index += QMetaObjectPrivate::signalOffset(smeta);
-
2764 signal_found = true;
executed (the execution status of this line is deduced): signal_found = true;
-
2765 }
executed: }
Execution Count:25125
25125
2766 -
2767 if (!method) {
evaluated: !method
TRUEFALSE
yes
Evaluation Count:11779
yes
Evaluation Count:21973
11779-21973
2768 res |= QMetaObjectPrivate::disconnect(sender, signal_index, smeta, receiver, -1, 0);
executed (the execution status of this line is deduced): res |= QMetaObjectPrivate::disconnect(sender, signal_index, smeta, receiver, -1, 0);
-
2769 } else {
executed: }
Execution Count:11779
11779
2770 const QMetaObject *rmeta = receiver->metaObject();
executed (the execution status of this line is deduced): const QMetaObject *rmeta = receiver->metaObject();
-
2771 do { -
2772 int method_index = QMetaObjectPrivate::indexOfMethod(
executed (the execution status of this line is deduced): int method_index = QMetaObjectPrivate::indexOfMethod(
-
2773 rmeta, methodName, methodTypes.size(), methodTypes.constData());
executed (the execution status of this line is deduced): rmeta, methodName, methodTypes.size(), methodTypes.constData());
-
2774 if (method_index >= 0)
evaluated: method_index >= 0
TRUEFALSE
yes
Evaluation Count:22344
yes
Evaluation Count:21966
21966-22344
2775 while (method_index < rmeta->methodOffset())
evaluated: method_index < rmeta->methodOffset()
TRUEFALSE
yes
Evaluation Count:11173
yes
Evaluation Count:22344
11173-22344
2776 rmeta = rmeta->superClass();
executed: rmeta = rmeta->superClass();
Execution Count:11173
11173
2777 if (method_index < 0)
evaluated: method_index < 0
TRUEFALSE
yes
Evaluation Count:21966
yes
Evaluation Count:22344
21966-22344
2778 break;
executed: break;
Execution Count:21966
21966
2779 res |= QMetaObjectPrivate::disconnect(sender, signal_index, smeta, receiver, method_index, 0);
executed (the execution status of this line is deduced): res |= QMetaObjectPrivate::disconnect(sender, signal_index, smeta, receiver, method_index, 0);
-
2780 method_found = true;
executed (the execution status of this line is deduced): method_found = true;
-
2781 } while ((rmeta = rmeta->superClass()));
executed: }
Execution Count:22344
evaluated: (rmeta = rmeta->superClass())
TRUEFALSE
yes
Evaluation Count:22337
yes
Evaluation Count:7
7-22344
2782 }
executed: }
Execution Count:21973
21973
2783 } while (signal && (smeta = smeta->superClass()));
evaluated: signal
TRUEFALSE
yes
Evaluation Count:25125
yes
Evaluation Count:8627
evaluated: (smeta = smeta->superClass())
TRUEFALSE
yes
Evaluation Count:23243
yes
Evaluation Count:1882
1882-25125
2784 -
2785 if (signal && !signal_found) {
evaluated: signal
TRUEFALSE
yes
Evaluation Count:25124
yes
Evaluation Count:8627
partially evaluated: !signal_found
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:25124
0-25124
2786 err_method_notfound(sender, signal_arg, "disconnect");
never executed (the execution status of this line is deduced): err_method_notfound(sender, signal_arg, "disconnect");
-
2787 err_info_about_objects("disconnect", sender, receiver);
never executed (the execution status of this line is deduced): err_info_about_objects("disconnect", sender, receiver);
-
2788 } else if (method && !method_found) {
never executed: }
evaluated: method
TRUEFALSE
yes
Evaluation Count:21972
yes
Evaluation Count:11779
partially evaluated: !method_found
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:21972
0-21972
2789 err_method_notfound(receiver, method_arg, "disconnect");
never executed (the execution status of this line is deduced): err_method_notfound(receiver, method_arg, "disconnect");
-
2790 err_info_about_objects("disconnect", sender, receiver);
never executed (the execution status of this line is deduced): err_info_about_objects("disconnect", sender, receiver);
-
2791 }
never executed: }
0
2792 if (res) {
evaluated: res
TRUEFALSE
yes
Evaluation Count:16902
yes
Evaluation Count:16849
16849-16902
2793 if (!signal)
evaluated: !signal
TRUEFALSE
yes
Evaluation Count:1992
yes
Evaluation Count:14910
1992-14910
2794 const_cast<QObject*>(sender)->disconnectNotify(QMetaMethod());
executed: const_cast<QObject*>(sender)->disconnectNotify(QMetaMethod());
Execution Count:1992
1992
2795 }
executed: }
Execution Count:16902
16902
2796 return res;
executed: return res;
Execution Count:33751
33751
2797} -
2798 -
2799/*! -
2800 \since 4.8 -
2801 -
2802 Disconnects \a signal in object \a sender from \a method in object -
2803 \a receiver. Returns true if the connection is successfully broken; -
2804 otherwise returns false. -
2805 -
2806 This function provides the same possibilities like -
2807 disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *method) -
2808 but uses QMetaMethod to represent the signal and the method to be disconnected. -
2809 -
2810 Additionally this function returnsfalse and no signals and slots disconnected -
2811 if: -
2812 \list 1 -
2813 -
2814 \li \a signal is not a member of sender class or one of its parent classes. -
2815 -
2816 \li \a method is not a member of receiver class or one of its parent classes. -
2817 -
2818 \li \a signal instance represents not a signal. -
2819 -
2820 \endlist -
2821 -
2822 QMetaMethod() may be used as wildcard in the meaning "any signal" or "any slot in receiving object". -
2823 In the same way 0 can be used for \a receiver in the meaning "any receiving object". In this case -
2824 method should also be QMetaMethod(). \a sender parameter should be never 0. -
2825 -
2826 \sa disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *method) -
2827 */ -
2828bool QObject::disconnect(const QObject *sender, const QMetaMethod &signal, -
2829 const QObject *receiver, const QMetaMethod &method) -
2830{ -
2831 if (sender == 0 || (receiver == 0 && method.mobj != 0)) {
partially evaluated: sender == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:22
evaluated: receiver == 0
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:14
partially evaluated: method.mobj != 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:8
0-22
2832 qWarning("QObject::disconnect: Unexpected null parameter");
never executed (the execution status of this line is deduced): QMessageLogger("kernel/qobject.cpp", 2832, __PRETTY_FUNCTION__).warning("QObject::disconnect: Unexpected null parameter");
-
2833 return false;
never executed: return false;
0
2834 } -
2835 if (signal.mobj) {
evaluated: signal.mobj
TRUEFALSE
yes
Evaluation Count:14
yes
Evaluation Count:8
8-14
2836 if(signal.methodType() != QMetaMethod::Signal) {
evaluated: signal.methodType() != QMetaMethod::Signal
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:13
1-13
2837 qWarning("QObject::%s: Attempt to %s non-signal %s::%s",
executed (the execution status of this line is deduced): QMessageLogger("kernel/qobject.cpp", 2837, __PRETTY_FUNCTION__).warning("QObject::%s: Attempt to %s non-signal %s::%s",
-
2838 "disconnect","unbind",
executed (the execution status of this line is deduced): "disconnect","unbind",
-
2839 sender->metaObject()->className(), signal.methodSignature().constData());
executed (the execution status of this line is deduced): sender->metaObject()->className(), signal.methodSignature().constData());
-
2840 return false;
executed: return false;
Execution Count:1
1
2841 } -
2842 }
executed: }
Execution Count:13
13
2843 if (method.mobj) {
evaluated: method.mobj
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:9
9-12
2844 if(method.methodType() == QMetaMethod::Constructor) {
partially evaluated: method.methodType() == QMetaMethod::Constructor
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:12
0-12
2845 qWarning("QObject::disconect: cannot use constructor as argument %s::%s",
never executed (the execution status of this line is deduced): QMessageLogger("kernel/qobject.cpp", 2845, __PRETTY_FUNCTION__).warning("QObject::disconect: cannot use constructor as argument %s::%s",
-
2846 receiver->metaObject()->className(), method.methodSignature().constData());
never executed (the execution status of this line is deduced): receiver->metaObject()->className(), method.methodSignature().constData());
-
2847 return false;
never executed: return false;
0
2848 } -
2849 }
executed: }
Execution Count:12
12
2850 -
2851 // Reconstructing SIGNAL() macro result for signal.methodSignature() string -
2852 QByteArray signalSignature;
executed (the execution status of this line is deduced): QByteArray signalSignature;
-
2853 if (signal.mobj) {
evaluated: signal.mobj
TRUEFALSE
yes
Evaluation Count:13
yes
Evaluation Count:8
8-13
2854 signalSignature.reserve(signal.methodSignature().size()+1);
executed (the execution status of this line is deduced): signalSignature.reserve(signal.methodSignature().size()+1);
-
2855 signalSignature.append((char)(QSIGNAL_CODE + '0'));
executed (the execution status of this line is deduced): signalSignature.append((char)(2 + '0'));
-
2856 signalSignature.append(signal.methodSignature());
executed (the execution status of this line is deduced): signalSignature.append(signal.methodSignature());
-
2857 }
executed: }
Execution Count:13
13
2858 -
2859 int signal_index;
executed (the execution status of this line is deduced): int signal_index;
-
2860 int method_index;
executed (the execution status of this line is deduced): int method_index;
-
2861 { -
2862 int dummy;
executed (the execution status of this line is deduced): int dummy;
-
2863 QMetaObjectPrivate::memberIndexes(sender, signal, &signal_index, &dummy);
executed (the execution status of this line is deduced): QMetaObjectPrivate::memberIndexes(sender, signal, &signal_index, &dummy);
-
2864 QMetaObjectPrivate::memberIndexes(receiver, method, &dummy, &method_index);
executed (the execution status of this line is deduced): QMetaObjectPrivate::memberIndexes(receiver, method, &dummy, &method_index);
-
2865 } -
2866 // If we are here sender is not null. If signal is not null while signal_index -
2867 // is -1 then this signal is not a member of sender. -
2868 if (signal.mobj && signal_index == -1) {
evaluated: signal.mobj
TRUEFALSE
yes
Evaluation Count:13
yes
Evaluation Count:8
partially evaluated: signal_index == -1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:13
0-13
2869 qWarning("QObject::disconect: signal %s not found on class %s",
never executed (the execution status of this line is deduced): QMessageLogger("kernel/qobject.cpp", 2869, __PRETTY_FUNCTION__).warning("QObject::disconect: signal %s not found on class %s",
-
2870 signal.methodSignature().constData(), sender->metaObject()->className());
never executed (the execution status of this line is deduced): signal.methodSignature().constData(), sender->metaObject()->className());
-
2871 return false;
never executed: return false;
0
2872 } -
2873 // If this condition is true then method is not a member of receeiver. -
2874 if (receiver && method.mobj && method_index == -1) {
evaluated: receiver
TRUEFALSE
yes
Evaluation Count:13
yes
Evaluation Count:8
evaluated: method.mobj
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:1
partially evaluated: method_index == -1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:12
0-13
2875 qWarning("QObject::disconect: method %s not found on class %s",
never executed (the execution status of this line is deduced): QMessageLogger("kernel/qobject.cpp", 2875, __PRETTY_FUNCTION__).warning("QObject::disconect: method %s not found on class %s",
-
2876 method.methodSignature().constData(), receiver->metaObject()->className());
never executed (the execution status of this line is deduced): method.methodSignature().constData(), receiver->metaObject()->className());
-
2877 return false;
never executed: return false;
0
2878 } -
2879 -
2880 if (!QMetaObjectPrivate::disconnect(sender, signal_index, signal.mobj, receiver, method_index, 0))
evaluated: !QMetaObjectPrivate::disconnect(sender, signal_index, signal.mobj, receiver, method_index, 0)
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:20
1-20
2881 return false;
executed: return false;
Execution Count:1
1
2882 -
2883 if (!signal.isValid()) {
evaluated: !signal.isValid()
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:12
8-12
2884 // The signal is a wildcard, meaning all signals were disconnected. -
2885 // QMetaObjectPrivate::disconnect() doesn't call disconnectNotify() -
2886 // per connection in this case. Call it once now, with an invalid -
2887 // QMetaMethod as argument, as documented. -
2888 const_cast<QObject*>(sender)->disconnectNotify(signal);
executed (the execution status of this line is deduced): const_cast<QObject*>(sender)->disconnectNotify(signal);
-
2889 }
executed: }
Execution Count:8
8
2890 return true;
executed: return true;
Execution Count:20
20
2891} -
2892 -
2893/*! -
2894 \threadsafe -
2895 -
2896 \fn bool QObject::disconnect(const char *signal, const QObject *receiver, const char *method) const -
2897 \overload disconnect() -
2898 -
2899 Disconnects \a signal from \a method of \a receiver. -
2900 -
2901 A signal-slot connection is removed when either of the objects -
2902 involved are destroyed. -
2903*/ -
2904 -
2905/*! -
2906 \fn bool QObject::disconnect(const QObject *receiver, const char *method) const -
2907 \overload disconnect() -
2908 -
2909 Disconnects all signals in this object from \a receiver's \a -
2910 method. -
2911 -
2912 A signal-slot connection is removed when either of the objects -
2913 involved are destroyed. -
2914*/ -
2915 -
2916 -
2917/*! -
2918 \since 5.0 -
2919 -
2920 This virtual function is called when something has been connected -
2921 to \a signal in this object. -
2922 -
2923 If you want to compare \a signal with a specific signal, you can -
2924 use QMetaMethod::fromSignal() as follows: -
2925 -
2926 \snippet code/src_corelib_kernel_qobject.cpp 32 -
2927 -
2928 \warning This function violates the object-oriented principle of -
2929 modularity. However, it might be useful when you need to perform -
2930 expensive initialization only if something is connected to a -
2931 signal. -
2932 -
2933 \sa connect(), disconnectNotify() -
2934*/ -
2935 -
2936void QObject::connectNotify(const QMetaMethod &signal) -
2937{ -
2938 Q_UNUSED(signal);
executed (the execution status of this line is deduced): (void)signal;;
-
2939}
executed: }
Execution Count:440151
440151
2940 -
2941/*! -
2942 \since 5.0 -
2943 -
2944 This virtual function is called when something has been -
2945 disconnected from \a signal in this object. -
2946 -
2947 See connectNotify() for an example of how to compare -
2948 \a signal with a specific signal. -
2949 -
2950 If all signals were disconnected from this object (e.g., the -
2951 signal argument to disconnect() was 0), disconnectNotify() -
2952 is only called once, and the \a signal will be an invalid -
2953 QMetaMethod (QMetaMethod::isValid() returns false). -
2954 -
2955 \warning This function violates the object-oriented principle of -
2956 modularity. However, it might be useful for optimizing access to -
2957 expensive resources. -
2958 -
2959 \sa disconnect(), connectNotify() -
2960*/ -
2961 -
2962void QObject::disconnectNotify(const QMetaMethod &signal) -
2963{ -
2964 Q_UNUSED(signal);
executed (the execution status of this line is deduced): (void)signal;;
-
2965}
executed: }
Execution Count:241442
241442
2966 -
2967/* -
2968 \internal -
2969 convert a signal index from the method range to the signal range -
2970 */ -
2971static int methodIndexToSignalIndex(const QMetaObject **base, int signal_index) -
2972{ -
2973 if (signal_index < 0)
evaluated: signal_index < 0
TRUEFALSE
yes
Evaluation Count:342
yes
Evaluation Count:206822
342-206822
2974 return signal_index;
executed: return signal_index;
Execution Count:342
342
2975 const QMetaObject *metaObject = *base;
executed (the execution status of this line is deduced): const QMetaObject *metaObject = *base;
-
2976 while (metaObject && metaObject->methodOffset() > signal_index)
partially evaluated: metaObject
TRUEFALSE
yes
Evaluation Count:414403
no
Evaluation Count:0
evaluated: metaObject->methodOffset() > signal_index
TRUEFALSE
yes
Evaluation Count:207581
yes
Evaluation Count:206822
0-414403
2977 metaObject = metaObject->superClass();
executed: metaObject = metaObject->superClass();
Execution Count:207581
207581
2978 -
2979 if (metaObject) {
partially evaluated: metaObject
TRUEFALSE
yes
Evaluation Count:206822
no
Evaluation Count:0
0-206822
2980 int signalOffset, methodOffset;
executed (the execution status of this line is deduced): int signalOffset, methodOffset;
-
2981 computeOffsets(metaObject, &signalOffset, &methodOffset);
executed (the execution status of this line is deduced): computeOffsets(metaObject, &signalOffset, &methodOffset);
-
2982 if (signal_index < metaObject->methodCount())
evaluated: signal_index < metaObject->methodCount()
TRUEFALSE
yes
Evaluation Count:206820
yes
Evaluation Count:2
2-206820
2983 signal_index = QMetaObjectPrivate::originalClone(metaObject, signal_index - methodOffset) + signalOffset;
executed: signal_index = QMetaObjectPrivate::originalClone(metaObject, signal_index - methodOffset) + signalOffset;
Execution Count:206820
206820
2984 else -
2985 signal_index = signal_index - methodOffset + signalOffset;
executed: signal_index = signal_index - methodOffset + signalOffset;
Execution Count:2
2
2986 *base = metaObject;
executed (the execution status of this line is deduced): *base = metaObject;
-
2987 }
executed: }
Execution Count:206822
206822
2988 return signal_index;
executed: return signal_index;
Execution Count:206822
206822
2989} -
2990 -
2991/*! -
2992 \internal -
2993 \a types is a 0-terminated vector of meta types for queued -
2994 connections. -
2995 -
2996 if \a signal_index is -1, then we effectively connect *all* signals -
2997 from the sender to the receiver's slot -
2998 */ -
2999QMetaObject::Connection QMetaObject::connect(const QObject *sender, int signal_index, -
3000 const QObject *receiver, int method_index, int type, int *types) -
3001{ -
3002 const QMetaObject *smeta = sender->metaObject();
executed (the execution status of this line is deduced): const QMetaObject *smeta = sender->metaObject();
-
3003 signal_index = methodIndexToSignalIndex(&smeta, signal_index);
executed (the execution status of this line is deduced): signal_index = methodIndexToSignalIndex(&smeta, signal_index);
-
3004 return Connection(QMetaObjectPrivate::connect(sender, signal_index, smeta,
executed: return Connection(QMetaObjectPrivate::connect(sender, signal_index, smeta, receiver, method_index, 0, type, types));
Execution Count:106730
106730
3005 receiver, method_index,
executed: return Connection(QMetaObjectPrivate::connect(sender, signal_index, smeta, receiver, method_index, 0, type, types));
Execution Count:106730
106730
3006 0, //FIXME, we could speed this connection up by computing the relative index
executed: return Connection(QMetaObjectPrivate::connect(sender, signal_index, smeta, receiver, method_index, 0, type, types));
Execution Count:106730
106730
3007 type, types));
executed: return Connection(QMetaObjectPrivate::connect(sender, signal_index, smeta, receiver, method_index, 0, type, types));
Execution Count:106730
106730
3008} -
3009 -
3010/*! -
3011 \internal -
3012 Same as the QMetaObject::connect, but \a signal_index must be the result of QObjectPrivate::signalIndex -
3013 -
3014 method_index is relative to the rmeta metaobject, if rmeta is null, then it is absolute index -
3015 -
3016 the QObjectPrivate::Connection* has a refcount of 2, so it must be passed to a QMetaObject::Connection -
3017 */ -
3018QObjectPrivate::Connection *QMetaObjectPrivate::connect(const QObject *sender, -
3019 int signal_index, const QMetaObject *smeta, -
3020 const QObject *receiver, int method_index, -
3021 const QMetaObject *rmeta, int type, int *types) -
3022{ -
3023 QObject *s = const_cast<QObject *>(sender);
executed (the execution status of this line is deduced): QObject *s = const_cast<QObject *>(sender);
-
3024 QObject *r = const_cast<QObject *>(receiver);
executed (the execution status of this line is deduced): QObject *r = const_cast<QObject *>(receiver);
-
3025 -
3026 int method_offset = rmeta ? rmeta->methodOffset() : 0;
evaluated: rmeta
TRUEFALSE
yes
Evaluation Count:333879
yes
Evaluation Count:106769
106769-333879
3027 Q_ASSERT(!rmeta || QMetaObjectPrivate::get(rmeta)->revision >= 6);
executed (the execution status of this line is deduced): qt_noop();
-
3028 QObjectPrivate::StaticMetaCallFunction callFunction =
executed (the execution status of this line is deduced): QObjectPrivate::StaticMetaCallFunction callFunction =
-
3029 rmeta ? rmeta->d.static_metacall : 0;
evaluated: rmeta
TRUEFALSE
yes
Evaluation Count:333882
yes
Evaluation Count:106769
106769-333882
3030 -
3031 QOrderedMutexLocker locker(signalSlotLock(sender),
executed (the execution status of this line is deduced): QOrderedMutexLocker locker(signalSlotLock(sender),
-
3032 signalSlotLock(receiver));
executed (the execution status of this line is deduced): signalSlotLock(receiver));
-
3033 -
3034 if (type & Qt::UniqueConnection) {
evaluated: type & Qt::UniqueConnection
TRUEFALSE
yes
Evaluation Count:1968
yes
Evaluation Count:438694
1968-438694
3035 QObjectConnectionListVector *connectionLists = QObjectPrivate::get(s)->connectionLists;
executed (the execution status of this line is deduced): QObjectConnectionListVector *connectionLists = QObjectPrivate::get(s)->connectionLists;
-
3036 if (connectionLists && connectionLists->count() > signal_index) {
evaluated: connectionLists
TRUEFALSE
yes
Evaluation Count:1588
yes
Evaluation Count:380
evaluated: connectionLists->count() > signal_index
TRUEFALSE
yes
Evaluation Count:1277
yes
Evaluation Count:311
311-1588
3037 const QObjectPrivate::Connection *c2 =
executed (the execution status of this line is deduced): const QObjectPrivate::Connection *c2 =
-
3038 (*connectionLists)[signal_index].first;
executed (the execution status of this line is deduced): (*connectionLists)[signal_index].first;
-
3039 -
3040 int method_index_absolute = method_index + method_offset;
executed (the execution status of this line is deduced): int method_index_absolute = method_index + method_offset;
-
3041 -
3042 while (c2) {
evaluated: c2
TRUEFALSE
yes
Evaluation Count:1235
yes
Evaluation Count:234
234-1235
3043 if (c2->receiver == receiver && c2->method() == method_index_absolute)
evaluated: c2->receiver == receiver
TRUEFALSE
yes
Evaluation Count:1045
yes
Evaluation Count:190
evaluated: c2->method() == method_index_absolute
TRUEFALSE
yes
Evaluation Count:1043
yes
Evaluation Count:2
2-1045
3044 return 0;
executed: return 0;
Execution Count:1043
1043
3045 c2 = c2->nextConnectionList;
executed (the execution status of this line is deduced): c2 = c2->nextConnectionList;
-
3046 }
executed: }
Execution Count:192
192
3047 }
executed: }
Execution Count:234
234
3048 type &= Qt::UniqueConnection - 1;
executed (the execution status of this line is deduced): type &= Qt::UniqueConnection - 1;
-
3049 }
executed: }
Execution Count:925
925
3050 -
3051 QScopedPointer<QObjectPrivate::Connection> c(new QObjectPrivate::Connection);
executed (the execution status of this line is deduced): QScopedPointer<QObjectPrivate::Connection> c(new QObjectPrivate::Connection);
-
3052 c->sender = s;
executed (the execution status of this line is deduced): c->sender = s;
-
3053 c->signal_index = signal_index;
executed (the execution status of this line is deduced): c->signal_index = signal_index;
-
3054 c->receiver = r;
executed (the execution status of this line is deduced): c->receiver = r;
-
3055 c->method_relative = method_index;
executed (the execution status of this line is deduced): c->method_relative = method_index;
-
3056 c->method_offset = method_offset;
executed (the execution status of this line is deduced): c->method_offset = method_offset;
-
3057 c->connectionType = type;
executed (the execution status of this line is deduced): c->connectionType = type;
-
3058 c->isSlotObject = false;
executed (the execution status of this line is deduced): c->isSlotObject = false;
-
3059 c->argumentTypes.store(types);
executed (the execution status of this line is deduced): c->argumentTypes.store(types);
-
3060 c->nextConnectionList = 0;
executed (the execution status of this line is deduced): c->nextConnectionList = 0;
-
3061 c->callFunction = callFunction;
executed (the execution status of this line is deduced): c->callFunction = callFunction;
-
3062 -
3063 QObjectPrivate::get(s)->addConnection(signal_index, c.data());
executed (the execution status of this line is deduced): QObjectPrivate::get(s)->addConnection(signal_index, c.data());
-
3064 -
3065 locker.unlock();
executed (the execution status of this line is deduced): locker.unlock();
-
3066 QMetaMethod smethod = QMetaObjectPrivate::signal(smeta, signal_index);
executed (the execution status of this line is deduced): QMetaMethod smethod = QMetaObjectPrivate::signal(smeta, signal_index);
-
3067 if (smethod.isValid())
evaluated: smethod.isValid()
TRUEFALSE
yes
Evaluation Count:439287
yes
Evaluation Count:321
321-439287
3068 s->connectNotify(smethod);
executed: s->connectNotify(smethod);
Execution Count:439287
439287
3069 -
3070 return c.take();
executed: return c.take();
Execution Count:439610
439610
3071} -
3072 -
3073/*! -
3074 \internal -
3075 */ -
3076bool QMetaObject::disconnect(const QObject *sender, int signal_index, -
3077 const QObject *receiver, int method_index) -
3078{ -
3079 const QMetaObject *smeta = sender->metaObject();
executed (the execution status of this line is deduced): const QMetaObject *smeta = sender->metaObject();
-
3080 signal_index = methodIndexToSignalIndex(&smeta, signal_index);
executed (the execution status of this line is deduced): signal_index = methodIndexToSignalIndex(&smeta, signal_index);
-
3081 return QMetaObjectPrivate::disconnect(sender, signal_index, smeta,
executed: return QMetaObjectPrivate::disconnect(sender, signal_index, smeta, receiver, method_index, 0);
Execution Count:100428
100428
3082 receiver, method_index, 0);
executed: return QMetaObjectPrivate::disconnect(sender, signal_index, smeta, receiver, method_index, 0);
Execution Count:100428
100428
3083} -
3084 -
3085/*! -
3086 \internal -
3087 -
3088Disconnect a single signal connection. If QMetaObject::connect() has been called -
3089multiple times for the same sender, signal_index, receiver and method_index only -
3090one of these connections will be removed. -
3091 */ -
3092bool QMetaObject::disconnectOne(const QObject *sender, int signal_index, -
3093 const QObject *receiver, int method_index) -
3094{ -
3095 const QMetaObject *smeta = sender->metaObject();
executed (the execution status of this line is deduced): const QMetaObject *smeta = sender->metaObject();
-
3096 signal_index = methodIndexToSignalIndex(&smeta, signal_index);
executed (the execution status of this line is deduced): signal_index = methodIndexToSignalIndex(&smeta, signal_index);
-
3097 return QMetaObjectPrivate::disconnect(sender, signal_index, smeta,
executed: return QMetaObjectPrivate::disconnect(sender, signal_index, smeta, receiver, method_index, 0, QMetaObjectPrivate::DisconnectOne);
Execution Count:6
6
3098 receiver, method_index, 0,
executed: return QMetaObjectPrivate::disconnect(sender, signal_index, smeta, receiver, method_index, 0, QMetaObjectPrivate::DisconnectOne);
Execution Count:6
6
3099 QMetaObjectPrivate::DisconnectOne);
executed: return QMetaObjectPrivate::disconnect(sender, signal_index, smeta, receiver, method_index, 0, QMetaObjectPrivate::DisconnectOne);
Execution Count:6
6
3100} -
3101 -
3102/*! -
3103 \internal -
3104 Helper function to remove the connection from the senders list and setting the receivers to 0 -
3105 */ -
3106bool QMetaObjectPrivate::disconnectHelper(QObjectPrivate::Connection *c, -
3107 const QObject *receiver, int method_index, void **slot, -
3108 QMutex *senderMutex, DisconnectType disconnectType) -
3109{ -
3110 bool success = false;
executed (the execution status of this line is deduced): bool success = false;
-
3111 while (c) {
evaluated: c
TRUEFALSE
yes
Evaluation Count:145281
yes
Evaluation Count:133208
133208-145281
3112 if (c->receiver
evaluated: c->receiver
TRUEFALSE
yes
Evaluation Count:140644
yes
Evaluation Count:4637
4637-140644
3113 && (receiver == 0 || (c->receiver == receiver
evaluated: receiver == 0
TRUEFALSE
yes
Evaluation Count:67
yes
Evaluation Count:140577
evaluated: c->receiver == receiver
TRUEFALSE
yes
Evaluation Count:120428
yes
Evaluation Count:20149
67-140577
3114 && (method_index < 0 || c->method() == method_index)
evaluated: method_index < 0
TRUEFALSE
yes
Evaluation Count:4137
yes
Evaluation Count:116291
evaluated: c->method() == method_index
TRUEFALSE
yes
Evaluation Count:115046
yes
Evaluation Count:1245
1245-116291
3115 && (slot == 0 || (c->isSlotObject && c->slotObj->compare(slot)))))) {
evaluated: slot == 0
TRUEFALSE
yes
Evaluation Count:119179
yes
Evaluation Count:4
partially evaluated: c->isSlotObject
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
partially evaluated: c->slotObj->compare(slot)
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
0-119179
3116 bool needToUnlock = false;
executed (the execution status of this line is deduced): bool needToUnlock = false;
-
3117 QMutex *receiverMutex = 0;
executed (the execution status of this line is deduced): QMutex *receiverMutex = 0;
-
3118 if (!receiver) {
evaluated: !receiver
TRUEFALSE
yes
Evaluation Count:67
yes
Evaluation Count:119183
67-119183
3119 receiverMutex = signalSlotLock(c->receiver);
executed (the execution status of this line is deduced): receiverMutex = signalSlotLock(c->receiver);
-
3120 // need to relock this receiver and sender in the correct order -
3121 needToUnlock = QOrderedMutexLocker::relock(senderMutex, receiverMutex);
executed (the execution status of this line is deduced): needToUnlock = QOrderedMutexLocker::relock(senderMutex, receiverMutex);
-
3122 }
executed: }
Execution Count:67
67
3123 if (c->receiver) {
partially evaluated: c->receiver
TRUEFALSE
yes
Evaluation Count:119250
no
Evaluation Count:0
0-119250
3124 *c->prev = c->next;
executed (the execution status of this line is deduced): *c->prev = c->next;
-
3125 if (c->next)
evaluated: c->next
TRUEFALSE
yes
Evaluation Count:27933
yes
Evaluation Count:91317
27933-91317
3126 c->next->prev = c->prev;
executed: c->next->prev = c->prev;
Execution Count:27933
27933
3127 }
executed: }
Execution Count:119250
119250
3128 -
3129 if (needToUnlock)
evaluated: needToUnlock
TRUEFALSE
yes
Evaluation Count:50
yes
Evaluation Count:119200
50-119200
3130 receiverMutex->unlock();
executed: receiverMutex->unlock();
Execution Count:50
50
3131 -
3132 c->receiver = 0;
executed (the execution status of this line is deduced): c->receiver = 0;
-
3133 -
3134 success = true;
executed (the execution status of this line is deduced): success = true;
-
3135 -
3136 if (disconnectType == DisconnectOne)
evaluated: disconnectType == DisconnectOne
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:119246
4-119246
3137 return success;
executed: return success;
Execution Count:4
4
3138 }
executed: }
Execution Count:119246
119246
3139 c = c->nextConnectionList;
executed (the execution status of this line is deduced): c = c->nextConnectionList;
-
3140 }
executed: }
Execution Count:145277
145277
3141 return success;
executed: return success;
Execution Count:133208
133208
3142} -
3143 -
3144/*! -
3145 \internal -
3146 Same as the QMetaObject::disconnect, but \a signal_index must be the result of QObjectPrivate::signalIndex -
3147 */ -
3148bool QMetaObjectPrivate::disconnect(const QObject *sender, -
3149 int signal_index, const QMetaObject *smeta, -
3150 const QObject *receiver, int method_index, void **slot, -
3151 DisconnectType disconnectType) -
3152{ -
3153 if (!sender)
partially evaluated: !sender
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:134587
0-134587
3154 return false;
never executed: return false;
0
3155 -
3156 QObject *s = const_cast<QObject *>(sender);
executed (the execution status of this line is deduced): QObject *s = const_cast<QObject *>(sender);
-
3157 -
3158 QMutex *senderMutex = signalSlotLock(sender);
executed (the execution status of this line is deduced): QMutex *senderMutex = signalSlotLock(sender);
-
3159 QMutex *receiverMutex = receiver ? signalSlotLock(receiver) : 0;
evaluated: receiver
TRUEFALSE
yes
Evaluation Count:124847
yes
Evaluation Count:9740
9740-124847
3160 QOrderedMutexLocker locker(senderMutex, receiverMutex);
executed (the execution status of this line is deduced): QOrderedMutexLocker locker(senderMutex, receiverMutex);
-
3161 -
3162 QObjectConnectionListVector *connectionLists = QObjectPrivate::get(s)->connectionLists;
executed (the execution status of this line is deduced): QObjectConnectionListVector *connectionLists = QObjectPrivate::get(s)->connectionLists;
-
3163 if (!connectionLists)
evaluated: !connectionLists
TRUEFALSE
yes
Evaluation Count:7087
yes
Evaluation Count:127500
7087-127500
3164 return false;
executed: return false;
Execution Count:7087
7087
3165 -
3166 // prevent incoming connections changing the connectionLists while unlocked -
3167 ++connectionLists->inUse;
executed (the execution status of this line is deduced): ++connectionLists->inUse;
-
3168 -
3169 bool success = false;
executed (the execution status of this line is deduced): bool success = false;
-
3170 if (signal_index < 0) {
evaluated: signal_index < 0
TRUEFALSE
yes
Evaluation Count:2026
yes
Evaluation Count:125474
2026-125474
3171 // remove from all connection lists -
3172 for (int sig_index = -1; sig_index < connectionLists->count(); ++sig_index) {
evaluated: sig_index < connectionLists->count()
TRUEFALSE
yes
Evaluation Count:13458
yes
Evaluation Count:2026
2026-13458
3173 QObjectPrivate::Connection *c =
executed (the execution status of this line is deduced): QObjectPrivate::Connection *c =
-
3174 (*connectionLists)[sig_index].first;
executed (the execution status of this line is deduced): (*connectionLists)[sig_index].first;
-
3175 if (disconnectHelper(c, receiver, method_index, slot, senderMutex, disconnectType)) {
evaluated: disconnectHelper(c, receiver, method_index, slot, senderMutex, disconnectType)
TRUEFALSE
yes
Evaluation Count:3872
yes
Evaluation Count:9586
3872-9586
3176 success = true;
executed (the execution status of this line is deduced): success = true;
-
3177 connectionLists->dirty = true;
executed (the execution status of this line is deduced): connectionLists->dirty = true;
-
3178 }
executed: }
Execution Count:3872
3872
3179 }
executed: }
Execution Count:13458
13458
3180 } else if (signal_index < connectionLists->count()) {
executed: }
Execution Count:2026
evaluated: signal_index < connectionLists->count()
TRUEFALSE
yes
Evaluation Count:119754
yes
Evaluation Count:5720
2026-119754
3181 QObjectPrivate::Connection *c =
executed (the execution status of this line is deduced): QObjectPrivate::Connection *c =
-
3182 (*connectionLists)[signal_index].first;
executed (the execution status of this line is deduced): (*connectionLists)[signal_index].first;
-
3183 if (disconnectHelper(c, receiver, method_index, slot, senderMutex, disconnectType)) {
evaluated: disconnectHelper(c, receiver, method_index, slot, senderMutex, disconnectType)
TRUEFALSE
yes
Evaluation Count:115136
yes
Evaluation Count:4618
4618-115136
3184 success = true;
executed (the execution status of this line is deduced): success = true;
-
3185 connectionLists->dirty = true;
executed (the execution status of this line is deduced): connectionLists->dirty = true;
-
3186 }
executed: }
Execution Count:115136
115136
3187 }
executed: }
Execution Count:119754
119754
3188 -
3189 --connectionLists->inUse;
executed (the execution status of this line is deduced): --connectionLists->inUse;
-
3190 Q_ASSERT(connectionLists->inUse >= 0);
executed (the execution status of this line is deduced): qt_noop();
-
3191 if (connectionLists->orphaned && !connectionLists->inUse)
partially evaluated: connectionLists->orphaned
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:127500
never evaluated: !connectionLists->inUse
0-127500
3192 delete connectionLists;
never executed: delete connectionLists;
0
3193 -
3194 locker.unlock();
executed (the execution status of this line is deduced): locker.unlock();
-
3195 if (success) {
evaluated: success
TRUEFALSE
yes
Evaluation Count:117139
yes
Evaluation Count:10361
10361-117139
3196 QMetaMethod smethod = QMetaObjectPrivate::signal(smeta, signal_index);
executed (the execution status of this line is deduced): QMetaMethod smethod = QMetaObjectPrivate::signal(smeta, signal_index);
-
3197 if (smethod.isValid())
evaluated: smethod.isValid()
TRUEFALSE
yes
Evaluation Count:115136
yes
Evaluation Count:2003
2003-115136
3198 s->disconnectNotify(smethod);
executed: s->disconnectNotify(smethod);
Execution Count:115136
115136
3199 }
executed: }
Execution Count:117139
117139
3200 -
3201 return success;
executed: return success;
Execution Count:127500
127500
3202} -
3203 -
3204/*! -
3205 \fn void QMetaObject::connectSlotsByName(QObject *object) -
3206 -
3207 Searches recursively for all child objects of the given \a object, and connects -
3208 matching signals from them to slots of \a object that follow the following form: -
3209 -
3210 \snippet code/src_corelib_kernel_qobject.cpp 33 -
3211 -
3212 Let's assume our object has a child object of type \c{QPushButton} with -
3213 the \l{QObject::objectName}{object name} \c{button1}. The slot to catch the -
3214 button's \c{clicked()} signal would be: -
3215 -
3216 \snippet code/src_corelib_kernel_qobject.cpp 34 -
3217 -
3218 \sa QObject::setObjectName() -
3219 */ -
3220void QMetaObject::connectSlotsByName(QObject *o) -
3221{ -
3222 if (!o)
partially evaluated: !o
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:180
0-180
3223 return;
never executed: return;
0
3224 const QMetaObject *mo = o->metaObject();
executed (the execution status of this line is deduced): const QMetaObject *mo = o->metaObject();
-
3225 Q_ASSERT(mo);
executed (the execution status of this line is deduced): qt_noop();
-
3226 const QObjectList list = o->findChildren<QObject *>(QString());
executed (the execution status of this line is deduced): const QObjectList list = o->findChildren<QObject *>(QString());
-
3227 for (int i = 0; i < mo->methodCount(); ++i) {
evaluated: i < mo->methodCount()
TRUEFALSE
yes
Evaluation Count:11238
yes
Evaluation Count:180
180-11238
3228 QByteArray slotSignature = mo->method(i).methodSignature();
executed (the execution status of this line is deduced): QByteArray slotSignature = mo->method(i).methodSignature();
-
3229 const char *slot = slotSignature.constData();
executed (the execution status of this line is deduced): const char *slot = slotSignature.constData();
-
3230 Q_ASSERT(slot);
executed (the execution status of this line is deduced): qt_noop();
-
3231 if (slot[0] != 'o' || slot[1] != 'n' || slot[2] != '_')
evaluated: slot[0] != 'o'
TRUEFALSE
yes
Evaluation Count:10866
yes
Evaluation Count:372
evaluated: slot[1] != 'n'
TRUEFALSE
yes
Evaluation Count:348
yes
Evaluation Count:24
evaluated: slot[2] != '_'
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:23
1-10866
3232 continue;
executed: continue;
Execution Count:11215
11215
3233 bool foundIt = false;
executed (the execution status of this line is deduced): bool foundIt = false;
-
3234 for(int j = 0; j < list.count(); ++j) {
evaluated: j < list.count()
TRUEFALSE
yes
Evaluation Count:26
yes
Evaluation Count:7
7-26
3235 const QObject *co = list.at(j);
executed (the execution status of this line is deduced): const QObject *co = list.at(j);
-
3236 QByteArray objName = co->objectName().toLatin1();
executed (the execution status of this line is deduced): QByteArray objName = co->objectName().toLatin1();
-
3237 int len = objName.length();
executed (the execution status of this line is deduced): int len = objName.length();
-
3238 if (!len || qstrncmp(slot + 3, objName.data(), len) || slot[len+3] != '_')
partially evaluated: !len
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:26
evaluated: qstrncmp(slot + 3, objName.data(), len)
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:16
partially evaluated: slot[len+3] != '_'
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:16
0-26
3239 continue;
executed: continue;
Execution Count:10
10
3240 const QMetaObject *smeta;
executed (the execution status of this line is deduced): const QMetaObject *smeta;
-
3241 int sigIndex = co->d_func()->signalIndex(slot + len + 4, &smeta);
executed (the execution status of this line is deduced): int sigIndex = co->d_func()->signalIndex(slot + len + 4, &smeta);
-
3242 if (sigIndex < 0) { // search for compatible signals
evaluated: sigIndex < 0
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:15
1-15
3243 const QMetaObject *smo = co->metaObject();
executed (the execution status of this line is deduced): const QMetaObject *smo = co->metaObject();
-
3244 int slotlen = qstrlen(slot + len + 4) - 1;
executed (the execution status of this line is deduced): int slotlen = qstrlen(slot + len + 4) - 1;
-
3245 for (int k = 0; k < QMetaObjectPrivate::absoluteSignalCount(smo); ++k) {
partially evaluated: k < QMetaObjectPrivate::absoluteSignalCount(smo)
TRUEFALSE
yes
Evaluation Count:7
no
Evaluation Count:0
0-7
3246 QMetaMethod method = QMetaObjectPrivate::signal(smo, k);
executed (the execution status of this line is deduced): QMetaMethod method = QMetaObjectPrivate::signal(smo, k);
-
3247 if (!qstrncmp(method.methodSignature().constData(), slot + len + 4, slotlen)) {
evaluated: !qstrncmp(method.methodSignature().constData(), slot + len + 4, slotlen)
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:6
1-6
3248 smeta = method.enclosingMetaObject();
executed (the execution status of this line is deduced): smeta = method.enclosingMetaObject();
-
3249 sigIndex = k;
executed (the execution status of this line is deduced): sigIndex = k;
-
3250 break;
executed: break;
Execution Count:1
1
3251 } -
3252 }
executed: }
Execution Count:6
6
3253 }
executed: }
Execution Count:1
1
3254 if (sigIndex < 0)
partially evaluated: sigIndex < 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:16
0-16
3255 continue;
never executed: continue;
0
3256 -
3257 if (Connection(QMetaObjectPrivate::connect(co, sigIndex, smeta, o, i))) {
partially evaluated: Connection(QMetaObjectPrivate::connect(co, sigIndex, smeta, o, i))
TRUEFALSE
yes
Evaluation Count:16
no
Evaluation Count:0
0-16
3258 foundIt = true;
executed (the execution status of this line is deduced): foundIt = true;
-
3259 break;
executed: break;
Execution Count:16
16
3260 } -
3261 }
never executed: }
0
3262 if (foundIt) {
evaluated: foundIt
TRUEFALSE
yes
Evaluation Count:16
yes
Evaluation Count:7
7-16
3263 // we found our slot, now skip all overloads -
3264 while (mo->method(i + 1).attributes() & QMetaMethod::Cloned)
evaluated: mo->method(i + 1).attributes() & QMetaMethod::Cloned
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:16
3-16
3265 ++i;
executed: ++i;
Execution Count:3
3
3266 } else if (!(mo->method(i).attributes() & QMetaMethod::Cloned)) {
executed: }
Execution Count:16
evaluated: !(mo->method(i).attributes() & QMetaMethod::Cloned)
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:2
2-16
3267 qWarning("QMetaObject::connectSlotsByName: No matching signal for %s", slot);
executed (the execution status of this line is deduced): QMessageLogger("kernel/qobject.cpp", 3267, __PRETTY_FUNCTION__).warning("QMetaObject::connectSlotsByName: No matching signal for %s", slot);
-
3268 }
executed: }
Execution Count:5
5
3269 } -
3270}
executed: }
Execution Count:180
180
3271 -
3272/*! -
3273 \internal -
3274 -
3275 \a signal must be in the signal index range (see QObjectPrivate::signalIndex()). -
3276*/ -
3277static void queued_activate(QObject *sender, int signal, QObjectPrivate::Connection *c, void **argv) -
3278{ -
3279 const int *argumentTypes = c->argumentTypes.load();
executed (the execution status of this line is deduced): const int *argumentTypes = c->argumentTypes.load();
-
3280 if (!argumentTypes && argumentTypes != &DIRECT_CONNECTION_ONLY) {
evaluated: !argumentTypes
TRUEFALSE
yes
Evaluation Count:1711
yes
Evaluation Count:18774
partially evaluated: argumentTypes != &DIRECT_CONNECTION_ONLY
TRUEFALSE
yes
Evaluation Count:1711
no
Evaluation Count:0
0-18774
3281 QMetaMethod m = QMetaObjectPrivate::signal(sender->metaObject(), signal);
executed (the execution status of this line is deduced): QMetaMethod m = QMetaObjectPrivate::signal(sender->metaObject(), signal);
-
3282 argumentTypes = queuedConnectionTypes(m.parameterTypes());
executed (the execution status of this line is deduced): argumentTypes = queuedConnectionTypes(m.parameterTypes());
-
3283 if (!argumentTypes) // cannot queue arguments
partially evaluated: !argumentTypes
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1711
0-1711
3284 argumentTypes = &DIRECT_CONNECTION_ONLY;
never executed: argumentTypes = &DIRECT_CONNECTION_ONLY;
0
3285 if (!c->argumentTypes.testAndSetOrdered(0, argumentTypes)) {
partially evaluated: !c->argumentTypes.testAndSetOrdered(0, argumentTypes)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1711
0-1711
3286 if (argumentTypes != &DIRECT_CONNECTION_ONLY)
never evaluated: argumentTypes != &DIRECT_CONNECTION_ONLY
0
3287 delete [] argumentTypes;
never executed: delete [] argumentTypes;
0
3288 argumentTypes = c->argumentTypes.load();
never executed (the execution status of this line is deduced): argumentTypes = c->argumentTypes.load();
-
3289 }
never executed: }
0
3290 }
executed: }
Execution Count:1711
1711
3291 if (argumentTypes == &DIRECT_CONNECTION_ONLY) // cannot activate
partially evaluated: argumentTypes == &DIRECT_CONNECTION_ONLY
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:20485
0-20485
3292 return;
never executed: return;
0
3293 int nargs = 1; // include return type
executed (the execution status of this line is deduced): int nargs = 1;
-
3294 while (argumentTypes[nargs-1])
evaluated: argumentTypes[nargs-1]
TRUEFALSE
yes
Evaluation Count:28332
yes
Evaluation Count:20485
20485-28332
3295 ++nargs;
executed: ++nargs;
Execution Count:28332
28332
3296 int *types = (int *) malloc(nargs*sizeof(int));
executed (the execution status of this line is deduced): int *types = (int *) malloc(nargs*sizeof(int));
-
3297 Q_CHECK_PTR(types);
never executed: qBadAlloc();
executed: }
Execution Count:20485
partially evaluated: !(types)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:20485
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:20485
0-20485
3298 void **args = (void **) malloc(nargs*sizeof(void *));
executed (the execution status of this line is deduced): void **args = (void **) malloc(nargs*sizeof(void *));
-
3299 Q_CHECK_PTR(args);
never executed: qBadAlloc();
executed: }
Execution Count:20485
partially evaluated: !(args)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:20485
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:20485
0-20485
3300 types[0] = 0; // return type
executed (the execution status of this line is deduced): types[0] = 0;
-
3301 args[0] = 0; // return value
executed (the execution status of this line is deduced): args[0] = 0;
-
3302 for (int n = 1; n < nargs; ++n)
evaluated: n < nargs
TRUEFALSE
yes
Evaluation Count:28332
yes
Evaluation Count:20485
20485-28332
3303 args[n] = QMetaType::create((types[n] = argumentTypes[n-1]), argv[n]);
executed: args[n] = QMetaType::create((types[n] = argumentTypes[n-1]), argv[n]);
Execution Count:28332
28332
3304 QMetaCallEvent *ev = c->isSlotObject ?
evaluated: c->isSlotObject
TRUEFALSE
yes
Evaluation Count:15
yes
Evaluation Count:20470
15-20470
3305 new QMetaCallEvent(c->slotObj, sender, signal, nargs, types, args) :
executed (the execution status of this line is deduced): new QMetaCallEvent(c->slotObj, sender, signal, nargs, types, args) :
-
3306 new QMetaCallEvent(c->method_offset, c->method_relative, c->callFunction, sender, signal, nargs, types, args);
executed (the execution status of this line is deduced): new QMetaCallEvent(c->method_offset, c->method_relative, c->callFunction, sender, signal, nargs, types, args);
-
3307 QCoreApplication::postEvent(c->receiver, ev);
executed (the execution status of this line is deduced): QCoreApplication::postEvent(c->receiver, ev);
-
3308}
executed: }
Execution Count:20485
20485
3309 -
3310/*! -
3311 \internal -
3312 */ -
3313void QMetaObject::activate(QObject *sender, const QMetaObject *m, int local_signal_index, -
3314 void **argv) -
3315{ -
3316 activate(sender, QMetaObjectPrivate::signalOffset(m), local_signal_index, argv);
executed (the execution status of this line is deduced): activate(sender, QMetaObjectPrivate::signalOffset(m), local_signal_index, argv);
-
3317}
executed: }
Execution Count:9493510
9493510
3318 -
3319/*! -
3320 \internal -
3321 */ -
3322void QMetaObject::activate(QObject *sender, int signalOffset, int local_signal_index, void **argv) -
3323{ -
3324 int signal_index = signalOffset + local_signal_index;
executed (the execution status of this line is deduced): int signal_index = signalOffset + local_signal_index;
-
3325 -
3326 if (!sender->d_func()->isSignalConnected(signal_index))
evaluated: !sender->d_func()->isSignalConnected(signal_index)
TRUEFALSE
yes
Evaluation Count:7359667
yes
Evaluation Count:2133740
2133740-7359667
3327 return; // nothing connected to these signals, and no spy
executed: return;
Execution Count:7359661
7359661
3328 -
3329 if (sender->d_func()->blockSig)
evaluated: sender->d_func()->blockSig
TRUEFALSE
yes
Evaluation Count:37738
yes
Evaluation Count:2096004
37738-2096004
3330 return;
executed: return;
Execution Count:37738
37738
3331 -
3332 if (sender->d_func()->declarativeData && QAbstractDeclarativeData::signalEmitted)
partially evaluated: sender->d_func()->declarativeData
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2096007
never evaluated: QAbstractDeclarativeData::signalEmitted
0-2096007
3333 QAbstractDeclarativeData::signalEmitted(sender->d_func()->declarativeData, sender,
never executed: QAbstractDeclarativeData::signalEmitted(sender->d_func()->declarativeData, sender, signal_index, argv);
0
3334 signal_index, argv);
never executed: QAbstractDeclarativeData::signalEmitted(sender->d_func()->declarativeData, sender, signal_index, argv);
0
3335 -
3336 void *empty_argv[] = { 0 };
executed (the execution status of this line is deduced): void *empty_argv[] = { 0 };
-
3337 if (qt_signal_spy_callback_set.signal_begin_callback != 0) {
partially evaluated: qt_signal_spy_callback_set.signal_begin_callback != 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2096001
0-2096001
3338 qt_signal_spy_callback_set.signal_begin_callback(sender, signal_index,
never executed (the execution status of this line is deduced): qt_signal_spy_callback_set.signal_begin_callback(sender, signal_index,
-
3339 argv ? argv : empty_argv);
never executed (the execution status of this line is deduced): argv ? argv : empty_argv);
-
3340 }
never executed: }
0
3341 -
3342 Qt::HANDLE currentThreadId = QThread::currentThreadId(); -
3343 -
3344 { -
3345 QMutexLocker locker(signalSlotLock(sender));
executed (the execution status of this line is deduced): QMutexLocker locker(signalSlotLock(sender));
-
3346 struct ConnectionListsRef {
executed (the execution status of this line is deduced): struct ConnectionListsRef {
-
3347 QObjectConnectionListVector *connectionLists;
executed (the execution status of this line is deduced): QObjectConnectionListVector *connectionLists;
-
3348 ConnectionListsRef(QObjectConnectionListVector *connectionLists) : connectionLists(connectionLists)
executed (the execution status of this line is deduced): ConnectionListsRef(QObjectConnectionListVector *connectionLists) : connectionLists(connectionLists)
-
3349 {
executed (the execution status of this line is deduced): {
-
3350 if (connectionLists)
evaluated: connectionLists
TRUEFALSE
yes
Evaluation Count:2095422
yes
Evaluation Count:594
594-2095422
3351 ++connectionLists->inUse;
executed: ++connectionLists->inUse;
Execution Count:2095420
2095420
3352 }
executed: }
Execution Count:2096012
2096012
3353 ~ConnectionListsRef()
executed (the execution status of this line is deduced): ~ConnectionListsRef()
-
3354 {
executed (the execution status of this line is deduced): {
-
3355 if (!connectionLists)
evaluated: !connectionLists
TRUEFALSE
yes
Evaluation Count:594
yes
Evaluation Count:2095341
594-2095341
3356 return;
executed: return;
Execution Count:594
594
3357
executed (the execution status of this line is deduced):
-
3358 --connectionLists->inUse;
executed (the execution status of this line is deduced): --connectionLists->inUse;
-
3359 Q_ASSERT(connectionLists->inUse >= 0);
executed (the execution status of this line is deduced): qt_noop();
-
3360 if (connectionLists->orphaned) {
evaluated: connectionLists->orphaned
TRUEFALSE
yes
Evaluation Count:75
yes
Evaluation Count:2095265
75-2095265
3361 if (!connectionLists->inUse)
evaluated: !connectionLists->inUse
TRUEFALSE
yes
Evaluation Count:74
yes
Evaluation Count:1
1-74
3362 delete connectionLists;
executed: delete connectionLists;
Execution Count:74
74
3363 }
executed: }
Execution Count:75
75
3364 }
executed: }
Execution Count:2095341
2095341
3365
executed (the execution status of this line is deduced):
-
3366 QObjectConnectionListVector *operator->() const { return connectionLists; }
executed: return connectionLists;
Execution Count:15328827
15328827
3367 };
executed (the execution status of this line is deduced): };
-
3368 ConnectionListsRef connectionLists = sender->d_func()->connectionLists;
executed (the execution status of this line is deduced): ConnectionListsRef connectionLists = sender->d_func()->connectionLists;
-
3369 if (!connectionLists.connectionLists) {
evaluated: !connectionLists.connectionLists
TRUEFALSE
yes
Evaluation Count:594
yes
Evaluation Count:2095413
594-2095413
3370 locker.unlock();
executed (the execution status of this line is deduced): locker.unlock();
-
3371 if (qt_signal_spy_callback_set.signal_end_callback != 0)
partially evaluated: qt_signal_spy_callback_set.signal_end_callback != 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:594
0-594
3372 qt_signal_spy_callback_set.signal_end_callback(sender, signal_index);
never executed: qt_signal_spy_callback_set.signal_end_callback(sender, signal_index);
0
3373 return;
executed: return;
Execution Count:594
594
3374 } -
3375 -
3376 const QObjectPrivate::ConnectionList *list;
executed (the execution status of this line is deduced): const QObjectPrivate::ConnectionList *list;
-
3377 if (signal_index < connectionLists->count())
evaluated: signal_index < connectionLists->count()
TRUEFALSE
yes
Evaluation Count:2094695
yes
Evaluation Count:722
722-2094695
3378 list = &connectionLists->at(signal_index);
executed: list = &connectionLists->at(signal_index);
Execution Count:2094688
2094688
3379 else -
3380 list = &connectionLists->allsignals;
executed: list = &connectionLists->allsignals;
Execution Count:722
722
3381 -
3382 do { -
3383 QObjectPrivate::Connection *c = list->first;
executed (the execution status of this line is deduced): QObjectPrivate::Connection *c = list->first;
-
3384 if (!c) continue;
executed: continue;
Execution Count:2094623
evaluated: !c
TRUEFALSE
yes
Evaluation Count:2094623
yes
Evaluation Count:2095334
2094623-2095334
3385 // We need to check against last here to ensure that signals added -
3386 // during the signal emission are not emitted in this emission. -
3387 QObjectPrivate::Connection *last = list->last;
executed (the execution status of this line is deduced): QObjectPrivate::Connection *last = list->last;
-
3388 -
3389 do { -
3390 if (!c->receiver)
evaluated: !c->receiver
TRUEFALSE
yes
Evaluation Count:30917
yes
Evaluation Count:2780009
30917-2780009
3391 continue;
executed: continue;
Execution Count:30917
30917
3392 -
3393 QObject * const receiver = c->receiver;
executed (the execution status of this line is deduced): QObject * const receiver = c->receiver;
-
3394 const bool receiverInSameThread = currentThreadId == receiver->d_func()->threadData->threadId;
executed (the execution status of this line is deduced): const bool receiverInSameThread = currentThreadId == receiver->d_func()->threadData->threadId;
-
3395 -
3396 // determine if this connection should be sent immediately or -
3397 // put into the event queue -
3398 if ((c->connectionType == Qt::AutoConnection && !receiverInSameThread)
evaluated: c->connectionType == Qt::AutoConnection
TRUEFALSE
yes
Evaluation Count:2737517
yes
Evaluation Count:42505
evaluated: !receiverInSameThread
TRUEFALSE
yes
Evaluation Count:5876
yes
Evaluation Count:2731644
5876-2737517
3399 || (c->connectionType == Qt::QueuedConnection)) {
evaluated: (c->connectionType == Qt::QueuedConnection)
TRUEFALSE
yes
Evaluation Count:14609
yes
Evaluation Count:2759492
14609-2759492
3400 queued_activate(sender, signal_index, c, argv ? argv : empty_argv);
executed (the execution status of this line is deduced): queued_activate(sender, signal_index, c, argv ? argv : empty_argv);
-
3401 continue;
executed: continue;
Execution Count:20485
20485
3402#ifndef QT_NO_THREAD -
3403 } else if (c->connectionType == Qt::BlockingQueuedConnection) {
evaluated: c->connectionType == Qt::BlockingQueuedConnection
TRUEFALSE
yes
Evaluation Count:531
yes
Evaluation Count:2758949
531-2758949
3404 locker.unlock();
executed (the execution status of this line is deduced): locker.unlock();
-
3405 if (receiverInSameThread) {
partially evaluated: receiverInSameThread
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:531
0-531
3406 qWarning("Qt: Dead lock detected while activating a BlockingQueuedConnection: "
never executed (the execution status of this line is deduced): QMessageLogger("kernel/qobject.cpp", 3406, __PRETTY_FUNCTION__).warning("Qt: Dead lock detected while activating a BlockingQueuedConnection: "
-
3407 "Sender is %s(%p), receiver is %s(%p)",
never executed (the execution status of this line is deduced): "Sender is %s(%p), receiver is %s(%p)",
-
3408 sender->metaObject()->className(), sender,
never executed (the execution status of this line is deduced): sender->metaObject()->className(), sender,
-
3409 receiver->metaObject()->className(), receiver);
never executed (the execution status of this line is deduced): receiver->metaObject()->className(), receiver);
-
3410 }
never executed: }
0
3411 QSemaphore semaphore;
executed (the execution status of this line is deduced): QSemaphore semaphore;
-
3412 QMetaCallEvent *ev = c->isSlotObject ?
evaluated: c->isSlotObject
TRUEFALSE
yes
Evaluation Count:52
yes
Evaluation Count:479
52-479
3413 new QMetaCallEvent(c->slotObj, sender, signal_index, 0, 0, argv ? argv : empty_argv, &semaphore) :
executed (the execution status of this line is deduced): new QMetaCallEvent(c->slotObj, sender, signal_index, 0, 0, argv ? argv : empty_argv, &semaphore) :
-
3414 new QMetaCallEvent(c->method_offset, c->method_relative, c->callFunction, sender, signal_index, 0, 0, argv ? argv : empty_argv, &semaphore);
executed (the execution status of this line is deduced): new QMetaCallEvent(c->method_offset, c->method_relative, c->callFunction, sender, signal_index, 0, 0, argv ? argv : empty_argv, &semaphore);
-
3415 QCoreApplication::postEvent(receiver, ev);
executed (the execution status of this line is deduced): QCoreApplication::postEvent(receiver, ev);
-
3416 semaphore.acquire();
executed (the execution status of this line is deduced): semaphore.acquire();
-
3417 locker.relock();
executed (the execution status of this line is deduced): locker.relock();
-
3418 continue;
executed: continue;
Execution Count:531
531
3419#endif -
3420 } -
3421 -
3422 QConnectionSenderSwitcher sw;
executed (the execution status of this line is deduced): QConnectionSenderSwitcher sw;
-
3423 -
3424 if (receiverInSameThread) {
evaluated: receiverInSameThread
TRUEFALSE
yes
Evaluation Count:2758846
yes
Evaluation Count:105
105-2758846
3425 sw.switchSender(receiver, sender, signal_index);
executed (the execution status of this line is deduced): sw.switchSender(receiver, sender, signal_index);
-
3426 }
executed: }
Execution Count:2758847
2758847
3427 const QObjectPrivate::StaticMetaCallFunction callFunction = c->callFunction;
executed (the execution status of this line is deduced): const QObjectPrivate::StaticMetaCallFunction callFunction = c->callFunction;
-
3428 const int method_relative = c->method_relative;
executed (the execution status of this line is deduced): const int method_relative = c->method_relative;
-
3429 if (c->isSlotObject) {
evaluated: c->isSlotObject
TRUEFALSE
yes
Evaluation Count:334
yes
Evaluation Count:2758619
334-2758619
3430 c->slotObj->ref();
executed (the execution status of this line is deduced): c->slotObj->ref();
-
3431 const QScopedPointer<QtPrivate::QSlotObjectBase, QSlotObjectBaseDeleter> obj(c->slotObj);
executed (the execution status of this line is deduced): const QScopedPointer<QtPrivate::QSlotObjectBase, QSlotObjectBaseDeleter> obj(c->slotObj);
-
3432 locker.unlock();
executed (the execution status of this line is deduced): locker.unlock();
-
3433 obj->call(receiver, argv ? argv : empty_argv);
executed (the execution status of this line is deduced): obj->call(receiver, argv ? argv : empty_argv);
-
3434 locker.relock();
executed (the execution status of this line is deduced): locker.relock();
-
3435 } else if (callFunction && c->method_offset <= receiver->metaObject()->methodOffset()) {
executed: }
Execution Count:334
evaluated: callFunction
TRUEFALSE
yes
Evaluation Count:2751127
yes
Evaluation Count:7490
evaluated: c->method_offset <= receiver->metaObject()->methodOffset()
TRUEFALSE
yes
Evaluation Count:2748858
yes
Evaluation Count:2279
334-2751127
3436 //we compare the vtable to make sure we are not in the destructor of the object. -
3437 locker.unlock();
executed (the execution status of this line is deduced): locker.unlock();
-
3438 if (qt_signal_spy_callback_set.slot_begin_callback != 0)
partially evaluated: qt_signal_spy_callback_set.slot_begin_callback != 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2748910
0-2748910
3439 qt_signal_spy_callback_set.slot_begin_callback(receiver, c->method(), argv ? argv : empty_argv);
never executed: qt_signal_spy_callback_set.slot_begin_callback(receiver, c->method(), argv ? argv : empty_argv);
0
3440 -
3441 callFunction(receiver, QMetaObject::InvokeMetaMethod, method_relative, argv ? argv : empty_argv);
executed (the execution status of this line is deduced): callFunction(receiver, QMetaObject::InvokeMetaMethod, method_relative, argv ? argv : empty_argv);
-
3442 -
3443 if (qt_signal_spy_callback_set.slot_end_callback != 0)
partially evaluated: qt_signal_spy_callback_set.slot_end_callback != 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2748901
0-2748901
3444 qt_signal_spy_callback_set.slot_end_callback(receiver, c->method());
never executed: qt_signal_spy_callback_set.slot_end_callback(receiver, c->method());
0
3445 locker.relock();
executed (the execution status of this line is deduced): locker.relock();
-
3446 } else {
executed: }
Execution Count:2748905
2748905
3447 const int method = method_relative + c->method_offset;
executed (the execution status of this line is deduced): const int method = method_relative + c->method_offset;
-
3448 locker.unlock();
executed (the execution status of this line is deduced): locker.unlock();
-
3449 -
3450 if (qt_signal_spy_callback_set.slot_begin_callback != 0) {
partially evaluated: qt_signal_spy_callback_set.slot_begin_callback != 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:9769
0-9769
3451 qt_signal_spy_callback_set.slot_begin_callback(receiver,
never executed (the execution status of this line is deduced): qt_signal_spy_callback_set.slot_begin_callback(receiver,
-
3452 method,
never executed (the execution status of this line is deduced): method,
-
3453 argv ? argv : empty_argv);
never executed (the execution status of this line is deduced): argv ? argv : empty_argv);
-
3454 }
never executed: }
0
3455 -
3456 metacall(receiver, QMetaObject::InvokeMetaMethod, method, argv ? argv : empty_argv);
executed (the execution status of this line is deduced): metacall(receiver, QMetaObject::InvokeMetaMethod, method, argv ? argv : empty_argv);
-
3457 -
3458 if (qt_signal_spy_callback_set.slot_end_callback != 0)
partially evaluated: qt_signal_spy_callback_set.slot_end_callback != 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:9769
0-9769
3459 qt_signal_spy_callback_set.slot_end_callback(receiver, method);
never executed: qt_signal_spy_callback_set.slot_end_callback(receiver, method);
0
3460 -
3461 locker.relock();
executed (the execution status of this line is deduced): locker.relock();
-
3462 }
executed: }
Execution Count:9769
9769
3463 -
3464 if (connectionLists->orphaned)
evaluated: connectionLists->orphaned
TRUEFALSE
yes
Evaluation Count:74
yes
Evaluation Count:2758926
74-2758926
3465 break;
executed: break;
Execution Count:74
74
3466 } while (c != last && (c = c->nextConnectionList) != 0);
executed: }
Execution Count:2758918
evaluated: c != last
TRUEFALSE
yes
Evaluation Count:715594
yes
Evaluation Count:2095238
partially evaluated: (c = c->nextConnectionList) != 0
TRUEFALSE
yes
Evaluation Count:715594
no
Evaluation Count:0
0-2758918
3467 -
3468 if (connectionLists->orphaned)
evaluated: connectionLists->orphaned
TRUEFALSE
yes
Evaluation Count:75
yes
Evaluation Count:2095225
75-2095225
3469 break;
executed: break;
Execution Count:75
75
3470 } while (list != &connectionLists->allsignals &&
executed: }
Execution Count:2095219
evaluated: list != &connectionLists->allsignals
TRUEFALSE
yes
Evaluation Count:2094562
yes
Evaluation Count:2095266
2094562-2095266
3471 //start over for all signals;
executed (the execution status of this line is deduced):
-
3472 ((list = &connectionLists->allsignals), true));
partially evaluated: ((list = &connectionLists->allsignals), true)
TRUEFALSE
yes
Evaluation Count:2094554
no
Evaluation Count:0
0-2094554
3473 -
3474 } -
3475 -
3476 if (qt_signal_spy_callback_set.signal_end_callback != 0)
partially evaluated: qt_signal_spy_callback_set.signal_end_callback != 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2095417
0-2095417
3477 qt_signal_spy_callback_set.signal_end_callback(sender, signal_index);
never executed: qt_signal_spy_callback_set.signal_end_callback(sender, signal_index);
0
3478 -
3479}
executed: }
Execution Count:2095415
2095415
3480 -
3481/*! -
3482 \internal -
3483 signal_index comes from indexOfMethod() -
3484*/ -
3485void QMetaObject::activate(QObject *sender, int signal_index, void **argv) -
3486{ -
3487 const QMetaObject *mo = sender->metaObject();
executed (the execution status of this line is deduced): const QMetaObject *mo = sender->metaObject();
-
3488 while (mo->methodOffset() > signal_index)
partially evaluated: mo->methodOffset() > signal_index
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
3489 mo = mo->superClass();
never executed: mo = mo->superClass();
0
3490 activate(sender, mo, signal_index - mo->methodOffset(), argv);
executed (the execution status of this line is deduced): activate(sender, mo, signal_index - mo->methodOffset(), argv);
-
3491}
executed: }
Execution Count:3
3
3492 -
3493/*! -
3494 \internal -
3495 Implementation of QObject::senderSignalIndex() -
3496*/ -
3497int QObjectPrivate::senderSignalIndex() const -
3498{ -
3499 Q_Q(const QObject);
executed (the execution status of this line is deduced): const QObject * const q = q_func();
-
3500 QMutexLocker locker(signalSlotLock(q));
executed (the execution status of this line is deduced): QMutexLocker locker(signalSlotLock(q));
-
3501 if (!currentSender)
evaluated: !currentSender
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:744
5-744
3502 return -1;
executed: return -1;
Execution Count:5
5
3503 -
3504 for (QObjectPrivate::Connection *c = senders; c; c = c->next) {
evaluated: c
TRUEFALSE
yes
Evaluation Count:938
yes
Evaluation Count:2
2-938
3505 if (c->sender == currentSender->sender)
evaluated: c->sender == currentSender->sender
TRUEFALSE
yes
Evaluation Count:742
yes
Evaluation Count:196
196-742
3506 return currentSender->signal;
executed: return currentSender->signal;
Execution Count:742
742
3507 }
executed: }
Execution Count:196
196
3508 -
3509 return -1;
executed: return -1;
Execution Count:2
2
3510} -
3511 -
3512/*! -
3513 \internal -
3514 Returns the signal index used in the internal connectionLists vector. -
3515 -
3516 It is different from QMetaObject::indexOfSignal(): indexOfSignal is the same as indexOfMethod -
3517 while QObjectPrivate::signalIndex is smaller because it doesn't give index to slots. -
3518 -
3519 If \a meta is not 0, it is set to the meta-object where the signal was found. -
3520*/ -
3521int QObjectPrivate::signalIndex(const char *signalName, -
3522 const QMetaObject **meta) const -
3523{ -
3524 Q_Q(const QObject);
executed (the execution status of this line is deduced): const QObject * const q = q_func();
-
3525 const QMetaObject *base = q->metaObject();
executed (the execution status of this line is deduced): const QMetaObject *base = q->metaObject();
-
3526 Q_ASSERT(QMetaObjectPrivate::get(base)->revision >= 7);
executed (the execution status of this line is deduced): qt_noop();
-
3527 QArgumentTypeArray types;
executed (the execution status of this line is deduced): QArgumentTypeArray types;
-
3528 QByteArray name = QMetaObjectPrivate::decodeMethodSignature(signalName, types);
executed (the execution status of this line is deduced): QByteArray name = QMetaObjectPrivate::decodeMethodSignature(signalName, types);
-
3529 int relative_index = QMetaObjectPrivate::indexOfSignalRelative(
executed (the execution status of this line is deduced): int relative_index = QMetaObjectPrivate::indexOfSignalRelative(
-
3530 &base, name, types.size(), types.constData());
executed (the execution status of this line is deduced): &base, name, types.size(), types.constData());
-
3531 if (relative_index < 0)
evaluated: relative_index < 0
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:279
1-279
3532 return relative_index;
executed: return relative_index;
Execution Count:1
1
3533 relative_index = QMetaObjectPrivate::originalClone(base, relative_index);
executed (the execution status of this line is deduced): relative_index = QMetaObjectPrivate::originalClone(base, relative_index);
-
3534 if (meta)
evaluated: meta
TRUEFALSE
yes
Evaluation Count:15
yes
Evaluation Count:264
15-264
3535 *meta = base;
executed: *meta = base;
Execution Count:15
15
3536 return relative_index + QMetaObjectPrivate::signalOffset(base);
executed: return relative_index + QMetaObjectPrivate::signalOffset(base);
Execution Count:279
279
3537} -
3538 -
3539/***************************************************************************** -
3540 Properties -
3541 *****************************************************************************/ -
3542 -
3543#ifndef QT_NO_PROPERTIES -
3544 -
3545/*! -
3546 Sets the value of the object's \a name property to \a value. -
3547 -
3548 If the property is defined in the class using Q_PROPERTY then -
3549 true is returned on success and false otherwise. If the property -
3550 is not defined using Q_PROPERTY, and therefore not listed in the -
3551 meta-object, it is added as a dynamic property and false is returned. -
3552 -
3553 Information about all available properties is provided through the -
3554 metaObject() and dynamicPropertyNames(). -
3555 -
3556 Dynamic properties can be queried again using property() and can be -
3557 removed by setting the property value to an invalid QVariant. -
3558 Changing the value of a dynamic property causes a QDynamicPropertyChangeEvent -
3559 to be sent to the object. -
3560 -
3561 \b{Note:} Dynamic properties starting with "_q_" are reserved for internal -
3562 purposes. -
3563 -
3564 \sa property(), metaObject(), dynamicPropertyNames() -
3565*/ -
3566bool QObject::setProperty(const char *name, const QVariant &value) -
3567{ -
3568 Q_D(QObject);
executed (the execution status of this line is deduced): QObjectPrivate * const d = d_func();
-
3569 const QMetaObject* meta = metaObject();
executed (the execution status of this line is deduced): const QMetaObject* meta = metaObject();
-
3570 if (!name || !meta)
partially evaluated: !name
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5924
partially evaluated: !meta
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5924
0-5924
3571 return false;
never executed: return false;
0
3572 -
3573 int id = meta->indexOfProperty(name);
executed (the execution status of this line is deduced): int id = meta->indexOfProperty(name);
-
3574 if (id < 0) {
evaluated: id < 0
TRUEFALSE
yes
Evaluation Count:5466
yes
Evaluation Count:458
458-5466
3575 if (!d->extraData)
evaluated: !d->extraData
TRUEFALSE
yes
Evaluation Count:4103
yes
Evaluation Count:1363
1363-4103
3576 d->extraData = new QObjectPrivate::ExtraData;
executed: d->extraData = new QObjectPrivate::ExtraData;
Execution Count:4103
4103
3577 -
3578 const int idx = d->extraData->propertyNames.indexOf(name);
executed (the execution status of this line is deduced): const int idx = d->extraData->propertyNames.indexOf(name);
-
3579 -
3580 if (!value.isValid()) {
evaluated: !value.isValid()
TRUEFALSE
yes
Evaluation Count:3997
yes
Evaluation Count:1469
1469-3997
3581 if (idx == -1)
evaluated: idx == -1
TRUEFALSE
yes
Evaluation Count:3995
yes
Evaluation Count:2
2-3995
3582 return false;
executed: return false;
Execution Count:3995
3995
3583 d->extraData->propertyNames.removeAt(idx);
executed (the execution status of this line is deduced): d->extraData->propertyNames.removeAt(idx);
-
3584 d->extraData->propertyValues.removeAt(idx);
executed (the execution status of this line is deduced): d->extraData->propertyValues.removeAt(idx);
-
3585 } else {
executed: }
Execution Count:2
2
3586 if (idx == -1) {
evaluated: idx == -1
TRUEFALSE
yes
Evaluation Count:192
yes
Evaluation Count:1277
192-1277
3587 d->extraData->propertyNames.append(name);
executed (the execution status of this line is deduced): d->extraData->propertyNames.append(name);
-
3588 d->extraData->propertyValues.append(value);
executed (the execution status of this line is deduced): d->extraData->propertyValues.append(value);
-
3589 } else {
executed: }
Execution Count:192
192
3590 d->extraData->propertyValues[idx] = value;
executed (the execution status of this line is deduced): d->extraData->propertyValues[idx] = value;
-
3591 }
executed: }
Execution Count:1277
1277
3592 } -
3593 -
3594 QDynamicPropertyChangeEvent ev(name);
executed (the execution status of this line is deduced): QDynamicPropertyChangeEvent ev(name);
-
3595 QCoreApplication::sendEvent(this, &ev);
executed (the execution status of this line is deduced): QCoreApplication::sendEvent(this, &ev);
-
3596 -
3597 return false;
executed: return false;
Execution Count:1471
1471
3598 } -
3599 QMetaProperty p = meta->property(id);
executed (the execution status of this line is deduced): QMetaProperty p = meta->property(id);
-
3600#ifndef QT_NO_DEBUG -
3601 if (!p.isWritable()) -
3602 qWarning("%s::setProperty: Property \"%s\" invalid," -
3603 " read-only or does not exist", metaObject()->className(), name); -
3604#endif -
3605 return p.write(this, value);
executed: return p.write(this, value);
Execution Count:458
458
3606} -
3607 -
3608/*! -
3609 Returns the value of the object's \a name property. -
3610 -
3611 If no such property exists, the returned variant is invalid. -
3612 -
3613 Information about all available properties is provided through the -
3614 metaObject() and dynamicPropertyNames(). -
3615 -
3616 \sa setProperty(), QVariant::isValid(), metaObject(), dynamicPropertyNames() -
3617*/ -
3618QVariant QObject::property(const char *name) const -
3619{ -
3620 Q_D(const QObject);
executed (the execution status of this line is deduced): const QObjectPrivate * const d = d_func();
-
3621 const QMetaObject* meta = metaObject();
executed (the execution status of this line is deduced): const QMetaObject* meta = metaObject();
-
3622 if (!name || !meta)
partially evaluated: !name
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6887
partially evaluated: !meta
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6887
0-6887
3623 return QVariant();
never executed: return QVariant();
0
3624 -
3625 int id = meta->indexOfProperty(name);
executed (the execution status of this line is deduced): int id = meta->indexOfProperty(name);
-
3626 if (id < 0) {
evaluated: id < 0
TRUEFALSE
yes
Evaluation Count:4784
yes
Evaluation Count:2103
2103-4784
3627 if (!d->extraData)
evaluated: !d->extraData
TRUEFALSE
yes
Evaluation Count:3216
yes
Evaluation Count:1568
1568-3216
3628 return QVariant();
executed: return QVariant();
Execution Count:3216
3216
3629 const int i = d->extraData->propertyNames.indexOf(name);
executed (the execution status of this line is deduced): const int i = d->extraData->propertyNames.indexOf(name);
-
3630 return d->extraData->propertyValues.value(i);
executed: return d->extraData->propertyValues.value(i);
Execution Count:1568
1568
3631 } -
3632 QMetaProperty p = meta->property(id);
executed (the execution status of this line is deduced): QMetaProperty p = meta->property(id);
-
3633#ifndef QT_NO_DEBUG -
3634 if (!p.isReadable()) -
3635 qWarning("%s::property: Property \"%s\" invalid or does not exist", -
3636 metaObject()->className(), name); -
3637#endif -
3638 return p.read(this);
executed: return p.read(this);
Execution Count:2103
2103
3639} -
3640 -
3641/*! -
3642 \since 4.2 -
3643 -
3644 Returns the names of all properties that were dynamically added to -
3645 the object using setProperty(). -
3646*/ -
3647QList<QByteArray> QObject::dynamicPropertyNames() const -
3648{ -
3649 Q_D(const QObject);
executed (the execution status of this line is deduced): const QObjectPrivate * const d = d_func();
-
3650 if (d->extraData)
evaluated: d->extraData
TRUEFALSE
yes
Evaluation Count:188
yes
Evaluation Count:1
1-188
3651 return d->extraData->propertyNames;
executed: return d->extraData->propertyNames;
Execution Count:188
188
3652 return QList<QByteArray>();
executed: return QList<QByteArray>();
Execution Count:1
1
3653} -
3654 -
3655#endif // QT_NO_PROPERTIES -
3656 -
3657 -
3658/***************************************************************************** -
3659 QObject debugging output routines. -
3660 *****************************************************************************/ -
3661 -
3662static void dumpRecursive(int level, QObject *object) -
3663{ -
3664#if defined(QT_DEBUG) -
3665 if (object) { -
3666 QByteArray buf; -
3667 buf.fill(' ', level / 2 * 8); -
3668 if (level % 2) -
3669 buf += " "; -
3670 QString name = object->objectName(); -
3671 QString flags = QLatin1String(""); -
3672#if 0 -
3673 if (qApp->focusWidget() == object) -
3674 flags += 'F'; -
3675 if (object->isWidgetType()) { -
3676 QWidget * w = (QWidget *)object; -
3677 if (w->isVisible()) { -
3678 QString t("<%1,%2,%3,%4>"); -
3679 flags += t.arg(w->x()).arg(w->y()).arg(w->width()).arg(w->height()); -
3680 } else { -
3681 flags += 'I'; -
3682 } -
3683 } -
3684#endif -
3685 qDebug("%s%s::%s %s", (const char*)buf, object->metaObject()->className(), name.toLocal8Bit().data(), -
3686 flags.toLatin1().data()); -
3687 QObjectList children = object->children(); -
3688 if (!children.isEmpty()) { -
3689 for (int i = 0; i < children.size(); ++i) -
3690 dumpRecursive(level+1, children.at(i)); -
3691 } -
3692 } -
3693#else -
3694 Q_UNUSED(level)
never executed (the execution status of this line is deduced): (void)level;
-
3695 Q_UNUSED(object)
never executed (the execution status of this line is deduced): (void)object;
-
3696#endif -
3697}
never executed: }
0
3698 -
3699/*! -
3700 Dumps a tree of children to the debug output. -
3701 -
3702 This function is useful for debugging, but does nothing if the -
3703 library has been compiled in release mode (i.e. without debugging -
3704 information). -
3705 -
3706 \sa dumpObjectInfo() -
3707*/ -
3708 -
3709void QObject::dumpObjectTree() -
3710{ -
3711 dumpRecursive(0, this);
never executed (the execution status of this line is deduced): dumpRecursive(0, this);
-
3712}
never executed: }
0
3713 -
3714/*! -
3715 Dumps information about signal connections, etc. for this object -
3716 to the debug output. -
3717 -
3718 This function is useful for debugging, but does nothing if the -
3719 library has been compiled in release mode (i.e. without debugging -
3720 information). -
3721 -
3722 \sa dumpObjectTree() -
3723*/ -
3724 -
3725void QObject::dumpObjectInfo() -
3726{ -
3727#if defined(QT_DEBUG) -
3728 qDebug("OBJECT %s::%s", metaObject()->className(), -
3729 objectName().isEmpty() ? "unnamed" : objectName().toLocal8Bit().data()); -
3730 -
3731 Q_D(QObject); -
3732 QMutexLocker locker(signalSlotLock(this)); -
3733 -
3734 // first, look for connections where this object is the sender -
3735 qDebug(" SIGNALS OUT"); -
3736 -
3737 if (d->connectionLists) { -
3738 for (int signal_index = 0; signal_index < d->connectionLists->count(); ++signal_index) { -
3739 const QMetaMethod signal = QMetaObjectPrivate::signal(metaObject(), signal_index); -
3740 qDebug(" signal: %s", signal.methodSignature().constData()); -
3741 -
3742 // receivers -
3743 const QObjectPrivate::Connection *c = -
3744 d->connectionLists->at(signal_index).first; -
3745 while (c) { -
3746 if (!c->receiver) { -
3747 qDebug(" <Disconnected receiver>"); -
3748 c = c->nextConnectionList; -
3749 continue; -
3750 } -
3751 const QMetaObject *receiverMetaObject = c->receiver->metaObject(); -
3752 const QMetaMethod method = receiverMetaObject->method(c->method()); -
3753 qDebug(" --> %s::%s %s", -
3754 receiverMetaObject->className(), -
3755 c->receiver->objectName().isEmpty() ? "unnamed" : qPrintable(c->receiver->objectName()), -
3756 method.methodSignature().constData()); -
3757 c = c->nextConnectionList; -
3758 } -
3759 } -
3760 } else { -
3761 qDebug( " <None>" ); -
3762 } -
3763 -
3764 // now look for connections where this object is the receiver -
3765 qDebug(" SIGNALS IN"); -
3766 -
3767 if (d->senders) { -
3768 for (QObjectPrivate::Connection *s = d->senders; s; s = s->next) { -
3769 const QMetaMethod slot = metaObject()->method(s->method()); -
3770 qDebug(" <-- %s::%s %s", -
3771 s->sender->metaObject()->className(), -
3772 s->sender->objectName().isEmpty() ? "unnamed" : qPrintable(s->sender->objectName()), -
3773 slot.methodSignature().constData()); -
3774 } -
3775 } else { -
3776 qDebug(" <None>"); -
3777 } -
3778#endif -
3779} -
3780 -
3781#ifndef QT_NO_USERDATA -
3782/*! -
3783 \internal -
3784 */ -
3785uint QObject::registerUserData() -
3786{ -
3787 static int user_data_registration = 0; -
3788 return user_data_registration++;
executed: return user_data_registration++;
Execution Count:100
100
3789} -
3790 -
3791/*! -
3792 \internal -
3793 */ -
3794QObjectUserData::~QObjectUserData() -
3795{ -
3796} -
3797 -
3798/*! -
3799 \internal -
3800 */ -
3801void QObject::setUserData(uint id, QObjectUserData* data) -
3802{ -
3803 Q_D(QObject);
executed (the execution status of this line is deduced): QObjectPrivate * const d = d_func();
-
3804 if (!d->extraData)
evaluated: !d->extraData
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:99
1-99
3805 d->extraData = new QObjectPrivate::ExtraData;
executed: d->extraData = new QObjectPrivate::ExtraData;
Execution Count:1
1
3806 -
3807 if (d->extraData->userData.size() <= (int) id)
evaluated: d->extraData->userData.size() <= (int) id
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:96
4-96
3808 d->extraData->userData.resize((int) id + 1);
executed: d->extraData->userData.resize((int) id + 1);
Execution Count:4
4
3809 d->extraData->userData[id] = data;
executed (the execution status of this line is deduced): d->extraData->userData[id] = data;
-
3810}
executed: }
Execution Count:100
100
3811 -
3812/*! -
3813 \internal -
3814 */ -
3815QObjectUserData* QObject::userData(uint id) const -
3816{ -
3817 Q_D(const QObject);
executed (the execution status of this line is deduced): const QObjectPrivate * const d = d_func();
-
3818 if (!d->extraData)
partially evaluated: !d->extraData
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:100
0-100
3819 return 0;
never executed: return 0;
0
3820 if ((int)id < d->extraData->userData.size())
partially evaluated: (int)id < d->extraData->userData.size()
TRUEFALSE
yes
Evaluation Count:100
no
Evaluation Count:0
0-100
3821 return d->extraData->userData.at(id);
executed: return d->extraData->userData.at(id);
Execution Count:100
100
3822 return 0;
never executed: return 0;
0
3823} -
3824 -
3825#endif // QT_NO_USERDATA -
3826 -
3827 -
3828#ifndef QT_NO_DEBUG_STREAM -
3829QDebug operator<<(QDebug dbg, const QObject *o) { -
3830 if (!o)
evaluated: !o
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:3
3-9
3831 return dbg << "QObject(0x0) ";
executed: return dbg << "QObject(0x0) ";
Execution Count:9
9
3832 dbg.nospace() << o->metaObject()->className() << '(' << (void *)o;
executed (the execution status of this line is deduced): dbg.nospace() << o->metaObject()->className() << '(' << (void *)o;
-
3833 if (!o->objectName().isEmpty())
partially evaluated: !o->objectName().isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
3834 dbg << ", name = " << o->objectName();
never executed: dbg << ", name = " << o->objectName();
0
3835 dbg << ')';
executed (the execution status of this line is deduced): dbg << ')';
-
3836 return dbg.space();
executed: return dbg.space();
Execution Count:3
3
3837} -
3838#endif -
3839 -
3840/*! -
3841 \macro Q_CLASSINFO(Name, Value) -
3842 \relates QObject -
3843 -
3844 This macro associates extra information to the class, which is -
3845 available using QObject::metaObject(). Except for the ActiveQt -
3846 extension, Qt doesn't use this information. -
3847 -
3848 The extra information takes the form of a \a Name string and a \a -
3849 Value literal string. -
3850 -
3851 Example: -
3852 -
3853 \snippet code/src_corelib_kernel_qobject.cpp 35 -
3854 -
3855 \sa QMetaObject::classInfo() -
3856*/ -
3857 -
3858/*! -
3859 \macro Q_INTERFACES(...) -
3860 \relates QObject -
3861 -
3862 This macro tells Qt which interfaces the class implements. This -
3863 is used when implementing plugins. -
3864 -
3865 Example: -
3866 -
3867 \snippet ../widgets/tools/plugandpaintplugins/basictools/basictoolsplugin.h 1 -
3868 \dots -
3869 \snippet ../widgets/tools/plugandpaintplugins/basictools/basictoolsplugin.h 3 -
3870 -
3871 See the \l{tools/plugandpaintplugins/basictools}{Plug & Paint -
3872 Basic Tools} example for details. -
3873 -
3874 \sa Q_DECLARE_INTERFACE(), Q_PLUGIN_METADATA(), {How to Create Qt Plugins} -
3875*/ -
3876 -
3877/*! -
3878 \macro Q_PROPERTY(...) -
3879 \relates QObject -
3880 -
3881 This macro is used for declaring properties in classes that -
3882 inherit QObject. Properties behave like class data members, but -
3883 they have additional features accessible through the \l -
3884 {Meta-Object System}. -
3885 -
3886 \snippet code/src_corelib_kernel_qobject.cpp 36 -
3887 -
3888 The property name and type and the \c READ function are required. -
3889 The type can be any type supported by QVariant, or it can be a -
3890 user-defined type. The other items are optional, but a \c WRITE -
3891 function is common. The attributes default to true except \c USER, -
3892 which defaults to false. -
3893 -
3894 For example: -
3895 -
3896 \snippet code/src_corelib_kernel_qobject.cpp 37 -
3897 -
3898 For more details about how to use this macro, and a more detailed -
3899 example of its use, see the discussion on \l {Qt's Property System}. -
3900 -
3901 \sa {Qt's Property System} -
3902*/ -
3903 -
3904/*! -
3905 \macro Q_ENUMS(...) -
3906 \relates QObject -
3907 -
3908 This macro registers one or several enum types to the meta-object -
3909 system. -
3910 -
3911 For example: -
3912 -
3913 \snippet code/src_corelib_kernel_qobject.cpp 38 -
3914 -
3915 If you want to register an enum that is declared in another class, -
3916 the enum must be fully qualified with the name of the class -
3917 defining it. In addition, the class \e defining the enum has to -
3918 inherit QObject as well as declare the enum using Q_ENUMS(). -
3919 -
3920 \sa {Qt's Property System} -
3921*/ -
3922 -
3923/*! -
3924 \macro Q_FLAGS(...) -
3925 \relates QObject -
3926 -
3927 This macro registers one or several \l{QFlags}{flags types} to the -
3928 meta-object system. It is typically used in a class definition to declare -
3929 that values of a given enum can be used as flags and combined using the -
3930 bitwise OR operator. -
3931 -
3932 For example, in QLibrary, the \l{QLibrary::LoadHints}{LoadHints} flag is -
3933 declared in the following way: -
3934 -
3935 \snippet code/src_corelib_kernel_qobject.cpp 39a -
3936 -
3937 The declaration of the flags themselves is performed in the public section -
3938 of the QLibrary class itself, using the \l Q_DECLARE_FLAGS() macro: -
3939 -
3940 \snippet code/src_corelib_kernel_qobject.cpp 39b -
3941 -
3942 \note This macro takes care of registering individual flag values -
3943 with the meta-object system, so it is unnecessary to use Q_ENUMS() -
3944 in addition to this macro. -
3945 -
3946 \sa {Qt's Property System} -
3947*/ -
3948 -
3949/*! -
3950 \macro Q_OBJECT -
3951 \relates QObject -
3952 -
3953 The Q_OBJECT macro must appear in the private section of a class -
3954 definition that declares its own signals and slots or that uses -
3955 other services provided by Qt's meta-object system. -
3956 -
3957 For example: -
3958 -
3959 \snippet signalsandslots/signalsandslots.h 1 -
3960 \codeline -
3961 \snippet signalsandslots/signalsandslots.h 2 -
3962 \snippet signalsandslots/signalsandslots.h 3 -
3963 -
3964 \note This macro requires the class to be a subclass of QObject. Use -
3965 Q_GADGET instead of Q_OBJECT to enable the meta object system's support -
3966 for enums in a class that is not a QObject subclass. Q_GADGET makes a -
3967 class member, \c{staticMetaObject}, available. -
3968 \c{staticMetaObject} is of type QMetaObject and provides access to the -
3969 enums declared with Q_ENUMS. -
3970 Q_GADGET is provided only for C++. -
3971 -
3972 \sa {Meta-Object System}, {Signals and Slots}, {Qt's Property System} -
3973*/ -
3974 -
3975/*! -
3976 \macro Q_SIGNALS -
3977 \relates QObject -
3978 -
3979 Use this macro to replace the \c signals keyword in class -
3980 declarations, when you want to use Qt Signals and Slots with a -
3981 \l{3rd Party Signals and Slots} {3rd party signal/slot mechanism}. -
3982 -
3983 The macro is normally used when \c no_keywords is specified with -
3984 the \c CONFIG variable in the \c .pro file, but it can be used -
3985 even when \c no_keywords is \e not specified. -
3986*/ -
3987 -
3988/*! -
3989 \macro Q_SIGNAL -
3990 \relates QObject -
3991 -
3992 This is an additional macro that allows you to mark a single -
3993 function as a signal. It can be quite useful, especially when you -
3994 use a 3rd-party source code parser which doesn't understand a \c -
3995 signals or \c Q_SIGNALS groups. -
3996 -
3997 Use this macro to replace the \c signals keyword in class -
3998 declarations, when you want to use Qt Signals and Slots with a -
3999 \l{3rd Party Signals and Slots} {3rd party signal/slot mechanism}. -
4000 -
4001 The macro is normally used when \c no_keywords is specified with -
4002 the \c CONFIG variable in the \c .pro file, but it can be used -
4003 even when \c no_keywords is \e not specified. -
4004*/ -
4005 -
4006/*! -
4007 \macro Q_SLOTS -
4008 \relates QObject -
4009 -
4010 Use this macro to replace the \c slots keyword in class -
4011 declarations, when you want to use Qt Signals and Slots with a -
4012 \l{3rd Party Signals and Slots} {3rd party signal/slot mechanism}. -
4013 -
4014 The macro is normally used when \c no_keywords is specified with -
4015 the \c CONFIG variable in the \c .pro file, but it can be used -
4016 even when \c no_keywords is \e not specified. -
4017*/ -
4018 -
4019/*! -
4020 \macro Q_SLOT -
4021 \relates QObject -
4022 -
4023 This is an additional macro that allows you to mark a single -
4024 function as a slot. It can be quite useful, especially when you -
4025 use a 3rd-party source code parser which doesn't understand a \c -
4026 slots or \c Q_SLOTS groups. -
4027 -
4028 Use this macro to replace the \c slots keyword in class -
4029 declarations, when you want to use Qt Signals and Slots with a -
4030 \l{3rd Party Signals and Slots} {3rd party signal/slot mechanism}. -
4031 -
4032 The macro is normally used when \c no_keywords is specified with -
4033 the \c CONFIG variable in the \c .pro file, but it can be used -
4034 even when \c no_keywords is \e not specified. -
4035*/ -
4036 -
4037/*! -
4038 \macro Q_EMIT -
4039 \relates QObject -
4040 -
4041 Use this macro to replace the \c emit keyword for emitting -
4042 signals, when you want to use Qt Signals and Slots with a -
4043 \l{3rd Party Signals and Slots} {3rd party signal/slot mechanism}. -
4044 -
4045 The macro is normally used when \c no_keywords is specified with -
4046 the \c CONFIG variable in the \c .pro file, but it can be used -
4047 even when \c no_keywords is \e not specified. -
4048*/ -
4049 -
4050/*! -
4051 \macro Q_INVOKABLE -
4052 \relates QObject -
4053 -
4054 Apply this macro to definitions of member functions to allow them to -
4055 be invoked via the meta-object system. The macro is written before -
4056 the return type, as shown in the following example: -
4057 -
4058 \snippet qmetaobject-invokable/window.h Window class with invokable method -
4059 -
4060 The \c invokableMethod() function is marked up using Q_INVOKABLE, causing -
4061 it to be registered with the meta-object system and enabling it to be -
4062 invoked using QMetaObject::invokeMethod(). -
4063 Since \c normalMethod() function is not registered in this way, it cannot -
4064 be invoked using QMetaObject::invokeMethod(). -
4065*/ -
4066 -
4067/*! -
4068 \macro Q_SET_OBJECT_NAME(Object) -
4069 \relates QObject -
4070 \since 5.0 -
4071 -
4072 This macro assigns \a Object the objectName "Object". -
4073 -
4074 It doesn't matter whether \a Object is a pointer or not, the -
4075 macro figures that out by itself. -
4076 -
4077 \sa QObject::objectName() -
4078*/ -
4079 -
4080/*! -
4081 \typedef QObjectList -
4082 \relates QObject -
4083 -
4084 Synonym for QList<QObject *>. -
4085*/ -
4086 -
4087void qDeleteInEventHandler(QObject *o) -
4088{ -
4089 delete o;
executed (the execution status of this line is deduced): delete o;
-
4090}
executed: }
Execution Count:18127
18127
4091 -
4092/*! -
4093 \fn QMetaObject::Connection QObject::connect(const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type) -
4094 \overload connect() -
4095 \threadsafe -
4096 -
4097 Creates a connection of the given \a type from the \a signal in -
4098 the \a sender object to the \a method in the \a receiver object. -
4099 Returns a handle to the connection that can be used to disconnect -
4100 it later. -
4101 -
4102 The signal must be a function declared as a signal in the header. -
4103 The slot function can be any member function that can be connected -
4104 to the signal. -
4105 A slot can be connected to a given signal if the signal has at -
4106 least as many arguments as the slot, and there is an implicit -
4107 conversion between the types of the corresponding arguments in the -
4108 signal and the slot. -
4109 -
4110 Example: -
4111 -
4112 \snippet code/src_corelib_kernel_qobject.cpp 44 -
4113 -
4114 This example ensures that the label always displays the current -
4115 line edit text. -
4116 -
4117 A signal can be connected to many slots and signals. Many signals -
4118 can be connected to one slot. -
4119 -
4120 If a signal is connected to several slots, the slots are activated -
4121 in the same order as the order the connection was made, when the -
4122 signal is emitted -
4123 -
4124 The function returns an handle to a connection if it successfully -
4125 connects the signal to the slot. The Connection handle will be invalid -
4126 if it cannot create the connection, for example, if QObject is unable -
4127 to verify the existence of \a signal (if it was not declared as a signal) -
4128 You can check if the QMetaObject::Connection is valid by casting it to a bool. -
4129 -
4130 By default, a signal is emitted for every connection you make; -
4131 two signals are emitted for duplicate connections. You can break -
4132 all of these connections with a single disconnect() call. -
4133 If you pass the Qt::UniqueConnection \a type, the connection will only -
4134 be made if it is not a duplicate. If there is already a duplicate -
4135 (exact same signal to the exact same slot on the same objects), -
4136 the connection will fail and connect will return an invalid QMetaObject::Connection. -
4137 -
4138 The optional \a type parameter describes the type of connection -
4139 to establish. In particular, it determines whether a particular -
4140 signal is delivered to a slot immediately or queued for delivery -
4141 at a later time. If the signal is queued, the parameters must be -
4142 of types that are known to Qt's meta-object system, because Qt -
4143 needs to copy the arguments to store them in an event behind the -
4144 scenes. If you try to use a queued connection and get the error -
4145 message -
4146 -
4147 \snippet code/src_corelib_kernel_qobject.cpp 25 -
4148 -
4149 make sure to declare the argument type with Q_DECLARE_METATYPE -
4150 */ -
4151 -
4152 -
4153/*! -
4154 \fn QMetaObject::Connection QObject::connect(const QObject *sender, PointerToMemberFunction signal, Functor functor) -
4155 -
4156 \threadsafe -
4157 \overload connect() -
4158 -
4159 Creates a connection from \a signal in -
4160 \a sender object to \a functor, and returns a handle to the connection -
4161 -
4162 The signal must be a function declared as a signal in the header. -
4163 The slot function can be any function or functor that can be connected -
4164 to the signal. -
4165 A function can be connected to a given signal if the signal as at -
4166 least as many argument as the slot. A functor can be connected to a signal -
4167 if they have exactly the same number of arguments. There must exist implicit -
4168 conversion between the types of the corresponding arguments in the -
4169 signal and the slot. -
4170 -
4171 Example: -
4172 -
4173 \snippet code/src_corelib_kernel_qobject.cpp 45 -
4174 -
4175 If your compiler support C++11 lambda expressions, you can use them: -
4176 -
4177 \snippet code/src_corelib_kernel_qobject.cpp 46 -
4178 -
4179 The connection will automatically disconnect if the sender is destroyed. -
4180 */ -
4181 -
4182/** -
4183 \internal -
4184 -
4185 Implementation of the template version of connect -
4186 -
4187 \a sender is the sender object -
4188 \a signal is a pointer to a pointer to a member signal of the sender -
4189 \a receiver is the receiver object, may not be null, will be equal to sender when -
4190 connecting to a static function or a functor -
4191 \a slot a pointer only used when using Qt::UniqueConnection -
4192 \a type the Qt::ConnctionType passed as argument to connect -
4193 \a types an array of integer with the metatype id of the parametter of the signal -
4194 to be used with queued connection -
4195 must stay valid at least for the whole time of the connection, this function -
4196 do not take ownership. typically static data. -
4197 If null, then the types will be computed when the signal is emit in a queued -
4198 connection from the types from the signature. -
4199 \a senderMetaObject is the metaobject used to lookup the signal, the signal must be in -
4200 this metaobject -
4201 */ -
4202QMetaObject::Connection QObject::connectImpl(const QObject *sender, void **signal, -
4203 const QObject *receiver, void **slot, -
4204 QtPrivate::QSlotObjectBase *slotObj, Qt::ConnectionType type, -
4205 const int *types, const QMetaObject *senderMetaObject) -
4206{ -
4207 if (!sender || !signal || !slotObj || !senderMetaObject) {
partially evaluated: !sender
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2592
partially evaluated: !signal
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2592
partially evaluated: !slotObj
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2592
partially evaluated: !senderMetaObject
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2592
0-2592
4208 qWarning("QObject::connect: invalid null parametter");
never executed (the execution status of this line is deduced): QMessageLogger("kernel/qobject.cpp", 4208, __PRETTY_FUNCTION__).warning("QObject::connect: invalid null parametter");
-
4209 if (slotObj)
never evaluated: slotObj
0
4210 slotObj->destroyIfLastRef();
never executed: slotObj->destroyIfLastRef();
0
4211 return QMetaObject::Connection();
never executed: return QMetaObject::Connection();
0
4212 } -
4213 int signal_index = -1;
executed (the execution status of this line is deduced): int signal_index = -1;
-
4214 void *args[] = { &signal_index, signal };
executed (the execution status of this line is deduced): void *args[] = { &signal_index, signal };
-
4215 senderMetaObject->static_metacall(QMetaObject::IndexOfMethod, 0, args);
executed (the execution status of this line is deduced): senderMetaObject->static_metacall(QMetaObject::IndexOfMethod, 0, args);
-
4216 if (signal_index < 0 || signal_index >= QMetaObjectPrivate::get(senderMetaObject)->signalCount) {
evaluated: signal_index < 0
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:2590
partially evaluated: signal_index >= QMetaObjectPrivate::get(senderMetaObject)->signalCount
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2590
0-2590
4217 qWarning("QObject::connect: signal not found in %s", senderMetaObject->className());
executed (the execution status of this line is deduced): QMessageLogger("kernel/qobject.cpp", 4217, __PRETTY_FUNCTION__).warning("QObject::connect: signal not found in %s", senderMetaObject->className());
-
4218 slotObj->destroyIfLastRef();
executed (the execution status of this line is deduced): slotObj->destroyIfLastRef();
-
4219 return QMetaObject::Connection(0);
executed: return QMetaObject::Connection(0);
Execution Count:2
2
4220 } -
4221 signal_index += QMetaObjectPrivate::signalOffset(senderMetaObject);
executed (the execution status of this line is deduced): signal_index += QMetaObjectPrivate::signalOffset(senderMetaObject);
-
4222 -
4223 QObject *s = const_cast<QObject *>(sender);
executed (the execution status of this line is deduced): QObject *s = const_cast<QObject *>(sender);
-
4224 QObject *r = const_cast<QObject *>(receiver);
executed (the execution status of this line is deduced): QObject *r = const_cast<QObject *>(receiver);
-
4225 -
4226 QOrderedMutexLocker locker(signalSlotLock(sender),
executed (the execution status of this line is deduced): QOrderedMutexLocker locker(signalSlotLock(sender),
-
4227 signalSlotLock(receiver));
executed (the execution status of this line is deduced): signalSlotLock(receiver));
-
4228 -
4229 if (type & Qt::UniqueConnection) {
evaluated: type & Qt::UniqueConnection
TRUEFALSE
yes
Evaluation Count:11
yes
Evaluation Count:2579
11-2579
4230 QObjectConnectionListVector *connectionLists = QObjectPrivate::get(s)->connectionLists;
executed (the execution status of this line is deduced): QObjectConnectionListVector *connectionLists = QObjectPrivate::get(s)->connectionLists;
-
4231 if (connectionLists && connectionLists->count() > signal_index) {
evaluated: connectionLists
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:2
evaluated: connectionLists->count() > signal_index
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:2
2-9
4232 const QObjectPrivate::Connection *c2 =
executed (the execution status of this line is deduced): const QObjectPrivate::Connection *c2 =
-
4233 (*connectionLists)[signal_index].first;
executed (the execution status of this line is deduced): (*connectionLists)[signal_index].first;
-
4234 -
4235 while (c2) {
evaluated: c2
TRUEFALSE
yes
Evaluation Count:11
yes
Evaluation Count:4
4-11
4236 if (c2->receiver == receiver && c2->isSlotObject && c2->slotObj->compare(slot)) {
evaluated: c2->receiver == receiver
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:6
partially evaluated: c2->isSlotObject
TRUEFALSE
yes
Evaluation Count:5
no
Evaluation Count:0
evaluated: c2->slotObj->compare(slot)
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:2
0-6
4237 slotObj->destroyIfLastRef();
executed (the execution status of this line is deduced): slotObj->destroyIfLastRef();
-
4238 return QMetaObject::Connection();
executed: return QMetaObject::Connection();
Execution Count:3
3
4239 } -
4240 c2 = c2->nextConnectionList;
executed (the execution status of this line is deduced): c2 = c2->nextConnectionList;
-
4241 }
executed: }
Execution Count:8
8
4242 }
executed: }
Execution Count:4
4
4243 type = static_cast<Qt::ConnectionType>(type ^ Qt::UniqueConnection);
executed (the execution status of this line is deduced): type = static_cast<Qt::ConnectionType>(type ^ Qt::UniqueConnection);
-
4244 }
executed: }
Execution Count:8
8
4245 -
4246 QScopedPointer<QObjectPrivate::Connection> c(new QObjectPrivate::Connection);
executed (the execution status of this line is deduced): QScopedPointer<QObjectPrivate::Connection> c(new QObjectPrivate::Connection);
-
4247 c->sender = s;
executed (the execution status of this line is deduced): c->sender = s;
-
4248 c->signal_index = signal_index;
executed (the execution status of this line is deduced): c->signal_index = signal_index;
-
4249 c->receiver = r;
executed (the execution status of this line is deduced): c->receiver = r;
-
4250 c->slotObj = slotObj;
executed (the execution status of this line is deduced): c->slotObj = slotObj;
-
4251 c->connectionType = type;
executed (the execution status of this line is deduced): c->connectionType = type;
-
4252 c->isSlotObject = true;
executed (the execution status of this line is deduced): c->isSlotObject = true;
-
4253 if (types) {
evaluated: types
TRUEFALSE
yes
Evaluation Count:35
yes
Evaluation Count:2552
35-2552
4254 c->argumentTypes.store(types);
executed (the execution status of this line is deduced): c->argumentTypes.store(types);
-
4255 c->ownArgumentTypes = false;
executed (the execution status of this line is deduced): c->ownArgumentTypes = false;
-
4256 }
executed: }
Execution Count:35
35
4257 -
4258 QObjectPrivate::get(s)->addConnection(signal_index, c.data());
executed (the execution status of this line is deduced): QObjectPrivate::get(s)->addConnection(signal_index, c.data());
-
4259 QMetaObject::Connection ret(c.take());
executed (the execution status of this line is deduced): QMetaObject::Connection ret(c.take());
-
4260 locker.unlock();
executed (the execution status of this line is deduced): locker.unlock();
-
4261 -
4262 QMetaMethod method = QMetaObjectPrivate::signal(senderMetaObject, signal_index);
executed (the execution status of this line is deduced): QMetaMethod method = QMetaObjectPrivate::signal(senderMetaObject, signal_index);
-
4263 Q_ASSERT(method.isValid());
executed (the execution status of this line is deduced): qt_noop();
-
4264 s->connectNotify(method);
executed (the execution status of this line is deduced): s->connectNotify(method);
-
4265 -
4266 return ret;
executed: return ret;
Execution Count:2587
2587
4267} -
4268 -
4269/*! -
4270 Disconnect a connection. -
4271 -
4272 If the \a connection is invalid or has already been disconnected, do nothing -
4273 and return false. -
4274 -
4275 \sa connect() -
4276 */ -
4277bool QObject::disconnect(const QMetaObject::Connection &connection) -
4278{ -
4279 QObjectPrivate::Connection *c = static_cast<QObjectPrivate::Connection *>(connection.d_ptr);
executed (the execution status of this line is deduced): QObjectPrivate::Connection *c = static_cast<QObjectPrivate::Connection *>(connection.d_ptr);
-
4280 -
4281 if (!c || !c->receiver)
evaluated: !c
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:8
partially evaluated: !c->receiver
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:8
0-8
4282 return false;
executed: return false;
Execution Count:3
3
4283 -
4284 QMutex *senderMutex = signalSlotLock(c->sender);
executed (the execution status of this line is deduced): QMutex *senderMutex = signalSlotLock(c->sender);
-
4285 QMutex *receiverMutex = signalSlotLock(c->receiver);
executed (the execution status of this line is deduced): QMutex *receiverMutex = signalSlotLock(c->receiver);
-
4286 QOrderedMutexLocker locker(senderMutex, receiverMutex);
executed (the execution status of this line is deduced): QOrderedMutexLocker locker(senderMutex, receiverMutex);
-
4287 -
4288 QObjectConnectionListVector *connectionLists = QObjectPrivate::get(c->sender)->connectionLists;
executed (the execution status of this line is deduced): QObjectConnectionListVector *connectionLists = QObjectPrivate::get(c->sender)->connectionLists;
-
4289 Q_ASSERT(connectionLists);
executed (the execution status of this line is deduced): qt_noop();
-
4290 connectionLists->dirty = true;
executed (the execution status of this line is deduced): connectionLists->dirty = true;
-
4291 -
4292 *c->prev = c->next;
executed (the execution status of this line is deduced): *c->prev = c->next;
-
4293 if (c->next)
evaluated: c->next
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:7
1-7
4294 c->next->prev = c->prev;
executed: c->next->prev = c->prev;
Execution Count:1
1
4295 c->receiver = 0;
executed (the execution status of this line is deduced): c->receiver = 0;
-
4296 -
4297 // destroy the QSlotObject, if possible -
4298 if (c->isSlotObject) {
partially evaluated: c->isSlotObject
TRUEFALSE
yes
Evaluation Count:8
no
Evaluation Count:0
0-8
4299 c->slotObj->destroyIfLastRef();
executed (the execution status of this line is deduced): c->slotObj->destroyIfLastRef();
-
4300 c->isSlotObject = false;
executed (the execution status of this line is deduced): c->isSlotObject = false;
-
4301 }
executed: }
Execution Count:8
8
4302 -
4303 const_cast<QMetaObject::Connection &>(connection).d_ptr = 0;
executed (the execution status of this line is deduced): const_cast<QMetaObject::Connection &>(connection).d_ptr = 0;
-
4304 c->deref(); // has been removed from the QMetaObject::Connection object
executed (the execution status of this line is deduced): c->deref();
-
4305 -
4306 // disconnectNotify() not called (the signal index is unknown). -
4307 -
4308 return true;
executed: return true;
Execution Count:8
8
4309} -
4310 -
4311/*! \fn bool QObject::disconnect(const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method) -
4312 \overload diconnect() -
4313 \threadsafe -
4314 -
4315 Disconnects \a signal in object \a sender from \a method in object -
4316 \a receiver. Returns true if the connection is successfully broken; -
4317 otherwise returns false. -
4318 -
4319 A signal-slot connection is removed when either of the objects -
4320 involved are destroyed. -
4321 -
4322 disconnect() is typically used in three ways, as the following -
4323 examples demonstrate. -
4324 \list 1 -
4325 \li Disconnect everything connected to an object's signals: -
4326 -
4327 \snippet code/src_corelib_kernel_qobject.cpp 26 -
4328 -
4329 \li Disconnect everything connected to a specific signal: -
4330 -
4331 \snippet code/src_corelib_kernel_qobject.cpp 47 -
4332 -
4333 \li Disconnect a specific receiver: -
4334 -
4335 \snippet code/src_corelib_kernel_qobject.cpp 30 -
4336 -
4337 \li Disconnect a connection from one specific signal to a specific slot: -
4338 -
4339 \snippet code/src_corelib_kernel_qobject.cpp 48 -
4340 -
4341 -
4342 \endlist -
4343 -
4344 0 may be used as a wildcard, meaning "any signal", "any receiving -
4345 object", or "any slot in the receiving object", respectively. -
4346 -
4347 The \a sender may never be 0. (You cannot disconnect signals from -
4348 more than one object in a single call.) -
4349 -
4350 If \a signal is 0, it disconnects \a receiver and \a method from -
4351 any signal. If not, only the specified signal is disconnected. -
4352 -
4353 If \a receiver is 0, it disconnects anything connected to \a -
4354 signal. If not, slots in objects other than \a receiver are not -
4355 disconnected. -
4356 -
4357 If \a method is 0, it disconnects anything that is connected to \a -
4358 receiver. If not, only slots named \a method will be disconnected, -
4359 and all other slots are left alone. The \a method must be 0 if \a -
4360 receiver is left out, so you cannot disconnect a -
4361 specifically-named slot on all objects. -
4362 -
4363 \note It is not possible to use this overload to diconnect signals -
4364 connected to functors or lambda expressions. That is because it is not -
4365 possible to compare them. Instead, use the olverload that take a -
4366 QMetaObject::Connection -
4367 -
4368 \sa connect() -
4369*/ -
4370 -
4371bool QObject::disconnectImpl(const QObject *sender, void **signal, const QObject *receiver, void **slot, const QMetaObject *senderMetaObject) -
4372{ -
4373 if (sender == 0 || (receiver == 0 && slot != 0)) {
partially evaluated: sender == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:9
evaluated: receiver == 0
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:8
partially evaluated: slot != 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-9
4374 qWarning("QObject::disconnect: Unexpected null parameter");
never executed (the execution status of this line is deduced): QMessageLogger("kernel/qobject.cpp", 4374, __PRETTY_FUNCTION__).warning("QObject::disconnect: Unexpected null parameter");
-
4375 return false;
never executed: return false;
0
4376 } -
4377 -
4378 int signal_index = -1;
executed (the execution status of this line is deduced): int signal_index = -1;
-
4379 if (signal) {
partially evaluated: signal
TRUEFALSE
yes
Evaluation Count:9
no
Evaluation Count:0
0-9
4380 void *args[] = { &signal_index, signal };
executed (the execution status of this line is deduced): void *args[] = { &signal_index, signal };
-
4381 senderMetaObject->static_metacall(QMetaObject::IndexOfMethod, 0, args);
executed (the execution status of this line is deduced): senderMetaObject->static_metacall(QMetaObject::IndexOfMethod, 0, args);
-
4382 if (signal_index < 0 || signal_index >= QMetaObjectPrivate::get(senderMetaObject)->signalCount) {
partially evaluated: signal_index < 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:9
partially evaluated: signal_index >= QMetaObjectPrivate::get(senderMetaObject)->signalCount
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:9
0-9
4383 qWarning("QObject::disconnect: signal not found in %s", senderMetaObject->className());
never executed (the execution status of this line is deduced): QMessageLogger("kernel/qobject.cpp", 4383, __PRETTY_FUNCTION__).warning("QObject::disconnect: signal not found in %s", senderMetaObject->className());
-
4384 return false;
never executed: return false;
0
4385 } -
4386 signal_index += QMetaObjectPrivate::signalOffset(senderMetaObject);
executed (the execution status of this line is deduced): signal_index += QMetaObjectPrivate::signalOffset(senderMetaObject);
-
4387 }
executed: }
Execution Count:9
9
4388 -
4389 return QMetaObjectPrivate::disconnect(sender, signal_index, senderMetaObject, receiver, -1, slot);
executed: return QMetaObjectPrivate::disconnect(sender, signal_index, senderMetaObject, receiver, -1, slot);
Execution Count:9
9
4390} -
4391 -
4392/*! \class QMetaObject::Connection -
4393 \inmodule QtCore -
4394 Represents a handle to a signal-slot connection. -
4395 It can be used to disconnect that connection, or check if -
4396 the connection was successful -
4397 -
4398 \sa QObject::disconnect -
4399 */ -
4400 -
4401/*! -
4402 Create a copy of the handle to the connection -
4403 */ -
4404QMetaObject::Connection::Connection(const QMetaObject::Connection &other) : d_ptr(other.d_ptr) -
4405{ -
4406 if (d_ptr)
never evaluated: d_ptr
0
4407 static_cast<QObjectPrivate::Connection *>(d_ptr)->ref();
never executed: static_cast<QObjectPrivate::Connection *>(d_ptr)->ref();
0
4408}
never executed: }
0
4409 -
4410QMetaObject::Connection& QMetaObject::Connection::operator=(const QMetaObject::Connection& other) -
4411{ -
4412 if (other.d_ptr != d_ptr) {
evaluated: other.d_ptr != d_ptr
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:1
1-6
4413 if (d_ptr)
evaluated: d_ptr
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:5
1-5
4414 static_cast<QObjectPrivate::Connection *>(d_ptr)->deref();
executed: static_cast<QObjectPrivate::Connection *>(d_ptr)->deref();
Execution Count:1
1
4415 d_ptr = other.d_ptr;
executed (the execution status of this line is deduced): d_ptr = other.d_ptr;
-
4416 if (other.d_ptr)
evaluated: other.d_ptr
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:1
1-5
4417 static_cast<QObjectPrivate::Connection *>(other.d_ptr)->ref();
executed: static_cast<QObjectPrivate::Connection *>(other.d_ptr)->ref();
Execution Count:5
5
4418 }
executed: }
Execution Count:6
6
4419 return *this;
executed: return *this;
Execution Count:7
7
4420} -
4421 -
4422QMetaObject::Connection::Connection() : d_ptr(0) {}
executed: }
Execution Count:7
7
4423 -
4424QMetaObject::Connection::~Connection() -
4425{ -
4426 if (d_ptr)
evaluated: d_ptr
TRUEFALSE
yes
Evaluation Count:442202
yes
Evaluation Count:337554
337554-442202
4427 static_cast<QObjectPrivate::Connection *>(d_ptr)->deref();
executed: static_cast<QObjectPrivate::Connection *>(d_ptr)->deref();
Execution Count:442201
442201
4428}
executed: }
Execution Count:779748
779748
4429 -
4430/*! -
4431 \fn QMetaObject::Connection::operator bool() const -
4432 -
4433 Returns true if the connection is valid. -
4434 -
4435 The connection is valid if the call to QObject::connect succeeded. -
4436 The connection is invalid if QObject::connect was not able to find -
4437 the signal or the slot, or if the arguments do not match. -
4438 */ -
4439 -
4440QT_END_NAMESPACE -
4441 -
4442#include "moc_qobject.cpp" -
4443 -
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial