qdbusconnection.cpp

Switch to Source codePreprocessed file
LineSource CodeCoverage
1 -
2 -
3 -
4 -
5 -
6 -
7 -
8 -
9 -
10 -
11static QDBusConnectionManager *_q_manager() { static QGlobalStatic<QDBusConnectionManager > thisGlobalStatic = { { (0) }, false }; if (!thisGlobalStatic.pointer.load() && !thisGlobalStatic.destroyed) { QDBusConnectionManager *x = new QDBusConnectionManager; if (!thisGlobalStatic.pointer.testAndSetOrdered(0, x)) delete x; else static QGlobalStaticDeleter<QDBusConnectionManager > cleanup(thisGlobalStatic); } return thisGlobalStatic.pointer.load(); }
never executed: delete x;
executed: return thisGlobalStatic.pointer.load();
Execution Count:2244
partially evaluated: !thisGlobalStatic.pointer.testAndSetOrdered(0, x)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:13
evaluated: !thisGlobalStatic.pointer.load()
TRUEFALSE
yes
Evaluation Count:13
yes
Evaluation Count:2231
partially evaluated: !thisGlobalStatic.destroyed
TRUEFALSE
yes
Evaluation Count:13
no
Evaluation Count:0
0-2244
12 -
13QDBusConnectionPrivate *QDBusConnectionManager::sender() const -
14{ -
15 QMutexLocker locker(&senderMutex); -
16 return connection(senderName);
executed: return connection(senderName);
Execution Count:10
10
17} -
18 -
19void QDBusConnectionManager::setSender(const QDBusConnectionPrivate *s) -
20{ -
21 QMutexLocker locker(&senderMutex); -
22 senderName = (s ? s->name : QString());
evaluated: s
TRUEFALSE
yes
Evaluation Count:395
yes
Evaluation Count:395
395
23}
executed: }
Execution Count:790
790
24 -
25QDBusConnectionPrivate *QDBusConnectionManager::connection(const QString &name) const -
26{ -
27 return connectionHash.value(name, 0);
executed: return connectionHash.value(name, 0);
Execution Count:474
474
28} -
29 -
30void QDBusConnectionManager::removeConnection(const QString &name) -
31{ -
32 QDBusConnectionPrivate *d = 0; -
33 d = connectionHash.take(name); -
34 if (d && !d->ref.deref())
partially evaluated: d
TRUEFALSE
yes
Evaluation Count:163
no
Evaluation Count:0
evaluated: !d->ref.deref()
TRUEFALSE
yes
Evaluation Count:142
yes
Evaluation Count:21
0-163
35 d->deleteYourself();
executed: d->deleteYourself();
Execution Count:142
142
36 -
37 -
38 -
39 -
40 -
41 -
42}
executed: }
Execution Count:163
163
43 -
44QDBusConnectionManager::~QDBusConnectionManager() -
45{ -
46 for (QHash<QString, QDBusConnectionPrivate *>::const_iterator it = connectionHash.constBegin(); -
47 it != connectionHash.constEnd(); ++it) {
evaluated: it != connectionHash.constEnd()
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:13
7-13
48 QDBusConnectionPrivate *d = it.value(); -
49 if (!d->ref.deref())
partially evaluated: !d->ref.deref()
TRUEFALSE
yes
Evaluation Count:7
no
Evaluation Count:0
0-7
50 d->deleteYourself();
executed: d->deleteYourself();
Execution Count:7
7
51 else -
52 d->closeConnection();
never executed: d->closeConnection();
0
53 } -
54 connectionHash.clear(); -
55}
executed: }
Execution Count:13
13
56 -
57QDBusConnectionManager* QDBusConnectionManager::instance() -
58{ -
59 return _q_manager();
executed: return _q_manager();
Execution Count:67
67
60} -
61 -
62__attribute__((visibility("default"))) void qDBusBindToApplication(); -
63void qDBusBindToApplication() -
64{ -
65} -
66 -
67void QDBusConnectionManager::setConnection(const QString &name, QDBusConnectionPrivate *c) -
68{ -
69 connectionHash[name] = c; -
70 c->name = name; -
71}
executed: }
Execution Count:170
170
72QDBusConnection::QDBusConnection(const QString &name) -
73{ -
74 if (name.isEmpty()) {
evaluated: name.isEmpty()
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:160
3-160
75 d = 0; -
76 } else {
executed: }
Execution Count:3
3
77 QMutexLocker locker(&_q_manager()->mutex); -
78 d = _q_manager()->connection(name); -
79 if (d)
evaluated: d
TRUEFALSE
yes
Evaluation Count:134
yes
Evaluation Count:26
26-134
80 d->ref.ref();
executed: d->ref.ref();
Execution Count:134
134
81 }
executed: }
Execution Count:160
160
82} -
83 -
84 -
85 -
86 -
87QDBusConnection::QDBusConnection(const QDBusConnection &other) -
88{ -
89 d = other.d; -
90 if (d)
evaluated: d
TRUEFALSE
yes
Evaluation Count:1717
yes
Evaluation Count:4
4-1717
91 d->ref.ref();
executed: d->ref.ref();
Execution Count:1717
1717
92}
executed: }
Execution Count:1721
1721
93 -
94 -
95 -
96 -
97 -
98QDBusConnection::QDBusConnection(QDBusConnectionPrivate *dd) -
99{ -
100 d = dd; -
101 if (d)
partially evaluated: d
TRUEFALSE
yes
Evaluation Count:752
no
Evaluation Count:0
0-752
102 d->ref.ref();
executed: d->ref.ref();
Execution Count:752
752
103}
executed: }
Execution Count:752
752
104 -
105 -
106 -
107 -
108 -
109QDBusConnection::~QDBusConnection() -
110{ -
111 if (d && !d->ref.deref())
evaluated: d
TRUEFALSE
yes
Evaluation Count:2606
yes
Evaluation Count:29
evaluated: !d->ref.deref()
TRUEFALSE
yes
Evaluation Count:21
yes
Evaluation Count:2585
21-2606
112 d->deleteYourself();
executed: d->deleteYourself();
Execution Count:21
21
113}
executed: }
Execution Count:2635
2635
114QDBusConnection &QDBusConnection::operator=(const QDBusConnection &other) -
115{ -
116 if (other.d)
partially evaluated: other.d
TRUEFALSE
yes
Evaluation Count:10
no
Evaluation Count:0
0-10
117 other.d->ref.ref();
executed: other.d->ref.ref();
Execution Count:10
10
118 if (d && !d->ref.deref())
evaluated: d
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:4
partially evaluated: !d->ref.deref()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6
0-6
119 d->deleteYourself();
never executed: d->deleteYourself();
0
120 d = other.d; -
121 return *this;
executed: return *this;
Execution Count:10
10
122} -
123 -
124 -
125 -
126 -
127 -
128 -
129QDBusConnection QDBusConnection::connectToBus(BusType type, const QString &name) -
130{ -
131 -
132 -
133 if (!qdbus_loadLibDBus()) {
partially evaluated: !qdbus_loadLibDBus()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:25
0-25
134 QDBusConnectionPrivate *d = 0; -
135 return QDBusConnection(d);
never executed: return QDBusConnection(d);
0
136 } -
137 -
138 QMutexLocker locker(&_q_manager()->mutex); -
139 -
140 QDBusConnectionPrivate *d = _q_manager()->connection(name); -
141 if (d || name.isEmpty())
evaluated: d
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:24
partially evaluated: name.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:24
0-24
142 return QDBusConnection(d);
executed: return QDBusConnection(d);
Execution Count:1
1
143 -
144 d = new QDBusConnectionPrivate; -
145 DBusConnection *c = 0; -
146 QDBusErrorInternal error; -
147 switch (type) { -
148 case SystemBus: -
149 c = q_dbus_bus_get_private(DBUS_BUS_SYSTEM, error); -
150 break;
never executed: break;
0
151 case SessionBus: -
152 c = q_dbus_bus_get_private(DBUS_BUS_SESSION, error); -
153 break;
executed: break;
Execution Count:24
24
154 case ActivationBus: -
155 c = q_dbus_bus_get_private(DBUS_BUS_STARTER, error); -
156 break;
never executed: break;
0
157 } -
158 d->setConnection(c, error); -
159 -
160 _q_manager()->setConnection(name, d); -
161 -
162 QDBusConnection retval(d); -
163 -
164 -
165 -
166 d->setBusService(retval); -
167 -
168 return retval;
executed: return retval;
Execution Count:24
24
169} -
170 -
171 -
172 -
173 -
174 -
175QDBusConnection QDBusConnection::connectToBus(const QString &address, -
176 const QString &name) -
177{ -
178 -
179 -
180 if (!qdbus_loadLibDBus()) {
partially evaluated: !qdbus_loadLibDBus()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
181 QDBusConnectionPrivate *d = 0; -
182 return QDBusConnection(d);
never executed: return QDBusConnection(d);
0
183 } -
184 -
185 QMutexLocker locker(&_q_manager()->mutex); -
186 -
187 QDBusConnectionPrivate *d = _q_manager()->connection(name); -
188 if (d || name.isEmpty())
partially evaluated: d
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
partially evaluated: name.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
189 return QDBusConnection(d);
never executed: return QDBusConnection(d);
0
190 -
191 d = new QDBusConnectionPrivate; -
192 -
193 QDBusErrorInternal error; -
194 DBusConnection *c = q_dbus_connection_open_private(address.toUtf8().constData(), error); -
195 if (c) {
partially evaluated: c
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
196 if (!q_dbus_bus_register(c, error)) {
never evaluated: !q_dbus_bus_register(c, error)
0
197 q_dbus_connection_unref(c); -
198 c = 0; -
199 }
never executed: }
0
200 }
never executed: }
0
201 d->setConnection(c, error); -
202 _q_manager()->setConnection(name, d); -
203 -
204 QDBusConnection retval(d); -
205 -
206 -
207 -
208 d->setBusService(retval); -
209 -
210 return retval;
executed: return retval;
Execution Count:1
1
211} -
212 -
213 -
214 -
215 -
216 -
217 -
218QDBusConnection QDBusConnection::connectToPeer(const QString &address, -
219 const QString &name) -
220{ -
221 -
222 -
223 if (!qdbus_loadLibDBus()) {
partially evaluated: !qdbus_loadLibDBus()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:128
0-128
224 QDBusConnectionPrivate *d = 0; -
225 return QDBusConnection(d);
never executed: return QDBusConnection(d);
0
226 } -
227 -
228 QMutexLocker locker(&_q_manager()->mutex); -
229 -
230 QDBusConnectionPrivate *d = _q_manager()->connection(name); -
231 if (d || name.isEmpty())
partially evaluated: d
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:128
partially evaluated: name.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:128
0-128
232 return QDBusConnection(d);
never executed: return QDBusConnection(d);
0
233 -
234 d = new QDBusConnectionPrivate; -
235 -
236 QDBusErrorInternal error; -
237 DBusConnection *c = q_dbus_connection_open_private(address.toUtf8().constData(), error); -
238 -
239 d->setPeer(c, error); -
240 _q_manager()->setConnection(name, d); -
241 -
242 QDBusConnection retval(d); -
243 -
244 return retval;
executed: return retval;
Execution Count:128
128
245} -
246void QDBusConnection::disconnectFromBus(const QString &name) -
247{ -
248 if (_q_manager()) {
partially evaluated: _q_manager()
TRUEFALSE
yes
Evaluation Count:26
no
Evaluation Count:0
0-26
249 QMutexLocker locker(&_q_manager()->mutex); -
250 QDBusConnectionPrivate *d = _q_manager()->connection(name); -
251 if (d && d->mode != QDBusConnectionPrivate::ClientMode)
partially evaluated: d
TRUEFALSE
yes
Evaluation Count:26
no
Evaluation Count:0
evaluated: d->mode != QDBusConnectionPrivate::ClientMode
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:23
0-26
252 return;
executed: return;
Execution Count:3
3
253 _q_manager()->removeConnection(name); -
254 }
executed: }
Execution Count:23
23
255}
executed: }
Execution Count:23
23
256void QDBusConnection::disconnectFromPeer(const QString &name) -
257{ -
258 if (_q_manager()) {
partially evaluated: _q_manager()
TRUEFALSE
yes
Evaluation Count:124
no
Evaluation Count:0
0-124
259 QMutexLocker locker(&_q_manager()->mutex); -
260 QDBusConnectionPrivate *d = _q_manager()->connection(name); -
261 if (d && d->mode != QDBusConnectionPrivate::PeerMode)
partially evaluated: d
TRUEFALSE
yes
Evaluation Count:124
no
Evaluation Count:0
evaluated: d->mode != QDBusConnectionPrivate::PeerMode
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:123
0-124
262 return;
executed: return;
Execution Count:1
1
263 _q_manager()->removeConnection(name); -
264 }
executed: }
Execution Count:123
123
265}
executed: }
Execution Count:123
123
266bool QDBusConnection::send(const QDBusMessage &message) const -
267{ -
268 if (!d || !d->connection) {
partially evaluated: !d
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:124
evaluated: !d->connection
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:123
0-124
269 QDBusError err = QDBusError(QDBusError::Disconnected, -
270 QLatin1String("Not connected to D-BUS server")); -
271 if (d)
partially evaluated: d
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
272 d->lastError = err;
executed: d->lastError = err;
Execution Count:1
1
273 return false;
executed: return false;
Execution Count:1
1
274 } -
275 return d->send(message) != 0;
executed: return d->send(message) != 0;
Execution Count:123
123
276} -
277bool QDBusConnection::callWithCallback(const QDBusMessage &message, QObject *receiver, -
278 const char *returnMethod, const char *errorMethod, -
279 int timeout) const -
280{ -
281 if (!d || !d->connection) {
partially evaluated: !d
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:10
evaluated: !d->connection
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:9
0-10
282 QDBusError err = QDBusError(QDBusError::Disconnected, -
283 QLatin1String("Not connected to D-BUS server")); -
284 if (d)
partially evaluated: d
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
285 d->lastError = err;
executed: d->lastError = err;
Execution Count:1
1
286 return false;
executed: return false;
Execution Count:1
1
287 } -
288 return d->sendWithReplyAsync(message, receiver, returnMethod, errorMethod, timeout) != 0;
executed: return d->sendWithReplyAsync(message, receiver, returnMethod, errorMethod, timeout) != 0;
Execution Count:9
9
289} -
290bool QDBusConnection::callWithCallback(const QDBusMessage &message, QObject *receiver, -
291 const char *returnMethod, int timeout) const -
292{ -
293 return callWithCallback(message, receiver, returnMethod, 0, timeout);
executed: return callWithCallback(message, receiver, returnMethod, 0, timeout);
Execution Count:2
2
294} -
295QDBusMessage QDBusConnection::call(const QDBusMessage &message, QDBus::CallMode mode, int timeout) const -
296{ -
297 if (!d || !d->connection) {
evaluated: !d
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:1534
evaluated: !d->connection
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1533
1-1534
298 QDBusError err = QDBusError(QDBusError::Disconnected, -
299 QLatin1String("Not connected to D-Bus server")); -
300 if (d)
evaluated: d
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:5
1-5
301 d->lastError = err;
executed: d->lastError = err;
Execution Count:1
1
302 -
303 return QDBusMessage::createError(err);
executed: return QDBusMessage::createError(err);
Execution Count:6
6
304 } -
305 -
306 if (mode != QDBus::NoBlock)
partially evaluated: mode != QDBus::NoBlock
TRUEFALSE
yes
Evaluation Count:1533
no
Evaluation Count:0
0-1533
307 return d->sendWithReply(message, mode, timeout);
executed: return d->sendWithReply(message, mode, timeout);
Execution Count:1533
1533
308 -
309 d->send(message); -
310 QDBusMessage retval; -
311 retval << QVariant(); -
312 return retval;
never executed: return retval;
0
313} -
314QDBusPendingCall QDBusConnection::asyncCall(const QDBusMessage &message, int timeout) const -
315{ -
316 if (!d || !d->connection) {
evaluated: !d
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:75
partially evaluated: !d->connection
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:75
0-75
317 return QDBusPendingCall(0);
executed: return QDBusPendingCall(0);
Execution Count:4
4
318 } -
319 -
320 QDBusPendingCallPrivate *priv = d->sendWithReplyAsync(message, timeout); -
321 return QDBusPendingCall(priv);
executed: return QDBusPendingCall(priv);
Execution Count:75
75
322} -
323bool QDBusConnection::connect(const QString &service, const QString &path, const QString& interface, -
324 const QString &name, QObject *receiver, const char *slot) -
325{ -
326 return connect(service, path, interface, name, QStringList(), QString(), receiver, slot);
executed: return connect(service, path, interface, name, QStringList(), QString(), receiver, slot);
Execution Count:139
139
327} -
328bool QDBusConnection::connect(const QString &service, const QString &path, const QString& interface, -
329 const QString &name, const QString &signature, -
330 QObject *receiver, const char *slot) -
331{ -
332 return connect(service, path, interface, name, QStringList(), signature, receiver, slot);
executed: return connect(service, path, interface, name, QStringList(), signature, receiver, slot);
Execution Count:25
25
333} -
334bool QDBusConnection::connect(const QString &service, const QString &path, const QString& interface, -
335 const QString &name, const QStringList &argumentMatch, const QString &signature, -
336 QObject *receiver, const char *slot) -
337{ -
338 -
339 if (!receiver || !slot || !d || !d->connection)
partially evaluated: !receiver
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:203
partially evaluated: !slot
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:203
partially evaluated: !d
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:203
partially evaluated: !d->connection
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:203
0-203
340 return false;
never executed: return false;
0
341 if (interface.isEmpty() && name.isEmpty())
partially evaluated: interface.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:203
never evaluated: name.isEmpty()
0-203
342 return false;
never executed: return false;
0
343 if (!interface.isEmpty() && !QDBusUtil::isValidInterfaceName(interface)) {
partially evaluated: !interface.isEmpty()
TRUEFALSE
yes
Evaluation Count:203
no
Evaluation Count:0
partially evaluated: !QDBusUtil::isValidInterfaceName(interface)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:203
0-203
344 -
345 -
346 -
347 return false;
never executed: return false;
0
348 } -
349 if (!service.isEmpty() && !QDBusUtil::isValidBusName(service)) {
evaluated: !service.isEmpty()
TRUEFALSE
yes
Evaluation Count:123
yes
Evaluation Count:80
partially evaluated: !QDBusUtil::isValidBusName(service)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:123
0-123
350 -
351 -
352 -
353 return false;
never executed: return false;
0
354 } -
355 if (!path.isEmpty() && !QDBusUtil::isValidObjectPath(path)) {
evaluated: !path.isEmpty()
TRUEFALSE
yes
Evaluation Count:167
yes
Evaluation Count:36
partially evaluated: !QDBusUtil::isValidObjectPath(path)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:167
0-167
356 -
357 -
358 -
359 return false;
never executed: return false;
0
360 } -
361 -
362 QDBusWriteLocker locker(ConnectAction, d); -
363 return d->connectSignal(service, path, interface, name, argumentMatch, signature, receiver, slot);
executed: return d->connectSignal(service, path, interface, name, argumentMatch, signature, receiver, slot);
Execution Count:203
203
364} -
365bool QDBusConnection::disconnect(const QString &service, const QString &path, const QString &interface, -
366 const QString &name, QObject *receiver, const char *slot) -
367{ -
368 return disconnect(service, path, interface, name, QStringList(), QString(), receiver, slot);
executed: return disconnect(service, path, interface, name, QStringList(), QString(), receiver, slot);
Execution Count:1
1
369} -
370bool QDBusConnection::disconnect(const QString &service, const QString &path, const QString& interface, -
371 const QString &name, const QString &signature, -
372 QObject *receiver, const char *slot) -
373{ -
374 return disconnect(service, path, interface, name, QStringList(), signature, receiver, slot);
never executed: return disconnect(service, path, interface, name, QStringList(), signature, receiver, slot);
0
375} -
376bool QDBusConnection::disconnect(const QString &service, const QString &path, const QString& interface, -
377 const QString &name, const QStringList &argumentMatch, const QString &signature, -
378 QObject *receiver, const char *slot) -
379{ -
380 if (!receiver || !slot || !d || !d->connection)
partially evaluated: !receiver
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5
partially evaluated: !slot
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5
partially evaluated: !d
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5
partially evaluated: !d->connection
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5
0-5
381 return false;
never executed: return false;
0
382 if (!interface.isEmpty() && !QDBusUtil::isValidInterfaceName(interface))
partially evaluated: !interface.isEmpty()
TRUEFALSE
yes
Evaluation Count:5
no
Evaluation Count:0
partially evaluated: !QDBusUtil::isValidInterfaceName(interface)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5
0-5
383 return false;
never executed: return false;
0
384 if (interface.isEmpty() && name.isEmpty())
partially evaluated: interface.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5
never evaluated: name.isEmpty()
0-5
385 return false;
never executed: return false;
0
386 -
387 QDBusWriteLocker locker(DisconnectAction, d); -
388 return d->disconnectSignal(service, path, interface, name, argumentMatch, signature, receiver, slot);
executed: return d->disconnectSignal(service, path, interface, name, argumentMatch, signature, receiver, slot);
Execution Count:5
5
389} -
390bool QDBusConnection::registerObject(const QString &path, QObject *object, RegisterOptions options) -
391{ -
392 qt_noop(); -
393 -
394 if (!d || !d->connection || !object || !options || !QDBusUtil::isValidObjectPath(path))
partially evaluated: !d
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:131
partially evaluated: !d->connection
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:131
partially evaluated: !object
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:131
evaluated: !options
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:129
partially evaluated: !QDBusUtil::isValidObjectPath(path)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:129
0-131
395 return false;
executed: return false;
Execution Count:2
2
396 -
397 QStringList pathComponents = path.split(QLatin1Char('/')); -
398 if (pathComponents.last().isEmpty())
evaluated: pathComponents.last().isEmpty()
TRUEFALSE
yes
Evaluation Count:43
yes
Evaluation Count:86
43-86
399 pathComponents.removeLast();
executed: pathComponents.removeLast();
Execution Count:43
43
400 QDBusWriteLocker locker(RegisterObjectAction, d); -
401 -
402 -
403 QDBusConnectionPrivate::ObjectTreeNode::DataList::Iterator node = &d->rootNode; -
404 int i = 1; -
405 while (node) {
partially evaluated: node
TRUEFALSE
yes
Evaluation Count:259
no
Evaluation Count:0
0-259
406 if (pathComponents.count() == i) {
evaluated: pathComponents.count() == i
TRUEFALSE
yes
Evaluation Count:128
yes
Evaluation Count:131
128-131
407 -
408 -
409 -
410 if (node->obj)
evaluated: node->obj
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:127
1-127
411 return false;
executed: return false;
Execution Count:1
1
412 -
413 if (options & QDBusConnectionPrivate::VirtualObject) {
evaluated: options & QDBusConnectionPrivate::VirtualObject
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:119
8-119
414 -
415 if (options & SubPath) {
evaluated: options & SubPath
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:1
1-7
416 for (QForeachContainer<__typeof__(node->children)> _container_(node->children); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (const QDBusConnectionPrivate::ObjectTreeNode &child = *_container_.i;; __extension__ ({--_container_.brk; break;})) { -
417 if (child.obj)
evaluated: child.obj
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:2
1-2
418 return false;
executed: return false;
Execution Count:1
1
419 }
executed: }
Execution Count:2
2
420 }
executed: }
Execution Count:6
6
421 } else {
executed: }
Execution Count:7
7
422 if ((options & ExportChildObjects && !node->children.isEmpty()))
evaluated: options & ExportChildObjects
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:117
partially evaluated: !node->children.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-117
423 return false;
never executed: return false;
0
424 }
executed: }
Execution Count:119
119
425 -
426 node->obj = object; -
427 node->flags = options; -
428 -
429 d->registerObject(node); -
430 -
431 return true;
executed: return true;
Execution Count:126
126
432 } -
433 -
434 -
435 if (node->obj && (node->flags & QDBusConnectionPrivate::VirtualObject) && (node->flags & QDBusConnection::SubPath)) {
evaluated: node->obj
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:128
evaluated: (node->flags & QDBusConnectionPrivate::VirtualObject)
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:2
partially evaluated: (node->flags & QDBusConnection::SubPath)
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-128
436 QMessageLogger("qdbusconnection.cpp", 828, __PRETTY_FUNCTION__).debug("Cannot register object at %s because QDBusVirtualObject handles all sub-paths.", -
437 QString(path).toLocal8Bit().constData()); -
438 return false;
executed: return false;
Execution Count:1
1
439 } -
440 -
441 -
442 QDBusConnectionPrivate::ObjectTreeNode::DataList::Iterator it = -
443 std::lower_bound(node->children.begin(), node->children.end(), pathComponents.at(i)); -
444 if (it != node->children.end() && it->name == pathComponents.at(i)) {
evaluated: it != node->children.end()
TRUEFALSE
yes
Evaluation Count:84
yes
Evaluation Count:46
evaluated: it->name == pathComponents.at(i)
TRUEFALSE
yes
Evaluation Count:83
yes
Evaluation Count:1
1-84
445 -
446 node = it; -
447 -
448 -
449 if (node->flags & ExportChildObjects) {
partially evaluated: node->flags & ExportChildObjects
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:83
0-83
450 -
451 QMessageLogger("qdbusconnection.cpp", 843, __PRETTY_FUNCTION__).debug("Cannot register object at %s because %s exports its own child objects", -
452 QString(path).toLocal8Bit().constData(), QString(pathComponents.at(i)).toLocal8Bit().constData()); -
453 return false;
never executed: return false;
0
454 } -
455 } else {
executed: }
Execution Count:83
83
456 -
457 node = node->children.insert(it, pathComponents.at(i)); -
458 }
executed: }
Execution Count:47
47
459 -
460 -
461 ++i; -
462 }
executed: }
Execution Count:130
130
463 -
464 qt_noop(); -
465 return false;
never executed: return false;
0
466} -
467bool QDBusConnection::registerVirtualObject(const QString &path, QDBusVirtualObject *treeNode, -
468 VirtualObjectRegisterOption options) -
469{ -
470 int opts = options | QDBusConnectionPrivate::VirtualObject; -
471 return registerObject(path, (QObject*) treeNode, (RegisterOptions) opts);
executed: return registerObject(path, (QObject*) treeNode, (RegisterOptions) opts);
Execution Count:8
8
472} -
473 -
474 -
475 -
476 -
477 -
478 -
479 -
480void QDBusConnection::unregisterObject(const QString &path, UnregisterMode mode) -
481{ -
482 if (!d || !d->connection || !QDBusUtil::isValidObjectPath(path))
partially evaluated: !d
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:30
partially evaluated: !d->connection
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:30
partially evaluated: !QDBusUtil::isValidObjectPath(path)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:30
0-30
483 return;
never executed: return;
0
484 -
485 QStringList pathComponents = path.split(QLatin1Char('/')); -
486 QDBusWriteLocker locker(UnregisterObjectAction, d); -
487 QDBusConnectionPrivate::ObjectTreeNode *node = &d->rootNode; -
488 int i = 1; -
489 -
490 -
491 while (node) {
partially evaluated: node
TRUEFALSE
yes
Evaluation Count:73
no
Evaluation Count:0
0-73
492 if (pathComponents.count() == i || !path.compare(QLatin1String("/"))) {
evaluated: pathComponents.count() == i
TRUEFALSE
yes
Evaluation Count:23
yes
Evaluation Count:50
evaluated: !path.compare(QLatin1String("/"))
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:47
3-50
493 -
494 node->obj = 0; -
495 node->flags = 0; -
496 -
497 if (mode == UnregisterTree) {
evaluated: mode == UnregisterTree
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:24
2-24
498 -
499 node->children.clear(); -
500 -
501 }
executed: }
Execution Count:2
2
502 -
503 return;
executed: return;
Execution Count:26
26
504 } -
505 -
506 QDBusConnectionPrivate::ObjectTreeNode::DataList::Iterator it = -
507 std::lower_bound(node->children.begin(), node->children.end(), pathComponents.at(i)); -
508 if (it == node->children.end() || it->name != pathComponents.at(i))
evaluated: it == node->children.end()
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:43
partially evaluated: it->name != pathComponents.at(i)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:43
0-43
509 break;
executed: break;
Execution Count:4
4
510 -
511 node = it; -
512 ++i; -
513 }
executed: }
Execution Count:43
43
514}
executed: }
Execution Count:4
4
515 -
516 -
517 -
518 -
519 -
520QObject *QDBusConnection::objectRegisteredAt(const QString &path) const -
521{ -
522 qt_noop(); -
523 -
524 if (!d || !d->connection || !QDBusUtil::isValidObjectPath(path))
partially evaluated: !d
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:55
partially evaluated: !d->connection
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:55
partially evaluated: !QDBusUtil::isValidObjectPath(path)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:55
0-55
525 return 0;
never executed: return 0;
0
526 -
527 QStringList pathComponents = path.split(QLatin1Char('/')); -
528 if (pathComponents.last().isEmpty())
evaluated: pathComponents.last().isEmpty()
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:48
7-48
529 pathComponents.removeLast();
executed: pathComponents.removeLast();
Execution Count:7
7
530 -
531 -
532 QDBusReadLocker lock(ObjectRegisteredAtAction, d); -
533 const QDBusConnectionPrivate::ObjectTreeNode *node = &d->rootNode; -
534 -
535 int i = 1; -
536 while (node) {
partially evaluated: node
TRUEFALSE
yes
Evaluation Count:146
no
Evaluation Count:0
0-146
537 if (pathComponents.count() == i)
evaluated: pathComponents.count() == i
TRUEFALSE
yes
Evaluation Count:46
yes
Evaluation Count:100
46-100
538 return node->obj;
executed: return node->obj;
Execution Count:46
46
539 if ((node->flags & QDBusConnectionPrivate::VirtualObject) && (node->flags & QDBusConnection::SubPath))
evaluated: (node->flags & QDBusConnectionPrivate::VirtualObject)
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:94
evaluated: (node->flags & QDBusConnection::SubPath)
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:1
1-94
540 return node->obj;
executed: return node->obj;
Execution Count:5
5
541 -
542 QDBusConnectionPrivate::ObjectTreeNode::DataList::ConstIterator it = -
543 std::lower_bound(node->children.constBegin(), node->children.constEnd(), pathComponents.at(i)); -
544 if (it == node->children.constEnd() || it->name != pathComponents.at(i))
evaluated: it == node->children.constEnd()
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:91
partially evaluated: it->name != pathComponents.at(i)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:91
0-91
545 break;
executed: break;
Execution Count:4
4
546 -
547 node = it; -
548 ++i; -
549 }
executed: }
Execution Count:91
91
550 return 0;
executed: return 0;
Execution Count:4
4
551} -
552 -
553 -
554 -
555 -
556 -
557 -
558 -
559QDBusConnectionInterface *QDBusConnection::interface() const -
560{ -
561 if (!d)
partially evaluated: !d
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:799
0-799
562 return 0;
never executed: return 0;
0
563 return d->busService;
executed: return d->busService;
Execution Count:799
799
564} -
565void *QDBusConnection::internalPointer() const -
566{ -
567 return d ? d->connection : 0;
never executed: return d ? d->connection : 0;
0
568} -
569 -
570 -
571 -
572 -
573bool QDBusConnection::isConnected() const -
574{ -
575 return d && d->connection && q_dbus_connection_get_is_connected(d->connection);
executed: return d && d->connection && q_dbus_connection_get_is_connected(d->connection);
Execution Count:1240
1240
576} -
577QDBusError QDBusConnection::lastError() const -
578{ -
579 return d ? d->lastError : QDBusError();
executed: return d ? d->lastError : QDBusError();
Execution Count:16
16
580} -
581QString QDBusConnection::baseService() const -
582{ -
583 return d ? d->baseService : QString();
executed: return d ? d->baseService : QString();
Execution Count:311
311
584} -
585QString QDBusConnection::name() const -
586{ -
587 return d ? d->name : QString();
executed: return d ? d->name : QString();
Execution Count:16
16
588} -
589QDBusConnection::ConnectionCapabilities QDBusConnection::connectionCapabilities() const -
590{ -
591 return d ? d->capabilities : ConnectionCapabilities(0);
never executed: return d ? d->capabilities : ConnectionCapabilities(0);
0
592} -
593bool QDBusConnection::registerService(const QString &serviceName) -
594{ -
595 if (interface() && interface()->registerService(serviceName)) {
partially evaluated: interface()
TRUEFALSE
yes
Evaluation Count:17
no
Evaluation Count:0
partially evaluated: interface()->registerService(serviceName)
TRUEFALSE
yes
Evaluation Count:17
no
Evaluation Count:0
0-17
596 if (d) d->registerService(serviceName);
executed: d->registerService(serviceName);
Execution Count:17
partially evaluated: d
TRUEFALSE
yes
Evaluation Count:17
no
Evaluation Count:0
0-17
597 return true;
executed: return true;
Execution Count:17
17
598 } -
599 return false;
never executed: return false;
0
600} -
601bool QDBusConnection::unregisterService(const QString &serviceName) -
602{ -
603 if (interface()->unregisterService(serviceName)) {
partially evaluated: interface()->unregisterService(serviceName)
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
0-4
604 if (d) d->unregisterService(serviceName);
executed: d->unregisterService(serviceName);
Execution Count:4
partially evaluated: d
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
0-4
605 return true;
executed: return true;
Execution Count:4
4
606 } -
607 return false;
never executed: return false;
0
608} -
609 -
610static const char _q_sessionBusName[] = "qt_default_session_bus"; -
611static const char _q_systemBusName[] = "qt_default_system_bus"; -
612 -
613class QDBusDefaultConnection: public QDBusConnection -
614{ -
615 const char *ownName; -
616public: -
617 inline QDBusDefaultConnection(BusType type, const char *name) -
618 : QDBusConnection(connectToBus(type, QString::fromLatin1(name))), ownName(name) -
619 { -
620 -
621 QCoreApplication *instance = QCoreApplication::instance(); -
622 if (!instance) {
partially evaluated: !instance
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:13
0-13
623 QMessageLogger("qdbusconnection.cpp", 1098, __PRETTY_FUNCTION__).warning("QDBusConnection: %s D-Bus connection created before QCoreApplication. Application may misbehave.", -
624 type == SessionBus ? "session" : type == SystemBus ? "system" : "generic"); -
625 } else if (QDBusConnectionPrivate::d(*this)) {
never executed: }
partially evaluated: QDBusConnectionPrivate::d(*this)
TRUEFALSE
yes
Evaluation Count:13
no
Evaluation Count:0
0-13
626 QDBusConnectionPrivate::d(*this)->moveToThread(instance->thread()); -
627 }
executed: }
Execution Count:13
13
628 } -
629 -
630 inline ~QDBusDefaultConnection() -
631 { disconnectFromBus(QString::fromLatin1(ownName)); }
executed: }
Execution Count:13
13
632}; -
633 -
634static QDBusDefaultConnection *_q_sessionBus() { static QGlobalStatic<QDBusDefaultConnection > thisGlobalStatic = { { (0) }, false }; if (!thisGlobalStatic.pointer.load() && !thisGlobalStatic.destroyed) { QDBusDefaultConnection *x = new QDBusDefaultConnection (QDBusConnection::SessionBus, _q_sessionBusName); if (!thisGlobalStatic.pointer.testAndSetOrdered(0, x)) delete x; else static QGlobalStaticDeleter<QDBusDefaultConnection > cleanup(thisGlobalStatic); } return thisGlobalStatic.pointer.load(); }
never executed: delete x;
executed: return thisGlobalStatic.pointer.load();
Execution Count:698
partially evaluated: !thisGlobalStatic.pointer.testAndSetOrdered(0, x)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:13
evaluated: !thisGlobalStatic.pointer.load()
TRUEFALSE
yes
Evaluation Count:13
yes
Evaluation Count:685
partially evaluated: !thisGlobalStatic.destroyed
TRUEFALSE
yes
Evaluation Count:13
no
Evaluation Count:0
0-698
635 -
636static QDBusDefaultConnection *_q_systemBus() { static QGlobalStatic<QDBusDefaultConnection > thisGlobalStatic = { { (0) }, false }; if (!thisGlobalStatic.pointer.load() && !thisGlobalStatic.destroyed) { QDBusDefaultConnection *x = new QDBusDefaultConnection (QDBusConnection::SystemBus, _q_systemBusName); if (!thisGlobalStatic.pointer.testAndSetOrdered(0, x)) delete x; else static QGlobalStaticDeleter<QDBusDefaultConnection > cleanup(thisGlobalStatic); } return thisGlobalStatic.pointer.load(); }
never executed: delete x;
never executed: return thisGlobalStatic.pointer.load();
never evaluated: !thisGlobalStatic.pointer.testAndSetOrdered(0, x)
never evaluated: !thisGlobalStatic.pointer.load()
never evaluated: !thisGlobalStatic.destroyed
0
637QDBusConnection QDBusConnection::sessionBus() -
638{ -
639 return *_q_sessionBus();
executed: return *_q_sessionBus();
Execution Count:698
698
640} -
641QDBusConnection QDBusConnection::systemBus() -
642{ -
643 return *_q_systemBus();
never executed: return *_q_systemBus();
0
644} -
645QDBusConnection QDBusConnection::sender() -
646{ -
647 return QDBusConnection(_q_manager()->sender());
executed: return QDBusConnection(_q_manager()->sender());
Execution Count:10
10
648} -
649 -
650 -
651 -
652 -
653void QDBusConnectionPrivate::setSender(const QDBusConnectionPrivate *s) -
654{ -
655 _q_manager()->setSender(s); -
656}
executed: }
Execution Count:790
790
657 -
658 -
659 -
660 -
661void QDBusConnectionPrivate::setBusService(const QDBusConnection &connection) -
662{ -
663 busService = new QDBusConnectionInterface(connection, this); -
664 ref.deref(); -
665 -
666 -
667 QObject::connect(this, "2""callWithCallbackFailed(QDBusError,QDBusMessage)", -
668 busService, "2""callWithCallbackFailed(QDBusError,QDBusMessage)", -
669 Qt::QueuedConnection); -
670}
executed: }
Execution Count:25
25
671QByteArray QDBusConnection::localMachineId() -
672{ -
673 char *dbus_machine_id = q_dbus_get_local_machine_id(); -
674 QByteArray result = dbus_machine_id; -
675 q_dbus_free(dbus_machine_id); -
676 return result;
executed: return result;
Execution Count:1
1
677} -
678 -
679 -
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial