diff options
author | Thiago Macieira <thiago.macieira@nokia.com> | 2010-02-27 14:22:55 (GMT) |
---|---|---|
committer | Thiago Macieira <thiago.macieira@nokia.com> | 2010-02-27 14:22:55 (GMT) |
commit | 3f626c3e14f2fe5fdecc38d4265d74f8315b3490 (patch) | |
tree | 357b32156e211a33841e44b7a224313c7072ee46 /src/network | |
parent | 57ce77e953b618739f6f1aec67f8e0de97e05b08 (diff) | |
parent | 6396e7a15079cb157caef319348a0bcd0b95a6a7 (diff) | |
download | Qt-3f626c3e14f2fe5fdecc38d4265d74f8315b3490.zip Qt-3f626c3e14f2fe5fdecc38d4265d74f8315b3490.tar.gz Qt-3f626c3e14f2fe5fdecc38d4265d74f8315b3490.tar.bz2 |
Merge remote branch 'origin/master' into 4.7
Conflicts:
src/corelib/kernel/qmetatype.cpp
src/declarative/graphicsitems/qdeclarativeevents.cpp
src/declarative/graphicsitems/qdeclarativeflickable.cpp
src/declarative/graphicsitems/qdeclarativegridview.cpp
src/declarative/qml/qdeclarativescript.cpp
src/declarative/util/qdeclarativeanimation.cpp
src/declarative/util/qdeclarativebehavior.cpp
src/declarative/util/qdeclarativeeasefollow.cpp
src/declarative/util/qdeclarativefontloader.cpp
src/declarative/util/qdeclarativelistmodel.cpp
src/declarative/util/qdeclarativespringfollow.cpp
src/declarative/util/qdeclarativestategroup.cpp
src/declarative/util/qdeclarativesystempalette.cpp
src/declarative/util/qdeclarativetimer.cpp
src/declarative/util/qmlstateoperations.cpp
src/multimedia/qml/qdeclarativeaudio.cpp
src/multimedia/qml/qdeclarativevideo.cpp
Diffstat (limited to 'src/network')
-rw-r--r-- | src/network/access/qhttpnetworkconnection.cpp | 18 | ||||
-rw-r--r-- | src/network/access/qhttpnetworkconnectionchannel.cpp | 2 | ||||
-rw-r--r-- | src/network/access/qnetworkaccessdatabackend.cpp | 7 | ||||
-rw-r--r-- | src/network/access/qnetworkaccessdebugpipebackend.cpp | 4 | ||||
-rw-r--r-- | src/network/access/qnetworkaccessmanager.cpp | 9 | ||||
-rw-r--r-- | src/network/access/qnetworkreplyimpl.cpp | 2 | ||||
-rw-r--r-- | src/network/access/qnetworkrequest.cpp | 2 | ||||
-rw-r--r-- | src/network/kernel/qhostinfo.cpp | 2 | ||||
-rw-r--r-- | src/network/kernel/qhostinfo_unix.cpp | 4 | ||||
-rw-r--r-- | src/network/socket/qabstractsocket.cpp | 10 |
10 files changed, 48 insertions, 12 deletions
diff --git a/src/network/access/qhttpnetworkconnection.cpp b/src/network/access/qhttpnetworkconnection.cpp index 62aa2d7..a887449 100644 --- a/src/network/access/qhttpnetworkconnection.cpp +++ b/src/network/access/qhttpnetworkconnection.cpp @@ -416,13 +416,25 @@ QHttpNetworkReply* QHttpNetworkConnectionPrivate::queueRequest(const QHttpNetwor lowPriorityQueue.prepend(pair); break; } + // this used to be called via invokeMethod and a QueuedConnection + // It is the only place _q_startNextRequest is called directly without going + // through the event loop using a QueuedConnection. + // This is dangerous because of recursion that might occur when emitting + // signals as DirectConnection from this code path. Therefore all signal + // emissions that can come out from this code path need to + // be QueuedConnection. + // We are currently trying to fine-tune this. _q_startNextRequest(); + + return reply; } void QHttpNetworkConnectionPrivate::requeueRequest(const HttpMessagePair &pair) { + Q_Q(QHttpNetworkConnection); + QHttpNetworkRequest request = pair.first; switch (request.priority()) { case QHttpNetworkRequest::HighPriority: @@ -433,8 +445,8 @@ void QHttpNetworkConnectionPrivate::requeueRequest(const HttpMessagePair &pair) lowPriorityQueue.prepend(pair); break; } - // this used to be called via invokeMethod and a QueuedConnection - _q_startNextRequest(); + + QMetaObject::invokeMethod(q, "_q_startNextRequest", Qt::QueuedConnection); } void QHttpNetworkConnectionPrivate::dequeueAndSendRequest(QAbstractSocket *socket) @@ -682,6 +694,8 @@ void QHttpNetworkConnectionPrivate::removeReply(QHttpNetworkReply *reply) +// This function must be called from the event loop. The only +// exception is documented in QHttpNetworkConnectionPrivate::queueRequest void QHttpNetworkConnectionPrivate::_q_startNextRequest() { //resend the necessary ones. diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp index dbee72a..e92b2f3 100644 --- a/src/network/access/qhttpnetworkconnectionchannel.cpp +++ b/src/network/access/qhttpnetworkconnectionchannel.cpp @@ -459,6 +459,8 @@ void QHttpNetworkConnectionChannel::handleUnexpectedEOF() } else { reconnectAttempts--; reply->d_func()->clear(); + reply->d_func()->connection = connection; + reply->d_func()->connectionChannel = this; closeAndResendCurrentRequest(); } } diff --git a/src/network/access/qnetworkaccessdatabackend.cpp b/src/network/access/qnetworkaccessdatabackend.cpp index a2e7ef5..efb6e3e 100644 --- a/src/network/access/qnetworkaccessdatabackend.cpp +++ b/src/network/access/qnetworkaccessdatabackend.cpp @@ -44,6 +44,7 @@ #include "qnetworkreply.h" #include "qurlinfo.h" #include "private/qdataurl_p.h" +#include <qcoreapplication.h> QT_BEGIN_NAMESPACE @@ -72,7 +73,8 @@ void QNetworkAccessDataBackend::open() if (operation() != QNetworkAccessManager::GetOperation && operation() != QNetworkAccessManager::HeadOperation) { // data: doesn't support anything but GET - QString msg = QObject::tr("Operation not supported on %1") + const QString msg = QCoreApplication::translate("QNetworkAccessDataBackend", + "Operation not supported on %1") .arg(uri.toString()); error(QNetworkReply::ContentOperationNotPermittedError, msg); finished(); @@ -96,7 +98,8 @@ void QNetworkAccessDataBackend::open() } // something wrong with this URI - QString msg = QObject::tr("Invalid URI: %1").arg(uri.toString()); + const QString msg = QCoreApplication::translate("QNetworkAccessDataBackend", + "Invalid URI: %1").arg(uri.toString()); error(QNetworkReply::ProtocolFailure, msg); finished(); } diff --git a/src/network/access/qnetworkaccessdebugpipebackend.cpp b/src/network/access/qnetworkaccessdebugpipebackend.cpp index 5926d0b..cd077e7 100644 --- a/src/network/access/qnetworkaccessdebugpipebackend.cpp +++ b/src/network/access/qnetworkaccessdebugpipebackend.cpp @@ -252,7 +252,7 @@ void QNetworkAccessDebugPipeBackend::socketError() break; } - error(code, QObject::tr("Socket error on %1: %2") + error(code, QNetworkAccessDebugPipeBackend::tr("Socket error on %1: %2") .arg(url().toString(), socket.errorString())); finished(); disconnect(&socket, SIGNAL(disconnected()), this, SLOT(socketDisconnected())); @@ -267,7 +267,7 @@ void QNetworkAccessDebugPipeBackend::socketDisconnected() // normal close } else { // abnormal close - QString msg = QObject::tr("Remote host closed the connection prematurely on %1") + QString msg = QNetworkAccessDebugPipeBackend::tr("Remote host closed the connection prematurely on %1") .arg(url().toString()); error(QNetworkReply::RemoteHostClosedError, msg); finished(); diff --git a/src/network/access/qnetworkaccessmanager.cpp b/src/network/access/qnetworkaccessmanager.cpp index b9bd52a..5876ee2 100644 --- a/src/network/access/qnetworkaccessmanager.cpp +++ b/src/network/access/qnetworkaccessmanager.cpp @@ -110,7 +110,8 @@ static void ensureInitialized() object, which holds the common configuration and settings for the requests it sends. It contains the proxy and cache configuration, as well as the signals related to such issues, and reply signals that can be used to - monitor the progress of a network operation. + monitor the progress of a network operation. One QNetworkAccessManager + should be enough for the whole Qt application. Once a QNetworkAccessManager object has been created, the application can use it to send requests over the network. A group of standard functions @@ -121,6 +122,7 @@ static void ensureInitialized() A simple download off the network could be accomplished with: \snippet doc/src/snippets/code/src_network_access_qnetworkaccessmanager.cpp 0 + QNetworkAccessManager has an asynchronous API. When the \tt replyFinished slot above is called, the parameter it takes is the QNetworkReply object containing the downloaded data as well as meta-data (headers, etc.). @@ -130,6 +132,11 @@ static void ensureInitialized() delete it inside the slot connected to finished(). You can use the deleteLater() function. + \note QNetworkAccessManager queues the requests it receives. The number + of requests executed in parallel is dependent on the protocol. + Currently, for the HTTP protocol on desktop platforms, 6 requests are + executed in parallel for one host/port combination. + A more involved example, assuming the manager is already existent, can be: \snippet doc/src/snippets/code/src_network_access_qnetworkaccessmanager.cpp 1 diff --git a/src/network/access/qnetworkreplyimpl.cpp b/src/network/access/qnetworkreplyimpl.cpp index 2175686..b201380 100644 --- a/src/network/access/qnetworkreplyimpl.cpp +++ b/src/network/access/qnetworkreplyimpl.cpp @@ -565,7 +565,7 @@ void QNetworkReplyImplPrivate::finished() } } else { error(QNetworkReply::TemporaryNetworkFailureError, - q->tr("Temporary network failure.")); + QNetworkReply::tr("Temporary network failure.")); } } } diff --git a/src/network/access/qnetworkrequest.cpp b/src/network/access/qnetworkrequest.cpp index e563f4e..61c116d 100644 --- a/src/network/access/qnetworkrequest.cpp +++ b/src/network/access/qnetworkrequest.cpp @@ -138,6 +138,8 @@ QT_BEGIN_NAMESPACE default follow redirections: it's up to the application to determine if the requested redirection should be allowed, according to its security policies. + The returned URL might be relative. Use QUrl::resolved() + to create an absolute URL out of it. \value ConnectionEncryptedAttribute Replies only, type: QVariant::Bool (default: false) diff --git a/src/network/kernel/qhostinfo.cpp b/src/network/kernel/qhostinfo.cpp index 9de499e..93f6d13 100644 --- a/src/network/kernel/qhostinfo.cpp +++ b/src/network/kernel/qhostinfo.cpp @@ -165,7 +165,7 @@ int QHostInfo::lookupHost(const QString &name, QObject *receiver, if (name.isEmpty()) { QHostInfo hostInfo(id); hostInfo.setError(QHostInfo::HostNotFound); - hostInfo.setErrorString(QObject::tr("No host name given")); + hostInfo.setErrorString(QCoreApplication::translate("QHostInfo", "No host name given")); QScopedPointer<QHostInfoResult> result(new QHostInfoResult); QObject::connect(result.data(), SIGNAL(resultsReady(QHostInfo)), receiver, member, Qt::QueuedConnection); diff --git a/src/network/kernel/qhostinfo_unix.cpp b/src/network/kernel/qhostinfo_unix.cpp index be06b6e..a186e78 100644 --- a/src/network/kernel/qhostinfo_unix.cpp +++ b/src/network/kernel/qhostinfo_unix.cpp @@ -193,7 +193,9 @@ QHostInfo QHostInfoAgent::fromName(const QString &hostName) results.setHostName(hostName); if (aceHostname.isEmpty()) { results.setError(QHostInfo::HostNotFound); - results.setErrorString(hostName.isEmpty() ? QObject::tr("No host name given") : QObject::tr("Invalid hostname")); + results.setErrorString(hostName.isEmpty() ? + QCoreApplication::translate("QHostInfoAgent", "No host name given") : + QCoreApplication::translate("QHostInfoAgent", "Invalid hostname")); return results; } diff --git a/src/network/socket/qabstractsocket.cpp b/src/network/socket/qabstractsocket.cpp index 829df89..275c436 100644 --- a/src/network/socket/qabstractsocket.cpp +++ b/src/network/socket/qabstractsocket.cpp @@ -155,6 +155,9 @@ See the \l network/fortuneclient and \l network/blockingfortuneclient examples for an overview of both approaches. + \note We discourage the use of the blocking functions together + with signals. One of the two possibilities should be used. + QAbstractSocket can be used with QTextStream and QDataStream's stream operators (operator<<() and operator>>()). There is one issue to be aware of, though: You must make sure that enough data @@ -1682,9 +1685,12 @@ static int qt_timeout_value(int msecs, int elapsed) If msecs is -1, this function will not time out. - Note: This function may wait slightly longer than \a msecs, + \note This function may wait slightly longer than \a msecs, depending on the time it takes to complete the host lookup. + \note Multiple calls to this functions do not accumulate the time. + If the function times out, the connecting process will be aborted. + \sa connectToHost(), connected() */ bool QAbstractSocket::waitForConnected(int msecs) @@ -1722,7 +1728,7 @@ bool QAbstractSocket::waitForConnected(int msecs) d->_q_startConnecting(QHostInfo::fromName(d->hostName)); } if (state() == UnconnectedState) - return false; + return false; // connect not im progress anymore! bool timedOut = true; #if defined (QABSTRACTSOCKET_DEBUG) |