Changeset 769 for trunk/src/dbus/qdbusintegrator.cpp
- Timestamp:
- Aug 2, 2010, 9:27:30 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 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/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
Note:
See TracChangeset
for help on using the changeset viewer.