| Line | Source Code | Coverage |
|---|
| 1 | | - |
| 2 | | - |
| 3 | | - |
| 4 | | - |
| 5 | | - |
| 6 | void QDBusPendingCallWatcherHelper::add(QDBusPendingCallWatcher *watcher) | - |
| 7 | { | - |
| 8 | connect(this, "2""finished()", watcher, "1""_q_finished()", Qt::QueuedConnection); | - |
| 9 | } executed: }Execution Count:8 | 8 |
| 10 | | - |
| 11 | QDBusPendingCallPrivate::~QDBusPendingCallPrivate() | - |
| 12 | { | - |
| 13 | if (pending) { partially evaluated: pending| no Evaluation Count:0 | yes Evaluation Count:239 |
| 0-239 |
| 14 | q_dbus_pending_call_cancel(pending); | - |
| 15 | q_dbus_pending_call_unref(pending); | - |
| 16 | } | 0 |
| 17 | delete watcherHelper; | - |
| 18 | } executed: }Execution Count:239 | 239 |
| 19 | | - |
| 20 | bool QDBusPendingCallPrivate::setReplyCallback(QObject *target, const char *member) | - |
| 21 | { | - |
| 22 | receiver = target; | - |
| 23 | metaTypes.clear(); | - |
| 24 | methodIdx = -1; | - |
| 25 | if (!target) partially evaluated: !target| no Evaluation Count:0 | yes Evaluation Count:7 |
| 0-7 |
| 26 | return true;; never executed: return true; | 0 |
| 27 | | - |
| 28 | if (!member || !*member) { partially evaluated: !member| no Evaluation Count:0 | yes Evaluation Count:7 |
partially evaluated: !*member| no Evaluation Count:0 | yes Evaluation Count:7 |
| 0-7 |
| 29 | | - |
| 30 | QMessageLogger("qdbuspendingcall.cpp", 153, __PRETTY_FUNCTION__).warning("QDBusPendingCall::setReplyCallback: error: cannot deliver a reply to %s::%s (%s)", | - |
| 31 | target ? target->metaObject()->className() : "(null)", | - |
| 32 | member ? member + 1 : "(null)", | - |
| 33 | target ? QString(target->objectName()).toLocal8Bit().constData() : "no name"); | - |
| 34 | return false; never executed: return false; | 0 |
| 35 | } | - |
| 36 | | - |
| 37 | methodIdx = QDBusConnectionPrivate::findSlot(target, member + 1, metaTypes); | - |
| 38 | if (methodIdx == -1) { partially evaluated: methodIdx == -1| no Evaluation Count:0 | yes Evaluation Count:7 |
| 0-7 |
| 39 | QByteArray normalizedName = QMetaObject::normalizedSignature(member + 1); | - |
| 40 | methodIdx = QDBusConnectionPrivate::findSlot(target, normalizedName, metaTypes); | - |
| 41 | } | 0 |
| 42 | if (methodIdx == -1) { partially evaluated: methodIdx == -1| no Evaluation Count:0 | yes Evaluation Count:7 |
| 0-7 |
| 43 | | - |
| 44 | QMessageLogger("qdbuspendingcall.cpp", 167, __PRETTY_FUNCTION__).warning("QDBusPendingCall::setReplyCallback: error: cannot deliver a reply to %s::%s (%s)", | - |
| 45 | target->metaObject()->className(), | - |
| 46 | member + 1, QString(target->objectName()).toLocal8Bit().constData()); | - |
| 47 | return false; never executed: return false; | 0 |
| 48 | } | - |
| 49 | | - |
| 50 | | - |
| 51 | | - |
| 52 | int count = metaTypes.count() - 1; | - |
| 53 | if (count == 1 && metaTypes.at(1) == QDBusMetaTypeId::message()) { evaluated: count == 1| yes Evaluation Count:2 | yes Evaluation Count:5 |
evaluated: metaTypes.at(1) == QDBusMetaTypeId::message()| yes Evaluation Count:1 | yes Evaluation Count:1 |
| 1-5 |
| 54 | | - |
| 55 | return true; executed: return true;Execution Count:1 | 1 |
| 56 | } | - |
| 57 | | - |
| 58 | if (metaTypes.at(count) == QDBusMetaTypeId::message()) partially evaluated: metaTypes.at(count) == QDBusMetaTypeId::message()| no Evaluation Count:0 | yes Evaluation Count:6 |
| 0-6 |
| 59 | --count; | 0 |
| 60 | | - |
| 61 | setMetaTypes(count, count ? metaTypes.constData() + 1 : 0); | - |
| 62 | return true; executed: return true;Execution Count:6 | 6 |
| 63 | } | - |
| 64 | | - |
| 65 | void QDBusPendingCallPrivate::setMetaTypes(int count, const int *types) | - |
| 66 | { | - |
| 67 | expectedReplyCount = count; | - |
| 68 | if (count == 0) { evaluated: count == 0| yes Evaluation Count:11 | yes Evaluation Count:75 |
| 11-75 |
| 69 | expectedReplySignature = QLatin1String(""); | - |
| 70 | return; executed: return;Execution Count:11 | 11 |
| 71 | } | - |
| 72 | | - |
| 73 | QByteArray sig; | - |
| 74 | sig.reserve(count + count / 2); | - |
| 75 | for (int i = 0; i < count; ++i) { evaluated: i < count| yes Evaluation Count:79 | yes Evaluation Count:75 |
| 75-79 |
| 76 | const char *typeSig = QDBusMetaType::typeToSignature(types[i]); | - |
| 77 | if (!typeSig) { partially evaluated: !typeSig| no Evaluation Count:0 | yes Evaluation Count:79 |
| 0-79 |
| 78 | QMessageLogger("qdbuspendingcall.cpp", 201, __PRETTY_FUNCTION__).fatal("QDBusPendingReply: type %s is not registered with QtDBus", | - |
| 79 | QMetaType::typeName(types[i])); | - |
| 80 | } | 0 |
| 81 | sig += typeSig; | - |
| 82 | } executed: }Execution Count:79 | 79 |
| 83 | | - |
| 84 | expectedReplySignature = QString::fromLatin1(sig); | - |
| 85 | } executed: }Execution Count:75 | 75 |
| 86 | | - |
| 87 | void QDBusPendingCallPrivate::checkReceivedSignature() | - |
| 88 | { | - |
| 89 | | - |
| 90 | | - |
| 91 | if (replyMessage.type() == QDBusMessage::InvalidMessage) evaluated: replyMessage.type() == QDBusMessage::InvalidMessage| yes Evaluation Count:9 | yes Evaluation Count:229 |
| 9-229 |
| 92 | return; executed: return;Execution Count:9 | 9 |
| 93 | | - |
| 94 | if (replyMessage.type() == QDBusMessage::ErrorMessage) evaluated: replyMessage.type() == QDBusMessage::ErrorMessage| yes Evaluation Count:85 | yes Evaluation Count:144 |
| 85-144 |
| 95 | return; executed: return;Execution Count:85 | 85 |
| 96 | | - |
| 97 | if (expectedReplySignature.isNull()) evaluated: expectedReplySignature.isNull()| yes Evaluation Count:77 | yes Evaluation Count:67 |
| 67-77 |
| 98 | return; executed: return;Execution Count:77 | 77 |
| 99 | | - |
| 100 | | - |
| 101 | if (!replyMessage.signature().indexOf(expectedReplySignature) == 0) { evaluated: !replyMessage.signature().indexOf(expectedReplySignature) == 0| yes Evaluation Count:9 | yes Evaluation Count:58 |
| 9-58 |
| 102 | QString errorMsg = QLatin1String("Unexpected reply signature: got \"%1\", " | - |
| 103 | "expected \"%2\""); | - |
| 104 | replyMessage = QDBusMessage::createError( | - |
| 105 | QDBusError::InvalidSignature, | - |
| 106 | errorMsg.arg(replyMessage.signature(), expectedReplySignature)); | - |
| 107 | | - |
| 108 | } executed: }Execution Count:9 | 9 |
| 109 | } executed: }Execution Count:67 | 67 |
| 110 | | - |
| 111 | void QDBusPendingCallPrivate::waitForFinished() | - |
| 112 | { | - |
| 113 | QMutexLocker locker(&mutex); | - |
| 114 | | - |
| 115 | if (replyMessage.type() != QDBusMessage::InvalidMessage) evaluated: replyMessage.type() != QDBusMessage::InvalidMessage| yes Evaluation Count:120 | yes Evaluation Count:19 |
| 19-120 |
| 116 | return; executed: return;Execution Count:120 | 120 |
| 117 | | - |
| 118 | connection->waitForFinished(this); | - |
| 119 | } executed: }Execution Count:19 | 19 |
| 120 | | - |
| 121 | | - |
| 122 | | - |
| 123 | | - |
| 124 | | - |
| 125 | QDBusPendingCall::QDBusPendingCall(const QDBusPendingCall &other) | - |
| 126 | : d(other.d) | - |
| 127 | { | - |
| 128 | } executed: }Execution Count:38 | 38 |
| 129 | | - |
| 130 | | - |
| 131 | | - |
| 132 | | - |
| 133 | QDBusPendingCall::QDBusPendingCall(QDBusPendingCallPrivate *dd) | - |
| 134 | : d(dd) | - |
| 135 | { | - |
| 136 | } executed: }Execution Count:169 | 169 |
| 137 | | - |
| 138 | | - |
| 139 | | - |
| 140 | | - |
| 141 | | - |
| 142 | | - |
| 143 | | - |
| 144 | QDBusPendingCall::~QDBusPendingCall() | - |
| 145 | { | - |
| 146 | | - |
| 147 | } | - |
| 148 | QDBusPendingCall &QDBusPendingCall::operator=(const QDBusPendingCall &other) | - |
| 149 | { | - |
| 150 | d = other.d; | - |
| 151 | return *this; executed: return *this;Execution Count:67 | 67 |
| 152 | } | - |
| 153 | bool QDBusPendingCall::isFinished() const | - |
| 154 | { | - |
| 155 | if (!d) evaluated: !d| yes Evaluation Count:2 | yes Evaluation Count:70 |
| 2-70 |
| 156 | return true; executed: return true;Execution Count:2 | 2 |
| 157 | | - |
| 158 | QMutexLocker locker(&d->mutex); | - |
| 159 | return d->replyMessage.type() != QDBusMessage::InvalidMessage; executed: return d->replyMessage.type() != QDBusMessage::InvalidMessage;Execution Count:70 | 70 |
| 160 | } | - |
| 161 | | - |
| 162 | void QDBusPendingCall::waitForFinished() | - |
| 163 | { | - |
| 164 | if (d) d->waitForFinished(); executed: d->waitForFinished();Execution Count:89 evaluated: d| yes Evaluation Count:89 | yes Evaluation Count:4 |
| 4-89 |
| 165 | } executed: }Execution Count:93 | 93 |
| 166 | bool QDBusPendingCall::isValid() const | - |
| 167 | { | - |
| 168 | if (!d) evaluated: !d| yes Evaluation Count:4 | yes Evaluation Count:10 |
| 4-10 |
| 169 | return false; executed: return false;Execution Count:4 | 4 |
| 170 | QMutexLocker locker(&d->mutex); | - |
| 171 | return d->replyMessage.type() == QDBusMessage::ReplyMessage; executed: return d->replyMessage.type() == QDBusMessage::ReplyMessage;Execution Count:10 | 10 |
| 172 | } | - |
| 173 | bool QDBusPendingCall::isError() const | - |
| 174 | { | - |
| 175 | if (!d) evaluated: !d| yes Evaluation Count:4 | yes Evaluation Count:50 |
| 4-50 |
| 176 | return true; executed: return true;Execution Count:4 | 4 |
| 177 | QMutexLocker locker(&d->mutex); | - |
| 178 | return d->replyMessage.type() == QDBusMessage::ErrorMessage; executed: return d->replyMessage.type() == QDBusMessage::ErrorMessage;Execution Count:50 | 50 |
| 179 | } | - |
| 180 | QDBusError QDBusPendingCall::error() const | - |
| 181 | { | - |
| 182 | if (d) { evaluated: d| yes Evaluation Count:30 | yes Evaluation Count:2 |
| 2-30 |
| 183 | QMutexLocker locker(&d->mutex); | - |
| 184 | return QDBusError(d->replyMessage); executed: return QDBusError(d->replyMessage);Execution Count:30 | 30 |
| 185 | } | - |
| 186 | | - |
| 187 | | - |
| 188 | QDBusError err = QDBusError(QDBusError::Disconnected, | - |
| 189 | QLatin1String("Not connected to D-Bus server")); | - |
| 190 | return err; executed: return err;Execution Count:2 | 2 |
| 191 | } | - |
| 192 | QDBusMessage QDBusPendingCall::reply() const | - |
| 193 | { | - |
| 194 | if (!d) evaluated: !d| yes Evaluation Count:2 | yes Evaluation Count:44 |
| 2-44 |
| 195 | return QDBusMessage::createError(error()); executed: return QDBusMessage::createError(error());Execution Count:2 | 2 |
| 196 | QMutexLocker locker(&d->mutex); | - |
| 197 | return d->replyMessage; executed: return d->replyMessage;Execution Count:44 | 44 |
| 198 | } | - |
| 199 | QDBusPendingCall QDBusPendingCall::fromError(const QDBusError &error) | - |
| 200 | { | - |
| 201 | return fromCompletedCall(QDBusMessage::createError(error)); executed: return fromCompletedCall(QDBusMessage::createError(error));Execution Count:14 | 14 |
| 202 | } | - |
| 203 | QDBusPendingCall QDBusPendingCall::fromCompletedCall(const QDBusMessage &msg) | - |
| 204 | { | - |
| 205 | QDBusPendingCallPrivate *d = 0; | - |
| 206 | if (msg.type() == QDBusMessage::ErrorMessage || partially evaluated: msg.type() == QDBusMessage::ErrorMessage| yes Evaluation Count:14 | no Evaluation Count:0 |
| 0-14 |
| 207 | msg.type() == QDBusMessage::ReplyMessage) { never evaluated: msg.type() == QDBusMessage::ReplyMessage | 0 |
| 208 | d = new QDBusPendingCallPrivate(QDBusMessage(), 0); | - |
| 209 | d->replyMessage = msg; | - |
| 210 | } executed: }Execution Count:14 | 14 |
| 211 | | - |
| 212 | return QDBusPendingCall(d); executed: return QDBusPendingCall(d);Execution Count:14 | 14 |
| 213 | } | - |
| 214 | | - |
| 215 | | - |
| 216 | class QDBusPendingCallWatcherPrivate: public QObjectPrivate | - |
| 217 | { | - |
| 218 | public: | - |
| 219 | void _q_finished(); | - |
| 220 | | - |
| 221 | inline QDBusPendingCallWatcher* q_func() { return static_cast<QDBusPendingCallWatcher *>(q_ptr); } inline const QDBusPendingCallWatcher* q_func() const { return static_cast<const QDBusPendingCallWatcher *>(q_ptr); } friend class QDBusPendingCallWatcher; | - |
| 222 | }; | - |
| 223 | | - |
| 224 | inline void QDBusPendingCallWatcherPrivate::_q_finished() | - |
| 225 | { | - |
| 226 | QDBusPendingCallWatcher * const q = q_func(); | - |
| 227 | q->finished(q); | - |
| 228 | } executed: }Execution Count:8 | 8 |
| 229 | | - |
| 230 | | - |
| 231 | | - |
| 232 | | - |
| 233 | | - |
| 234 | | - |
| 235 | QDBusPendingCallWatcher::QDBusPendingCallWatcher(const QDBusPendingCall &call, QObject *parent) | - |
| 236 | : QObject(*new QDBusPendingCallWatcherPrivate, parent), QDBusPendingCall(call) | - |
| 237 | { | - |
| 238 | if (d) { partially evaluated: d| yes Evaluation Count:8 | no Evaluation Count:0 |
| 0-8 |
| 239 | QMutexLocker locker(&d->mutex); | - |
| 240 | if (!d->watcherHelper) { partially evaluated: !d->watcherHelper| yes Evaluation Count:8 | no Evaluation Count:0 |
| 0-8 |
| 241 | d->watcherHelper = new QDBusPendingCallWatcherHelper; | - |
| 242 | if (d->replyMessage.type() != QDBusMessage::InvalidMessage) { evaluated: d->replyMessage.type() != QDBusMessage::InvalidMessage| yes Evaluation Count:2 | yes Evaluation Count:6 |
| 2-6 |
| 243 | | - |
| 244 | QMetaObject::invokeMethod(d->watcherHelper, "finished", Qt::QueuedConnection); | - |
| 245 | } executed: }Execution Count:2 | 2 |
| 246 | } executed: }Execution Count:8 | 8 |
| 247 | d->watcherHelper->add(this); | - |
| 248 | } executed: }Execution Count:8 | 8 |
| 249 | } executed: }Execution Count:8 | 8 |
| 250 | | - |
| 251 | | - |
| 252 | | - |
| 253 | | - |
| 254 | | - |
| 255 | | - |
| 256 | QDBusPendingCallWatcher::~QDBusPendingCallWatcher() | - |
| 257 | { | - |
| 258 | } | - |
| 259 | void QDBusPendingCallWatcher::waitForFinished() | - |
| 260 | { | - |
| 261 | if (d) { partially evaluated: d| yes Evaluation Count:5 | no Evaluation Count:0 |
| 0-5 |
| 262 | d->waitForFinished(); | - |
| 263 | | - |
| 264 | | - |
| 265 | QCoreApplication::sendPostedEvents(d->watcherHelper, QEvent::MetaCall); | - |
| 266 | QCoreApplication::sendPostedEvents(this, QEvent::MetaCall); | - |
| 267 | } executed: }Execution Count:5 | 5 |
| 268 | } executed: }Execution Count:5 | 5 |
| 269 | | - |
| 270 | | - |
| 271 | | - |
| 272 | | - |
| 273 | | - |
| | |