Changeset 769 for trunk/src/dbus


Ignore:
Timestamp:
Aug 2, 2010, 9:27:30 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.3 sources from branches/vendor/nokia/qt.

Location:
trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/dbus/qdbusargument.cpp

    r651 r769  
    536536/*!
    537537    \internal
    538     Returns the type signature of the D-Bus type this QDBusArgument
    539538    \since 4.5
    540539
  • trunk/src/dbus/qdbusconnection.cpp

    r651 r769  
    492492    QDBusMessage::ReplyMessage or QDBusMessage::ErrorMessage.
    493493
     494
     495
     496
     497
     498
     499
    494500    See the QDBusInterface::call() function for a more friendly way
    495501    of placing calls.
     
    527533    immediately. This function is suitable for method calls only. It
    528534    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().
    532543
    533544    See the QDBusInterface::asyncCall() function for a more friendly way
  • trunk/src/dbus/qdbusintegrator.cpp

    r651 r769  
    524524
    525525    QDBusMessage amsg = QDBusMessagePrivate::fromDBusMessage(message);
    526     qDBusDebug() << d << "got message:" << amsg;
     526    qDBusDebug() << d << "got message:" << amsg;
    527527
    528528    return d->handleMessage(amsg) ?
     
    16611661
    16621662    QString busService = QLatin1String(DBUS_SERVICE_DBUS);
    1663     WatchedServicesHash::mapped_type &bus = watchedServices[busService];
    1664     bus.refcount = 1;
    1665     bus.owner = getNameOwnerNoCache(busService);
    16661663    connectSignal(busService, QString(), QString(), QLatin1String("NameAcquired"), QStringList(), QString(),
    16671664                  this, SLOT(registerService(QString)));
     
    16911688{
    16921689    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    }
    16961707}
    16971708
     
    16991710{
    17001711    QDBusConnectionPrivate *connection = const_cast<QDBusConnectionPrivate *>(call->connection);
     1712
     1713
    17011714
    17021715    QDBusMessage &msg = call->replyMessage;
     
    17291742    }
    17301743
     1744
     1745
     1746
     1747
     1748
     1749
    17311750    // Are there any watchers?
    17321751    if (call->watcherHelper)
     
    17361755        emit connection->callWithCallbackFailed(QDBusError(msg), call->sentMessage);
    17371756
    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!
    17431759        delete call;
     1760
    17441761}
    17451762
     
    18831900    if (isServiceRegisteredByThread(message.service())) {
    18841901        // special case for local calls
    1885         QDBusPendingCallPrivate *pcall = new QDBusPendingCallPrivate;
    1886         pcall->sentMessage = message;
     1902        QDBusPendingCallPrivate *pcall = new QDBusPendingCallPrivate(message, this);
    18871903        pcall->replyMessage = sendWithReplyLocal(message);
    1888         pcall->connection = this;
    18891904
    18901905        return pcall;
     
    18921907
    18931908    checkThread();
    1894     QDBusPendingCallPrivate *pcall = new QDBusPendingCallPrivate;
    1895     pcall->sentMessage = message;
     1909    QDBusPendingCallPrivate *pcall = new QDBusPendingCallPrivate(message, this);
    18961910    pcall->ref = 0;
    18971911
     
    19171931
    19181932            pcall->pending = pending;
    1919             pcall->connection = this;
    19201933            q_dbus_pending_call_set_notify(pending, qDBusResultReceived, pcall, 0);
    19211934
     
    19411954    Q_ASSERT(pcall);
    19421955
    1943     // has it already finished (dispatched locally)?
     1956    // has it already finished (dispatched locally)?
    19441957    if (pcall->replyMessage.type() == QDBusMessage::ReplyMessage) {
    19451958        pcall->setReplyCallback(receiver, returnMethod);
     
    19491962    }
    19501963
     1964
     1965
     1966
     1967
     1968
     1969
     1970
     1971
    19511972    // has it already finished and is an error reply message?
    19521973    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         }
    19581974        processFinishedCall(pcall);
    19591975        delete pcall;
     
    19611977    }
    19621978
    1963     // has it already finished with error?
    1964     if (pcall->replyMessage.type() != QDBusMessage::InvalidMessage) {
    1965         delete pcall;
    1966         return 0;
    1967     }
    1968 
    19691979    pcall->autoDelete = true;
    19701980    pcall->ref.ref();
    1971 
    19721981    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     }
    19781982
    19791983    return 1;
     
    20052009            entry.signature == hook.signature &&
    20062010            entry.obj == hook.obj &&
    2007             entry.midx == hook.midx) {
     2011            entry.midx == hook.midx &&
     2012            entry.argumentMatch == hook.argumentMatch) {
    20082013            // no need to compare the parameters if it's the same slot
    20092014            return true;        // already there
     
    20472052            if (shouldWatchService(hook.service)) {
    20482053                WatchedServicesHash::mapped_type &data = watchedServices[hook.service];
    2049                 if (data.refcount) {
    2050                     // already watching
    2051                     ++data.refcount;
    2052                 } else {
     2054                if (++data.refcount == 1) {
    20532055                    // we need to watch for this service changing
    20542056                    QString dbusServerService = QLatin1String(DBUS_SERVICE_DBUS);
     
    20902092            entry.signature == hook.signature &&
    20912093            entry.obj == hook.obj &&
    2092             entry.midx == hook.midx) {
     2094            entry.midx == hook.midx &&
     2095            entry.argumentMatch == hook.argumentMatch) {
    20932096            // no need to compare the parameters if it's the same slot
    20942097            disconnectSignal(it);
     
    21052108{
    21062109    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     }
    21202110
    21212111    bool erase = false;
     
    21372127        qDBusDebug("Removing rule: %s", hook.matchRule.constData());
    21382128        q_dbus_bus_remove_match(connection, hook.matchRule, NULL);
     2129
     2130
     2131
     2132
     2133
     2134
     2135
     2136
     2137
     2138
     2139
     2140
     2141
     2142
    21392143    }
    21402144
  • trunk/src/dbus/qdbusinterface.cpp

    r651 r769  
    259259{
    260260    _id = QDBusAbstractInterface::qt_metacall(_c, _id, _a);
    261     if (_id < 0 || !d_func()->isValid)
     261    if (_id < 0 || !d_func()->isValid)
    262262        return _id;
    263263    return d_func()->metacall(_c, _id, _a);
  • trunk/src/dbus/qdbusmacros.h

    r651 r769  
    4949#if defined(QDBUS_MAKEDLL)
    5050# define QDBUS_EXPORT Q_DECL_EXPORT
     51
     52
    5153#else
    52 # define QDBUS_EXPORT Q_DECL_IMPORT
     54# define QDBUS_EXPORT
    5355#endif
    5456
  • trunk/src/dbus/qdbusmarshaller.cpp

    r651 r769  
    4141
    4242#include "qdbusargument_p.h"
     43
    4344#include "qdbusutil_p.h"
    4445
     
    168169    QByteArray tmpSignature;
    169170    const char *signature = 0;
    170     if (int(id) == qMetaTypeId<QDBusArgument>()) {
     171    if (int(id) == ) {
    171172        // take the signature from the QDBusArgument object we're marshalling
    172173        tmpSignature =
     
    354355
    355356    // intercept QDBusArgument parameters here
    356     if (id == qMetaTypeId<QDBusArgument>()) {
     357    if (id == ) {
    357358        QDBusArgument dbusargument = qvariant_cast<QDBusArgument>(arg);
    358359        QDBusArgumentPrivate *d = QDBusArgumentPrivate::d(dbusargument);
  • trunk/src/dbus/qdbuspendingcall.cpp

    r651 r769  
    209209void QDBusPendingCallPrivate::checkReceivedSignature()
    210210{
     211
     212
    211213    if (replyMessage.type() == QDBusMessage::InvalidMessage)
    212214        return;                 // not yet finished - no message to
     
    231233void QDBusPendingCallPrivate::waitForFinished()
    232234{
     235
     236
    233237    if (replyMessage.type() != QDBusMessage::InvalidMessage)
    234238        return;                 // already finished
     
    311315bool QDBusPendingCall::isFinished() const
    312316{
    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;
    314322}
    315323
     
    330338bool QDBusPendingCall::isValid() const
    331339{
    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;
    333344}
    334345
     
    344355bool QDBusPendingCall::isError() const
    345356{
    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;
    347361}
    348362
     
    357371QDBusError QDBusPendingCall::error() const
    358372{
    359     if (d)
     373    if (d) {
     374        QMutexLocker locker(&d->mutex);
    360375        return d->replyMessage;
     376
    361377
    362378    // not connected, return an error
     
    379395QDBusMessage QDBusPendingCall::reply() const
    380396{
    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;
    382401}
    383402
     
    440459    if (msg.type() == QDBusMessage::ErrorMessage ||
    441460        msg.type() == QDBusMessage::ReplyMessage) {
    442         d = new QDBusPendingCallPrivate;
     461        d = new QDBusPendingCallPrivate;
    443462        d->replyMessage = msg;
    444         d->connection = 0;
    445463    }
    446464
     
    472490{
    473491    if (d) {                    // QDBusPendingCall::d
     492
    474493        if (!d->watcherHelper) {
    475494            d->watcherHelper = new QDBusPendingCallWatcherHelper;
    476             if (isFinished()) {
     495            if () {
    477496                // cause a signal emission anyways
    478497                QMetaObject::invokeMethod(d->watcherHelper, "finished", Qt::QueuedConnection);
  • trunk/src/dbus/qdbuspendingcall_p.h

    r651 r769  
    5858#include <qpointer.h>
    5959#include <qlist.h>
     60
     61
    6062
    6163#include "qdbusmessage.h"
     
    7274{
    7375public:
    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;
    8080
    81     QString expectedReplySignature;
    82     int expectedReplyCount;
    83 
    84     // for the callback
     81    // for the callback mechanism (see setReplyCallback and QDBusConnectionPrivate::sendWithReplyAsync)
    8582    QPointer<QObject> receiver;
    8683    QList<int> metaTypes;
     
    8885
    8986    bool autoDelete;
     87
    9088
    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)
    92105    { }
    93106    ~QDBusPendingCallPrivate();
  • trunk/src/dbus/qdbuspendingreply.cpp

    r651 r769  
    253253void QDBusPendingReplyData::assign(const QDBusMessage &message)
    254254{
    255     d = new QDBusPendingCallPrivate; // drops the reference to the old one
     255    d = new QDBusPendingCallPrivate; // drops the reference to the old one
    256256    d->replyMessage = message;
    257257}
     
    272272{
    273273    Q_ASSERT(d);
     274
    274275    d->setMetaTypes(count, types);
    275276    d->checkReceivedSignature();
Note: See TracChangeset for help on using the changeset viewer.