kernel/qobject.cpp

Source codeSwitch to Preprocessed file
LineSource CodeCoverage
1/**************************************************************************** -
2** -
3** Copyright (C) 2013 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:372
partially evaluated: slot
TRUEFALSE
yes
Evaluation Count:372
no
Evaluation Count:0
0-372
78 }
executed: }
Execution Count:372
372
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:1780
partially evaluated: !(types)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1780
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1780
0-1780
84 for (int i = 0; i < typeNames.count(); ++i) {
evaluated: i < typeNames.count()
TRUEFALSE
yes
Evaluation Count:1384
yes
Evaluation Count:1780
1384-1780
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:1384
0-1384
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:1384
1384
90 -
91 if (!types[i]) {
partially evaluated: !types[i]
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1384
0-1384
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:1384
1384
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:1780
1780
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:34165
yes
Evaluation Count:21073
21073-34165
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:34164
yes
Evaluation Count:1
1-34164
110 types[i] = type.type();
executed: types[i] = type.type();
Execution Count:34164
34164
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:34165
0-34165
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:34165
34165
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:21073
21073
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:9395226
9395226
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:9395226
9395226
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:8326818
8326818
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:91586
91586
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:8418280
8418280
168 -
169 inline ~QConnectionSenderSwitcher() -
170 { -
171 if (switched)
evaluated: switched
TRUEFALSE
yes
Evaluation Count:8418322
yes
Evaluation Count:105
105-8418322
172 QObjectPrivate::resetCurrentSender(receiver, &currentSender, previousSender);
executed: QObjectPrivate::resetCurrentSender(receiver, &currentSender, previousSender);
Execution Count:8418322
8418322
173 }
executed: }
Execution Count:8418426
8418426
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:3600974
0-3600974
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:3600979
3600979
214 -
215QObjectPrivate::~QObjectPrivate() -
216{ -
217 if (extraData && !extraData->runningTimers.isEmpty()) {
evaluated: extraData
TRUEFALSE
yes
Evaluation Count:56772
yes
Evaluation Count:3541668
evaluated: !extraData->runningTimers.isEmpty()
TRUEFALSE
yes
Evaluation Count:1245
yes
Evaluation Count:55527
1245-3541668
218 // unregister pending timers -
219 if (threadData->eventDispatcher)
evaluated: threadData->eventDispatcher
TRUEFALSE
yes
Evaluation Count:1177
yes
Evaluation Count:68
68-1177
220 threadData->eventDispatcher->unregisterTimers(q_ptr);
executed: threadData->eventDispatcher->unregisterTimers(q_ptr);
Execution Count:1177
1177
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:1294
yes
Evaluation Count:1245
1245-1294
224 QAbstractEventDispatcherPrivate::releaseTimerId(extraData->runningTimers.at(i));
executed: QAbstractEventDispatcherPrivate::releaseTimerId(extraData->runningTimers.at(i));
Execution Count:1294
1294
225 }
executed: }
Execution Count:1245
1245
226 -
227 if (postedEvents)
evaluated: postedEvents
TRUEFALSE
yes
Evaluation Count:7312
yes
Evaluation Count:3591124
7312-3591124
228 QCoreApplication::removePostedEvents(q_ptr, 0);
executed: QCoreApplication::removePostedEvents(q_ptr, 0);
Execution Count:7312
7312
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:3598488
0-3598488
233 -
234#ifndef QT_NO_USERDATA -
235 if (extraData)
evaluated: extraData
TRUEFALSE
yes
Evaluation Count:56772
yes
Evaluation Count:3541742
56772-3541742
236 qDeleteAll(extraData->userData);
executed: qDeleteAll(extraData->userData);
Execution Count:56772
56772
237#endif -
238 delete extraData;
executed (the execution status of this line is deduced): delete extraData;
-
239}
executed: }
Execution Count:3598481
3598481
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:10003
yes
Evaluation Count:207552
10003-207552
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:10003
10003
256}
executed: }
Execution Count:207552
207552
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:78776
78776
284 -
285 QObjectPrivate::ConnectionList &operator[](int at) -
286 { -
287 if (at < 0)
evaluated: at < 0
TRUEFALSE
yes
Evaluation Count:185723
yes
Evaluation Count:1584227
185723-1584227
288 return allsignals;
executed: return allsignals;
Execution Count:185723
185723
289 return QVector<QObjectPrivate::ConnectionList>::operator[](at);
executed: return QVector<QObjectPrivate::ConnectionList>::operator[](at);
Execution Count:1584227
1584227
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);
executed (the execution status of this line is deduced): const QObject * const q = q_func();
-
320 QObjectList returnValue;
executed (the execution status of this line is deduced): QObjectList returnValue;
-
321 int signal_index = signalIndex(signal);
executed (the execution status of this line is deduced): int signal_index = signalIndex(signal);
-
322 if (signal_index < 0)
partially evaluated: signal_index < 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
323 return returnValue;
never executed: return returnValue;
0
324 QMutexLocker locker(signalSlotLock(q));
executed (the execution status of this line is deduced): QMutexLocker locker(signalSlotLock(q));
-
325 if (connectionLists) {
partially evaluated: connectionLists
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
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;
executed: return returnValue;
Execution Count:1
1
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:78776
yes
Evaluation Count:411538
78776-411538
363 connectionLists = new QObjectConnectionListVector();
executed: connectionLists = new QObjectConnectionListVector();
Execution Count:78776
78776
364 if (signal >= connectionLists->count())
evaluated: signal >= connectionLists->count()
TRUEFALSE
yes
Evaluation Count:160428
yes
Evaluation Count:329886
160428-329886
365 connectionLists->resize(signal + 1);
executed: connectionLists->resize(signal + 1);
Execution Count:160429
160429
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:263399
yes
Evaluation Count:226915
226915-263399
369 connectionList.last->nextConnectionList = c;
executed (the execution status of this line is deduced): connectionList.last->nextConnectionList = c;
-
370 } else {
executed: }
Execution Count:263399
263399
371 connectionList.first = c;
executed (the execution status of this line is deduced): connectionList.first = c;
-
372 }
executed: }
Execution Count:226913
226913
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:311936
yes
Evaluation Count:178370
178370-311936
381 c->next->prev = &c->next;
executed: c->next->prev = &c->next;
Execution Count:311936
311936
382 -
383 if (signal < 0) {
evaluated: signal < 0
TRUEFALSE
yes
Evaluation Count:133
yes
Evaluation Count:490170
133-490170
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:133
evaluated: signal < (int)sizeof(connectedSignals) * 8
TRUEFALSE
yes
Evaluation Count:490168
yes
Evaluation Count:2
2-490168
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:490166
490166
388} -
389 -
390void QObjectPrivate::cleanConnectionLists() -
391{ -
392 if (connectionLists->dirty && !connectionLists->inUse) {
evaluated: connectionLists->dirty
TRUEFALSE
yes
Evaluation Count:107265
yes
Evaluation Count:383042
evaluated: !connectionLists->inUse
TRUEFALSE
yes
Evaluation Count:107068
yes
Evaluation Count:197
197-383042
393 // remove broken connections -
394 for (int signal = -1; signal < connectionLists->count(); ++signal) {
evaluated: signal < connectionLists->count()
TRUEFALSE
yes
Evaluation Count:466611
yes
Evaluation Count:107068
107068-466611
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:315870
yes
Evaluation Count:466611
315870-466611
406 if (c->receiver) {
evaluated: c->receiver
TRUEFALSE
yes
Evaluation Count:180581
yes
Evaluation Count:135289
135289-180581
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:180581
180581
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:135289
135289
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:466611
466611
422 connectionLists->dirty = false;
executed (the execution status of this line is deduced): connectionLists->dirty = false;
-
423 }
executed: }
Execution Count:107068
107068
424}
executed: }
Execution Count:490305
490305
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:99311
99311
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:98804
yes
Evaluation Count:750
750-98804
456 for (int i = 0; i < nargs_; ++i) {
evaluated: i < nargs_
TRUEFALSE
yes
Evaluation Count:155681
yes
Evaluation Count:98802
98802-155681
457 if (types_[i] && args_[i])
evaluated: types_[i]
TRUEFALSE
yes
Evaluation Count:56895
yes
Evaluation Count:98803
partially evaluated: args_[i]
TRUEFALSE
yes
Evaluation Count:56897
no
Evaluation Count:0
0-98803
458 QMetaType::destroy(types_[i], args_[i]);
executed: QMetaType::destroy(types_[i], args_[i]);
Execution Count:56897
56897
459 }
executed: }
Execution Count:155693
155693
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:98818
98818
463#ifndef QT_NO_THREAD -
464 if (semaphore_)
evaluated: semaphore_
TRUEFALSE
yes
Evaluation Count:587
yes
Evaluation Count:98979
587-98979
465 semaphore_->release();
executed: semaphore_->release();
Execution Count:587
587
466#endif -
467 if (slotObj_)
evaluated: slotObj_
TRUEFALSE
yes
Evaluation Count:67
yes
Evaluation Count:99499
67-99499
468 slotObj_->destroyIfLastRef();
executed: slotObj_->destroyIfLastRef();
Execution Count:67
67
469}
executed: }
Execution Count:99565
99565
470 -
471/*! -
472 \internal -
473 */ -
474void QMetaCallEvent::placeMetaCall(QObject *object) -
475{ -
476 if (slotObj_) {
evaluated: slotObj_
TRUEFALSE
yes
Evaluation Count:67
yes
Evaluation Count:91342
67-91342
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:91341
yes
Evaluation Count:7
evaluated: method_offset_ <= object->metaObject()->methodOffset()
TRUEFALSE
yes
Evaluation Count:91316
yes
Evaluation Count:1
1-91341
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:91384
91384
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:54435
no
Evaluation Count:0
partially evaluated: parentThreadData != currentThreadData
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:54435
0-54435
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:54435
54435
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:5257
yes
Evaluation Count:77079
evaluated: !parent->thread()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:5256
1-77079
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:5257
yes
Evaluation Count:77081
5257-77081
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:5257
0-5257
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:5257
5257
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:5257
5257
692 qt_addObject(this);
executed (the execution status of this line is deduced): qt_addObject(this);
-
693}
executed: }
Execution Count:82339
82339
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:49176
yes
Evaluation Count:3469456
partially evaluated: !parent->thread()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:49177
0-3469456
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:49178
yes
Evaluation Count:3469461
49178-3469461
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:49178
0-49178
708 parent = 0;
never executed: parent = 0;
0
709 if (d->isWidget) {
partially evaluated: d->isWidget
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:49178
0-49178
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:49177
49177
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:49177
49177
723 qt_addObject(this);
executed (the execution status of this line is deduced): qt_addObject(this);
-
724}
executed: }
Execution Count:3518615
3518615
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:38488
yes
Evaluation Count:3560078
38488-3560078
758 if (sharedRefcount->strongref.load() > 0) {
partially evaluated: sharedRefcount->strongref.load() > 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:38489
0-38489
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:16944
yes
Evaluation Count:21546
16944-21546
766 delete sharedRefcount;
executed: delete sharedRefcount;
Execution Count:16944
16944
767 }
executed: }
Execution Count:38489
38489
768 -
769 if (!d->isWidget && d->isSignalConnected(0)) {
evaluated: !d->isWidget
TRUEFALSE
yes
Evaluation Count:3555579
yes
Evaluation Count:42959
evaluated: d->isSignalConnected(0)
TRUEFALSE
yes
Evaluation Count:4392
yes
Evaluation Count:3551228
4392-3555579
770 QT_TRY { -
771 emit destroyed(this);
executed (the execution status of this line is deduced): destroyed(this);
-
772 } QT_CATCH(...) {
executed: }
Execution Count:4392
4392
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:4392
4392
779 -
780 if (d->declarativeData)
partially evaluated: d->declarativeData
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3598572
0-3598572
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:3598521
30-3598521
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:76806
yes
Evaluation Count:3521743
evaluated: d->senders
TRUEFALSE
yes
Evaluation Count:54148
yes
Evaluation Count:3467625
54148-3521743
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:76806
yes
Evaluation Count:54148
54148-76806
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:674595
yes
Evaluation Count:76808
76808-674595
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:340979
yes
Evaluation Count:674607
340979-674607
801 if (!c->receiver) {
evaluated: !c->receiver
TRUEFALSE
yes
Evaluation Count:121519
yes
Evaluation Count:219464
121519-219464
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:121520
121520
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:219422
yes
Evaluation Count:50
50-219422
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:129502
evaluated: c->next
TRUEFALSE
yes
Evaluation Count:129502
yes
Evaluation Count:89920
89920-129502
813 }
executed: }
Execution Count:219422
219422
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:210921
yes
Evaluation Count:8551
8551-210921
816 m->unlock();
executed: m->unlock();
Execution Count:210920
210920
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:219470
219470
821 }
executed: }
Execution Count:674607
674607
822 -
823 if (!--d->connectionLists->inUse) {
evaluated: !--d->connectionLists->inUse
TRUEFALSE
yes
Evaluation Count:76734
yes
Evaluation Count:74
74-76734
824 delete d->connectionLists;
executed (the execution status of this line is deduced): delete d->connectionLists;
-
825 } else {
executed: }
Execution Count:76734
76734
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:76808
76808
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:139795
yes
Evaluation Count:130955
130955-139795
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:12
yes
Evaluation Count:139783
evaluated: node->sender != sender
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:139780
3-139783
840 m->unlock();
executed (the execution status of this line is deduced): m->unlock();
-
841 continue;
executed: continue;
Execution Count:15
15
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:139780
no
Evaluation Count:0
0-139780
846 senderLists->dirty = true;
executed: senderLists->dirty = true;
Execution Count:139780
139780
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:138723
yes
Evaluation Count:1057
1057-138723
851 m->unlock();
executed: m->unlock();
Execution Count:138723
138723
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:139780
139780
854 }
executed: }
Execution Count:130955
130955
855 -
856 if (!d->children.isEmpty())
evaluated: !d->children.isEmpty()
TRUEFALSE
yes
Evaluation Count:9602
yes
Evaluation Count:3588931
9602-3588931
857 d->deleteChildren();
executed: d->deleteChildren();
Execution Count:9602
9602
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:111769
yes
Evaluation Count:3486749
111769-3486749
862 d->setParent_helper(0);
executed: d->setParent_helper(0);
Execution Count:111769
111769
863}
executed: }
Execution Count:3598592
3598592
864 -
865QObjectPrivate::Connection::~Connection() -
866{ -
867 if (ownArgumentTypes) {
evaluated: ownArgumentTypes
TRUEFALSE
yes
Evaluation Count:476247
yes
Evaluation Count:35
35-476247
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:476247
no
Evaluation Count:0
0-476247
870 delete [] v;
executed: delete [] v;
Execution Count:476247
476247
871 }
executed: }
Execution Count:476246
476246
872 if (isSlotObject)
evaluated: isSlotObject
TRUEFALSE
yes
Evaluation Count:3940
yes
Evaluation Count:472341
3940-472341
873 slotObj->destroyIfLastRef();
executed: slotObj->destroyIfLastRef();
Execution Count:3940
3940
874}
executed: }
Execution Count:476281
476281
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:1726345
1726345
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:38079
yes
Evaluation Count:411
411-38079
1003 d->extraData = new QObjectPrivate::ExtraData;
executed: d->extraData = new QObjectPrivate::ExtraData;
Execution Count:38079
38079
1004 -
1005 if (d->extraData->objectName != name) {
evaluated: d->extraData->objectName != name
TRUEFALSE
yes
Evaluation Count:38473
yes
Evaluation Count:17
17-38473
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:38473
38473
1009}
executed: }
Execution Count:38490
38490
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:42115
42115
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:201906
201906
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:2768
2768
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:91620
91620
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:23328
yes
Evaluation Count:7
7-23328
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:23301
3-23301
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:23301
23301
1087 break;
executed: break;
Execution Count:23316
23316
1088 } -
1089 -
1090 default: -
1091 if (e->type() >= QEvent::User) {
evaluated: e->type() >= QEvent::User
TRUEFALSE
yes
Evaluation Count:268767
yes
Evaluation Count:199507
199507-268767
1092 customEvent(e);
executed (the execution status of this line is deduced): customEvent(e);
-
1093 break;
executed: break;
Execution Count:268723
268723
1094 } -
1095 return false;
executed: return false;
Execution Count:199507
199507
1096 } -
1097 return true;
executed: return true;
Execution Count:630313
630313
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:205230
205230
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:26864
26864
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:2174759
2174759
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:8922
yes
Evaluation Count:23167
8922-23167
1279 // object is already in this thread -
1280 return;
executed: return;
Execution Count:8922
8922
1281 } -
1282 -
1283 if (d->parent != 0) {
partially evaluated: d->parent != 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:23168
0-23168
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:23165
0-23165
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:23156
yes
Evaluation Count:5
5-23156
1294 if (d->threadData->thread == 0 && currentData == targetData) {
evaluated: d->threadData->thread == 0
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:23168
partially evaluated: currentData == targetData
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-23168
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:23168
0-23168
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:23188
23188
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:166
yes
Evaluation Count:23293
166-23293
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:166
166
1338}
executed: }
Execution Count:23290
23290
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:3295088
yes
Evaluation Count:23357
23357-3295088
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:1119223
yes
Evaluation Count:2175865
1119223-2175865
1349 continue;
executed: continue;
Execution Count:1119223
1119223
1350 if (pe.receiver == q) {
evaluated: pe.receiver == q
TRUEFALSE
yes
Evaluation Count:408838
yes
Evaluation Count:1767027
408838-1767027
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:408838
408838
1356 }
executed: }
Execution Count:2175865
2175865
1357 if (eventsMoved > 0 && targetData->eventDispatcher) {
evaluated: eventsMoved > 0
TRUEFALSE
yes
Evaluation Count:20505
yes
Evaluation Count:2852
evaluated: targetData->eventDispatcher
TRUEFALSE
yes
Evaluation Count:20501
yes
Evaluation Count:4
4-20505
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:20501
20501
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:2356
2356-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:166
yes
Evaluation Count:23357
166-23357
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:166
166
1376}
executed: }
Execution Count:23357
23357
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:12025
0-12025
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:12025
0-12025
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:5281
yes
Evaluation Count:6744
5281-6744
1447 d->extraData = new QObjectPrivate::ExtraData;
executed: d->extraData = new QObjectPrivate::ExtraData;
Execution Count:5281
5281
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:12025
12025
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:10725
no
Evaluation Count:0
0-10725
1465 int at = d->extraData ? d->extraData->runningTimers.indexOf(id) : -1;
partially evaluated: d->extraData
TRUEFALSE
yes
Evaluation Count:10725
no
Evaluation Count:0
0-10725
1466 if (at == -1) {
partially evaluated: at == -1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:10725
0-10725
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:10614
yes
Evaluation Count:111
111-10614
1476 d->threadData->eventDispatcher->unregisterTimer(id);
executed: d->threadData->eventDispatcher->unregisterTimer(id);
Execution Count:10614
10614
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:10725
10725
1481}
executed: }
Execution Count:10725
10725
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:41086
partially evaluated: !list
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:41086
0-41086
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:39094
yes
Evaluation Count:41086
39094-41086
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:16640
yes
Evaluation Count:22454
16640-22454
1662 if (name.isNull() || obj->objectName() == name)
evaluated: name.isNull()
TRUEFALSE
yes
Evaluation Count:16351
yes
Evaluation Count:289
evaluated: obj->objectName() == name
TRUEFALSE
yes
Evaluation Count:34
yes
Evaluation Count:255
34-16351
1663 list->append(obj);
executed: list->append(obj);
Execution Count:16385
16385
1664 }
executed: }
Execution Count:16640
16640
1665 if (options & Qt::FindChildrenRecursively)
evaluated: options & Qt::FindChildrenRecursively
TRUEFALSE
yes
Evaluation Count:39009
yes
Evaluation Count:85
85-39009
1666 qt_qFindChildren_helper(obj, name, mo, list, options);
executed: qt_qFindChildren_helper(obj, name, mo, list, options);
Execution Count:39009
39009
1667 }
executed: }
Execution Count:39094
39094
1668}
executed: }
Execution Count:41086
41086
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:4898
0-4898
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:6252
yes
Evaluation Count:4534
4534-6252
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:526
yes
Evaluation Count:5726
evaluated: name.isNull()
TRUEFALSE
yes
Evaluation Count:220
yes
Evaluation Count:306
evaluated: obj->objectName() == name
TRUEFALSE
yes
Evaluation Count:144
yes
Evaluation Count:162
144-5726
1730 return obj;
executed: return obj;
Execution Count:364
364
1731 }
executed: }
Execution Count:5888
5888
1732 if (options & Qt::FindChildrenRecursively) {
evaluated: options & Qt::FindChildrenRecursively
TRUEFALSE
yes
Evaluation Count:4525
yes
Evaluation Count:9
9-4525
1733 for (i = 0; i < children.size(); ++i) {
evaluated: i < children.size()
TRUEFALSE
yes
Evaluation Count:4099
yes
Evaluation Count:4363
4099-4363
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:162
yes
Evaluation Count:3937
162-3937
1736 return obj;
executed: return obj;
Execution Count:162
162
1737 }
executed: }
Execution Count:3937
3937
1738 }
executed: }
Execution Count:4363
4363
1739 return 0;
executed: return 0;
Execution Count:4372
4372
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:77519
77519
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:63369
yes
Evaluation Count:29164
29164-63369
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:63369
63369
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:29164
29164
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:1646
yes
Evaluation Count:229801
1646-229801
1775 return;
executed: return;
Execution Count:1646
1646
1776 if (parent) {
evaluated: parent
TRUEFALSE
yes
Evaluation Count:113156
yes
Evaluation Count:116646
113156-116646
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:63369
yes
Evaluation Count:49787
partially evaluated: wasDeleted
TRUEFALSE
yes
Evaluation Count:63369
no
Evaluation Count:0
0-63369
1779 && parentD->currentChildBeingDeleted == q) {
evaluated: parentD->currentChildBeingDeleted == q
TRUEFALSE
yes
Evaluation Count:63367
yes
Evaluation Count:2
2-63367
1780 // don't do anything since QObjectPrivate::deleteChildren() already -
1781 // cleared our entry in parentD->children. -
1782 } else {
executed: }
Execution Count:63367
63367
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:2
yes
Evaluation Count:49787
2-49787
1785 parentD->children[index] = 0;
executed (the execution status of this line is deduced): parentD->children[index] = 0;
-
1786 } else {
executed: }
Execution Count:2
2
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:49786
yes
Evaluation Count:1
partially evaluated: parentD->receiveChildEvents
TRUEFALSE
yes
Evaluation Count:49786
no
Evaluation Count:0
0-49786
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:49786
49786
1792 }
executed: }
Execution Count:49786
49786
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:117438
yes
Evaluation Count:112364
112364-117438
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:117439
0-117439
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:117437
yes
Evaluation Count:1
partially evaluated: parent->d_func()->receiveChildEvents
TRUEFALSE
yes
Evaluation Count:117437
no
Evaluation Count:0
0-117437
1805 if (!isWidget) {
evaluated: !isWidget
TRUEFALSE
yes
Evaluation Count:75428
yes
Evaluation Count:42009
42009-75428
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:75426
75426
1809 }
executed: }
Execution Count:117435
117435
1810 }
executed: }
Execution Count:117436
117436
1811 if (!isDeletingChildren && declarativeData)
partially evaluated: !isDeletingChildren
TRUEFALSE
yes
Evaluation Count:229800
no
Evaluation Count:0
partially evaluated: declarativeData
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:229800
0-229800
1812 QAbstractDeclarativeData::parentChanged(declarativeData, q, o);
never executed: QAbstractDeclarativeData::parentChanged(declarativeData, q, o);
0
1813}
executed: }
Execution Count:229801
229801
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:19282
0-19282
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:19281
1-19281
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:12891
yes
Evaluation Count:6390
6390-12891
1868 d->extraData = new QObjectPrivate::ExtraData;
executed: d->extraData = new QObjectPrivate::ExtraData;
Execution Count:12891
12891
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:19281
19281
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:1092
yes
Evaluation Count:921
921-1092
1893 for (int i = 0; i < d->extraData->eventFilters.count(); ++i) {
evaluated: i < d->extraData->eventFilters.count()
TRUEFALSE
yes
Evaluation Count:1315
yes
Evaluation Count:1092
1092-1315
1894 if (d->extraData->eventFilters.at(i) == obj)
evaluated: d->extraData->eventFilters.at(i) == obj
TRUEFALSE
yes
Evaluation Count:668
yes
Evaluation Count:647
647-668
1895 d->extraData->eventFilters[i] = 0;
executed: d->extraData->eventFilters[i] = 0;
Execution Count:668
668
1896 }
executed: }
Execution Count:1315
1315
1897 }
executed: }
Execution Count:1092
1092
1898}
executed: }
Execution Count:2013
2013
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. If deleteLater() is called after the main event loop -
1921 has stopped, the object will not be deleted. -
1922 Since Qt 4.8, if deleteLater() is called on an object that lives in a -
1923 thread with no running event loop, the object will be destroyed when the -
1924 thread finishes. -
1925 -
1926 Note that entering and leaving a new event loop (e.g., by opening a modal -
1927 dialog) will \e not perform the deferred deletion; for the object to be -
1928 deleted, the control must return to the event loop from which -
1929 deleteLater() was called. -
1930 -
1931 \b{Note:} It is safe to call this function more than once; when the -
1932 first deferred deletion event is delivered, any pending events for the -
1933 object are removed from the event queue. -
1934 -
1935 \sa destroyed(), QPointer -
1936*/ -
1937void QObject::deleteLater() -
1938{ -
1939 QCoreApplication::postEvent(this, new QDeferredDeleteEvent());
executed (the execution status of this line is deduced): QCoreApplication::postEvent(this, new QDeferredDeleteEvent());
-
1940}
executed: }
Execution Count:8432
8432
1941 -
1942/*! -
1943 \fn QString QObject::tr(const char *sourceText, const char *disambiguation, int n) -
1944 \reentrant -
1945 -
1946 Returns a translated version of \a sourceText, optionally based on a -
1947 \a disambiguation string and value of \a n for strings containing plurals; -
1948 otherwise returns \a sourceText itself if no appropriate translated string -
1949 is available. -
1950 -
1951 Example: -
1952 \snippet ../widgets/mainwindows/sdi/mainwindow.cpp implicit tr context -
1953 \dots -
1954 -
1955 If the same \a sourceText is used in different roles within the -
1956 same context, an additional identifying string may be passed in -
1957 \a disambiguation (0 by default). In Qt 4.4 and earlier, this was -
1958 the preferred way to pass comments to translators. -
1959 -
1960 Example: -
1961 -
1962 \snippet code/src_corelib_kernel_qobject.cpp 17 -
1963 \dots -
1964 -
1965 See \l{Writing Source Code for Translation} for a detailed description of -
1966 Qt's translation mechanisms in general, and the -
1967 \l{Writing Source Code for Translation#Disambiguation}{Disambiguation} -
1968 section for information on disambiguation. -
1969 -
1970 \warning This method is reentrant only if all translators are -
1971 installed \e before calling this method. Installing or removing -
1972 translators while performing translations is not supported. Doing -
1973 so will probably result in crashes or other undesirable behavior. -
1974 -
1975 \sa trUtf8(), QCoreApplication::translate(), {Internationalization with Qt} -
1976*/ -
1977 -
1978/*! -
1979 \fn QString QObject::trUtf8(const char *sourceText, const char *disambiguation, int n) -
1980 \reentrant -
1981 \obsolete -
1982 -
1983 Returns a translated version of \a sourceText, or -
1984 QString::fromUtf8(\a sourceText) if there is no appropriate -
1985 version. It is otherwise identical to tr(\a sourceText, \a -
1986 disambiguation, \a n). -
1987 -
1988 \warning This method is reentrant only if all translators are -
1989 installed \e before calling this method. Installing or removing -
1990 translators while performing translations is not supported. Doing -
1991 so will probably result in crashes or other undesirable behavior. -
1992 -
1993 \warning For portability reasons, we recommend that you use -
1994 escape sequences for specifying non-ASCII characters in string -
1995 literals to trUtf8(). For example: -
1996 -
1997 \snippet code/src_corelib_kernel_qobject.cpp 20 -
1998 -
1999 \sa tr(), QCoreApplication::translate(), {Internationalization with Qt} -
2000*/ -
2001 -
2002 -
2003 -
2004 -
2005/***************************************************************************** -
2006 Signals and slots -
2007 *****************************************************************************/ -
2008 -
2009 -
2010const int flagged_locations_count = 2; -
2011static const char* flagged_locations[flagged_locations_count] = {0}; -
2012 -
2013const char *qFlagLocation(const char *method) -
2014{ -
2015 static int idx = 0; -
2016 flagged_locations[idx] = method;
never executed (the execution status of this line is deduced): flagged_locations[idx] = method;
-
2017 idx = (idx+1) % flagged_locations_count;
never executed (the execution status of this line is deduced): idx = (idx+1) % flagged_locations_count;
-
2018 return method;
never executed: return method;
0
2019} -
2020 -
2021static int extract_code(const char *member) -
2022{ -
2023 // extract code, ensure QMETHOD_CODE <= code <= QSIGNAL_CODE -
2024 return (((int)(*member) - '0') & 0x3);
executed: return (((int)(*member) - '0') & 0x3);
Execution Count:810355
810355
2025} -
2026 -
2027static const char * extract_location(const char *member) -
2028{ -
2029 for (int i = 0; i < flagged_locations_count; ++i) {
never evaluated: i < flagged_locations_count
0
2030 if (member == flagged_locations[i]) {
never evaluated: member == flagged_locations[i]
0
2031 // signature includes location information after the first null-terminator -
2032 const char *location = member + qstrlen(member) + 1;
never executed (the execution status of this line is deduced): const char *location = member + qstrlen(member) + 1;
-
2033 if (*location != '\0')
never evaluated: *location != '\0'
0
2034 return location;
never executed: return location;
0
2035 return 0;
never executed: return 0;
0
2036 } -
2037 }
never executed: }
0
2038 return 0;
never executed: return 0;
0
2039} -
2040 -
2041static bool check_signal_macro(const QObject *sender, const char *signal, -
2042 const char *func, const char *op) -
2043{ -
2044 int sigcode = extract_code(signal);
executed (the execution status of this line is deduced): int sigcode = extract_code(signal);
-
2045 if (sigcode != QSIGNAL_CODE) {
partially evaluated: sigcode != 2
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:406885
0-406885
2046 if (sigcode == QSLOT_CODE)
never evaluated: sigcode == 1
0
2047 qWarning("QObject::%s: Attempt to %s non-signal %s::%s",
never executed: QMessageLogger("kernel/qobject.cpp", 2047, __PRETTY_FUNCTION__).warning("QObject::%s: Attempt to %s non-signal %s::%s", func, op, sender->metaObject()->className(), signal+1);
0
2048 func, op, sender->metaObject()->className(), signal+1);
never executed: QMessageLogger("kernel/qobject.cpp", 2047, __PRETTY_FUNCTION__).warning("QObject::%s: Attempt to %s non-signal %s::%s", func, op, sender->metaObject()->className(), signal+1);
0
2049 else -
2050 qWarning("QObject::%s: Use the SIGNAL macro to %s %s::%s",
never executed: QMessageLogger("kernel/qobject.cpp", 2050, __PRETTY_FUNCTION__).warning("QObject::%s: Use the SIGNAL macro to %s %s::%s", func, op, sender->metaObject()->className(), signal);
0
2051 func, op, sender->metaObject()->className(), signal);
never executed: QMessageLogger("kernel/qobject.cpp", 2050, __PRETTY_FUNCTION__).warning("QObject::%s: Use the SIGNAL macro to %s %s::%s", func, op, sender->metaObject()->className(), signal);
0
2052 return false;
never executed: return false;
0
2053 } -
2054 return true;
executed: return true;
Execution Count:406886
406886
2055} -
2056 -
2057static bool check_method_code(int code, const QObject *object, -
2058 const char *method, const char *func) -
2059{ -
2060 if (code != QSLOT_CODE && code != QSIGNAL_CODE) {
evaluated: code != 1
TRUEFALSE
yes
Evaluation Count:12239
yes
Evaluation Count:391250
partially evaluated: code != 2
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:12239
0-391250
2061 qWarning("QObject::%s: Use the SLOT or SIGNAL macro to "
never executed (the execution status of this line is deduced): QMessageLogger("kernel/qobject.cpp", 2061, __PRETTY_FUNCTION__).warning("QObject::%s: Use the SLOT or SIGNAL macro to "
-
2062 "%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);
-
2063 return false;
never executed: return false;
0
2064 } -
2065 return true;
executed: return true;
Execution Count:403483
403483
2066} -
2067 -
2068static void err_method_notfound(const QObject *object, -
2069 const char *method, const char *func) -
2070{ -
2071 const char *type = "method";
never executed (the execution status of this line is deduced): const char *type = "method";
-
2072 switch (extract_code(method)) { -
2073 case QSLOT_CODE: type = "slot"; break;
never executed: break;
0
2074 case QSIGNAL_CODE: type = "signal"; break;
never executed: break;
0
2075 } -
2076 const char *loc = extract_location(method);
never executed (the execution status of this line is deduced): const char *loc = extract_location(method);
-
2077 if (strchr(method,')') == 0) // common typing mistake
never evaluated: strchr(method,')') == 0
0
2078 qWarning("QObject::%s: Parentheses expected, %s %s::%s%s%s",
never executed: QMessageLogger("kernel/qobject.cpp", 2078, __PRETTY_FUNCTION__).warning("QObject::%s: Parentheses expected, %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: Parentheses expected, %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: Parentheses expected, %s %s::%s%s%s", func, type, object->metaObject()->className(), method+1, loc ? " in ": "", loc ? loc : "");
0
2081 else -
2082 qWarning("QObject::%s: No such %s %s::%s%s%s",
never executed: QMessageLogger("kernel/qobject.cpp", 2082, __PRETTY_FUNCTION__).warning("QObject::%s: No such %s %s::%s%s%s", func, type, object->metaObject()->className(), method+1, loc ? " in ": "", loc ? loc : "");
0
2083 func, type, object->metaObject()->className(), method+1,
never executed: QMessageLogger("kernel/qobject.cpp", 2082, __PRETTY_FUNCTION__).warning("QObject::%s: No such %s %s::%s%s%s", func, type, object->metaObject()->className(), method+1, loc ? " in ": "", loc ? loc : "");
0
2084 loc ? " in ": "", loc ? loc : "");
never executed: QMessageLogger("kernel/qobject.cpp", 2082, __PRETTY_FUNCTION__).warning("QObject::%s: No such %s %s::%s%s%s", func, type, object->metaObject()->className(), method+1, loc ? " in ": "", loc ? loc : "");
0
2085 -
2086} -
2087 -
2088 -
2089static void err_info_about_objects(const char * func, -
2090 const QObject * sender, -
2091 const QObject * receiver) -
2092{ -
2093 QString a = sender ? sender->objectName() : QString();
never evaluated: sender
0
2094 QString b = receiver ? receiver->objectName() : QString();
never evaluated: receiver
0
2095 if (!a.isEmpty())
never evaluated: !a.isEmpty()
0
2096 qWarning("QObject::%s: (sender name: '%s')", func, a.toLocal8Bit().data());
never executed: QMessageLogger("kernel/qobject.cpp", 2096, __PRETTY_FUNCTION__).warning("QObject::%s: (sender name: '%s')", func, a.toLocal8Bit().data());
0
2097 if (!b.isEmpty())
never evaluated: !b.isEmpty()
0
2098 qWarning("QObject::%s: (receiver name: '%s')", func, b.toLocal8Bit().data());
never executed: QMessageLogger("kernel/qobject.cpp", 2098, __PRETTY_FUNCTION__).warning("QObject::%s: (receiver name: '%s')", func, b.toLocal8Bit().data());
0
2099}
never executed: }
0
2100 -
2101/*! -
2102 Returns a pointer to the object that sent the signal, if called in -
2103 a slot activated by a signal; otherwise it returns 0. The pointer -
2104 is valid only during the execution of the slot that calls this -
2105 function from this object's thread context. -
2106 -
2107 The pointer returned by this function becomes invalid if the -
2108 sender is destroyed, or if the slot is disconnected from the -
2109 sender's signal. -
2110 -
2111 \warning This function violates the object-oriented principle of -
2112 modularity. However, getting access to the sender might be useful -
2113 when many signals are connected to a single slot. -
2114 -
2115 \warning As mentioned above, the return value of this function is -
2116 not valid when the slot is called via a Qt::DirectConnection from -
2117 a thread different from this object's thread. Do not use this -
2118 function in this type of scenario. -
2119 -
2120 \sa senderSignalIndex(), QSignalMapper -
2121*/ -
2122 -
2123QObject *QObject::sender() const -
2124{ -
2125 Q_D(const QObject);
executed (the execution status of this line is deduced): const QObjectPrivate * const d = d_func();
-
2126 -
2127 QMutexLocker locker(signalSlotLock(this));
executed (the execution status of this line is deduced): QMutexLocker locker(signalSlotLock(this));
-
2128 if (!d->currentSender)
evaluated: !d->currentSender
TRUEFALSE
yes
Evaluation Count:35
yes
Evaluation Count:6693
35-6693
2129 return 0;
executed: return 0;
Execution Count:35
35
2130 -
2131 for (QObjectPrivate::Connection *c = d->senders; c; c = c->next) {
evaluated: c
TRUEFALSE
yes
Evaluation Count:32039
yes
Evaluation Count:3
3-32039
2132 if (c->sender == d->currentSender->sender)
evaluated: c->sender == d->currentSender->sender
TRUEFALSE
yes
Evaluation Count:6690
yes
Evaluation Count:25349
6690-25349
2133 return d->currentSender->sender;
executed: return d->currentSender->sender;
Execution Count:6690
6690
2134 }
executed: }
Execution Count:25349
25349
2135 -
2136 return 0;
executed: return 0;
Execution Count:3
3
2137} -
2138 -
2139/*! -
2140 \since 4.8 -
2141 -
2142 Returns the meta-method index of the signal that called the currently -
2143 executing slot, which is a member of the class returned by sender(). -
2144 If called outside of a slot activated by a signal, -1 is returned. -
2145 -
2146 For signals with default parameters, this function will always return -
2147 the index with all parameters, regardless of which was used with -
2148 connect(). For example, the signal \c {destroyed(QObject *obj = 0)} -
2149 will have two different indexes (with and without the parameter), but -
2150 this function will always return the index with a parameter. This does -
2151 not apply when overloading signals with different parameters. -
2152 -
2153 \warning This function violates the object-oriented principle of -
2154 modularity. However, getting access to the signal index might be useful -
2155 when many signals are connected to a single slot. -
2156 -
2157 \warning The return value of this function is not valid when the slot -
2158 is called via a Qt::DirectConnection from a thread different from this -
2159 object's thread. Do not use this function in this type of scenario. -
2160 -
2161 \sa sender(), QMetaObject::indexOfSignal(), QMetaObject::method() -
2162*/ -
2163 -
2164int QObject::senderSignalIndex() const -
2165{ -
2166 Q_D(const QObject);
executed (the execution status of this line is deduced): const QObjectPrivate * const d = d_func();
-
2167 int signal_index = d->senderSignalIndex();
executed (the execution status of this line is deduced): int signal_index = d->senderSignalIndex();
-
2168 if (signal_index < 0)
evaluated: signal_index < 0
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:226
7-226
2169 return signal_index;
executed: return signal_index;
Execution Count:7
7
2170 // Convert from signal range to method range -
2171 return QMetaObjectPrivate::signal(sender()->metaObject(), signal_index).methodIndex();
executed: return QMetaObjectPrivate::signal(sender()->metaObject(), signal_index).methodIndex();
Execution Count:226
226
2172} -
2173 -
2174/*! -
2175 Returns the number of receivers connected to the \a signal. -
2176 -
2177 Since both slots and signals can be used as receivers for signals, -
2178 and the same connections can be made many times, the number of -
2179 receivers is the same as the number of connections made from this -
2180 signal. -
2181 -
2182 When calling this function, you can use the \c SIGNAL() macro to -
2183 pass a specific signal: -
2184 -
2185 \snippet code/src_corelib_kernel_qobject.cpp 21 -
2186 -
2187 \warning This function violates the object-oriented principle of -
2188 modularity. However, it might be useful when you need to perform -
2189 expensive initialization only if something is connected to a -
2190 signal. -
2191 -
2192 \sa isSignalConnected() -
2193*/ -
2194 -
2195int QObject::receivers(const char *signal) const -
2196{ -
2197 Q_D(const QObject);
executed (the execution status of this line is deduced): const QObjectPrivate * const d = d_func();
-
2198 int receivers = 0;
executed (the execution status of this line is deduced): int receivers = 0;
-
2199 if (signal) {
partially evaluated: signal
TRUEFALSE
yes
Evaluation Count:36
no
Evaluation Count:0
0-36
2200 QByteArray signal_name = QMetaObject::normalizedSignature(signal);
executed (the execution status of this line is deduced): QByteArray signal_name = QMetaObject::normalizedSignature(signal);
-
2201 signal = signal_name;
executed (the execution status of this line is deduced): signal = signal_name;
-
2202#ifndef QT_NO_DEBUG -
2203 if (!check_signal_macro(this, signal, "receivers", "bind")) -
2204 return 0; -
2205#endif -
2206 signal++; // skip code
executed (the execution status of this line is deduced): signal++;
-
2207 int signal_index = d->signalIndex(signal);
executed (the execution status of this line is deduced): int signal_index = d->signalIndex(signal);
-
2208 if (signal_index < 0) {
partially evaluated: signal_index < 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:36
0-36
2209#ifndef QT_NO_DEBUG -
2210 err_method_notfound(this, signal-1, "receivers"); -
2211#endif -
2212 return 0;
never executed: return 0;
0
2213 } -
2214 -
2215 if (!d->isSignalConnected(signal_index))
evaluated: !d->isSignalConnected(signal_index)
TRUEFALSE
yes
Evaluation Count:25
yes
Evaluation Count:11
11-25
2216 return receivers;
executed: return receivers;
Execution Count:25
25
2217 -
2218 if (d->declarativeData && QAbstractDeclarativeData::receivers) {
partially evaluated: d->declarativeData
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:11
never evaluated: QAbstractDeclarativeData::receivers
0-11
2219 receivers += QAbstractDeclarativeData::receivers(d->declarativeData, this,
never executed (the execution status of this line is deduced): receivers += QAbstractDeclarativeData::receivers(d->declarativeData, this,
-
2220 signal_index);
never executed (the execution status of this line is deduced): signal_index);
-
2221 }
never executed: }
0
2222 -
2223 QMutexLocker locker(signalSlotLock(this));
executed (the execution status of this line is deduced): QMutexLocker locker(signalSlotLock(this));
-
2224 if (d->connectionLists) {
partially evaluated: d->connectionLists
TRUEFALSE
yes
Evaluation Count:11
no
Evaluation Count:0
0-11
2225 if (signal_index < d->connectionLists->count()) {
partially evaluated: signal_index < d->connectionLists->count()
TRUEFALSE
yes
Evaluation Count:11
no
Evaluation Count:0
0-11
2226 const QObjectPrivate::Connection *c =
executed (the execution status of this line is deduced): const QObjectPrivate::Connection *c =
-
2227 d->connectionLists->at(signal_index).first;
executed (the execution status of this line is deduced): d->connectionLists->at(signal_index).first;
-
2228 while (c) {
evaluated: c
TRUEFALSE
yes
Evaluation Count:13
yes
Evaluation Count:11
11-13
2229 receivers += c->receiver ? 1 : 0;
evaluated: c->receiver
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:6
6-7
2230 c = c->nextConnectionList;
executed (the execution status of this line is deduced): c = c->nextConnectionList;
-
2231 }
executed: }
Execution Count:13
13
2232 }
executed: }
Execution Count:11
11
2233 }
executed: }
Execution Count:11
11
2234 }
executed: }
Execution Count:11
11
2235 return receivers;
executed: return receivers;
Execution Count:11
11
2236} -
2237 -
2238/*! -
2239 \since 5.0 -
2240 Returns true if the \a signal is connected to at least one receiver, -
2241 otherwise returns false. -
2242 -
2243 \a signal must be a signal member of this object, otherwise the behaviour -
2244 is undefined. -
2245 -
2246 \snippet code/src_corelib_kernel_qobject.cpp 49 -
2247 -
2248 As the code snippet above illustrates, you can use this function -
2249 to avoid emitting a signal that nobody listens to. -
2250 -
2251 \warning This function violates the object-oriented principle of -
2252 modularity. However, it might be useful when you need to perform -
2253 expensive initialization only if something is connected to a -
2254 signal. -
2255*/ -
2256bool QObject::isSignalConnected(const QMetaMethod &signal) const -
2257{ -
2258 Q_D(const QObject);
executed (the execution status of this line is deduced): const QObjectPrivate * const d = d_func();
-
2259 if (!signal.mobj)
evaluated: !signal.mobj
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:24
1-24
2260 return false;
executed: return false;
Execution Count:1
1
2261 -
2262 Q_ASSERT_X(signal.mobj->cast(this) && signal.methodType() == QMetaMethod::Signal,
executed (the execution status of this line is deduced): qt_noop();
-
2263 "QObject::isSignalConnected" , "the parameter must be a signal member of the object"); -
2264 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;
-
2265 -
2266 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
2267 signalIndex = QMetaObjectPrivate::originalClone(signal.mobj, signalIndex);
executed: signalIndex = QMetaObjectPrivate::originalClone(signal.mobj, signalIndex);
Execution Count:3
3
2268 -
2269 signalIndex += QMetaObjectPrivate::signalOffset(signal.mobj);
executed (the execution status of this line is deduced): signalIndex += QMetaObjectPrivate::signalOffset(signal.mobj);
-
2270 -
2271 if (signalIndex < sizeof(d->connectedSignals) * 8)
evaluated: signalIndex < sizeof(d->connectedSignals) * 8
TRUEFALSE
yes
Evaluation Count:20
yes
Evaluation Count:4
4-20
2272 return d->isSignalConnected(signalIndex);
executed: return d->isSignalConnected(signalIndex);
Execution Count:20
20
2273 -
2274 QMutexLocker locker(signalSlotLock(this));
executed (the execution status of this line is deduced): QMutexLocker locker(signalSlotLock(this));
-
2275 if (d->connectionLists) {
evaluated: d->connectionLists
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:1
1-3
2276 if (signalIndex < uint(d->connectionLists->count())) {
partially evaluated: signalIndex < uint(d->connectionLists->count())
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-3
2277 const QObjectPrivate::Connection *c =
executed (the execution status of this line is deduced): const QObjectPrivate::Connection *c =
-
2278 d->connectionLists->at(signalIndex).first;
executed (the execution status of this line is deduced): d->connectionLists->at(signalIndex).first;
-
2279 while (c) {
partially evaluated: c
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-3
2280 if (c->receiver)
partially evaluated: c->receiver
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-3
2281 return true;
executed: return true;
Execution Count:3
3
2282 c = c->nextConnectionList;
never executed (the execution status of this line is deduced): c = c->nextConnectionList;
-
2283 }
never executed: }
0
2284 }
never executed: }
0
2285 }
never executed: }
0
2286 return false;
executed: return false;
Execution Count:1
1
2287} -
2288 -
2289/*! -
2290 \internal -
2291 -
2292 This helper function calculates signal and method index for the given -
2293 member in the specified class. -
2294 -
2295 \list -
2296 \li If member.mobj is 0 then both signalIndex and methodIndex are set to -1. -
2297 -
2298 \li If specified member is not a member of obj instance class (or one of -
2299 its parent classes) then both signalIndex and methodIndex are set to -1. -
2300 \endlist -
2301 -
2302 This function is used by QObject::connect and QObject::disconnect which -
2303 are working with QMetaMethod. -
2304 -
2305 \a signalIndex is set to the signal index of member. If the member -
2306 specified is not signal this variable is set to -1. -
2307 -
2308 \a methodIndex is set to the method index of the member. If the -
2309 member is not a method of the object specified by the \a obj argument this -
2310 variable is set to -1. -
2311*/ -
2312void QMetaObjectPrivate::memberIndexes(const QObject *obj, -
2313 const QMetaMethod &member, -
2314 int *signalIndex, int *methodIndex) -
2315{ -
2316 *signalIndex = -1;
executed (the execution status of this line is deduced): *signalIndex = -1;
-
2317 *methodIndex = -1;
executed (the execution status of this line is deduced): *methodIndex = -1;
-
2318 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
2319 return;
executed: return;
Execution Count:17
17
2320 const QMetaObject *m = obj->metaObject();
executed (the execution status of this line is deduced): const QMetaObject *m = obj->metaObject();
-
2321 // Check that member is member of obj class -
2322 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
2323 m = m->d.superdata;
executed: m = m->d.superdata;
Execution Count:2
2
2324 if (!m)
partially evaluated: !m
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:71
0-71
2325 return;
never executed: return;
0
2326 *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;
-
2327 -
2328 int signalOffset;
executed (the execution status of this line is deduced): int signalOffset;
-
2329 int methodOffset;
executed (the execution status of this line is deduced): int methodOffset;
-
2330 computeOffsets(m, &signalOffset, &methodOffset);
executed (the execution status of this line is deduced): computeOffsets(m, &signalOffset, &methodOffset);
-
2331 -
2332 *methodIndex += methodOffset;
executed (the execution status of this line is deduced): *methodIndex += methodOffset;
-
2333 if (member.methodType() == QMetaMethod::Signal) {
evaluated: member.methodType() == QMetaMethod::Signal
TRUEFALSE
yes
Evaluation Count:36
yes
Evaluation Count:35
35-36
2334 *signalIndex = originalClone(m, *signalIndex);
executed (the execution status of this line is deduced): *signalIndex = originalClone(m, *signalIndex);
-
2335 *signalIndex += signalOffset;
executed (the execution status of this line is deduced): *signalIndex += signalOffset;
-
2336 } else {
executed: }
Execution Count:36
36
2337 *signalIndex = -1;
executed (the execution status of this line is deduced): *signalIndex = -1;
-
2338 }
executed: }
Execution Count:35
35
2339} -
2340 -
2341static inline void check_and_warn_compat(const QMetaObject *sender, const QMetaMethod &signal, -
2342 const QMetaObject *receiver, const QMetaMethod &method) -
2343{ -
2344 if (signal.attributes() & QMetaMethod::Compatibility) {
never evaluated: signal.attributes() & QMetaMethod::Compatibility
0
2345 if (!(method.attributes() & QMetaMethod::Compatibility))
never evaluated: !(method.attributes() & QMetaMethod::Compatibility)
0
2346 qWarning("QObject::connect: Connecting from COMPAT signal (%s::%s)",
never executed: QMessageLogger("kernel/qobject.cpp", 2346, __PRETTY_FUNCTION__).warning("QObject::connect: Connecting from COMPAT signal (%s::%s)", sender->className(), signal.methodSignature().constData());
0
2347 sender->className(), signal.methodSignature().constData());
never executed: QMessageLogger("kernel/qobject.cpp", 2346, __PRETTY_FUNCTION__).warning("QObject::connect: Connecting from COMPAT signal (%s::%s)", sender->className(), signal.methodSignature().constData());
0
2348 } else if ((method.attributes() & QMetaMethod::Compatibility) &&
never executed: }
never evaluated: (method.attributes() & QMetaMethod::Compatibility)
0
2349 method.methodType() == QMetaMethod::Signal) {
never evaluated: method.methodType() == QMetaMethod::Signal
0
2350 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", 2350, __PRETTY_FUNCTION__).warning("QObject::connect: Connecting from %s::%s to COMPAT slot (%s::%s)",
-
2351 sender->className(), signal.methodSignature().constData(),
never executed (the execution status of this line is deduced): sender->className(), signal.methodSignature().constData(),
-
2352 receiver->className(), method.methodSignature().constData());
never executed (the execution status of this line is deduced): receiver->className(), method.methodSignature().constData());
-
2353 }
never executed: }
0
2354} -
2355 -
2356/*! -
2357 \threadsafe -
2358 -
2359 Creates a connection of the given \a type from the \a signal in -
2360 the \a sender object to the \a method in the \a receiver object. -
2361 Returns a handle to the connection that can be used to disconnect -
2362 it later. -
2363 -
2364 You must use the \c SIGNAL() and \c SLOT() macros when specifying -
2365 the \a signal and the \a method, for example: -
2366 -
2367 \snippet code/src_corelib_kernel_qobject.cpp 22 -
2368 -
2369 This example ensures that the label always displays the current -
2370 scroll bar value. Note that the signal and slots parameters must not -
2371 contain any variable names, only the type. E.g. the following would -
2372 not work and return false: -
2373 -
2374 \snippet code/src_corelib_kernel_qobject.cpp 23 -
2375 -
2376 A signal can also be connected to another signal: -
2377 -
2378 \snippet code/src_corelib_kernel_qobject.cpp 24 -
2379 -
2380 In this example, the \c MyWidget constructor relays a signal from -
2381 a private member variable, and makes it available under a name -
2382 that relates to \c MyWidget. -
2383 -
2384 A signal can be connected to many slots and signals. Many signals -
2385 can be connected to one slot. -
2386 -
2387 If a signal is connected to several slots, the slots are activated -
2388 in the same order in which the connections were made, when the -
2389 signal is emitted. -
2390 -
2391 The function returns a QMetaObject::Connection that represents -
2392 a handle to a connection if it successfully -
2393 connects the signal to the slot. The connection handle will be invalid -
2394 if it cannot create the connection, for example, if QObject is unable -
2395 to verify the existence of either \a signal or \a method, or if their -
2396 signatures aren't compatible. -
2397 You can check if the handle is valid by casting it to a bool. -
2398 -
2399 By default, a signal is emitted for every connection you make; -
2400 two signals are emitted for duplicate connections. You can break -
2401 all of these connections with a single disconnect() call. -
2402 If you pass the Qt::UniqueConnection \a type, the connection will only -
2403 be made if it is not a duplicate. If there is already a duplicate -
2404 (exact same signal to the exact same slot on the same objects), -
2405 the connection will fail and connect will return an invalid QMetaObject::Connection. -
2406 -
2407 The optional \a type parameter describes the type of connection -
2408 to establish. In particular, it determines whether a particular -
2409 signal is delivered to a slot immediately or queued for delivery -
2410 at a later time. If the signal is queued, the parameters must be -
2411 of types that are known to Qt's meta-object system, because Qt -
2412 needs to copy the arguments to store them in an event behind the -
2413 scenes. If you try to use a queued connection and get the error -
2414 message -
2415 -
2416 \snippet code/src_corelib_kernel_qobject.cpp 25 -
2417 -
2418 call qRegisterMetaType() to register the data type before you -
2419 establish the connection. -
2420 -
2421 \sa disconnect(), sender(), qRegisterMetaType(), Q_DECLARE_METATYPE() -
2422*/ -
2423QMetaObject::Connection QObject::connect(const QObject *sender, const char *signal, -
2424 const QObject *receiver, const char *method, -
2425 Qt::ConnectionType type) -
2426{ -
2427 if (sender == 0 || receiver == 0 || signal == 0 || method == 0) {
partially evaluated: sender == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:380481
partially evaluated: receiver == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:380480
partially evaluated: signal == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:380481
partially evaluated: method == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:380483
0-380483
2428 qWarning("QObject::connect: Cannot connect %s::%s to %s::%s",
never executed (the execution status of this line is deduced): QMessageLogger("kernel/qobject.cpp", 2428, __PRETTY_FUNCTION__).warning("QObject::connect: Cannot connect %s::%s to %s::%s",
-
2429 sender ? sender->metaObject()->className() : "(null)",
never executed (the execution status of this line is deduced): sender ? sender->metaObject()->className() : "(null)",
-
2430 (signal && *signal) ? signal+1 : "(null)",
never executed (the execution status of this line is deduced): (signal && *signal) ? signal+1 : "(null)",
-
2431 receiver ? receiver->metaObject()->className() : "(null)",
never executed (the execution status of this line is deduced): receiver ? receiver->metaObject()->className() : "(null)",
-
2432 (method && *method) ? method+1 : "(null)");
never executed (the execution status of this line is deduced): (method && *method) ? method+1 : "(null)");
-
2433 return QMetaObject::Connection(0);
never executed: return QMetaObject::Connection(0);
0
2434 } -
2435 QByteArray tmp_signal_name;
executed (the execution status of this line is deduced): QByteArray tmp_signal_name;
-
2436 -
2437 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:380480
0-380480
2438 return QMetaObject::Connection(0);
never executed: return QMetaObject::Connection(0);
0
2439 const QMetaObject *smeta = sender->metaObject();
executed (the execution status of this line is deduced): const QMetaObject *smeta = sender->metaObject();
-
2440 const char *signal_arg = signal;
executed (the execution status of this line is deduced): const char *signal_arg = signal;
-
2441 ++signal; //skip code
executed (the execution status of this line is deduced): ++signal;
-
2442 QArgumentTypeArray signalTypes;
executed (the execution status of this line is deduced): QArgumentTypeArray signalTypes;
-
2443 Q_ASSERT(QMetaObjectPrivate::get(smeta)->revision >= 7);
executed (the execution status of this line is deduced): qt_noop();
-
2444 QByteArray signalName = QMetaObjectPrivate::decodeMethodSignature(signal, signalTypes);
executed (the execution status of this line is deduced): QByteArray signalName = QMetaObjectPrivate::decodeMethodSignature(signal, signalTypes);
-
2445 int signal_index = QMetaObjectPrivate::indexOfSignalRelative(
executed (the execution status of this line is deduced): int signal_index = QMetaObjectPrivate::indexOfSignalRelative(
-
2446 &smeta, signalName, signalTypes.size(), signalTypes.constData());
executed (the execution status of this line is deduced): &smeta, signalName, signalTypes.size(), signalTypes.constData());
-
2447 if (signal_index < 0) {
evaluated: signal_index < 0
TRUEFALSE
yes
Evaluation Count:111
yes
Evaluation Count:380366
111-380366
2448 // check for normalized signatures -
2449 tmp_signal_name = QMetaObject::normalizedSignature(signal - 1);
executed (the execution status of this line is deduced): tmp_signal_name = QMetaObject::normalizedSignature(signal - 1);
-
2450 signal = tmp_signal_name.constData() + 1;
executed (the execution status of this line is deduced): signal = tmp_signal_name.constData() + 1;
-
2451 -
2452 signalTypes.clear();
executed (the execution status of this line is deduced): signalTypes.clear();
-
2453 signalName = QMetaObjectPrivate::decodeMethodSignature(signal, signalTypes);
executed (the execution status of this line is deduced): signalName = QMetaObjectPrivate::decodeMethodSignature(signal, signalTypes);
-
2454 smeta = sender->metaObject();
executed (the execution status of this line is deduced): smeta = sender->metaObject();
-
2455 signal_index = QMetaObjectPrivate::indexOfSignalRelative(
executed (the execution status of this line is deduced): signal_index = QMetaObjectPrivate::indexOfSignalRelative(
-
2456 &smeta, signalName, signalTypes.size(), signalTypes.constData());
executed (the execution status of this line is deduced): &smeta, signalName, signalTypes.size(), signalTypes.constData());
-
2457 }
executed: }
Execution Count:111
111
2458 if (signal_index < 0) {
partially evaluated: signal_index < 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:380477
0-380477
2459 err_method_notfound(sender, signal_arg, "connect");
never executed (the execution status of this line is deduced): err_method_notfound(sender, signal_arg, "connect");
-
2460 err_info_about_objects("connect", sender, receiver);
never executed (the execution status of this line is deduced): err_info_about_objects("connect", sender, receiver);
-
2461 return QMetaObject::Connection(0);
never executed: return QMetaObject::Connection(0);
0
2462 } -
2463 signal_index = QMetaObjectPrivate::originalClone(smeta, signal_index);
executed (the execution status of this line is deduced): signal_index = QMetaObjectPrivate::originalClone(smeta, signal_index);
-
2464 signal_index += QMetaObjectPrivate::signalOffset(smeta);
executed (the execution status of this line is deduced): signal_index += QMetaObjectPrivate::signalOffset(smeta);
-
2465 -
2466 QByteArray tmp_method_name;
executed (the execution status of this line is deduced): QByteArray tmp_method_name;
-
2467 int membcode = extract_code(method);
executed (the execution status of this line is deduced): int membcode = extract_code(method);
-
2468 -
2469 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:380469
0-380469
2470 return QMetaObject::Connection(0);
never executed: return QMetaObject::Connection(0);
0
2471 const char *method_arg = method;
executed (the execution status of this line is deduced): const char *method_arg = method;
-
2472 ++method; // skip code
executed (the execution status of this line is deduced): ++method;
-
2473 -
2474 QByteArray methodName;
executed (the execution status of this line is deduced): QByteArray methodName;
-
2475 QArgumentTypeArray methodTypes;
executed (the execution status of this line is deduced): QArgumentTypeArray methodTypes;
-
2476 const QMetaObject *rmeta = receiver->metaObject();
executed (the execution status of this line is deduced): const QMetaObject *rmeta = receiver->metaObject();
-
2477 int method_index_relative = -1;
executed (the execution status of this line is deduced): int method_index_relative = -1;
-
2478 Q_ASSERT(QMetaObjectPrivate::get(rmeta)->revision >= 7);
executed (the execution status of this line is deduced): qt_noop();
-
2479 switch (membcode) { -
2480 case QSLOT_CODE: -
2481 method_index_relative = QMetaObjectPrivate::indexOfSlotRelative(
executed (the execution status of this line is deduced): method_index_relative = QMetaObjectPrivate::indexOfSlotRelative(
-
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:368271
368271
2484 case QSIGNAL_CODE: -
2485 method_index_relative = QMetaObjectPrivate::indexOfSignalRelative(
executed (the execution status of this line is deduced): method_index_relative = QMetaObjectPrivate::indexOfSignalRelative(
-
2486 &rmeta, methodName, methodTypes.size(), methodTypes.constData());
executed (the execution status of this line is deduced): &rmeta, methodName, methodTypes.size(), methodTypes.constData());
-
2487 break;
executed: break;
Execution Count:12199
12199
2488 } -
2489 if (method_index_relative < 0) {
partially evaluated: method_index_relative < 0
TRUEFALSE
yes
Evaluation Count:380465
no
Evaluation Count:0
0-380465
2490 // check for normalized methods -
2491 tmp_method_name = QMetaObject::normalizedSignature(method);
executed (the execution status of this line is deduced): tmp_method_name = QMetaObject::normalizedSignature(method);
-
2492 method = tmp_method_name.constData();
executed (the execution status of this line is deduced): method = tmp_method_name.constData();
-
2493 -
2494 methodTypes.clear();
executed (the execution status of this line is deduced): methodTypes.clear();
-
2495 methodName = QMetaObjectPrivate::decodeMethodSignature(method, methodTypes);
executed (the execution status of this line is deduced): methodName = QMetaObjectPrivate::decodeMethodSignature(method, methodTypes);
-
2496 // rmeta may have been modified above -
2497 rmeta = receiver->metaObject();
executed (the execution status of this line is deduced): rmeta = receiver->metaObject();
-
2498 switch (membcode) { -
2499 case QSLOT_CODE: -
2500 method_index_relative = QMetaObjectPrivate::indexOfSlotRelative(
executed (the execution status of this line is deduced): method_index_relative = QMetaObjectPrivate::indexOfSlotRelative(
-
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:368279
368279
2503 case QSIGNAL_CODE: -
2504 method_index_relative = QMetaObjectPrivate::indexOfSignalRelative(
executed (the execution status of this line is deduced): method_index_relative = QMetaObjectPrivate::indexOfSignalRelative(
-
2505 &rmeta, methodName, methodTypes.size(), methodTypes.constData());
executed (the execution status of this line is deduced): &rmeta, methodName, methodTypes.size(), methodTypes.constData());
-
2506 break;
executed: break;
Execution Count:12196
12196
2507 } -
2508 }
executed: }
Execution Count:380473
380473
2509 -
2510 if (method_index_relative < 0) {
partially evaluated: method_index_relative < 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:380473
0-380473
2511 err_method_notfound(receiver, method_arg, "connect");
never executed (the execution status of this line is deduced): err_method_notfound(receiver, method_arg, "connect");
-
2512 err_info_about_objects("connect", sender, receiver);
never executed (the execution status of this line is deduced): err_info_about_objects("connect", sender, receiver);
-
2513 return QMetaObject::Connection(0);
never executed: return QMetaObject::Connection(0);
0
2514 } -
2515 -
2516 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:380473
1-380473
2517 methodTypes.size(), methodTypes.constData())) {
evaluated: !QMetaObjectPrivate::checkConnectArgs(signalTypes.size(), signalTypes.constData(), methodTypes.size(), methodTypes.constData())
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:380473
1-380473
2518 qWarning("QObject::connect: Incompatible sender/receiver arguments"
executed (the execution status of this line is deduced): QMessageLogger("kernel/qobject.cpp", 2518, __PRETTY_FUNCTION__).warning("QObject::connect: Incompatible sender/receiver arguments"
-
2519 "\n %s::%s --> %s::%s",
executed (the execution status of this line is deduced): "\n %s::%s --> %s::%s",
-
2520 sender->metaObject()->className(), signal,
executed (the execution status of this line is deduced): sender->metaObject()->className(), signal,
-
2521 receiver->metaObject()->className(), method);
executed (the execution status of this line is deduced): receiver->metaObject()->className(), method);
-
2522 return QMetaObject::Connection(0);
executed: return QMetaObject::Connection(0);
Execution Count:1
1
2523 } -
2524 -
2525 int *types = 0;
executed (the execution status of this line is deduced): int *types = 0;
-
2526 if ((type == Qt::QueuedConnection)
evaluated: (type == Qt::QueuedConnection)
TRUEFALSE
yes
Evaluation Count:21073
yes
Evaluation Count:359397
21073-359397
2527 && !(types = queuedConnectionTypes(signalTypes.constData(), signalTypes.size()))) {
partially evaluated: !(types = queuedConnectionTypes(signalTypes.constData(), signalTypes.size()))
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:21073
0-21073
2528 return QMetaObject::Connection(0);
never executed: return QMetaObject::Connection(0);
0
2529 } -
2530 -
2531#ifndef QT_NO_DEBUG -
2532 QMetaMethod smethod = QMetaObjectPrivate::signal(smeta, signal_index); -
2533 QMetaMethod rmethod = rmeta->method(method_index_relative + rmeta->methodOffset()); -
2534 check_and_warn_compat(smeta, smethod, rmeta, rmethod); -
2535#endif -
2536 QMetaObject::Connection handle = QMetaObject::Connection(QMetaObjectPrivate::connect(
executed (the execution status of this line is deduced): QMetaObject::Connection handle = QMetaObject::Connection(QMetaObjectPrivate::connect(
-
2537 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));
-
2538 return handle;
executed: return handle;
Execution Count:380475
380475
2539} -
2540 -
2541/*! -
2542 \since 4.8 -
2543 -
2544 Creates a connection of the given \a type from the \a signal in -
2545 the \a sender object to the \a method in the \a receiver object. -
2546 Returns a handle to the connection that can be used to disconnect -
2547 it later. -
2548 -
2549 The Connection handle will be invalid if it cannot create the -
2550 connection, for example, the parameters were invalid. -
2551 You can check if the QMetaObject::Connection is valid by casting it to a bool. -
2552 -
2553 This function works in the same way as -
2554 connect(const QObject *sender, const char *signal, -
2555 const QObject *receiver, const char *method, -
2556 Qt::ConnectionType type) -
2557 but it uses QMetaMethod to specify signal and method. -
2558 -
2559 \sa connect(const QObject *sender, const char *signal, -
2560 const QObject *receiver, const char *method, -
2561 Qt::ConnectionType type) -
2562 */ -
2563QMetaObject::Connection QObject::connect(const QObject *sender, const QMetaMethod &signal, -
2564 const QObject *receiver, const QMetaMethod &method, -
2565 Qt::ConnectionType type) -
2566{ -
2567 if (sender == 0
partially evaluated: sender == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:27
0-27
2568 || receiver == 0
partially evaluated: receiver == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:27
0-27
2569 || signal.methodType() != QMetaMethod::Signal
evaluated: signal.methodType() != QMetaMethod::Signal
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:24
3-24
2570 || method.methodType() == QMetaMethod::Constructor) {
evaluated: method.methodType() == QMetaMethod::Constructor
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:23
1-23
2571 qWarning("QObject::connect: Cannot connect %s::%s to %s::%s",
executed (the execution status of this line is deduced): QMessageLogger("kernel/qobject.cpp", 2571, __PRETTY_FUNCTION__).warning("QObject::connect: Cannot connect %s::%s to %s::%s",
-
2572 sender ? sender->metaObject()->className() : "(null)",
executed (the execution status of this line is deduced): sender ? sender->metaObject()->className() : "(null)",
-
2573 signal.methodSignature().constData(),
executed (the execution status of this line is deduced): signal.methodSignature().constData(),
-
2574 receiver ? receiver->metaObject()->className() : "(null)",
executed (the execution status of this line is deduced): receiver ? receiver->metaObject()->className() : "(null)",
-
2575 method.methodSignature().constData() );
executed (the execution status of this line is deduced): method.methodSignature().constData() );
-
2576 return QMetaObject::Connection(0);
executed: return QMetaObject::Connection(0);
Execution Count:4
4
2577 } -
2578 -
2579 int signal_index;
executed (the execution status of this line is deduced): int signal_index;
-
2580 int method_index;
executed (the execution status of this line is deduced): int method_index;
-
2581 { -
2582 int dummy;
executed (the execution status of this line is deduced): int dummy;
-
2583 QMetaObjectPrivate::memberIndexes(sender, signal, &signal_index, &dummy);
executed (the execution status of this line is deduced): QMetaObjectPrivate::memberIndexes(sender, signal, &signal_index, &dummy);
-
2584 QMetaObjectPrivate::memberIndexes(receiver, method, &dummy, &method_index);
executed (the execution status of this line is deduced): QMetaObjectPrivate::memberIndexes(receiver, method, &dummy, &method_index);
-
2585 } -
2586 -
2587 const QMetaObject *smeta = sender->metaObject();
executed (the execution status of this line is deduced): const QMetaObject *smeta = sender->metaObject();
-
2588 const QMetaObject *rmeta = receiver->metaObject();
executed (the execution status of this line is deduced): const QMetaObject *rmeta = receiver->metaObject();
-
2589 if (signal_index == -1) {
partially evaluated: signal_index == -1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:23
0-23
2590 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", 2590, __PRETTY_FUNCTION__).warning("QObject::connect: Can't find signal %s on instance of class %s",
-
2591 signal.methodSignature().constData(), smeta->className());
never executed (the execution status of this line is deduced): signal.methodSignature().constData(), smeta->className());
-
2592 return QMetaObject::Connection(0);
never executed: return QMetaObject::Connection(0);
0
2593 } -
2594 if (method_index == -1) {
partially evaluated: method_index == -1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:23
0-23
2595 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", 2595, __PRETTY_FUNCTION__).warning("QObject::connect: Can't find method %s on instance of class %s",
-
2596 method.methodSignature().constData(), rmeta->className());
never executed (the execution status of this line is deduced): method.methodSignature().constData(), rmeta->className());
-
2597 return QMetaObject::Connection(0);
never executed: return QMetaObject::Connection(0);
0
2598 } -
2599 -
2600 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
2601 qWarning("QObject::connect: Incompatible sender/receiver arguments"
never executed (the execution status of this line is deduced): QMessageLogger("kernel/qobject.cpp", 2601, __PRETTY_FUNCTION__).warning("QObject::connect: Incompatible sender/receiver arguments"
-
2602 "\n %s::%s --> %s::%s",
never executed (the execution status of this line is deduced): "\n %s::%s --> %s::%s",
-
2603 smeta->className(), signal.methodSignature().constData(),
never executed (the execution status of this line is deduced): smeta->className(), signal.methodSignature().constData(),
-
2604 rmeta->className(), method.methodSignature().constData());
never executed (the execution status of this line is deduced): rmeta->className(), method.methodSignature().constData());
-
2605 return QMetaObject::Connection(0);
never executed: return QMetaObject::Connection(0);
0
2606 } -
2607 -
2608 int *types = 0;
executed (the execution status of this line is deduced): int *types = 0;
-
2609 if ((type == Qt::QueuedConnection)
partially evaluated: (type == Qt::QueuedConnection)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:23
0-23
2610 && !(types = queuedConnectionTypes(signal.parameterTypes())))
never evaluated: !(types = queuedConnectionTypes(signal.parameterTypes()))
0
2611 return QMetaObject::Connection(0);
never executed: return QMetaObject::Connection(0);
0
2612 -
2613#ifndef QT_NO_DEBUG -
2614 check_and_warn_compat(smeta, signal, rmeta, method); -
2615#endif -
2616 QMetaObject::Connection handle = QMetaObject::Connection(QMetaObjectPrivate::connect(
executed (the execution status of this line is deduced): QMetaObject::Connection handle = QMetaObject::Connection(QMetaObjectPrivate::connect(
-
2617 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));
-
2618 return handle;
executed: return handle;
Execution Count:23
23
2619} -
2620 -
2621/*! -
2622 \fn bool QObject::connect(const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const -
2623 \overload connect() -
2624 \threadsafe -
2625 -
2626 Connects \a signal from the \a sender object to this object's \a -
2627 method. -
2628 -
2629 Equivalent to connect(\a sender, \a signal, \c this, \a method, \a type). -
2630 -
2631 Every connection you make emits a signal, so duplicate connections emit -
2632 two signals. You can break a connection using disconnect(). -
2633 -
2634 \sa disconnect() -
2635*/ -
2636 -
2637/*! -
2638 \threadsafe -
2639 -
2640 Disconnects \a signal in object \a sender from \a method in object -
2641 \a receiver. Returns true if the connection is successfully broken; -
2642 otherwise returns false. -
2643 -
2644 A signal-slot connection is removed when either of the objects -
2645 involved are destroyed. -
2646 -
2647 disconnect() is typically used in three ways, as the following -
2648 examples demonstrate. -
2649 \list 1 -
2650 \li Disconnect everything connected to an object's signals: -
2651 -
2652 \snippet code/src_corelib_kernel_qobject.cpp 26 -
2653 -
2654 equivalent to the non-static overloaded function -
2655 -
2656 \snippet code/src_corelib_kernel_qobject.cpp 27 -
2657 -
2658 \li Disconnect everything connected to a specific signal: -
2659 -
2660 \snippet code/src_corelib_kernel_qobject.cpp 28 -
2661 -
2662 equivalent to the non-static overloaded function -
2663 -
2664 \snippet code/src_corelib_kernel_qobject.cpp 29 -
2665 -
2666 \li Disconnect a specific receiver: -
2667 -
2668 \snippet code/src_corelib_kernel_qobject.cpp 30 -
2669 -
2670 equivalent to the non-static overloaded function -
2671 -
2672 \snippet code/src_corelib_kernel_qobject.cpp 31 -
2673 -
2674 \endlist -
2675 -
2676 0 may be used as a wildcard, meaning "any signal", "any receiving -
2677 object", or "any slot in the receiving object", respectively. -
2678 -
2679 The \a sender may never be 0. (You cannot disconnect signals from -
2680 more than one object in a single call.) -
2681 -
2682 If \a signal is 0, it disconnects \a receiver and \a method from -
2683 any signal. If not, only the specified signal is disconnected. -
2684 -
2685 If \a receiver is 0, it disconnects anything connected to \a -
2686 signal. If not, slots in objects other than \a receiver are not -
2687 disconnected. -
2688 -
2689 If \a method is 0, it disconnects anything that is connected to \a -
2690 receiver. If not, only slots named \a method will be disconnected, -
2691 and all other slots are left alone. The \a method must be 0 if \a -
2692 receiver is left out, so you cannot disconnect a -
2693 specifically-named slot on all objects. -
2694 -
2695 \sa connect() -
2696*/ -
2697bool QObject::disconnect(const QObject *sender, const char *signal, -
2698 const QObject *receiver, const char *method) -
2699{ -
2700 if (sender == 0 || (receiver == 0 && method != 0)) {
partially evaluated: sender == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:34757
evaluated: receiver == 0
TRUEFALSE
yes
Evaluation Count:9998
yes
Evaluation Count:24759
partially evaluated: method != 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:9998
0-34757
2701 qWarning("QObject::disconnect: Unexpected null parameter");
never executed (the execution status of this line is deduced): QMessageLogger("kernel/qobject.cpp", 2701, __PRETTY_FUNCTION__).warning("QObject::disconnect: Unexpected null parameter");
-
2702 return false;
never executed: return false;
0
2703 } -
2704 -
2705 const char *signal_arg = signal;
executed (the execution status of this line is deduced): const char *signal_arg = signal;
-
2706 QByteArray signal_name;
executed (the execution status of this line is deduced): QByteArray signal_name;
-
2707 bool signal_found = false;
executed (the execution status of this line is deduced): bool signal_found = false;
-
2708 if (signal) {
evaluated: signal
TRUEFALSE
yes
Evaluation Count:26406
yes
Evaluation Count:8351
8351-26406
2709 QT_TRY { -
2710 signal_name = QMetaObject::normalizedSignature(signal);
executed (the execution status of this line is deduced): signal_name = QMetaObject::normalizedSignature(signal);
-
2711 signal = signal_name.constData();
executed (the execution status of this line is deduced): signal = signal_name.constData();
-
2712 } QT_CATCH (const std::bad_alloc &) {
executed: }
Execution Count:26406
26406
2713 // if the signal is already normalized, we can continue. -
2714 if (sender->metaObject()->indexOfSignal(signal + 1) == -1)
never evaluated: sender->metaObject()->indexOfSignal(signal + 1) == -1
0
2715 QT_RETHROW;
never executed: throw;
0
2716 }
never executed: }
0
2717 -
2718 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:26406
0-26406
2719 return false;
never executed: return false;
0
2720 signal++; // skip code
executed (the execution status of this line is deduced): signal++;
-
2721 }
executed: }
Execution Count:26406
26406
2722 -
2723 QByteArray method_name;
executed (the execution status of this line is deduced): QByteArray method_name;
-
2724 const char *method_arg = method;
executed (the execution status of this line is deduced): const char *method_arg = method;
-
2725 int membcode = -1;
executed (the execution status of this line is deduced): int membcode = -1;
-
2726 bool method_found = false;
executed (the execution status of this line is deduced): bool method_found = false;
-
2727 if (method) {
evaluated: method
TRUEFALSE
yes
Evaluation Count:23014
yes
Evaluation Count:11743
11743-23014
2728 QT_TRY { -
2729 method_name = QMetaObject::normalizedSignature(method);
executed (the execution status of this line is deduced): method_name = QMetaObject::normalizedSignature(method);
-
2730 method = method_name.constData();
executed (the execution status of this line is deduced): method = method_name.constData();
-
2731 } QT_CATCH(const std::bad_alloc &) {
executed: }
Execution Count:23014
23014
2732 // if the method is already normalized, we can continue. -
2733 if (receiver->metaObject()->indexOfMethod(method + 1) == -1)
never evaluated: receiver->metaObject()->indexOfMethod(method + 1) == -1
0
2734 QT_RETHROW;
never executed: throw;
0
2735 }
never executed: }
0
2736 -
2737 membcode = extract_code(method);
executed (the execution status of this line is deduced): membcode = extract_code(method);
-
2738 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:23014
0-23014
2739 return false;
never executed: return false;
0
2740 method++; // skip code
executed (the execution status of this line is deduced): method++;
-
2741 }
executed: }
Execution Count:23014
23014
2742 -
2743 /* We now iterate through all the sender's and receiver's meta -
2744 * objects in order to also disconnect possibly shadowed signals -
2745 * and slots with the same signature. -
2746 */ -
2747 bool res = false;
executed (the execution status of this line is deduced): bool res = false;
-
2748 const QMetaObject *smeta = sender->metaObject();
executed (the execution status of this line is deduced): const QMetaObject *smeta = sender->metaObject();
-
2749 QByteArray signalName;
executed (the execution status of this line is deduced): QByteArray signalName;
-
2750 QArgumentTypeArray signalTypes;
executed (the execution status of this line is deduced): QArgumentTypeArray signalTypes;
-
2751 Q_ASSERT(QMetaObjectPrivate::get(smeta)->revision >= 7);
executed (the execution status of this line is deduced): qt_noop();
-
2752 if (signal)
evaluated: signal
TRUEFALSE
yes
Evaluation Count:26406
yes
Evaluation Count:8351
8351-26406
2753 signalName = QMetaObjectPrivate::decodeMethodSignature(signal, signalTypes);
executed: signalName = QMetaObjectPrivate::decodeMethodSignature(signal, signalTypes);
Execution Count:26406
26406
2754 QByteArray methodName;
executed (the execution status of this line is deduced): QByteArray methodName;
-
2755 QArgumentTypeArray methodTypes;
executed (the execution status of this line is deduced): QArgumentTypeArray methodTypes;
-
2756 Q_ASSERT(!receiver || QMetaObjectPrivate::get(receiver->metaObject())->revision >= 7);
executed (the execution status of this line is deduced): qt_noop();
-
2757 if (method)
evaluated: method
TRUEFALSE
yes
Evaluation Count:23014
yes
Evaluation Count:11741
11741-23014
2758 methodName = QMetaObjectPrivate::decodeMethodSignature(method, methodTypes);
executed: methodName = QMetaObjectPrivate::decodeMethodSignature(method, methodTypes);
Execution Count:23014
23014
2759 do { -
2760 int signal_index = -1;
executed (the execution status of this line is deduced): int signal_index = -1;
-
2761 if (signal) {
evaluated: signal
TRUEFALSE
yes
Evaluation Count:50740
yes
Evaluation Count:8349
8349-50740
2762 signal_index = QMetaObjectPrivate::indexOfSignalRelative(
executed (the execution status of this line is deduced): signal_index = QMetaObjectPrivate::indexOfSignalRelative(
-
2763 &smeta, signalName, signalTypes.size(), signalTypes.constData());
executed (the execution status of this line is deduced): &smeta, signalName, signalTypes.size(), signalTypes.constData());
-
2764 if (signal_index < 0)
evaluated: signal_index < 0
TRUEFALSE
yes
Evaluation Count:24333
yes
Evaluation Count:26407
24333-26407
2765 break;
executed: break;
Execution Count:24333
24333
2766 signal_index = QMetaObjectPrivate::originalClone(smeta, signal_index);
executed (the execution status of this line is deduced): signal_index = QMetaObjectPrivate::originalClone(smeta, signal_index);
-
2767 signal_index += QMetaObjectPrivate::signalOffset(smeta);
executed (the execution status of this line is deduced): signal_index += QMetaObjectPrivate::signalOffset(smeta);
-
2768 signal_found = true;
executed (the execution status of this line is deduced): signal_found = true;
-
2769 }
executed: }
Execution Count:26407
26407
2770 -
2771 if (!method) {
evaluated: !method
TRUEFALSE
yes
Evaluation Count:11741
yes
Evaluation Count:23015
11741-23015
2772 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);
-
2773 } else {
executed: }
Execution Count:11743
11743
2774 const QMetaObject *rmeta = receiver->metaObject();
executed (the execution status of this line is deduced): const QMetaObject *rmeta = receiver->metaObject();
-
2775 do { -
2776 int method_index = QMetaObjectPrivate::indexOfMethod(
executed (the execution status of this line is deduced): int method_index = QMetaObjectPrivate::indexOfMethod(
-
2777 rmeta, methodName, methodTypes.size(), methodTypes.constData());
executed (the execution status of this line is deduced): rmeta, methodName, methodTypes.size(), methodTypes.constData());
-
2778 if (method_index >= 0)
evaluated: method_index >= 0
TRUEFALSE
yes
Evaluation Count:23440
yes
Evaluation Count:23008
23008-23440
2779 while (method_index < rmeta->methodOffset())
evaluated: method_index < rmeta->methodOffset()
TRUEFALSE
yes
Evaluation Count:12340
yes
Evaluation Count:23440
12340-23440
2780 rmeta = rmeta->superClass();
executed: rmeta = rmeta->superClass();
Execution Count:12340
12340
2781 if (method_index < 0)
evaluated: method_index < 0
TRUEFALSE
yes
Evaluation Count:23008
yes
Evaluation Count:23440
23008-23440
2782 break;
executed: break;
Execution Count:23008
23008
2783 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);
-
2784 method_found = true;
executed (the execution status of this line is deduced): method_found = true;
-
2785 } while ((rmeta = rmeta->superClass()));
executed: }
Execution Count:23440
evaluated: (rmeta = rmeta->superClass())
TRUEFALSE
yes
Evaluation Count:23433
yes
Evaluation Count:7
7-23440
2786 }
executed: }
Execution Count:23015
23015
2787 } while (signal && (smeta = smeta->superClass()));
evaluated: signal
TRUEFALSE
yes
Evaluation Count:26407
yes
Evaluation Count:8351
evaluated: (smeta = smeta->superClass())
TRUEFALSE
yes
Evaluation Count:24334
yes
Evaluation Count:2073
2073-26407
2788 -
2789 if (signal && !signal_found) {
evaluated: signal
TRUEFALSE
yes
Evaluation Count:26406
yes
Evaluation Count:8351
partially evaluated: !signal_found
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:26406
0-26406
2790 err_method_notfound(sender, signal_arg, "disconnect");
never executed (the execution status of this line is deduced): err_method_notfound(sender, signal_arg, "disconnect");
-
2791 err_info_about_objects("disconnect", sender, receiver);
never executed (the execution status of this line is deduced): err_info_about_objects("disconnect", sender, receiver);
-
2792 } else if (method && !method_found) {
never executed: }
evaluated: method
TRUEFALSE
yes
Evaluation Count:23014
yes
Evaluation Count:11743
partially evaluated: !method_found
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:23014
0-23014
2793 err_method_notfound(receiver, method_arg, "disconnect");
never executed (the execution status of this line is deduced): err_method_notfound(receiver, method_arg, "disconnect");
-
2794 err_info_about_objects("disconnect", sender, receiver);
never executed (the execution status of this line is deduced): err_info_about_objects("disconnect", sender, receiver);
-
2795 }
never executed: }
0
2796 if (res) {
evaluated: res
TRUEFALSE
yes
Evaluation Count:17917
yes
Evaluation Count:16840
16840-17917
2797 if (!signal)
evaluated: !signal
TRUEFALSE
yes
Evaluation Count:1670
yes
Evaluation Count:16247
1670-16247
2798 const_cast<QObject*>(sender)->disconnectNotify(QMetaMethod());
executed: const_cast<QObject*>(sender)->disconnectNotify(QMetaMethod());
Execution Count:1670
1670
2799 }
executed: }
Execution Count:17917
17917
2800 return res;
executed: return res;
Execution Count:34755
34755
2801} -
2802 -
2803/*! -
2804 \since 4.8 -
2805 -
2806 Disconnects \a signal in object \a sender from \a method in object -
2807 \a receiver. Returns true if the connection is successfully broken; -
2808 otherwise returns false. -
2809 -
2810 This function provides the same possibilities like -
2811 disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *method) -
2812 but uses QMetaMethod to represent the signal and the method to be disconnected. -
2813 -
2814 Additionally this function returnsfalse and no signals and slots disconnected -
2815 if: -
2816 \list 1 -
2817 -
2818 \li \a signal is not a member of sender class or one of its parent classes. -
2819 -
2820 \li \a method is not a member of receiver class or one of its parent classes. -
2821 -
2822 \li \a signal instance represents not a signal. -
2823 -
2824 \endlist -
2825 -
2826 QMetaMethod() may be used as wildcard in the meaning "any signal" or "any slot in receiving object". -
2827 In the same way 0 can be used for \a receiver in the meaning "any receiving object". In this case -
2828 method should also be QMetaMethod(). \a sender parameter should be never 0. -
2829 -
2830 \sa disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *method) -
2831 */ -
2832bool QObject::disconnect(const QObject *sender, const QMetaMethod &signal, -
2833 const QObject *receiver, const QMetaMethod &method) -
2834{ -
2835 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
2836 qWarning("QObject::disconnect: Unexpected null parameter");
never executed (the execution status of this line is deduced): QMessageLogger("kernel/qobject.cpp", 2836, __PRETTY_FUNCTION__).warning("QObject::disconnect: Unexpected null parameter");
-
2837 return false;
never executed: return false;
0
2838 } -
2839 if (signal.mobj) {
evaluated: signal.mobj
TRUEFALSE
yes
Evaluation Count:14
yes
Evaluation Count:8
8-14
2840 if(signal.methodType() != QMetaMethod::Signal) {
evaluated: signal.methodType() != QMetaMethod::Signal
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:13
1-13
2841 qWarning("QObject::%s: Attempt to %s non-signal %s::%s",
executed (the execution status of this line is deduced): QMessageLogger("kernel/qobject.cpp", 2841, __PRETTY_FUNCTION__).warning("QObject::%s: Attempt to %s non-signal %s::%s",
-
2842 "disconnect","unbind",
executed (the execution status of this line is deduced): "disconnect","unbind",
-
2843 sender->metaObject()->className(), signal.methodSignature().constData());
executed (the execution status of this line is deduced): sender->metaObject()->className(), signal.methodSignature().constData());
-
2844 return false;
executed: return false;
Execution Count:1
1
2845 } -
2846 }
executed: }
Execution Count:13
13
2847 if (method.mobj) {
evaluated: method.mobj
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:9
9-12
2848 if(method.methodType() == QMetaMethod::Constructor) {
partially evaluated: method.methodType() == QMetaMethod::Constructor
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:12
0-12
2849 qWarning("QObject::disconect: cannot use constructor as argument %s::%s",
never executed (the execution status of this line is deduced): QMessageLogger("kernel/qobject.cpp", 2849, __PRETTY_FUNCTION__).warning("QObject::disconect: cannot use constructor as argument %s::%s",
-
2850 receiver->metaObject()->className(), method.methodSignature().constData());
never executed (the execution status of this line is deduced): receiver->metaObject()->className(), method.methodSignature().constData());
-
2851 return false;
never executed: return false;
0
2852 } -
2853 }
executed: }
Execution Count:12
12
2854 -
2855 // Reconstructing SIGNAL() macro result for signal.methodSignature() string -
2856 QByteArray signalSignature;
executed (the execution status of this line is deduced): QByteArray signalSignature;
-
2857 if (signal.mobj) {
evaluated: signal.mobj
TRUEFALSE
yes
Evaluation Count:13
yes
Evaluation Count:8
8-13
2858 signalSignature.reserve(signal.methodSignature().size()+1);
executed (the execution status of this line is deduced): signalSignature.reserve(signal.methodSignature().size()+1);
-
2859 signalSignature.append((char)(QSIGNAL_CODE + '0'));
executed (the execution status of this line is deduced): signalSignature.append((char)(2 + '0'));
-
2860 signalSignature.append(signal.methodSignature());
executed (the execution status of this line is deduced): signalSignature.append(signal.methodSignature());
-
2861 }
executed: }
Execution Count:13
13
2862 -
2863 int signal_index;
executed (the execution status of this line is deduced): int signal_index;
-
2864 int method_index;
executed (the execution status of this line is deduced): int method_index;
-
2865 { -
2866 int dummy;
executed (the execution status of this line is deduced): int dummy;
-
2867 QMetaObjectPrivate::memberIndexes(sender, signal, &signal_index, &dummy);
executed (the execution status of this line is deduced): QMetaObjectPrivate::memberIndexes(sender, signal, &signal_index, &dummy);
-
2868 QMetaObjectPrivate::memberIndexes(receiver, method, &dummy, &method_index);
executed (the execution status of this line is deduced): QMetaObjectPrivate::memberIndexes(receiver, method, &dummy, &method_index);
-
2869 } -
2870 // If we are here sender is not null. If signal is not null while signal_index -
2871 // is -1 then this signal is not a member of sender. -
2872 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
2873 qWarning("QObject::disconect: signal %s not found on class %s",
never executed (the execution status of this line is deduced): QMessageLogger("kernel/qobject.cpp", 2873, __PRETTY_FUNCTION__).warning("QObject::disconect: signal %s not found on class %s",
-
2874 signal.methodSignature().constData(), sender->metaObject()->className());
never executed (the execution status of this line is deduced): signal.methodSignature().constData(), sender->metaObject()->className());
-
2875 return false;
never executed: return false;
0
2876 } -
2877 // If this condition is true then method is not a member of receeiver. -
2878 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
2879 qWarning("QObject::disconect: method %s not found on class %s",
never executed (the execution status of this line is deduced): QMessageLogger("kernel/qobject.cpp", 2879, __PRETTY_FUNCTION__).warning("QObject::disconect: method %s not found on class %s",
-
2880 method.methodSignature().constData(), receiver->metaObject()->className());
never executed (the execution status of this line is deduced): method.methodSignature().constData(), receiver->metaObject()->className());
-
2881 return false;
never executed: return false;
0
2882 } -
2883 -
2884 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
2885 return false;
executed: return false;
Execution Count:1
1
2886 -
2887 if (!signal.isValid()) {
evaluated: !signal.isValid()
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:12
8-12
2888 // The signal is a wildcard, meaning all signals were disconnected. -
2889 // QMetaObjectPrivate::disconnect() doesn't call disconnectNotify() -
2890 // per connection in this case. Call it once now, with an invalid -
2891 // QMetaMethod as argument, as documented. -
2892 const_cast<QObject*>(sender)->disconnectNotify(signal);
executed (the execution status of this line is deduced): const_cast<QObject*>(sender)->disconnectNotify(signal);
-
2893 }
executed: }
Execution Count:8
8
2894 return true;
executed: return true;
Execution Count:20
20
2895} -
2896 -
2897/*! -
2898 \threadsafe -
2899 -
2900 \fn bool QObject::disconnect(const char *signal, const QObject *receiver, const char *method) const -
2901 \overload disconnect() -
2902 -
2903 Disconnects \a signal from \a method of \a receiver. -
2904 -
2905 A signal-slot connection is removed when either of the objects -
2906 involved are destroyed. -
2907*/ -
2908 -
2909/*! -
2910 \fn bool QObject::disconnect(const QObject *receiver, const char *method) const -
2911 \overload disconnect() -
2912 -
2913 Disconnects all signals in this object from \a receiver's \a -
2914 method. -
2915 -
2916 A signal-slot connection is removed when either of the objects -
2917 involved are destroyed. -
2918*/ -
2919 -
2920 -
2921/*! -
2922 \since 5.0 -
2923 -
2924 This virtual function is called when something has been connected -
2925 to \a signal in this object. -
2926 -
2927 If you want to compare \a signal with a specific signal, you can -
2928 use QMetaMethod::fromSignal() as follows: -
2929 -
2930 \snippet code/src_corelib_kernel_qobject.cpp 32 -
2931 -
2932 \warning This function violates the object-oriented principle of -
2933 modularity. However, it might be useful when you need to perform -
2934 expensive initialization only if something is connected to a -
2935 signal. -
2936 -
2937 \sa connect(), disconnectNotify() -
2938*/ -
2939 -
2940void QObject::connectNotify(const QMetaMethod &signal) -
2941{ -
2942 Q_UNUSED(signal);
executed (the execution status of this line is deduced): (void)signal;;
-
2943}
executed: }
Execution Count:488525
488525
2944 -
2945/*! -
2946 \since 5.0 -
2947 -
2948 This virtual function is called when something has been -
2949 disconnected from \a signal in this object. -
2950 -
2951 See connectNotify() for an example of how to compare -
2952 \a signal with a specific signal. -
2953 -
2954 If all signals were disconnected from this object (e.g., the -
2955 signal argument to disconnect() was 0), disconnectNotify() -
2956 is only called once, and the \a signal will be an invalid -
2957 QMetaMethod (QMetaMethod::isValid() returns false). -
2958 -
2959 \warning This function violates the object-oriented principle of -
2960 modularity. However, it might be useful for optimizing access to -
2961 expensive resources. -
2962 -
2963 \sa disconnect(), connectNotify() -
2964*/ -
2965 -
2966void QObject::disconnectNotify(const QMetaMethod &signal) -
2967{ -
2968 Q_UNUSED(signal);
executed (the execution status of this line is deduced): (void)signal;;
-
2969}
executed: }
Execution Count:257189
257189
2970 -
2971/* -
2972 \internal -
2973 convert a signal index from the method range to the signal range -
2974 */ -
2975static int methodIndexToSignalIndex(const QMetaObject **base, int signal_index) -
2976{ -
2977 if (signal_index < 0)
evaluated: signal_index < 0
TRUEFALSE
yes
Evaluation Count:156
yes
Evaluation Count:207481
156-207481
2978 return signal_index;
executed: return signal_index;
Execution Count:156
156
2979 const QMetaObject *metaObject = *base;
executed (the execution status of this line is deduced): const QMetaObject *metaObject = *base;
-
2980 while (metaObject && metaObject->methodOffset() > signal_index)
partially evaluated: metaObject
TRUEFALSE
yes
Evaluation Count:415082
no
Evaluation Count:0
evaluated: metaObject->methodOffset() > signal_index
TRUEFALSE
yes
Evaluation Count:207601
yes
Evaluation Count:207481
0-415082
2981 metaObject = metaObject->superClass();
executed: metaObject = metaObject->superClass();
Execution Count:207601
207601
2982 -
2983 if (metaObject) {
partially evaluated: metaObject
TRUEFALSE
yes
Evaluation Count:207481
no
Evaluation Count:0
0-207481
2984 int signalOffset, methodOffset;
executed (the execution status of this line is deduced): int signalOffset, methodOffset;
-
2985 computeOffsets(metaObject, &signalOffset, &methodOffset);
executed (the execution status of this line is deduced): computeOffsets(metaObject, &signalOffset, &methodOffset);
-
2986 if (signal_index < metaObject->methodCount())
evaluated: signal_index < metaObject->methodCount()
TRUEFALSE
yes
Evaluation Count:207479
yes
Evaluation Count:2
2-207479
2987 signal_index = QMetaObjectPrivate::originalClone(metaObject, signal_index - methodOffset) + signalOffset;
executed: signal_index = QMetaObjectPrivate::originalClone(metaObject, signal_index - methodOffset) + signalOffset;
Execution Count:207479
207479
2988 else -
2989 signal_index = signal_index - methodOffset + signalOffset;
executed: signal_index = signal_index - methodOffset + signalOffset;
Execution Count:2
2
2990 *base = metaObject;
executed (the execution status of this line is deduced): *base = metaObject;
-
2991 }
executed: }
Execution Count:207481
207481
2992 return signal_index;
executed: return signal_index;
Execution Count:207481
207481
2993} -
2994 -
2995/*! -
2996 \internal -
2997 \a types is a 0-terminated vector of meta types for queued -
2998 connections. -
2999 -
3000 if \a signal_index is -1, then we effectively connect *all* signals -
3001 from the sender to the receiver's slot -
3002 */ -
3003QMetaObject::Connection QMetaObject::connect(const QObject *sender, int signal_index, -
3004 const QObject *receiver, int method_index, int type, int *types) -
3005{ -
3006 const QMetaObject *smeta = sender->metaObject();
executed (the execution status of this line is deduced): const QMetaObject *smeta = sender->metaObject();
-
3007 signal_index = methodIndexToSignalIndex(&smeta, signal_index);
executed (the execution status of this line is deduced): signal_index = methodIndexToSignalIndex(&smeta, signal_index);
-
3008 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:106898
106898
3009 receiver, method_index,
executed: return Connection(QMetaObjectPrivate::connect(sender, signal_index, smeta, receiver, method_index, 0, type, types));
Execution Count:106898
106898
3010 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:106898
106898
3011 type, types));
executed: return Connection(QMetaObjectPrivate::connect(sender, signal_index, smeta, receiver, method_index, 0, type, types));
Execution Count:106898
106898
3012} -
3013 -
3014/*! -
3015 \internal -
3016 Same as the QMetaObject::connect, but \a signal_index must be the result of QObjectPrivate::signalIndex -
3017 -
3018 method_index is relative to the rmeta metaobject, if rmeta is null, then it is absolute index -
3019 -
3020 the QObjectPrivate::Connection* has a refcount of 2, so it must be passed to a QMetaObject::Connection -
3021 */ -
3022QObjectPrivate::Connection *QMetaObjectPrivate::connect(const QObject *sender, -
3023 int signal_index, const QMetaObject *smeta, -
3024 const QObject *receiver, int method_index, -
3025 const QMetaObject *rmeta, int type, int *types) -
3026{ -
3027 QObject *s = const_cast<QObject *>(sender);
executed (the execution status of this line is deduced): QObject *s = const_cast<QObject *>(sender);
-
3028 QObject *r = const_cast<QObject *>(receiver);
executed (the execution status of this line is deduced): QObject *r = const_cast<QObject *>(receiver);
-
3029 -
3030 int method_offset = rmeta ? rmeta->methodOffset() : 0;
evaluated: rmeta
TRUEFALSE
yes
Evaluation Count:380472
yes
Evaluation Count:106937
106937-380472
3031 Q_ASSERT(!rmeta || QMetaObjectPrivate::get(rmeta)->revision >= 6);
executed (the execution status of this line is deduced): qt_noop();
-
3032 QObjectPrivate::StaticMetaCallFunction callFunction =
executed (the execution status of this line is deduced): QObjectPrivate::StaticMetaCallFunction callFunction =
-
3033 rmeta ? rmeta->d.static_metacall : 0;
evaluated: rmeta
TRUEFALSE
yes
Evaluation Count:380473
yes
Evaluation Count:106937
106937-380473
3034 -
3035 QOrderedMutexLocker locker(signalSlotLock(sender),
executed (the execution status of this line is deduced): QOrderedMutexLocker locker(signalSlotLock(sender),
-
3036 signalSlotLock(receiver));
executed (the execution status of this line is deduced): signalSlotLock(receiver));
-
3037 -
3038 if (type & Qt::UniqueConnection) {
evaluated: type & Qt::UniqueConnection
TRUEFALSE
yes
Evaluation Count:4424
yes
Evaluation Count:482996
4424-482996
3039 QObjectConnectionListVector *connectionLists = QObjectPrivate::get(s)->connectionLists;
executed (the execution status of this line is deduced): QObjectConnectionListVector *connectionLists = QObjectPrivate::get(s)->connectionLists;
-
3040 if (connectionLists && connectionLists->count() > signal_index) {
evaluated: connectionLists
TRUEFALSE
yes
Evaluation Count:2464
yes
Evaluation Count:1960
evaluated: connectionLists->count() > signal_index
TRUEFALSE
yes
Evaluation Count:2127
yes
Evaluation Count:337
337-2464
3041 const QObjectPrivate::Connection *c2 =
executed (the execution status of this line is deduced): const QObjectPrivate::Connection *c2 =
-
3042 (*connectionLists)[signal_index].first;
executed (the execution status of this line is deduced): (*connectionLists)[signal_index].first;
-
3043 -
3044 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;
-
3045 -
3046 while (c2) {
evaluated: c2
TRUEFALSE
yes
Evaluation Count:1303
yes
Evaluation Count:1017
1017-1303
3047 if (c2->receiver == receiver && c2->method() == method_index_absolute)
evaluated: c2->receiver == receiver
TRUEFALSE
yes
Evaluation Count:1112
yes
Evaluation Count:191
evaluated: c2->method() == method_index_absolute
TRUEFALSE
yes
Evaluation Count:1110
yes
Evaluation Count:2
2-1112
3048 return 0;
executed: return 0;
Execution Count:1110
1110
3049 c2 = c2->nextConnectionList;
executed (the execution status of this line is deduced): c2 = c2->nextConnectionList;
-
3050 }
executed: }
Execution Count:193
193
3051 }
executed: }
Execution Count:1017
1017
3052 type &= Qt::UniqueConnection - 1;
executed (the execution status of this line is deduced): type &= Qt::UniqueConnection - 1;
-
3053 }
executed: }
Execution Count:3314
3314
3054 -
3055 QScopedPointer<QObjectPrivate::Connection> c(new QObjectPrivate::Connection);
executed (the execution status of this line is deduced): QScopedPointer<QObjectPrivate::Connection> c(new QObjectPrivate::Connection);
-
3056 c->sender = s;
executed (the execution status of this line is deduced): c->sender = s;
-
3057 c->signal_index = signal_index;
executed (the execution status of this line is deduced): c->signal_index = signal_index;
-
3058 c->receiver = r;
executed (the execution status of this line is deduced): c->receiver = r;
-
3059 c->method_relative = method_index;
executed (the execution status of this line is deduced): c->method_relative = method_index;
-
3060 c->method_offset = method_offset;
executed (the execution status of this line is deduced): c->method_offset = method_offset;
-
3061 c->connectionType = type;
executed (the execution status of this line is deduced): c->connectionType = type;
-
3062 c->isSlotObject = false;
executed (the execution status of this line is deduced): c->isSlotObject = false;
-
3063 c->argumentTypes.store(types);
executed (the execution status of this line is deduced): c->argumentTypes.store(types);
-
3064 c->nextConnectionList = 0;
executed (the execution status of this line is deduced): c->nextConnectionList = 0;
-
3065 c->callFunction = callFunction;
executed (the execution status of this line is deduced): c->callFunction = callFunction;
-
3066 -
3067 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());
-
3068 -
3069 locker.unlock();
executed (the execution status of this line is deduced): locker.unlock();
-
3070 QMetaMethod smethod = QMetaObjectPrivate::signal(smeta, signal_index);
executed (the execution status of this line is deduced): QMetaMethod smethod = QMetaObjectPrivate::signal(smeta, signal_index);
-
3071 if (smethod.isValid())
evaluated: smethod.isValid()
TRUEFALSE
yes
Evaluation Count:486165
yes
Evaluation Count:135
135-486165
3072 s->connectNotify(smethod);
executed: s->connectNotify(smethod);
Execution Count:486166
486166
3073 -
3074 return c.take();
executed: return c.take();
Execution Count:486299
486299
3075} -
3076 -
3077/*! -
3078 \internal -
3079 */ -
3080bool QMetaObject::disconnect(const QObject *sender, int signal_index, -
3081 const QObject *receiver, int method_index) -
3082{ -
3083 const QMetaObject *smeta = sender->metaObject();
executed (the execution status of this line is deduced): const QMetaObject *smeta = sender->metaObject();
-
3084 signal_index = methodIndexToSignalIndex(&smeta, signal_index);
executed (the execution status of this line is deduced): signal_index = methodIndexToSignalIndex(&smeta, signal_index);
-
3085 return QMetaObjectPrivate::disconnect(sender, signal_index, smeta,
executed: return QMetaObjectPrivate::disconnect(sender, signal_index, smeta, receiver, method_index, 0);
Execution Count:100733
100733
3086 receiver, method_index, 0);
executed: return QMetaObjectPrivate::disconnect(sender, signal_index, smeta, receiver, method_index, 0);
Execution Count:100733
100733
3087} -
3088 -
3089/*! -
3090 \internal -
3091 -
3092Disconnect a single signal connection. If QMetaObject::connect() has been called -
3093multiple times for the same sender, signal_index, receiver and method_index only -
3094one of these connections will be removed. -
3095 */ -
3096bool QMetaObject::disconnectOne(const QObject *sender, int signal_index, -
3097 const QObject *receiver, int method_index) -
3098{ -
3099 const QMetaObject *smeta = sender->metaObject();
executed (the execution status of this line is deduced): const QMetaObject *smeta = sender->metaObject();
-
3100 signal_index = methodIndexToSignalIndex(&smeta, signal_index);
executed (the execution status of this line is deduced): signal_index = methodIndexToSignalIndex(&smeta, signal_index);
-
3101 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
3102 receiver, method_index, 0,
executed: return QMetaObjectPrivate::disconnect(sender, signal_index, smeta, receiver, method_index, 0, QMetaObjectPrivate::DisconnectOne);
Execution Count:6
6
3103 QMetaObjectPrivate::DisconnectOne);
executed: return QMetaObjectPrivate::disconnect(sender, signal_index, smeta, receiver, method_index, 0, QMetaObjectPrivate::DisconnectOne);
Execution Count:6
6
3104} -
3105 -
3106/*! -
3107 \internal -
3108 Helper function to remove the connection from the senders list and setting the receivers to 0 -
3109 */ -
3110bool QMetaObjectPrivate::disconnectHelper(QObjectPrivate::Connection *c, -
3111 const QObject *receiver, int method_index, void **slot, -
3112 QMutex *senderMutex, DisconnectType disconnectType) -
3113{ -
3114 bool success = false;
executed (the execution status of this line is deduced): bool success = false;
-
3115 while (c) {
evaluated: c
TRUEFALSE
yes
Evaluation Count:148305
yes
Evaluation Count:136283
136283-148305
3116 if (c->receiver
evaluated: c->receiver
TRUEFALSE
yes
Evaluation Count:143183
yes
Evaluation Count:5122
5122-143183
3117 && (receiver == 0 || (c->receiver == receiver
evaluated: receiver == 0
TRUEFALSE
yes
Evaluation Count:67
yes
Evaluation Count:143116
evaluated: c->receiver == receiver
TRUEFALSE
yes
Evaluation Count:122827
yes
Evaluation Count:20289
67-143116
3118 && (method_index < 0 || c->method() == method_index)
evaluated: method_index < 0
TRUEFALSE
yes
Evaluation Count:4663
yes
Evaluation Count:118164
evaluated: c->method() == method_index
TRUEFALSE
yes
Evaluation Count:116498
yes
Evaluation Count:1666
1666-118164
3119 && (slot == 0 || (c->isSlotObject && c->slotObj->compare(slot)))))) {
evaluated: slot == 0
TRUEFALSE
yes
Evaluation Count:121157
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-121157
3120 bool needToUnlock = false;
executed (the execution status of this line is deduced): bool needToUnlock = false;
-
3121 QMutex *receiverMutex = 0;
executed (the execution status of this line is deduced): QMutex *receiverMutex = 0;
-
3122 if (!receiver) {
evaluated: !receiver
TRUEFALSE
yes
Evaluation Count:67
yes
Evaluation Count:121161
67-121161
3123 receiverMutex = signalSlotLock(c->receiver);
executed (the execution status of this line is deduced): receiverMutex = signalSlotLock(c->receiver);
-
3124 // need to relock this receiver and sender in the correct order -
3125 needToUnlock = QOrderedMutexLocker::relock(senderMutex, receiverMutex);
executed (the execution status of this line is deduced): needToUnlock = QOrderedMutexLocker::relock(senderMutex, receiverMutex);
-
3126 }
executed: }
Execution Count:67
67
3127 if (c->receiver) {
partially evaluated: c->receiver
TRUEFALSE
yes
Evaluation Count:121228
no
Evaluation Count:0
0-121228
3128 *c->prev = c->next;
executed (the execution status of this line is deduced): *c->prev = c->next;
-
3129 if (c->next)
evaluated: c->next
TRUEFALSE
yes
Evaluation Count:22812
yes
Evaluation Count:98416
22812-98416
3130 c->next->prev = c->prev;
executed: c->next->prev = c->prev;
Execution Count:22812
22812
3131 }
executed: }
Execution Count:121228
121228
3132 -
3133 if (needToUnlock)
evaluated: needToUnlock
TRUEFALSE
yes
Evaluation Count:50
yes
Evaluation Count:121178
50-121178
3134 receiverMutex->unlock();
executed: receiverMutex->unlock();
Execution Count:50
50
3135 -
3136 c->receiver = 0;
executed (the execution status of this line is deduced): c->receiver = 0;
-
3137 -
3138 success = true;
executed (the execution status of this line is deduced): success = true;
-
3139 -
3140 if (disconnectType == DisconnectOne)
evaluated: disconnectType == DisconnectOne
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:121224
4-121224
3141 return success;
executed: return success;
Execution Count:4
4
3142 }
executed: }
Execution Count:121224
121224
3143 c = c->nextConnectionList;
executed (the execution status of this line is deduced): c = c->nextConnectionList;
-
3144 }
executed: }
Execution Count:148301
148301
3145 return success;
executed: return success;
Execution Count:136283
136283
3146} -
3147 -
3148/*! -
3149 \internal -
3150 Same as the QMetaObject::disconnect, but \a signal_index must be the result of QObjectPrivate::signalIndex -
3151 */ -
3152bool QMetaObjectPrivate::disconnect(const QObject *sender, -
3153 int signal_index, const QMetaObject *smeta, -
3154 const QObject *receiver, int method_index, void **slot, -
3155 DisconnectType disconnectType) -
3156{ -
3157 if (!sender)
partially evaluated: !sender
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:135950
0-135950
3158 return false;
never executed: return false;
0
3159 -
3160 QObject *s = const_cast<QObject *>(sender);
executed (the execution status of this line is deduced): QObject *s = const_cast<QObject *>(sender);
-
3161 -
3162 QMutex *senderMutex = signalSlotLock(sender);
executed (the execution status of this line is deduced): QMutex *senderMutex = signalSlotLock(sender);
-
3163 QMutex *receiverMutex = receiver ? signalSlotLock(receiver) : 0;
evaluated: receiver
TRUEFALSE
yes
Evaluation Count:125945
yes
Evaluation Count:10005
10005-125945
3164 QOrderedMutexLocker locker(senderMutex, receiverMutex);
executed (the execution status of this line is deduced): QOrderedMutexLocker locker(senderMutex, receiverMutex);
-
3165 -
3166 QObjectConnectionListVector *connectionLists = QObjectPrivate::get(s)->connectionLists;
executed (the execution status of this line is deduced): QObjectConnectionListVector *connectionLists = QObjectPrivate::get(s)->connectionLists;
-
3167 if (!connectionLists)
evaluated: !connectionLists
TRUEFALSE
yes
Evaluation Count:6751
yes
Evaluation Count:129201
6751-129201
3168 return false;
executed: return false;
Execution Count:6751
6751
3169 -
3170 // prevent incoming connections changing the connectionLists while unlocked -
3171 ++connectionLists->inUse;
executed (the execution status of this line is deduced): ++connectionLists->inUse;
-
3172 -
3173 bool success = false;
executed (the execution status of this line is deduced): bool success = false;
-
3174 if (signal_index < 0) {
evaluated: signal_index < 0
TRUEFALSE
yes
Evaluation Count:1717
yes
Evaluation Count:127484
1717-127484
3175 // remove from all connection lists -
3176 for (int sig_index = -1; sig_index < connectionLists->count(); ++sig_index) {
evaluated: sig_index < connectionLists->count()
TRUEFALSE
yes
Evaluation Count:14550
yes
Evaluation Count:1717
1717-14550
3177 QObjectPrivate::Connection *c =
executed (the execution status of this line is deduced): QObjectPrivate::Connection *c =
-
3178 (*connectionLists)[sig_index].first;
executed (the execution status of this line is deduced): (*connectionLists)[sig_index].first;
-
3179 if (disconnectHelper(c, receiver, method_index, slot, senderMutex, disconnectType)) {
evaluated: disconnectHelper(c, receiver, method_index, slot, senderMutex, disconnectType)
TRUEFALSE
yes
Evaluation Count:4280
yes
Evaluation Count:10270
4280-10270
3180 success = true;
executed (the execution status of this line is deduced): success = true;
-
3181 connectionLists->dirty = true;
executed (the execution status of this line is deduced): connectionLists->dirty = true;
-
3182 }
executed: }
Execution Count:4280
4280
3183 }
executed: }
Execution Count:14550
14550
3184 } else if (signal_index < connectionLists->count()) {
executed: }
Execution Count:1717
evaluated: signal_index < connectionLists->count()
TRUEFALSE
yes
Evaluation Count:121737
yes
Evaluation Count:5747
1717-121737
3185 QObjectPrivate::Connection *c =
executed (the execution status of this line is deduced): QObjectPrivate::Connection *c =
-
3186 (*connectionLists)[signal_index].first;
executed (the execution status of this line is deduced): (*connectionLists)[signal_index].first;
-
3187 if (disconnectHelper(c, receiver, method_index, slot, senderMutex, disconnectType)) {
evaluated: disconnectHelper(c, receiver, method_index, slot, senderMutex, disconnectType)
TRUEFALSE
yes
Evaluation Count:116593
yes
Evaluation Count:5144
5144-116593
3188 success = true;
executed (the execution status of this line is deduced): success = true;
-
3189 connectionLists->dirty = true;
executed (the execution status of this line is deduced): connectionLists->dirty = true;
-
3190 }
executed: }
Execution Count:116593
116593
3191 }
executed: }
Execution Count:121737
121737
3192 -
3193 --connectionLists->inUse;
executed (the execution status of this line is deduced): --connectionLists->inUse;
-
3194 Q_ASSERT(connectionLists->inUse >= 0);
executed (the execution status of this line is deduced): qt_noop();
-
3195 if (connectionLists->orphaned && !connectionLists->inUse)
partially evaluated: connectionLists->orphaned
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:129201
never evaluated: !connectionLists->inUse
0-129201
3196 delete connectionLists;
never executed: delete connectionLists;
0
3197 -
3198 locker.unlock();
executed (the execution status of this line is deduced): locker.unlock();
-
3199 if (success) {
evaluated: success
TRUEFALSE
yes
Evaluation Count:118274
yes
Evaluation Count:10927
10927-118274
3200 QMetaMethod smethod = QMetaObjectPrivate::signal(smeta, signal_index);
executed (the execution status of this line is deduced): QMetaMethod smethod = QMetaObjectPrivate::signal(smeta, signal_index);
-
3201 if (smethod.isValid())
evaluated: smethod.isValid()
TRUEFALSE
yes
Evaluation Count:116593
yes
Evaluation Count:1681
1681-116593
3202 s->disconnectNotify(smethod);
executed: s->disconnectNotify(smethod);
Execution Count:116593
116593
3203 }
executed: }
Execution Count:118274
118274
3204 -
3205 return success;
executed: return success;
Execution Count:129201
129201
3206} -
3207 -
3208/*! -
3209 \fn void QMetaObject::connectSlotsByName(QObject *object) -
3210 -
3211 Searches recursively for all child objects of the given \a object, and connects -
3212 matching signals from them to slots of \a object that follow the following form: -
3213 -
3214 \snippet code/src_corelib_kernel_qobject.cpp 33 -
3215 -
3216 Let's assume our object has a child object of type \c{QPushButton} with -
3217 the \l{QObject::objectName}{object name} \c{button1}. The slot to catch the -
3218 button's \c{clicked()} signal would be: -
3219 -
3220 \snippet code/src_corelib_kernel_qobject.cpp 34 -
3221 -
3222 \sa QObject::setObjectName() -
3223 */ -
3224void QMetaObject::connectSlotsByName(QObject *o) -
3225{ -
3226 if (!o)
partially evaluated: !o
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:203
0-203
3227 return;
never executed: return;
0
3228 const QMetaObject *mo = o->metaObject();
executed (the execution status of this line is deduced): const QMetaObject *mo = o->metaObject();
-
3229 Q_ASSERT(mo);
executed (the execution status of this line is deduced): qt_noop();
-
3230 const QObjectList list = o->findChildren<QObject *>(QString());
executed (the execution status of this line is deduced): const QObjectList list = o->findChildren<QObject *>(QString());
-
3231 for (int i = 0; i < mo->methodCount(); ++i) {
evaluated: i < mo->methodCount()
TRUEFALSE
yes
Evaluation Count:12945
yes
Evaluation Count:203
203-12945
3232 QByteArray slotSignature = mo->method(i).methodSignature();
executed (the execution status of this line is deduced): QByteArray slotSignature = mo->method(i).methodSignature();
-
3233 const char *slot = slotSignature.constData();
executed (the execution status of this line is deduced): const char *slot = slotSignature.constData();
-
3234 Q_ASSERT(slot);
executed (the execution status of this line is deduced): qt_noop();
-
3235 if (slot[0] != 'o' || slot[1] != 'n' || slot[2] != '_')
evaluated: slot[0] != 'o'
TRUEFALSE
yes
Evaluation Count:12527
yes
Evaluation Count:418
evaluated: slot[1] != 'n'
TRUEFALSE
yes
Evaluation Count:394
yes
Evaluation Count:24
evaluated: slot[2] != '_'
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:23
1-12527
3236 continue;
executed: continue;
Execution Count:12922
12922
3237 bool foundIt = false;
executed (the execution status of this line is deduced): bool foundIt = false;
-
3238 for(int j = 0; j < list.count(); ++j) {
evaluated: j < list.count()
TRUEFALSE
yes
Evaluation Count:26
yes
Evaluation Count:7
7-26
3239 const QObject *co = list.at(j);
executed (the execution status of this line is deduced): const QObject *co = list.at(j);
-
3240 QByteArray objName = co->objectName().toLatin1();
executed (the execution status of this line is deduced): QByteArray objName = co->objectName().toLatin1();
-
3241 int len = objName.length();
executed (the execution status of this line is deduced): int len = objName.length();
-
3242 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
3243 continue;
executed: continue;
Execution Count:10
10
3244 const QMetaObject *smeta;
executed (the execution status of this line is deduced): const QMetaObject *smeta;
-
3245 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);
-
3246 if (sigIndex < 0) { // search for compatible signals
evaluated: sigIndex < 0
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:15
1-15
3247 const QMetaObject *smo = co->metaObject();
executed (the execution status of this line is deduced): const QMetaObject *smo = co->metaObject();
-
3248 int slotlen = qstrlen(slot + len + 4) - 1;
executed (the execution status of this line is deduced): int slotlen = qstrlen(slot + len + 4) - 1;
-
3249 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
3250 QMetaMethod method = QMetaObjectPrivate::signal(smo, k);
executed (the execution status of this line is deduced): QMetaMethod method = QMetaObjectPrivate::signal(smo, k);
-
3251 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
3252 smeta = method.enclosingMetaObject();
executed (the execution status of this line is deduced): smeta = method.enclosingMetaObject();
-
3253 sigIndex = k;
executed (the execution status of this line is deduced): sigIndex = k;
-
3254 break;
executed: break;
Execution Count:1
1
3255 } -
3256 }
executed: }
Execution Count:6
6
3257 }
executed: }
Execution Count:1
1
3258 if (sigIndex < 0)
partially evaluated: sigIndex < 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:16
0-16
3259 continue;
never executed: continue;
0
3260 -
3261 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
3262 foundIt = true;
executed (the execution status of this line is deduced): foundIt = true;
-
3263 break;
executed: break;
Execution Count:16
16
3264 } -
3265 }
never executed: }
0
3266 if (foundIt) {
evaluated: foundIt
TRUEFALSE
yes
Evaluation Count:16
yes
Evaluation Count:7
7-16
3267 // we found our slot, now skip all overloads -
3268 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
3269 ++i;
executed: ++i;
Execution Count:3
3
3270 } 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
3271 qWarning("QMetaObject::connectSlotsByName: No matching signal for %s", slot);
executed (the execution status of this line is deduced): QMessageLogger("kernel/qobject.cpp", 3271, __PRETTY_FUNCTION__).warning("QMetaObject::connectSlotsByName: No matching signal for %s", slot);
-
3272 }
executed: }
Execution Count:5
5
3273 } -
3274}
executed: }
Execution Count:203
203
3275 -
3276/*! -
3277 \internal -
3278 -
3279 \a signal must be in the signal index range (see QObjectPrivate::signalIndex()). -
3280*/ -
3281static void queued_activate(QObject *sender, int signal, QObjectPrivate::Connection *c, void **argv) -
3282{ -
3283 const int *argumentTypes = c->argumentTypes.load();
executed (the execution status of this line is deduced): const int *argumentTypes = c->argumentTypes.load();
-
3284 if (!argumentTypes && argumentTypes != &DIRECT_CONNECTION_ONLY) {
evaluated: !argumentTypes
TRUEFALSE
yes
Evaluation Count:1780
yes
Evaluation Count:23174
partially evaluated: argumentTypes != &DIRECT_CONNECTION_ONLY
TRUEFALSE
yes
Evaluation Count:1780
no
Evaluation Count:0
0-23174
3285 QMetaMethod m = QMetaObjectPrivate::signal(sender->metaObject(), signal);
executed (the execution status of this line is deduced): QMetaMethod m = QMetaObjectPrivate::signal(sender->metaObject(), signal);
-
3286 argumentTypes = queuedConnectionTypes(m.parameterTypes());
executed (the execution status of this line is deduced): argumentTypes = queuedConnectionTypes(m.parameterTypes());
-
3287 if (!argumentTypes) // cannot queue arguments
partially evaluated: !argumentTypes
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1780
0-1780
3288 argumentTypes = &DIRECT_CONNECTION_ONLY;
never executed: argumentTypes = &DIRECT_CONNECTION_ONLY;
0
3289 if (!c->argumentTypes.testAndSetOrdered(0, argumentTypes)) {
partially evaluated: !c->argumentTypes.testAndSetOrdered(0, argumentTypes)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1780
0-1780
3290 if (argumentTypes != &DIRECT_CONNECTION_ONLY)
never evaluated: argumentTypes != &DIRECT_CONNECTION_ONLY
0
3291 delete [] argumentTypes;
never executed: delete [] argumentTypes;
0
3292 argumentTypes = c->argumentTypes.load();
never executed (the execution status of this line is deduced): argumentTypes = c->argumentTypes.load();
-
3293 }
never executed: }
0
3294 }
executed: }
Execution Count:1780
1780
3295 if (argumentTypes == &DIRECT_CONNECTION_ONLY) // cannot activate
partially evaluated: argumentTypes == &DIRECT_CONNECTION_ONLY
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:24954
0-24954
3296 return;
never executed: return;
0
3297 int nargs = 1; // include return type
executed (the execution status of this line is deduced): int nargs = 1;
-
3298 while (argumentTypes[nargs-1])
evaluated: argumentTypes[nargs-1]
TRUEFALSE
yes
Evaluation Count:35745
yes
Evaluation Count:24954
24954-35745
3299 ++nargs;
executed: ++nargs;
Execution Count:35745
35745
3300 int *types = (int *) malloc(nargs*sizeof(int));
executed (the execution status of this line is deduced): int *types = (int *) malloc(nargs*sizeof(int));
-
3301 Q_CHECK_PTR(types);
never executed: qBadAlloc();
executed: }
Execution Count:24954
partially evaluated: !(types)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:24954
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:24954
0-24954
3302 void **args = (void **) malloc(nargs*sizeof(void *));
executed (the execution status of this line is deduced): void **args = (void **) malloc(nargs*sizeof(void *));
-
3303 Q_CHECK_PTR(args);
never executed: qBadAlloc();
executed: }
Execution Count:24954
partially evaluated: !(args)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:24954
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:24954
0-24954
3304 types[0] = 0; // return type
executed (the execution status of this line is deduced): types[0] = 0;
-
3305 args[0] = 0; // return value
executed (the execution status of this line is deduced): args[0] = 0;
-
3306 for (int n = 1; n < nargs; ++n)
evaluated: n < nargs
TRUEFALSE
yes
Evaluation Count:35745
yes
Evaluation Count:24954
24954-35745
3307 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:35745
35745
3308 QMetaCallEvent *ev = c->isSlotObject ?
evaluated: c->isSlotObject
TRUEFALSE
yes
Evaluation Count:15
yes
Evaluation Count:24939
15-24939
3309 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) :
-
3310 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);
-
3311 QCoreApplication::postEvent(c->receiver, ev);
executed (the execution status of this line is deduced): QCoreApplication::postEvent(c->receiver, ev);
-
3312}
executed: }
Execution Count:24954
24954
3313 -
3314/*! -
3315 \internal -
3316 */ -
3317void QMetaObject::activate(QObject *sender, const QMetaObject *m, int local_signal_index, -
3318 void **argv) -
3319{ -
3320 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);
-
3321}
executed: }
Execution Count:20609033
20609033
3322 -
3323/*! -
3324 \internal -
3325 */ -
3326void QMetaObject::activate(QObject *sender, int signalOffset, int local_signal_index, void **argv) -
3327{ -
3328 int signal_index = signalOffset + local_signal_index;
executed (the execution status of this line is deduced): int signal_index = signalOffset + local_signal_index;
-
3329 -
3330 if (!sender->d_func()->isSignalConnected(signal_index))
evaluated: !sender->d_func()->isSignalConnected(signal_index)
TRUEFALSE
yes
Evaluation Count:12917625
yes
Evaluation Count:7691301
7691301-12917625
3331 return; // nothing connected to these signals, and no spy
executed: return;
Execution Count:12917631
12917631
3332 -
3333 if (sender->d_func()->blockSig)
evaluated: sender->d_func()->blockSig
TRUEFALSE
yes
Evaluation Count:38011
yes
Evaluation Count:7653290
38011-7653290
3334 return;
executed: return;
Execution Count:38011
38011
3335 -
3336 if (sender->d_func()->declarativeData && QAbstractDeclarativeData::signalEmitted)
partially evaluated: sender->d_func()->declarativeData
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:7653288
never evaluated: QAbstractDeclarativeData::signalEmitted
0-7653288
3337 QAbstractDeclarativeData::signalEmitted(sender->d_func()->declarativeData, sender,
never executed: QAbstractDeclarativeData::signalEmitted(sender->d_func()->declarativeData, sender, signal_index, argv);
0
3338 signal_index, argv);
never executed: QAbstractDeclarativeData::signalEmitted(sender->d_func()->declarativeData, sender, signal_index, argv);
0
3339 -
3340 void *empty_argv[] = { 0 };
executed (the execution status of this line is deduced): void *empty_argv[] = { 0 };
-
3341 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:7653287
0-7653287
3342 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,
-
3343 argv ? argv : empty_argv);
never executed (the execution status of this line is deduced): argv ? argv : empty_argv);
-
3344 }
never executed: }
0
3345 -
3346 Qt::HANDLE currentThreadId = QThread::currentThreadId(); -
3347 -
3348 { -
3349 QMutexLocker locker(signalSlotLock(sender));
executed (the execution status of this line is deduced): QMutexLocker locker(signalSlotLock(sender));
-
3350 struct ConnectionListsRef {
executed (the execution status of this line is deduced): struct ConnectionListsRef {
-
3351 QObjectConnectionListVector *connectionLists;
executed (the execution status of this line is deduced): QObjectConnectionListVector *connectionLists;
-
3352 ConnectionListsRef(QObjectConnectionListVector *connectionLists) : connectionLists(connectionLists)
executed (the execution status of this line is deduced): ConnectionListsRef(QObjectConnectionListVector *connectionLists) : connectionLists(connectionLists)
-
3353 {
executed (the execution status of this line is deduced): {
-
3354 if (connectionLists)
evaluated: connectionLists
TRUEFALSE
yes
Evaluation Count:7652687
yes
Evaluation Count:619
619-7652687
3355 ++connectionLists->inUse;
executed: ++connectionLists->inUse;
Execution Count:7652685
7652685
3356 }
executed: }
Execution Count:7653300
7653300
3357 ~ConnectionListsRef()
executed (the execution status of this line is deduced): ~ConnectionListsRef()
-
3358 {
executed (the execution status of this line is deduced): {
-
3359 if (!connectionLists)
evaluated: !connectionLists
TRUEFALSE
yes
Evaluation Count:619
yes
Evaluation Count:7652632
619-7652632
3360 return;
executed: return;
Execution Count:619
619
3361
executed (the execution status of this line is deduced):
-
3362 --connectionLists->inUse;
executed (the execution status of this line is deduced): --connectionLists->inUse;
-
3363 Q_ASSERT(connectionLists->inUse >= 0);
executed (the execution status of this line is deduced): qt_noop();
-
3364 if (connectionLists->orphaned) {
evaluated: connectionLists->orphaned
TRUEFALSE
yes
Evaluation Count:75
yes
Evaluation Count:7652557
75-7652557
3365 if (!connectionLists->inUse)
evaluated: !connectionLists->inUse
TRUEFALSE
yes
Evaluation Count:74
yes
Evaluation Count:1
1-74
3366 delete connectionLists;
executed: delete connectionLists;
Execution Count:74
74
3367 }
executed: }
Execution Count:75
75
3368 }
executed: }
Execution Count:7652635
7652635
3369
executed (the execution status of this line is deduced):
-
3370 QObjectConnectionListVector *operator->() const { return connectionLists; }
executed: return connectionLists;
Execution Count:54241509
54241509
3371 };
executed (the execution status of this line is deduced): };
-
3372 ConnectionListsRef connectionLists = sender->d_func()->connectionLists;
executed (the execution status of this line is deduced): ConnectionListsRef connectionLists = sender->d_func()->connectionLists;
-
3373 if (!connectionLists.connectionLists) {
evaluated: !connectionLists.connectionLists
TRUEFALSE
yes
Evaluation Count:619
yes
Evaluation Count:7652682
619-7652682
3374 locker.unlock();
executed (the execution status of this line is deduced): locker.unlock();
-
3375 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:619
0-619
3376 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
3377 return;
executed: return;
Execution Count:619
619
3378 } -
3379 -
3380 const QObjectPrivate::ConnectionList *list;
executed (the execution status of this line is deduced): const QObjectPrivate::ConnectionList *list;
-
3381 if (signal_index < connectionLists->count())
evaluated: signal_index < connectionLists->count()
TRUEFALSE
yes
Evaluation Count:7652448
yes
Evaluation Count:206
206-7652448
3382 list = &connectionLists->at(signal_index);
executed: list = &connectionLists->at(signal_index);
Execution Count:7652452
7652452
3383 else -
3384 list = &connectionLists->allsignals;
executed: list = &connectionLists->allsignals;
Execution Count:206
206
3385 -
3386 do { -
3387 QObjectPrivate::Connection *c = list->first;
executed (the execution status of this line is deduced): QObjectPrivate::Connection *c = list->first;
-
3388 if (!c) continue;
executed: continue;
Execution Count:7652418
evaluated: !c
TRUEFALSE
yes
Evaluation Count:7652421
yes
Evaluation Count:7652579
7652418-7652579
3389 // We need to check against last here to ensure that signals added -
3390 // during the signal emission are not emitted in this emission. -
3391 QObjectPrivate::Connection *last = list->last;
executed (the execution status of this line is deduced): QObjectPrivate::Connection *last = list->last;
-
3392 -
3393 do { -
3394 if (!c->receiver)
evaluated: !c->receiver
TRUEFALSE
yes
Evaluation Count:38874
yes
Evaluation Count:8352307
38874-8352307
3395 continue;
executed: continue;
Execution Count:38874
38874
3396 -
3397 QObject * const receiver = c->receiver;
executed (the execution status of this line is deduced): QObject * const receiver = c->receiver;
-
3398 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;
-
3399 -
3400 // determine if this connection should be sent immediately or -
3401 // put into the event queue -
3402 if ((c->connectionType == Qt::AutoConnection && !receiverInSameThread)
evaluated: c->connectionType == Qt::AutoConnection
TRUEFALSE
yes
Evaluation Count:8305468
yes
Evaluation Count:46864
evaluated: !receiverInSameThread
TRUEFALSE
yes
Evaluation Count:7443
yes
Evaluation Count:8298028
7443-8305468
3403 || (c->connectionType == Qt::QueuedConnection)) {
evaluated: (c->connectionType == Qt::QueuedConnection)
TRUEFALSE
yes
Evaluation Count:17511
yes
Evaluation Count:8327362
17511-8327362
3404 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);
-
3405 continue;
executed: continue;
Execution Count:24954
24954
3406#ifndef QT_NO_THREAD -
3407 } else if (c->connectionType == Qt::BlockingQueuedConnection) {
evaluated: c->connectionType == Qt::BlockingQueuedConnection
TRUEFALSE
yes
Evaluation Count:544
yes
Evaluation Count:8326817
544-8326817
3408 locker.unlock();
executed (the execution status of this line is deduced): locker.unlock();
-
3409 if (receiverInSameThread) {
partially evaluated: receiverInSameThread
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:544
0-544
3410 qWarning("Qt: Dead lock detected while activating a BlockingQueuedConnection: "
never executed (the execution status of this line is deduced): QMessageLogger("kernel/qobject.cpp", 3410, __PRETTY_FUNCTION__).warning("Qt: Dead lock detected while activating a BlockingQueuedConnection: "
-
3411 "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)",
-
3412 sender->metaObject()->className(), sender,
never executed (the execution status of this line is deduced): sender->metaObject()->className(), sender,
-
3413 receiver->metaObject()->className(), receiver);
never executed (the execution status of this line is deduced): receiver->metaObject()->className(), receiver);
-
3414 }
never executed: }
0
3415 QSemaphore semaphore;
executed (the execution status of this line is deduced): QSemaphore semaphore;
-
3416 QMetaCallEvent *ev = c->isSlotObject ?
evaluated: c->isSlotObject
TRUEFALSE
yes
Evaluation Count:52
yes
Evaluation Count:492
52-492
3417 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) :
-
3418 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);
-
3419 QCoreApplication::postEvent(receiver, ev);
executed (the execution status of this line is deduced): QCoreApplication::postEvent(receiver, ev);
-
3420 semaphore.acquire();
executed (the execution status of this line is deduced): semaphore.acquire();
-
3421 locker.relock();
executed (the execution status of this line is deduced): locker.relock();
-
3422 continue;
executed: continue;
Execution Count:544
544
3423#endif -
3424 } -
3425 -
3426 QConnectionSenderSwitcher sw;
executed (the execution status of this line is deduced): QConnectionSenderSwitcher sw;
-
3427 -
3428 if (receiverInSameThread) {
evaluated: receiverInSameThread
TRUEFALSE
yes
Evaluation Count:8326713
yes
Evaluation Count:105
105-8326713
3429 sw.switchSender(receiver, sender, signal_index);
executed (the execution status of this line is deduced): sw.switchSender(receiver, sender, signal_index);
-
3430 }
executed: }
Execution Count:8326713
8326713
3431 const QObjectPrivate::StaticMetaCallFunction callFunction = c->callFunction;
executed (the execution status of this line is deduced): const QObjectPrivate::StaticMetaCallFunction callFunction = c->callFunction;
-
3432 const int method_relative = c->method_relative;
executed (the execution status of this line is deduced): const int method_relative = c->method_relative;
-
3433 if (c->isSlotObject) {
evaluated: c->isSlotObject
TRUEFALSE
yes
Evaluation Count:372
yes
Evaluation Count:8326447
372-8326447
3434 c->slotObj->ref();
executed (the execution status of this line is deduced): c->slotObj->ref();
-
3435 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);
-
3436 locker.unlock();
executed (the execution status of this line is deduced): locker.unlock();
-
3437 obj->call(receiver, argv ? argv : empty_argv);
executed (the execution status of this line is deduced): obj->call(receiver, argv ? argv : empty_argv);
-
3438 locker.relock();
executed (the execution status of this line is deduced): locker.relock();
-
3439 } else if (callFunction && c->method_offset <= receiver->metaObject()->methodOffset()) {
executed: }
Execution Count:372
evaluated: callFunction
TRUEFALSE
yes
Evaluation Count:8319188
yes
Evaluation Count:7261
evaluated: c->method_offset <= receiver->metaObject()->methodOffset()
TRUEFALSE
yes
Evaluation Count:8316572
yes
Evaluation Count:2622
372-8319188
3440 //we compare the vtable to make sure we are not in the destructor of the object. -
3441 locker.unlock();
executed (the execution status of this line is deduced): locker.unlock();
-
3442 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:8316594
0-8316594
3443 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
3444 -
3445 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);
-
3446 -
3447 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:8316591
0-8316591
3448 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
3449 locker.relock();
executed (the execution status of this line is deduced): locker.relock();
-
3450 } else {
executed: }
Execution Count:8316592
8316592
3451 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;
-
3452 locker.unlock();
executed (the execution status of this line is deduced): locker.unlock();
-
3453 -
3454 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:9883
0-9883
3455 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,
-
3456 method,
never executed (the execution status of this line is deduced): method,
-
3457 argv ? argv : empty_argv);
never executed (the execution status of this line is deduced): argv ? argv : empty_argv);
-
3458 }
never executed: }
0
3459 -
3460 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);
-
3461 -
3462 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:9883
0-9883
3463 qt_signal_spy_callback_set.slot_end_callback(receiver, method);
never executed: qt_signal_spy_callback_set.slot_end_callback(receiver, method);
0
3464 -
3465 locker.relock();
executed (the execution status of this line is deduced): locker.relock();
-
3466 }
executed: }
Execution Count:9883
9883
3467 -
3468 if (connectionLists->orphaned)
evaluated: connectionLists->orphaned
TRUEFALSE
yes
Evaluation Count:74
yes
Evaluation Count:8326766
74-8326766
3469 break;
executed: break;
Execution Count:74
74
3470 } while (c != last && (c = c->nextConnectionList) != 0);
executed: }
Execution Count:8326757
evaluated: c != last
TRUEFALSE
yes
Evaluation Count:738601
yes
Evaluation Count:7652512
partially evaluated: (c = c->nextConnectionList) != 0
TRUEFALSE
yes
Evaluation Count:738601
no
Evaluation Count:0
0-8326757
3471 -
3472 if (connectionLists->orphaned)
evaluated: connectionLists->orphaned
TRUEFALSE
yes
Evaluation Count:75
yes
Evaluation Count:7652503
75-7652503
3473 break;
executed: break;
Execution Count:75
75
3474 } while (list != &connectionLists->allsignals &&
executed: }
Execution Count:7652504
evaluated: list != &connectionLists->allsignals
TRUEFALSE
yes
Evaluation Count:7652359
yes
Evaluation Count:7652555
7652359-7652555
3475 //start over for all signals;
executed (the execution status of this line is deduced):
-
3476 ((list = &connectionLists->allsignals), true));
partially evaluated: ((list = &connectionLists->allsignals), true)
TRUEFALSE
yes
Evaluation Count:7652344
no
Evaluation Count:0
0-7652344
3477 -
3478 } -
3479 -
3480 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:7652683
0-7652683
3481 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
3482 -
3483}
executed: }
Execution Count:7652686
7652686
3484 -
3485/*! -
3486 \internal -
3487 signal_index comes from indexOfMethod() -
3488*/ -
3489void QMetaObject::activate(QObject *sender, int signal_index, void **argv) -
3490{ -
3491 const QMetaObject *mo = sender->metaObject();
executed (the execution status of this line is deduced): const QMetaObject *mo = sender->metaObject();
-
3492 while (mo->methodOffset() > signal_index)
partially evaluated: mo->methodOffset() > signal_index
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
3493 mo = mo->superClass();
never executed: mo = mo->superClass();
0
3494 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);
-
3495}
executed: }
Execution Count:3
3
3496 -
3497/*! -
3498 \internal -
3499 Implementation of QObject::senderSignalIndex() -
3500*/ -
3501int QObjectPrivate::senderSignalIndex() const -
3502{ -
3503 Q_Q(const QObject);
executed (the execution status of this line is deduced): const QObject * const q = q_func();
-
3504 QMutexLocker locker(signalSlotLock(q));
executed (the execution status of this line is deduced): QMutexLocker locker(signalSlotLock(q));
-
3505 if (!currentSender)
evaluated: !currentSender
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:228
5-228
3506 return -1;
executed: return -1;
Execution Count:5
5
3507 -
3508 for (QObjectPrivate::Connection *c = senders; c; c = c->next) {
evaluated: c
TRUEFALSE
yes
Evaluation Count:422
yes
Evaluation Count:2
2-422
3509 if (c->sender == currentSender->sender)
evaluated: c->sender == currentSender->sender
TRUEFALSE
yes
Evaluation Count:226
yes
Evaluation Count:196
196-226
3510 return currentSender->signal;
executed: return currentSender->signal;
Execution Count:226
226
3511 }
executed: }
Execution Count:196
196
3512 -
3513 return -1;
executed: return -1;
Execution Count:2
2
3514} -
3515 -
3516/*! -
3517 \internal -
3518 Returns the signal index used in the internal connectionLists vector. -
3519 -
3520 It is different from QMetaObject::indexOfSignal(): indexOfSignal is the same as indexOfMethod -
3521 while QObjectPrivate::signalIndex is smaller because it doesn't give index to slots. -
3522 -
3523 If \a meta is not 0, it is set to the meta-object where the signal was found. -
3524*/ -
3525int QObjectPrivate::signalIndex(const char *signalName, -
3526 const QMetaObject **meta) const -
3527{ -
3528 Q_Q(const QObject);
executed (the execution status of this line is deduced): const QObject * const q = q_func();
-
3529 const QMetaObject *base = q->metaObject();
executed (the execution status of this line is deduced): const QMetaObject *base = q->metaObject();
-
3530 Q_ASSERT(QMetaObjectPrivate::get(base)->revision >= 7);
executed (the execution status of this line is deduced): qt_noop();
-
3531 QArgumentTypeArray types;
executed (the execution status of this line is deduced): QArgumentTypeArray types;
-
3532 QByteArray name = QMetaObjectPrivate::decodeMethodSignature(signalName, types);
executed (the execution status of this line is deduced): QByteArray name = QMetaObjectPrivate::decodeMethodSignature(signalName, types);
-
3533 int relative_index = QMetaObjectPrivate::indexOfSignalRelative(
executed (the execution status of this line is deduced): int relative_index = QMetaObjectPrivate::indexOfSignalRelative(
-
3534 &base, name, types.size(), types.constData());
executed (the execution status of this line is deduced): &base, name, types.size(), types.constData());
-
3535 if (relative_index < 0)
evaluated: relative_index < 0
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:866
1-866
3536 return relative_index;
executed: return relative_index;
Execution Count:1
1
3537 relative_index = QMetaObjectPrivate::originalClone(base, relative_index);
executed (the execution status of this line is deduced): relative_index = QMetaObjectPrivate::originalClone(base, relative_index);
-
3538 if (meta)
evaluated: meta
TRUEFALSE
yes
Evaluation Count:15
yes
Evaluation Count:851
15-851
3539 *meta = base;
executed: *meta = base;
Execution Count:15
15
3540 return relative_index + QMetaObjectPrivate::signalOffset(base);
executed: return relative_index + QMetaObjectPrivate::signalOffset(base);
Execution Count:866
866
3541} -
3542 -
3543/***************************************************************************** -
3544 Properties -
3545 *****************************************************************************/ -
3546 -
3547#ifndef QT_NO_PROPERTIES -
3548 -
3549/*! -
3550 Sets the value of the object's \a name property to \a value. -
3551 -
3552 If the property is defined in the class using Q_PROPERTY then -
3553 true is returned on success and false otherwise. If the property -
3554 is not defined using Q_PROPERTY, and therefore not listed in the -
3555 meta-object, it is added as a dynamic property and false is returned. -
3556 -
3557 Information about all available properties is provided through the -
3558 metaObject() and dynamicPropertyNames(). -
3559 -
3560 Dynamic properties can be queried again using property() and can be -
3561 removed by setting the property value to an invalid QVariant. -
3562 Changing the value of a dynamic property causes a QDynamicPropertyChangeEvent -
3563 to be sent to the object. -
3564 -
3565 \b{Note:} Dynamic properties starting with "_q_" are reserved for internal -
3566 purposes. -
3567 -
3568 \sa property(), metaObject(), dynamicPropertyNames() -
3569*/ -
3570bool QObject::setProperty(const char *name, const QVariant &value) -
3571{ -
3572 Q_D(QObject);
executed (the execution status of this line is deduced): QObjectPrivate * const d = d_func();
-
3573 const QMetaObject* meta = metaObject();
executed (the execution status of this line is deduced): const QMetaObject* meta = metaObject();
-
3574 if (!name || !meta)
partially evaluated: !name
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:8179
partially evaluated: !meta
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:8179
0-8179
3575 return false;
never executed: return false;
0
3576 -
3577 int id = meta->indexOfProperty(name);
executed (the execution status of this line is deduced): int id = meta->indexOfProperty(name);
-
3578 if (id < 0) {
evaluated: id < 0
TRUEFALSE
yes
Evaluation Count:7545
yes
Evaluation Count:634
634-7545
3579 if (!d->extraData)
evaluated: !d->extraData
TRUEFALSE
yes
Evaluation Count:4567
yes
Evaluation Count:2978
2978-4567
3580 d->extraData = new QObjectPrivate::ExtraData;
executed: d->extraData = new QObjectPrivate::ExtraData;
Execution Count:4567
4567
3581 -
3582 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);
-
3583 -
3584 if (!value.isValid()) {
evaluated: !value.isValid()
TRUEFALSE
yes
Evaluation Count:4124
yes
Evaluation Count:3421
3421-4124
3585 if (idx == -1)
evaluated: idx == -1
TRUEFALSE
yes
Evaluation Count:4118
yes
Evaluation Count:6
6-4118
3586 return false;
executed: return false;
Execution Count:4118
4118
3587 d->extraData->propertyNames.removeAt(idx);
executed (the execution status of this line is deduced): d->extraData->propertyNames.removeAt(idx);
-
3588 d->extraData->propertyValues.removeAt(idx);
executed (the execution status of this line is deduced): d->extraData->propertyValues.removeAt(idx);
-
3589 } else {
executed: }
Execution Count:6
6
3590 if (idx == -1) {
evaluated: idx == -1
TRUEFALSE
yes
Evaluation Count:2148
yes
Evaluation Count:1273
1273-2148
3591 d->extraData->propertyNames.append(name);
executed (the execution status of this line is deduced): d->extraData->propertyNames.append(name);
-
3592 d->extraData->propertyValues.append(value);
executed (the execution status of this line is deduced): d->extraData->propertyValues.append(value);
-
3593 } else {
executed: }
Execution Count:2148
2148
3594 d->extraData->propertyValues[idx] = value;
executed (the execution status of this line is deduced): d->extraData->propertyValues[idx] = value;
-
3595 }
executed: }
Execution Count:1273
1273
3596 } -
3597 -
3598 QDynamicPropertyChangeEvent ev(name);
executed (the execution status of this line is deduced): QDynamicPropertyChangeEvent ev(name);
-
3599 QCoreApplication::sendEvent(this, &ev);
executed (the execution status of this line is deduced): QCoreApplication::sendEvent(this, &ev);
-
3600 -
3601 return false;
executed: return false;
Execution Count:3427
3427
3602 } -
3603 QMetaProperty p = meta->property(id);
executed (the execution status of this line is deduced): QMetaProperty p = meta->property(id);
-
3604#ifndef QT_NO_DEBUG -
3605 if (!p.isWritable()) -
3606 qWarning("%s::setProperty: Property \"%s\" invalid," -
3607 " read-only or does not exist", metaObject()->className(), name); -
3608#endif -
3609 return p.write(this, value);
executed: return p.write(this, value);
Execution Count:634
634
3610} -
3611 -
3612/*! -
3613 Returns the value of the object's \a name property. -
3614 -
3615 If no such property exists, the returned variant is invalid. -
3616 -
3617 Information about all available properties is provided through the -
3618 metaObject() and dynamicPropertyNames(). -
3619 -
3620 \sa setProperty(), QVariant::isValid(), metaObject(), dynamicPropertyNames() -
3621*/ -
3622QVariant QObject::property(const char *name) const -
3623{ -
3624 Q_D(const QObject);
executed (the execution status of this line is deduced): const QObjectPrivate * const d = d_func();
-
3625 const QMetaObject* meta = metaObject();
executed (the execution status of this line is deduced): const QMetaObject* meta = metaObject();
-
3626 if (!name || !meta)
partially evaluated: !name
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:25046
partially evaluated: !meta
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:25046
0-25046
3627 return QVariant();
never executed: return QVariant();
0
3628 -
3629 int id = meta->indexOfProperty(name);
executed (the execution status of this line is deduced): int id = meta->indexOfProperty(name);
-
3630 if (id < 0) {
evaluated: id < 0
TRUEFALSE
yes
Evaluation Count:16645
yes
Evaluation Count:8401
8401-16645
3631 if (!d->extraData)
evaluated: !d->extraData
TRUEFALSE
yes
Evaluation Count:5600
yes
Evaluation Count:11045
5600-11045
3632 return QVariant();
executed: return QVariant();
Execution Count:5600
5600
3633 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);
-
3634 return d->extraData->propertyValues.value(i);
executed: return d->extraData->propertyValues.value(i);
Execution Count:11045
11045
3635 } -
3636 QMetaProperty p = meta->property(id);
executed (the execution status of this line is deduced): QMetaProperty p = meta->property(id);
-
3637#ifndef QT_NO_DEBUG -
3638 if (!p.isReadable()) -
3639 qWarning("%s::property: Property \"%s\" invalid or does not exist", -
3640 metaObject()->className(), name); -
3641#endif -
3642 return p.read(this);
executed: return p.read(this);
Execution Count:8401
8401
3643} -
3644 -
3645/*! -
3646 \since 4.2 -
3647 -
3648 Returns the names of all properties that were dynamically added to -
3649 the object using setProperty(). -
3650*/ -
3651QList<QByteArray> QObject::dynamicPropertyNames() const -
3652{ -
3653 Q_D(const QObject);
executed (the execution status of this line is deduced): const QObjectPrivate * const d = d_func();
-
3654 if (d->extraData)
evaluated: d->extraData
TRUEFALSE
yes
Evaluation Count:188
yes
Evaluation Count:1
1-188
3655 return d->extraData->propertyNames;
executed: return d->extraData->propertyNames;
Execution Count:188
188
3656 return QList<QByteArray>();
executed: return QList<QByteArray>();
Execution Count:1
1
3657} -
3658 -
3659#endif // QT_NO_PROPERTIES -
3660 -
3661 -
3662/***************************************************************************** -
3663 QObject debugging output routines. -
3664 *****************************************************************************/ -
3665 -
3666static void dumpRecursive(int level, QObject *object) -
3667{ -
3668#if defined(QT_DEBUG) -
3669 if (object) { -
3670 QByteArray buf; -
3671 buf.fill(' ', level / 2 * 8); -
3672 if (level % 2) -
3673 buf += " "; -
3674 QString name = object->objectName(); -
3675 QString flags = QLatin1String(""); -
3676#if 0 -
3677 if (qApp->focusWidget() == object) -
3678 flags += 'F'; -
3679 if (object->isWidgetType()) { -
3680 QWidget * w = (QWidget *)object; -
3681 if (w->isVisible()) { -
3682 QString t("<%1,%2,%3,%4>"); -
3683 flags += t.arg(w->x()).arg(w->y()).arg(w->width()).arg(w->height()); -
3684 } else { -
3685 flags += 'I'; -
3686 } -
3687 } -
3688#endif -
3689 qDebug("%s%s::%s %s", (const char*)buf, object->metaObject()->className(), name.toLocal8Bit().data(), -
3690 flags.toLatin1().data()); -
3691 QObjectList children = object->children(); -
3692 if (!children.isEmpty()) { -
3693 for (int i = 0; i < children.size(); ++i) -
3694 dumpRecursive(level+1, children.at(i)); -
3695 } -
3696 } -
3697#else -
3698 Q_UNUSED(level)
never executed (the execution status of this line is deduced): (void)level;
-
3699 Q_UNUSED(object)
never executed (the execution status of this line is deduced): (void)object;
-
3700#endif -
3701}
never executed: }
0
3702 -
3703/*! -
3704 Dumps a tree of children to the debug output. -
3705 -
3706 This function is useful for debugging, but does nothing if the -
3707 library has been compiled in release mode (i.e. without debugging -
3708 information). -
3709 -
3710 \sa dumpObjectInfo() -
3711*/ -
3712 -
3713void QObject::dumpObjectTree() -
3714{ -
3715 dumpRecursive(0, this);
never executed (the execution status of this line is deduced): dumpRecursive(0, this);
-
3716}
never executed: }
0
3717 -
3718/*! -
3719 Dumps information about signal connections, etc. for this object -
3720 to the debug output. -
3721 -
3722 This function is useful for debugging, but does nothing if the -
3723 library has been compiled in release mode (i.e. without debugging -
3724 information). -
3725 -
3726 \sa dumpObjectTree() -
3727*/ -
3728 -
3729void QObject::dumpObjectInfo() -
3730{ -
3731#if defined(QT_DEBUG) -
3732 qDebug("OBJECT %s::%s", metaObject()->className(), -
3733 objectName().isEmpty() ? "unnamed" : objectName().toLocal8Bit().data()); -
3734 -
3735 Q_D(QObject); -
3736 QMutexLocker locker(signalSlotLock(this)); -
3737 -
3738 // first, look for connections where this object is the sender -
3739 qDebug(" SIGNALS OUT"); -
3740 -
3741 if (d->connectionLists) { -
3742 for (int signal_index = 0; signal_index < d->connectionLists->count(); ++signal_index) { -
3743 const QMetaMethod signal = QMetaObjectPrivate::signal(metaObject(), signal_index); -
3744 qDebug(" signal: %s", signal.methodSignature().constData()); -
3745 -
3746 // receivers -
3747 const QObjectPrivate::Connection *c = -
3748 d->connectionLists->at(signal_index).first; -
3749 while (c) { -
3750 if (!c->receiver) { -
3751 qDebug(" <Disconnected receiver>"); -
3752 c = c->nextConnectionList; -
3753 continue; -
3754 } -
3755 const QMetaObject *receiverMetaObject = c->receiver->metaObject(); -
3756 const QMetaMethod method = receiverMetaObject->method(c->method()); -
3757 qDebug(" --> %s::%s %s", -
3758 receiverMetaObject->className(), -
3759 c->receiver->objectName().isEmpty() ? "unnamed" : qPrintable(c->receiver->objectName()), -
3760 method.methodSignature().constData()); -
3761 c = c->nextConnectionList; -
3762 } -
3763 } -
3764 } else { -
3765 qDebug( " <None>" ); -
3766 } -
3767 -
3768 // now look for connections where this object is the receiver -
3769 qDebug(" SIGNALS IN"); -
3770 -
3771 if (d->senders) { -
3772 for (QObjectPrivate::Connection *s = d->senders; s; s = s->next) { -
3773 const QMetaMethod slot = metaObject()->method(s->method()); -
3774 qDebug(" <-- %s::%s %s", -
3775 s->sender->metaObject()->className(), -
3776 s->sender->objectName().isEmpty() ? "unnamed" : qPrintable(s->sender->objectName()), -
3777 slot.methodSignature().constData()); -
3778 } -
3779 } else { -
3780 qDebug(" <None>"); -
3781 } -
3782#endif -
3783} -
3784 -
3785#ifndef QT_NO_USERDATA -
3786/*! -
3787 \internal -
3788 */ -
3789uint QObject::registerUserData() -
3790{ -
3791 static int user_data_registration = 0; -
3792 return user_data_registration++;
executed: return user_data_registration++;
Execution Count:100
100
3793} -
3794 -
3795/*! -
3796 \internal -
3797 */ -
3798QObjectUserData::~QObjectUserData() -
3799{ -
3800} -
3801 -
3802/*! -
3803 \internal -
3804 */ -
3805void QObject::setUserData(uint id, QObjectUserData* data) -
3806{ -
3807 Q_D(QObject);
executed (the execution status of this line is deduced): QObjectPrivate * const d = d_func();
-
3808 if (!d->extraData)
evaluated: !d->extraData
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:99
1-99
3809 d->extraData = new QObjectPrivate::ExtraData;
executed: d->extraData = new QObjectPrivate::ExtraData;
Execution Count:1
1
3810 -
3811 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
3812 d->extraData->userData.resize((int) id + 1);
executed: d->extraData->userData.resize((int) id + 1);
Execution Count:4
4
3813 d->extraData->userData[id] = data;
executed (the execution status of this line is deduced): d->extraData->userData[id] = data;
-
3814}
executed: }
Execution Count:100
100
3815 -
3816/*! -
3817 \internal -
3818 */ -
3819QObjectUserData* QObject::userData(uint id) const -
3820{ -
3821 Q_D(const QObject);
executed (the execution status of this line is deduced): const QObjectPrivate * const d = d_func();
-
3822 if (!d->extraData)
partially evaluated: !d->extraData
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:100
0-100
3823 return 0;
never executed: return 0;
0
3824 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
3825 return d->extraData->userData.at(id);
executed: return d->extraData->userData.at(id);
Execution Count:100
100
3826 return 0;
never executed: return 0;
0
3827} -
3828 -
3829#endif // QT_NO_USERDATA -
3830 -
3831 -
3832#ifndef QT_NO_DEBUG_STREAM -
3833QDebug operator<<(QDebug dbg, const QObject *o) { -
3834 if (!o)
evaluated: !o
TRUEFALSE
yes
Evaluation Count:13
yes
Evaluation Count:33
13-33
3835 return dbg << "QObject(0x0) ";
executed: return dbg << "QObject(0x0) ";
Execution Count:13
13
3836 dbg.nospace() << o->metaObject()->className() << '(' << (void *)o;
executed (the execution status of this line is deduced): dbg.nospace() << o->metaObject()->className() << '(' << (void *)o;
-
3837 if (!o->objectName().isEmpty())
partially evaluated: !o->objectName().isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:33
0-33
3838 dbg << ", name = " << o->objectName();
never executed: dbg << ", name = " << o->objectName();
0
3839 dbg << ')';
executed (the execution status of this line is deduced): dbg << ')';
-
3840 return dbg.space();
executed: return dbg.space();
Execution Count:33
33
3841} -
3842#endif -
3843 -
3844/*! -
3845 \macro Q_CLASSINFO(Name, Value) -
3846 \relates QObject -
3847 -
3848 This macro associates extra information to the class, which is -
3849 available using QObject::metaObject(). Except for the ActiveQt -
3850 extension, Qt doesn't use this information. -
3851 -
3852 The extra information takes the form of a \a Name string and a \a -
3853 Value literal string. -
3854 -
3855 Example: -
3856 -
3857 \snippet code/src_corelib_kernel_qobject.cpp 35 -
3858 -
3859 \sa QMetaObject::classInfo() -
3860*/ -
3861 -
3862/*! -
3863 \macro Q_INTERFACES(...) -
3864 \relates QObject -
3865 -
3866 This macro tells Qt which interfaces the class implements. This -
3867 is used when implementing plugins. -
3868 -
3869 Example: -
3870 -
3871 \snippet ../widgets/tools/plugandpaintplugins/basictools/basictoolsplugin.h 1 -
3872 \dots -
3873 \snippet ../widgets/tools/plugandpaintplugins/basictools/basictoolsplugin.h 3 -
3874 -
3875 See the \l{tools/plugandpaintplugins/basictools}{Plug & Paint -
3876 Basic Tools} example for details. -
3877 -
3878 \sa Q_DECLARE_INTERFACE(), Q_PLUGIN_METADATA(), {How to Create Qt Plugins} -
3879*/ -
3880 -
3881/*! -
3882 \macro Q_PROPERTY(...) -
3883 \relates QObject -
3884 -
3885 This macro is used for declaring properties in classes that -
3886 inherit QObject. Properties behave like class data members, but -
3887 they have additional features accessible through the \l -
3888 {Meta-Object System}. -
3889 -
3890 \snippet code/src_corelib_kernel_qobject.cpp 36 -
3891 -
3892 The property name and type and the \c READ function are required. -
3893 The type can be any type supported by QVariant, or it can be a -
3894 user-defined type. The other items are optional, but a \c WRITE -
3895 function is common. The attributes default to true except \c USER, -
3896 which defaults to false. -
3897 -
3898 For example: -
3899 -
3900 \snippet code/src_corelib_kernel_qobject.cpp 37 -
3901 -
3902 For more details about how to use this macro, and a more detailed -
3903 example of its use, see the discussion on \l {Qt's Property System}. -
3904 -
3905 \sa {Qt's Property System} -
3906*/ -
3907 -
3908/*! -
3909 \macro Q_ENUMS(...) -
3910 \relates QObject -
3911 -
3912 This macro registers one or several enum types to the meta-object -
3913 system. -
3914 -
3915 For example: -
3916 -
3917 \snippet code/src_corelib_kernel_qobject.cpp 38 -
3918 -
3919 If you want to register an enum that is declared in another class, -
3920 the enum must be fully qualified with the name of the class -
3921 defining it. In addition, the class \e defining the enum has to -
3922 inherit QObject as well as declare the enum using Q_ENUMS(). -
3923 -
3924 \sa {Qt's Property System} -
3925*/ -
3926 -
3927/*! -
3928 \macro Q_FLAGS(...) -
3929 \relates QObject -
3930 -
3931 This macro registers one or several \l{QFlags}{flags types} to the -
3932 meta-object system. It is typically used in a class definition to declare -
3933 that values of a given enum can be used as flags and combined using the -
3934 bitwise OR operator. -
3935 -
3936 For example, in QLibrary, the \l{QLibrary::LoadHints}{LoadHints} flag is -
3937 declared in the following way: -
3938 -
3939 \snippet code/src_corelib_kernel_qobject.cpp 39a -
3940 -
3941 The declaration of the flags themselves is performed in the public section -
3942 of the QLibrary class itself, using the \l Q_DECLARE_FLAGS() macro: -
3943 -
3944 \snippet code/src_corelib_kernel_qobject.cpp 39b -
3945 -
3946 \note This macro takes care of registering individual flag values -
3947 with the meta-object system, so it is unnecessary to use Q_ENUMS() -
3948 in addition to this macro. -
3949 -
3950 \sa {Qt's Property System} -
3951*/ -
3952 -
3953/*! -
3954 \macro Q_OBJECT -
3955 \relates QObject -
3956 -
3957 The Q_OBJECT macro must appear in the private section of a class -
3958 definition that declares its own signals and slots or that uses -
3959 other services provided by Qt's meta-object system. -
3960 -
3961 For example: -
3962 -
3963 \snippet signalsandslots/signalsandslots.h 1 -
3964 \codeline -
3965 \snippet signalsandslots/signalsandslots.h 2 -
3966 \snippet signalsandslots/signalsandslots.h 3 -
3967 -
3968 \note This macro requires the class to be a subclass of QObject. Use -
3969 Q_GADGET instead of Q_OBJECT to enable the meta object system's support -
3970 for enums in a class that is not a QObject subclass. Q_GADGET makes a -
3971 class member, \c{staticMetaObject}, available. -
3972 \c{staticMetaObject} is of type QMetaObject and provides access to the -
3973 enums declared with Q_ENUMS. -
3974 Q_GADGET is provided only for C++. -
3975 -
3976 \sa {Meta-Object System}, {Signals and Slots}, {Qt's Property System} -
3977*/ -
3978 -
3979/*! -
3980 \macro Q_SIGNALS -
3981 \relates QObject -
3982 -
3983 Use this macro to replace the \c signals keyword in class -
3984 declarations, when you want to use Qt Signals and Slots with a -
3985 \l{3rd Party Signals and Slots} {3rd party signal/slot mechanism}. -
3986 -
3987 The macro is normally used when \c no_keywords is specified with -
3988 the \c CONFIG variable in the \c .pro file, but it can be used -
3989 even when \c no_keywords is \e not specified. -
3990*/ -
3991 -
3992/*! -
3993 \macro Q_SIGNAL -
3994 \relates QObject -
3995 -
3996 This is an additional macro that allows you to mark a single -
3997 function as a signal. It can be quite useful, especially when you -
3998 use a 3rd-party source code parser which doesn't understand a \c -
3999 signals or \c Q_SIGNALS groups. -
4000 -
4001 Use this macro to replace the \c signals keyword in class -
4002 declarations, when you want to use Qt Signals and Slots with a -
4003 \l{3rd Party Signals and Slots} {3rd party signal/slot mechanism}. -
4004 -
4005 The macro is normally used when \c no_keywords is specified with -
4006 the \c CONFIG variable in the \c .pro file, but it can be used -
4007 even when \c no_keywords is \e not specified. -
4008*/ -
4009 -
4010/*! -
4011 \macro Q_SLOTS -
4012 \relates QObject -
4013 -
4014 Use this macro to replace the \c slots keyword in class -
4015 declarations, when you want to use Qt Signals and Slots with a -
4016 \l{3rd Party Signals and Slots} {3rd party signal/slot mechanism}. -
4017 -
4018 The macro is normally used when \c no_keywords is specified with -
4019 the \c CONFIG variable in the \c .pro file, but it can be used -
4020 even when \c no_keywords is \e not specified. -
4021*/ -
4022 -
4023/*! -
4024 \macro Q_SLOT -
4025 \relates QObject -
4026 -
4027 This is an additional macro that allows you to mark a single -
4028 function as a slot. It can be quite useful, especially when you -
4029 use a 3rd-party source code parser which doesn't understand a \c -
4030 slots or \c Q_SLOTS groups. -
4031 -
4032 Use this macro to replace the \c slots keyword in class -
4033 declarations, when you want to use Qt Signals and Slots with a -
4034 \l{3rd Party Signals and Slots} {3rd party signal/slot mechanism}. -
4035 -
4036 The macro is normally used when \c no_keywords is specified with -
4037 the \c CONFIG variable in the \c .pro file, but it can be used -
4038 even when \c no_keywords is \e not specified. -
4039*/ -
4040 -
4041/*! -
4042 \macro Q_EMIT -
4043 \relates QObject -
4044 -
4045 Use this macro to replace the \c emit keyword for emitting -
4046 signals, when you want to use Qt Signals and Slots with a -
4047 \l{3rd Party Signals and Slots} {3rd party signal/slot mechanism}. -
4048 -
4049 The macro is normally used when \c no_keywords is specified with -
4050 the \c CONFIG variable in the \c .pro file, but it can be used -
4051 even when \c no_keywords is \e not specified. -
4052*/ -
4053 -
4054/*! -
4055 \macro Q_INVOKABLE -
4056 \relates QObject -
4057 -
4058 Apply this macro to definitions of member functions to allow them to -
4059 be invoked via the meta-object system. The macro is written before -
4060 the return type, as shown in the following example: -
4061 -
4062 \snippet qmetaobject-invokable/window.h Window class with invokable method -
4063 -
4064 The \c invokableMethod() function is marked up using Q_INVOKABLE, causing -
4065 it to be registered with the meta-object system and enabling it to be -
4066 invoked using QMetaObject::invokeMethod(). -
4067 Since \c normalMethod() function is not registered in this way, it cannot -
4068 be invoked using QMetaObject::invokeMethod(). -
4069*/ -
4070 -
4071/*! -
4072 \macro Q_SET_OBJECT_NAME(Object) -
4073 \relates QObject -
4074 \since 5.0 -
4075 -
4076 This macro assigns \a Object the objectName "Object". -
4077 -
4078 It doesn't matter whether \a Object is a pointer or not, the -
4079 macro figures that out by itself. -
4080 -
4081 \sa QObject::objectName() -
4082*/ -
4083 -
4084/*! -
4085 \typedef QObjectList -
4086 \relates QObject -
4087 -
4088 Synonym for QList<QObject *>. -
4089*/ -
4090 -
4091void qDeleteInEventHandler(QObject *o) -
4092{ -
4093 delete o;
executed (the execution status of this line is deduced): delete o;
-
4094}
executed: }
Execution Count:18530
18530
4095 -
4096/*! -
4097 \fn QMetaObject::Connection QObject::connect(const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type) -
4098 \overload connect() -
4099 \threadsafe -
4100 -
4101 Creates a connection of the given \a type from the \a signal in -
4102 the \a sender object to the \a method in the \a receiver object. -
4103 Returns a handle to the connection that can be used to disconnect -
4104 it later. -
4105 -
4106 The signal must be a function declared as a signal in the header. -
4107 The slot function can be any member function that can be connected -
4108 to the signal. -
4109 A slot can be connected to a given signal if the signal has at -
4110 least as many arguments as the slot, and there is an implicit -
4111 conversion between the types of the corresponding arguments in the -
4112 signal and the slot. -
4113 -
4114 Example: -
4115 -
4116 \snippet code/src_corelib_kernel_qobject.cpp 44 -
4117 -
4118 This example ensures that the label always displays the current -
4119 line edit text. -
4120 -
4121 A signal can be connected to many slots and signals. Many signals -
4122 can be connected to one slot. -
4123 -
4124 If a signal is connected to several slots, the slots are activated -
4125 in the same order as the order the connection was made, when the -
4126 signal is emitted -
4127 -
4128 The function returns an handle to a connection if it successfully -
4129 connects the signal to the slot. The Connection handle will be invalid -
4130 if it cannot create the connection, for example, if QObject is unable -
4131 to verify the existence of \a signal (if it was not declared as a signal) -
4132 You can check if the QMetaObject::Connection is valid by casting it to a bool. -
4133 -
4134 By default, a signal is emitted for every connection you make; -
4135 two signals are emitted for duplicate connections. You can break -
4136 all of these connections with a single disconnect() call. -
4137 If you pass the Qt::UniqueConnection \a type, the connection will only -
4138 be made if it is not a duplicate. If there is already a duplicate -
4139 (exact same signal to the exact same slot on the same objects), -
4140 the connection will fail and connect will return an invalid QMetaObject::Connection. -
4141 -
4142 The optional \a type parameter describes the type of connection -
4143 to establish. In particular, it determines whether a particular -
4144 signal is delivered to a slot immediately or queued for delivery -
4145 at a later time. If the signal is queued, the parameters must be -
4146 of types that are known to Qt's meta-object system, because Qt -
4147 needs to copy the arguments to store them in an event behind the -
4148 scenes. If you try to use a queued connection and get the error -
4149 message -
4150 -
4151 \snippet code/src_corelib_kernel_qobject.cpp 25 -
4152 -
4153 make sure to declare the argument type with Q_DECLARE_METATYPE -
4154 */ -
4155 -
4156 -
4157/*! -
4158 \fn QMetaObject::Connection QObject::connect(const QObject *sender, PointerToMemberFunction signal, Functor functor) -
4159 -
4160 \threadsafe -
4161 \overload connect() -
4162 -
4163 Creates a connection from \a signal in -
4164 \a sender object to \a functor, and returns a handle to the connection -
4165 -
4166 The signal must be a function declared as a signal in the header. -
4167 The slot function can be any function or functor that can be connected -
4168 to the signal. -
4169 A function can be connected to a given signal if the signal as at -
4170 least as many argument as the slot. A functor can be connected to a signal -
4171 if they have exactly the same number of arguments. There must exist implicit -
4172 conversion between the types of the corresponding arguments in the -
4173 signal and the slot. -
4174 -
4175 Example: -
4176 -
4177 \snippet code/src_corelib_kernel_qobject.cpp 45 -
4178 -
4179 If your compiler support C++11 lambda expressions, you can use them: -
4180 -
4181 \snippet code/src_corelib_kernel_qobject.cpp 46 -
4182 -
4183 The connection will automatically disconnect if the sender is destroyed. -
4184 */ -
4185 -
4186/** -
4187 \internal -
4188 -
4189 Implementation of the template version of connect -
4190 -
4191 \a sender is the sender object -
4192 \a signal is a pointer to a pointer to a member signal of the sender -
4193 \a receiver is the receiver object, may not be null, will be equal to sender when -
4194 connecting to a static function or a functor -
4195 \a slot a pointer only used when using Qt::UniqueConnection -
4196 \a type the Qt::ConnctionType passed as argument to connect -
4197 \a types an array of integer with the metatype id of the parametter of the signal -
4198 to be used with queued connection -
4199 must stay valid at least for the whole time of the connection, this function -
4200 do not take ownership. typically static data. -
4201 If null, then the types will be computed when the signal is emit in a queued -
4202 connection from the types from the signature. -
4203 \a senderMetaObject is the metaobject used to lookup the signal, the signal must be in -
4204 this metaobject -
4205 */ -
4206QMetaObject::Connection QObject::connectImpl(const QObject *sender, void **signal, -
4207 const QObject *receiver, void **slot, -
4208 QtPrivate::QSlotObjectBase *slotObj, Qt::ConnectionType type, -
4209 const int *types, const QMetaObject *senderMetaObject) -
4210{ -
4211 if (!sender || !signal || !slotObj || !senderMetaObject) {
partially evaluated: !sender
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4007
partially evaluated: !signal
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4007
partially evaluated: !slotObj
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4007
partially evaluated: !senderMetaObject
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4007
0-4007
4212 qWarning("QObject::connect: invalid null parametter");
never executed (the execution status of this line is deduced): QMessageLogger("kernel/qobject.cpp", 4212, __PRETTY_FUNCTION__).warning("QObject::connect: invalid null parametter");
-
4213 if (slotObj)
never evaluated: slotObj
0
4214 slotObj->destroyIfLastRef();
never executed: slotObj->destroyIfLastRef();
0
4215 return QMetaObject::Connection();
never executed: return QMetaObject::Connection();
0
4216 } -
4217 int signal_index = -1;
executed (the execution status of this line is deduced): int signal_index = -1;
-
4218 void *args[] = { &signal_index, signal };
executed (the execution status of this line is deduced): void *args[] = { &signal_index, signal };
-
4219 senderMetaObject->static_metacall(QMetaObject::IndexOfMethod, 0, args);
executed (the execution status of this line is deduced): senderMetaObject->static_metacall(QMetaObject::IndexOfMethod, 0, args);
-
4220 if (signal_index < 0 || signal_index >= QMetaObjectPrivate::get(senderMetaObject)->signalCount) {
evaluated: signal_index < 0
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:4005
partially evaluated: signal_index >= QMetaObjectPrivate::get(senderMetaObject)->signalCount
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4005
0-4005
4221 qWarning("QObject::connect: signal not found in %s", senderMetaObject->className());
executed (the execution status of this line is deduced): QMessageLogger("kernel/qobject.cpp", 4221, __PRETTY_FUNCTION__).warning("QObject::connect: signal not found in %s", senderMetaObject->className());
-
4222 slotObj->destroyIfLastRef();
executed (the execution status of this line is deduced): slotObj->destroyIfLastRef();
-
4223 return QMetaObject::Connection(0);
executed: return QMetaObject::Connection(0);
Execution Count:2
2
4224 } -
4225 signal_index += QMetaObjectPrivate::signalOffset(senderMetaObject);
executed (the execution status of this line is deduced): signal_index += QMetaObjectPrivate::signalOffset(senderMetaObject);
-
4226 -
4227 QObject *s = const_cast<QObject *>(sender);
executed (the execution status of this line is deduced): QObject *s = const_cast<QObject *>(sender);
-
4228 QObject *r = const_cast<QObject *>(receiver);
executed (the execution status of this line is deduced): QObject *r = const_cast<QObject *>(receiver);
-
4229 -
4230 QOrderedMutexLocker locker(signalSlotLock(sender),
executed (the execution status of this line is deduced): QOrderedMutexLocker locker(signalSlotLock(sender),
-
4231 signalSlotLock(receiver));
executed (the execution status of this line is deduced): signalSlotLock(receiver));
-
4232 -
4233 if (type & Qt::UniqueConnection) {
evaluated: type & Qt::UniqueConnection
TRUEFALSE
yes
Evaluation Count:11
yes
Evaluation Count:3994
11-3994
4234 QObjectConnectionListVector *connectionLists = QObjectPrivate::get(s)->connectionLists;
executed (the execution status of this line is deduced): QObjectConnectionListVector *connectionLists = QObjectPrivate::get(s)->connectionLists;
-
4235 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
4236 const QObjectPrivate::Connection *c2 =
executed (the execution status of this line is deduced): const QObjectPrivate::Connection *c2 =
-
4237 (*connectionLists)[signal_index].first;
executed (the execution status of this line is deduced): (*connectionLists)[signal_index].first;
-
4238 -
4239 while (c2) {
evaluated: c2
TRUEFALSE
yes
Evaluation Count:11
yes
Evaluation Count:4
4-11
4240 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
4241 slotObj->destroyIfLastRef();
executed (the execution status of this line is deduced): slotObj->destroyIfLastRef();
-
4242 return QMetaObject::Connection();
executed: return QMetaObject::Connection();
Execution Count:3
3
4243 } -
4244 c2 = c2->nextConnectionList;
executed (the execution status of this line is deduced): c2 = c2->nextConnectionList;
-
4245 }
executed: }
Execution Count:8
8
4246 }
executed: }
Execution Count:4
4
4247 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);
-
4248 }
executed: }
Execution Count:8
8
4249 -
4250 QScopedPointer<QObjectPrivate::Connection> c(new QObjectPrivate::Connection);
executed (the execution status of this line is deduced): QScopedPointer<QObjectPrivate::Connection> c(new QObjectPrivate::Connection);
-
4251 c->sender = s;
executed (the execution status of this line is deduced): c->sender = s;
-
4252 c->signal_index = signal_index;
executed (the execution status of this line is deduced): c->signal_index = signal_index;
-
4253 c->receiver = r;
executed (the execution status of this line is deduced): c->receiver = r;
-
4254 c->slotObj = slotObj;
executed (the execution status of this line is deduced): c->slotObj = slotObj;
-
4255 c->connectionType = type;
executed (the execution status of this line is deduced): c->connectionType = type;
-
4256 c->isSlotObject = true;
executed (the execution status of this line is deduced): c->isSlotObject = true;
-
4257 if (types) {
evaluated: types
TRUEFALSE
yes
Evaluation Count:35
yes
Evaluation Count:3967
35-3967
4258 c->argumentTypes.store(types);
executed (the execution status of this line is deduced): c->argumentTypes.store(types);
-
4259 c->ownArgumentTypes = false;
executed (the execution status of this line is deduced): c->ownArgumentTypes = false;
-
4260 }
executed: }
Execution Count:35
35
4261 -
4262 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());
-
4263 QMetaObject::Connection ret(c.take());
executed (the execution status of this line is deduced): QMetaObject::Connection ret(c.take());
-
4264 locker.unlock();
executed (the execution status of this line is deduced): locker.unlock();
-
4265 -
4266 QMetaMethod method = QMetaObjectPrivate::signal(senderMetaObject, signal_index);
executed (the execution status of this line is deduced): QMetaMethod method = QMetaObjectPrivate::signal(senderMetaObject, signal_index);
-
4267 Q_ASSERT(method.isValid());
executed (the execution status of this line is deduced): qt_noop();
-
4268 s->connectNotify(method);
executed (the execution status of this line is deduced): s->connectNotify(method);
-
4269 -
4270 return ret;
executed: return ret;
Execution Count:4002
4002
4271} -
4272 -
4273/*! -
4274 Disconnect a connection. -
4275 -
4276 If the \a connection is invalid or has already been disconnected, do nothing -
4277 and return false. -
4278 -
4279 \sa connect() -
4280 */ -
4281bool QObject::disconnect(const QMetaObject::Connection &connection) -
4282{ -
4283 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);
-
4284 -
4285 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
4286 return false;
executed: return false;
Execution Count:3
3
4287 -
4288 QMutex *senderMutex = signalSlotLock(c->sender);
executed (the execution status of this line is deduced): QMutex *senderMutex = signalSlotLock(c->sender);
-
4289 QMutex *receiverMutex = signalSlotLock(c->receiver);
executed (the execution status of this line is deduced): QMutex *receiverMutex = signalSlotLock(c->receiver);
-
4290 QOrderedMutexLocker locker(senderMutex, receiverMutex);
executed (the execution status of this line is deduced): QOrderedMutexLocker locker(senderMutex, receiverMutex);
-
4291 -
4292 QObjectConnectionListVector *connectionLists = QObjectPrivate::get(c->sender)->connectionLists;
executed (the execution status of this line is deduced): QObjectConnectionListVector *connectionLists = QObjectPrivate::get(c->sender)->connectionLists;
-
4293 Q_ASSERT(connectionLists);
executed (the execution status of this line is deduced): qt_noop();
-
4294 connectionLists->dirty = true;
executed (the execution status of this line is deduced): connectionLists->dirty = true;
-
4295 -
4296 *c->prev = c->next;
executed (the execution status of this line is deduced): *c->prev = c->next;
-
4297 if (c->next)
evaluated: c->next
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:7
1-7
4298 c->next->prev = c->prev;
executed: c->next->prev = c->prev;
Execution Count:1
1
4299 c->receiver = 0;
executed (the execution status of this line is deduced): c->receiver = 0;
-
4300 -
4301 // destroy the QSlotObject, if possible -
4302 if (c->isSlotObject) {
partially evaluated: c->isSlotObject
TRUEFALSE
yes
Evaluation Count:8
no
Evaluation Count:0
0-8
4303 c->slotObj->destroyIfLastRef();
executed (the execution status of this line is deduced): c->slotObj->destroyIfLastRef();
-
4304 c->isSlotObject = false;
executed (the execution status of this line is deduced): c->isSlotObject = false;
-
4305 }
executed: }
Execution Count:8
8
4306 -
4307 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;
-
4308 c->deref(); // has been removed from the QMetaObject::Connection object
executed (the execution status of this line is deduced): c->deref();
-
4309 -
4310 // disconnectNotify() not called (the signal index is unknown). -
4311 -
4312 return true;
executed: return true;
Execution Count:8
8
4313} -
4314 -
4315/*! \fn bool QObject::disconnect(const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method) -
4316 \overload diconnect() -
4317 \threadsafe -
4318 -
4319 Disconnects \a signal in object \a sender from \a method in object -
4320 \a receiver. Returns true if the connection is successfully broken; -
4321 otherwise returns false. -
4322 -
4323 A signal-slot connection is removed when either of the objects -
4324 involved are destroyed. -
4325 -
4326 disconnect() is typically used in three ways, as the following -
4327 examples demonstrate. -
4328 \list 1 -
4329 \li Disconnect everything connected to an object's signals: -
4330 -
4331 \snippet code/src_corelib_kernel_qobject.cpp 26 -
4332 -
4333 \li Disconnect everything connected to a specific signal: -
4334 -
4335 \snippet code/src_corelib_kernel_qobject.cpp 47 -
4336 -
4337 \li Disconnect a specific receiver: -
4338 -
4339 \snippet code/src_corelib_kernel_qobject.cpp 30 -
4340 -
4341 \li Disconnect a connection from one specific signal to a specific slot: -
4342 -
4343 \snippet code/src_corelib_kernel_qobject.cpp 48 -
4344 -
4345 -
4346 \endlist -
4347 -
4348 0 may be used as a wildcard, meaning "any signal", "any receiving -
4349 object", or "any slot in the receiving object", respectively. -
4350 -
4351 The \a sender may never be 0. (You cannot disconnect signals from -
4352 more than one object in a single call.) -
4353 -
4354 If \a signal is 0, it disconnects \a receiver and \a method from -
4355 any signal. If not, only the specified signal is disconnected. -
4356 -
4357 If \a receiver is 0, it disconnects anything connected to \a -
4358 signal. If not, slots in objects other than \a receiver are not -
4359 disconnected. -
4360 -
4361 If \a method is 0, it disconnects anything that is connected to \a -
4362 receiver. If not, only slots named \a method will be disconnected, -
4363 and all other slots are left alone. The \a method must be 0 if \a -
4364 receiver is left out, so you cannot disconnect a -
4365 specifically-named slot on all objects. -
4366 -
4367 \note It is not possible to use this overload to diconnect signals -
4368 connected to functors or lambda expressions. That is because it is not -
4369 possible to compare them. Instead, use the olverload that take a -
4370 QMetaObject::Connection -
4371 -
4372 \sa connect() -
4373*/ -
4374 -
4375bool QObject::disconnectImpl(const QObject *sender, void **signal, const QObject *receiver, void **slot, const QMetaObject *senderMetaObject) -
4376{ -
4377 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
4378 qWarning("QObject::disconnect: Unexpected null parameter");
never executed (the execution status of this line is deduced): QMessageLogger("kernel/qobject.cpp", 4378, __PRETTY_FUNCTION__).warning("QObject::disconnect: Unexpected null parameter");
-
4379 return false;
never executed: return false;
0
4380 } -
4381 -
4382 int signal_index = -1;
executed (the execution status of this line is deduced): int signal_index = -1;
-
4383 if (signal) {
partially evaluated: signal
TRUEFALSE
yes
Evaluation Count:9
no
Evaluation Count:0
0-9
4384 void *args[] = { &signal_index, signal };
executed (the execution status of this line is deduced): void *args[] = { &signal_index, signal };
-
4385 senderMetaObject->static_metacall(QMetaObject::IndexOfMethod, 0, args);
executed (the execution status of this line is deduced): senderMetaObject->static_metacall(QMetaObject::IndexOfMethod, 0, args);
-
4386 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
4387 qWarning("QObject::disconnect: signal not found in %s", senderMetaObject->className());
never executed (the execution status of this line is deduced): QMessageLogger("kernel/qobject.cpp", 4387, __PRETTY_FUNCTION__).warning("QObject::disconnect: signal not found in %s", senderMetaObject->className());
-
4388 return false;
never executed: return false;
0
4389 } -
4390 signal_index += QMetaObjectPrivate::signalOffset(senderMetaObject);
executed (the execution status of this line is deduced): signal_index += QMetaObjectPrivate::signalOffset(senderMetaObject);
-
4391 }
executed: }
Execution Count:9
9
4392 -
4393 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
4394} -
4395 -
4396/*! \class QMetaObject::Connection -
4397 \inmodule QtCore -
4398 Represents a handle to a signal-slot connection. -
4399 It can be used to disconnect that connection, or check if -
4400 the connection was successful -
4401 -
4402 \sa QObject::disconnect -
4403 */ -
4404 -
4405/*! -
4406 Create a copy of the handle to the connection -
4407 */ -
4408QMetaObject::Connection::Connection(const QMetaObject::Connection &other) : d_ptr(other.d_ptr) -
4409{ -
4410 if (d_ptr)
never evaluated: d_ptr
0
4411 static_cast<QObjectPrivate::Connection *>(d_ptr)->ref();
never executed: static_cast<QObjectPrivate::Connection *>(d_ptr)->ref();
0
4412}
never executed: }
0
4413 -
4414QMetaObject::Connection& QMetaObject::Connection::operator=(const QMetaObject::Connection& other) -
4415{ -
4416 if (other.d_ptr != d_ptr) {
evaluated: other.d_ptr != d_ptr
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:1
1-6
4417 if (d_ptr)
evaluated: d_ptr
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:5
1-5
4418 static_cast<QObjectPrivate::Connection *>(d_ptr)->deref();
executed: static_cast<QObjectPrivate::Connection *>(d_ptr)->deref();
Execution Count:1
1
4419 d_ptr = other.d_ptr;
executed (the execution status of this line is deduced): d_ptr = other.d_ptr;
-
4420 if (other.d_ptr)
evaluated: other.d_ptr
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:1
1-5
4421 static_cast<QObjectPrivate::Connection *>(other.d_ptr)->ref();
executed: static_cast<QObjectPrivate::Connection *>(other.d_ptr)->ref();
Execution Count:5
5
4422 }
executed: }
Execution Count:6
6
4423 return *this;
executed: return *this;
Execution Count:7
7
4424} -
4425 -
4426QMetaObject::Connection::Connection() : d_ptr(0) {}
executed: }
Execution Count:7
7
4427 -
4428QMetaObject::Connection::~Connection() -
4429{ -
4430 if (d_ptr)
evaluated: d_ptr
TRUEFALSE
yes
Evaluation Count:490308
yes
Evaluation Count:385629
385629-490308
4431 static_cast<QObjectPrivate::Connection *>(d_ptr)->deref();
executed: static_cast<QObjectPrivate::Connection *>(d_ptr)->deref();
Execution Count:490308
490308
4432}
executed: }
Execution Count:875925
875925
4433 -
4434/*! -
4435 \fn QMetaObject::Connection::operator bool() const -
4436 -
4437 Returns true if the connection is valid. -
4438 -
4439 The connection is valid if the call to QObject::connect succeeded. -
4440 The connection is invalid if QObject::connect was not able to find -
4441 the signal or the slot, or if the arguments do not match. -
4442 */ -
4443 -
4444QT_END_NAMESPACE -
4445 -
4446#include "moc_qobject.cpp" -
4447 -
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial