Changeset 769 for trunk/src/dbus
- Timestamp:
- Aug 2, 2010, 9:27:30 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/vendor/nokia/qt/4.6.3 (added) merged: 768 /branches/vendor/nokia/qt/current merged: 767 /branches/vendor/nokia/qt/4.6.2 removed
- Property svn:mergeinfo changed
-
trunk/src/dbus/qdbusargument.cpp
r651 r769 536 536 /*! 537 537 \internal 538 Returns the type signature of the D-Bus type this QDBusArgument539 538 \since 4.5 540 539 -
trunk/src/dbus/qdbusconnection.cpp
r651 r769 492 492 QDBusMessage::ReplyMessage or QDBusMessage::ErrorMessage. 493 493 494 495 496 497 498 499 494 500 See the QDBusInterface::call() function for a more friendly way 495 501 of placing calls. … … 527 533 immediately. This function is suitable for method calls only. It 528 534 returns an object of type QDBusPendingCall which can be used to 529 track the status of the reply. The \a timeout parameter is used to 530 determine when an auto-generated error reply may be emitted and is 531 also the upper limit for waiting in QDBusPendingCall::waitForFinished(). 535 track the status of the reply. 536 537 If no reply is received within \a timeout milliseconds, an automatic 538 error will be delivered indicating the expiration of the call. The 539 default \a timeout is -1, which will be replaced with an 540 implementation-defined value that is suitable for inter-process 541 communications (generally, 25 seconds). This timeout is also the 542 upper limit for waiting in QDBusPendingCall::waitForFinished(). 532 543 533 544 See the QDBusInterface::asyncCall() function for a more friendly way -
trunk/src/dbus/qdbusintegrator.cpp
r651 r769 524 524 525 525 QDBusMessage amsg = QDBusMessagePrivate::fromDBusMessage(message); 526 qDBusDebug() << d << "got message :" << amsg;526 qDBusDebug() << d << "got message:" << amsg; 527 527 528 528 return d->handleMessage(amsg) ? … … 1661 1661 1662 1662 QString busService = QLatin1String(DBUS_SERVICE_DBUS); 1663 WatchedServicesHash::mapped_type &bus = watchedServices[busService];1664 bus.refcount = 1;1665 bus.owner = getNameOwnerNoCache(busService);1666 1663 connectSignal(busService, QString(), QString(), QLatin1String("NameAcquired"), QStringList(), QString(), 1667 1664 this, SLOT(registerService(QString))); … … 1691 1688 { 1692 1689 Q_ASSERT(pcall->pending); 1693 QDBusDispatchLocker locker(PendingCallBlockAction, this); 1694 q_dbus_pending_call_block(pcall->pending); 1695 // QDBusConnectionPrivate::processFinishedCall() is called automatically 1690 Q_ASSERT(!pcall->autoDelete); 1691 //Q_ASSERT(pcall->mutex.isLocked()); // there's no such function 1692 1693 if (pcall->waitingForFinished) { 1694 // another thread is already waiting 1695 pcall->waitForFinishedCondition.wait(&pcall->mutex); 1696 } else { 1697 pcall->waitingForFinished = true; 1698 pcall->mutex.unlock(); 1699 1700 { 1701 QDBusDispatchLocker locker(PendingCallBlockAction, this); 1702 q_dbus_pending_call_block(pcall->pending); 1703 // QDBusConnectionPrivate::processFinishedCall() is called automatically 1704 } 1705 pcall->mutex.lock(); 1706 } 1696 1707 } 1697 1708 … … 1699 1710 { 1700 1711 QDBusConnectionPrivate *connection = const_cast<QDBusConnectionPrivate *>(call->connection); 1712 1713 1701 1714 1702 1715 QDBusMessage &msg = call->replyMessage; … … 1729 1742 } 1730 1743 1744 1745 1746 1747 1748 1749 1731 1750 // Are there any watchers? 1732 1751 if (call->watcherHelper) … … 1736 1755 emit connection->callWithCallbackFailed(QDBusError(msg), call->sentMessage); 1737 1756 1738 if (call->pending) 1739 q_dbus_pending_call_unref(call->pending); 1740 call->pending = 0; 1741 1742 if (call->autoDelete) 1757 if (call->autoDelete) { 1758 Q_ASSERT(!call->waitingForFinished); // can't wait on a call with autoDelete! 1743 1759 delete call; 1760 1744 1761 } 1745 1762 … … 1883 1900 if (isServiceRegisteredByThread(message.service())) { 1884 1901 // special case for local calls 1885 QDBusPendingCallPrivate *pcall = new QDBusPendingCallPrivate; 1886 pcall->sentMessage = message; 1902 QDBusPendingCallPrivate *pcall = new QDBusPendingCallPrivate(message, this); 1887 1903 pcall->replyMessage = sendWithReplyLocal(message); 1888 pcall->connection = this;1889 1904 1890 1905 return pcall; … … 1892 1907 1893 1908 checkThread(); 1894 QDBusPendingCallPrivate *pcall = new QDBusPendingCallPrivate; 1895 pcall->sentMessage = message; 1909 QDBusPendingCallPrivate *pcall = new QDBusPendingCallPrivate(message, this); 1896 1910 pcall->ref = 0; 1897 1911 … … 1917 1931 1918 1932 pcall->pending = pending; 1919 pcall->connection = this;1920 1933 q_dbus_pending_call_set_notify(pending, qDBusResultReceived, pcall, 0); 1921 1934 … … 1941 1954 Q_ASSERT(pcall); 1942 1955 1943 // has it already finished (dispatched locally)?1956 // has it already finished (dispatched locally)? 1944 1957 if (pcall->replyMessage.type() == QDBusMessage::ReplyMessage) { 1945 1958 pcall->setReplyCallback(receiver, returnMethod); … … 1949 1962 } 1950 1963 1964 1965 1966 1967 1968 1969 1970 1971 1951 1972 // has it already finished and is an error reply message? 1952 1973 if (pcall->replyMessage.type() == QDBusMessage::ErrorMessage) { 1953 if (errorMethod) {1954 pcall->watcherHelper = new QDBusPendingCallWatcherHelper;1955 connect(pcall->watcherHelper, SIGNAL(error(QDBusError,QDBusMessage)), receiver, errorMethod);1956 pcall->watcherHelper->moveToThread(thread());1957 }1958 1974 processFinishedCall(pcall); 1959 1975 delete pcall; … … 1961 1977 } 1962 1978 1963 // has it already finished with error?1964 if (pcall->replyMessage.type() != QDBusMessage::InvalidMessage) {1965 delete pcall;1966 return 0;1967 }1968 1969 1979 pcall->autoDelete = true; 1970 1980 pcall->ref.ref(); 1971 1972 1981 pcall->setReplyCallback(receiver, returnMethod); 1973 if (errorMethod) {1974 pcall->watcherHelper = new QDBusPendingCallWatcherHelper;1975 connect(pcall->watcherHelper, SIGNAL(error(QDBusError,QDBusMessage)), receiver, errorMethod);1976 pcall->watcherHelper->moveToThread(thread());1977 }1978 1982 1979 1983 return 1; … … 2005 2009 entry.signature == hook.signature && 2006 2010 entry.obj == hook.obj && 2007 entry.midx == hook.midx) { 2011 entry.midx == hook.midx && 2012 entry.argumentMatch == hook.argumentMatch) { 2008 2013 // no need to compare the parameters if it's the same slot 2009 2014 return true; // already there … … 2047 2052 if (shouldWatchService(hook.service)) { 2048 2053 WatchedServicesHash::mapped_type &data = watchedServices[hook.service]; 2049 if (data.refcount) { 2050 // already watching 2051 ++data.refcount; 2052 } else { 2054 if (++data.refcount == 1) { 2053 2055 // we need to watch for this service changing 2054 2056 QString dbusServerService = QLatin1String(DBUS_SERVICE_DBUS); … … 2090 2092 entry.signature == hook.signature && 2091 2093 entry.obj == hook.obj && 2092 entry.midx == hook.midx) { 2094 entry.midx == hook.midx && 2095 entry.argumentMatch == hook.argumentMatch) { 2093 2096 // no need to compare the parameters if it's the same slot 2094 2097 disconnectSignal(it); … … 2105 2108 { 2106 2109 const SignalHook &hook = it.value(); 2107 2108 WatchedServicesHash::Iterator sit = watchedServices.find(hook.service);2109 if (sit != watchedServices.end()) {2110 if (sit.value().refcount == 1) {2111 watchedServices.erase(sit);2112 QString dbusServerService = QLatin1String(DBUS_SERVICE_DBUS);2113 disconnectSignal(dbusServerService, QString(), QLatin1String(DBUS_INTERFACE_DBUS),2114 QLatin1String("NameOwnerChanged"), QStringList() << hook.service, QString(),2115 this, SLOT(_q_serviceOwnerChanged(QString,QString,QString)));2116 } else {2117 --sit.value().refcount;2118 }2119 }2120 2110 2121 2111 bool erase = false; … … 2137 2127 qDBusDebug("Removing rule: %s", hook.matchRule.constData()); 2138 2128 q_dbus_bus_remove_match(connection, hook.matchRule, NULL); 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2139 2143 } 2140 2144 -
trunk/src/dbus/qdbusinterface.cpp
r651 r769 259 259 { 260 260 _id = QDBusAbstractInterface::qt_metacall(_c, _id, _a); 261 if (_id < 0 || !d_func()->isValid )261 if (_id < 0 || !d_func()->isValid) 262 262 return _id; 263 263 return d_func()->metacall(_c, _id, _a); -
trunk/src/dbus/qdbusmacros.h
r651 r769 49 49 #if defined(QDBUS_MAKEDLL) 50 50 # define QDBUS_EXPORT Q_DECL_EXPORT 51 52 51 53 #else 52 # define QDBUS_EXPORT Q_DECL_IMPORT54 # define QDBUS_EXPORT 53 55 #endif 54 56 -
trunk/src/dbus/qdbusmarshaller.cpp
r651 r769 41 41 42 42 #include "qdbusargument_p.h" 43 43 44 #include "qdbusutil_p.h" 44 45 … … 168 169 QByteArray tmpSignature; 169 170 const char *signature = 0; 170 if (int(id) == qMetaTypeId<QDBusArgument>()) {171 if (int(id) == ) { 171 172 // take the signature from the QDBusArgument object we're marshalling 172 173 tmpSignature = … … 354 355 355 356 // intercept QDBusArgument parameters here 356 if (id == qMetaTypeId<QDBusArgument>()) {357 if (id == ) { 357 358 QDBusArgument dbusargument = qvariant_cast<QDBusArgument>(arg); 358 359 QDBusArgumentPrivate *d = QDBusArgumentPrivate::d(dbusargument); -
trunk/src/dbus/qdbuspendingcall.cpp
r651 r769 209 209 void QDBusPendingCallPrivate::checkReceivedSignature() 210 210 { 211 212 211 213 if (replyMessage.type() == QDBusMessage::InvalidMessage) 212 214 return; // not yet finished - no message to … … 231 233 void QDBusPendingCallPrivate::waitForFinished() 232 234 { 235 236 233 237 if (replyMessage.type() != QDBusMessage::InvalidMessage) 234 238 return; // already finished … … 311 315 bool QDBusPendingCall::isFinished() const 312 316 { 313 return !d || (d->replyMessage.type() != QDBusMessage::InvalidMessage); 317 if (!d) 318 return true; // considered finished 319 320 QMutexLocker locker(&d->mutex); 321 return d->replyMessage.type() != QDBusMessage::InvalidMessage; 314 322 } 315 323 … … 330 338 bool QDBusPendingCall::isValid() const 331 339 { 332 return d ? d->replyMessage.type() == QDBusMessage::ReplyMessage : false; 340 if (!d) 341 return false; 342 QMutexLocker locker(&d->mutex); 343 return d->replyMessage.type() == QDBusMessage::ReplyMessage; 333 344 } 334 345 … … 344 355 bool QDBusPendingCall::isError() const 345 356 { 346 return d ? d->replyMessage.type() == QDBusMessage::ErrorMessage : true; 357 if (!d) 358 return true; // considered finished and an error 359 QMutexLocker locker(&d->mutex); 360 return d->replyMessage.type() == QDBusMessage::ErrorMessage; 347 361 } 348 362 … … 357 371 QDBusError QDBusPendingCall::error() const 358 372 { 359 if (d) 373 if (d) { 374 QMutexLocker locker(&d->mutex); 360 375 return d->replyMessage; 376 361 377 362 378 // not connected, return an error … … 379 395 QDBusMessage QDBusPendingCall::reply() const 380 396 { 381 return d ? d->replyMessage : QDBusMessage::createError(error()); 397 if (!d) 398 return QDBusMessage::createError(error()); 399 QMutexLocker locker(&d->mutex); 400 return d->replyMessage; 382 401 } 383 402 … … 440 459 if (msg.type() == QDBusMessage::ErrorMessage || 441 460 msg.type() == QDBusMessage::ReplyMessage) { 442 d = new QDBusPendingCallPrivate ;461 d = new QDBusPendingCallPrivate; 443 462 d->replyMessage = msg; 444 d->connection = 0;445 463 } 446 464 … … 472 490 { 473 491 if (d) { // QDBusPendingCall::d 492 474 493 if (!d->watcherHelper) { 475 494 d->watcherHelper = new QDBusPendingCallWatcherHelper; 476 if ( isFinished()) {495 if () { 477 496 // cause a signal emission anyways 478 497 QMetaObject::invokeMethod(d->watcherHelper, "finished", Qt::QueuedConnection); -
trunk/src/dbus/qdbuspendingcall_p.h
r651 r769 58 58 #include <qpointer.h> 59 59 #include <qlist.h> 60 61 60 62 61 63 #include "qdbusmessage.h" … … 72 74 { 73 75 public: 74 QDBusMessage sentMessage; 75 QDBusMessage replyMessage; 76 // QDBusMessage pendingReplyMessage; // used in the local loop 77 QDBusPendingCallWatcherHelper *watcherHelper; 78 DBusPendingCall *pending; 79 QDBusConnectionPrivate *connection; 76 // { 77 // set only during construction: 78 const QDBusMessage sentMessage; 79 QDBusConnectionPrivate * const connection; 80 80 81 QString expectedReplySignature; 82 int expectedReplyCount; 83 84 // for the callback 81 // for the callback mechanism (see setReplyCallback and QDBusConnectionPrivate::sendWithReplyAsync) 85 82 QPointer<QObject> receiver; 86 83 QList<int> metaTypes; … … 88 85 89 86 bool autoDelete; 87 90 88 91 QDBusPendingCallPrivate() : watcherHelper(0), pending(0), autoDelete(false) 89 mutable QMutex mutex; 90 QWaitCondition waitForFinishedCondition; 91 92 // { 93 // protected by the mutex above: 94 QDBusPendingCallWatcherHelper *watcherHelper; 95 QDBusMessage replyMessage; 96 DBusPendingCall *pending; 97 volatile bool waitingForFinished; 98 99 QString expectedReplySignature; 100 int expectedReplyCount; 101 // } 102 103 QDBusPendingCallPrivate(const QDBusMessage &sent, QDBusConnectionPrivate *connection) 104 : sentMessage(sent), connection(connection), autoDelete(false), watcherHelper(0), pending(0), waitingForFinished(false) 92 105 { } 93 106 ~QDBusPendingCallPrivate(); -
trunk/src/dbus/qdbuspendingreply.cpp
r651 r769 253 253 void QDBusPendingReplyData::assign(const QDBusMessage &message) 254 254 { 255 d = new QDBusPendingCallPrivate ; // drops the reference to the old one255 d = new QDBusPendingCallPrivate; // drops the reference to the old one 256 256 d->replyMessage = message; 257 257 } … … 272 272 { 273 273 Q_ASSERT(d); 274 274 275 d->setMetaTypes(count, types); 275 276 d->checkReceivedSignature();
Note:
See TracChangeset
for help on using the changeset viewer.