diff options
author | Thierry Bastian <thierry.bastian@nokia.com> | 2011-05-19 12:15:26 (GMT) |
---|---|---|
committer | Thierry Bastian <thierry.bastian@nokia.com> | 2011-05-19 12:15:26 (GMT) |
commit | 37c4cd4801106112b638ed9d2164b87bbc0a0d1e (patch) | |
tree | 3dcc9e1b9908328d1355f5746fd77de7030b547f /src/plugins/qmltooling/qmldbg_ost | |
parent | b6a6953d21a95c402e8a5010c1ea5131509eeea3 (diff) | |
parent | 35b5f15c3fe5c2f1f0d046d09b9d95dee3bb91b5 (diff) | |
download | Qt-37c4cd4801106112b638ed9d2164b87bbc0a0d1e.zip Qt-37c4cd4801106112b638ed9d2164b87bbc0a0d1e.tar.gz Qt-37c4cd4801106112b638ed9d2164b87bbc0a0d1e.tar.bz2 |
Merge branch '4.8-upstream'
Diffstat (limited to 'src/plugins/qmltooling/qmldbg_ost')
-rw-r--r-- | src/plugins/qmltooling/qmldbg_ost/qmlostplugin.cpp | 6 | ||||
-rw-r--r-- | src/plugins/qmltooling/qmldbg_ost/qmlostplugin.h | 1 | ||||
-rw-r--r-- | src/plugins/qmltooling/qmldbg_ost/qostdevice.cpp | 42 | ||||
-rw-r--r-- | src/plugins/qmltooling/qmldbg_ost/qostdevice.h | 4 |
4 files changed, 51 insertions, 2 deletions
diff --git a/src/plugins/qmltooling/qmldbg_ost/qmlostplugin.cpp b/src/plugins/qmltooling/qmldbg_ost/qmlostplugin.cpp index 1c91c34..ac32081 100644 --- a/src/plugins/qmltooling/qmldbg_ost/qmlostplugin.cpp +++ b/src/plugins/qmltooling/qmldbg_ost/qmlostplugin.cpp @@ -109,6 +109,12 @@ void QmlOstPlugin::disconnect() d->protocol = 0; } +bool QmlOstPlugin::waitForMessage() +{ + Q_D(QmlOstPlugin); + return d->protocol->waitForReadyRead(-1); +} + void QmlOstPlugin::setPort(int port, bool block) { Q_UNUSED(port); diff --git a/src/plugins/qmltooling/qmldbg_ost/qmlostplugin.h b/src/plugins/qmltooling/qmldbg_ost/qmlostplugin.h index eee6ee1..b4ff377 100644 --- a/src/plugins/qmltooling/qmldbg_ost/qmlostplugin.h +++ b/src/plugins/qmltooling/qmldbg_ost/qmlostplugin.h @@ -68,6 +68,7 @@ public: bool isConnected() const; void send(const QByteArray &message); void disconnect(); + bool waitForMessage(); private Q_SLOTS: void readyRead(); diff --git a/src/plugins/qmltooling/qmldbg_ost/qostdevice.cpp b/src/plugins/qmltooling/qmldbg_ost/qostdevice.cpp index 21b0169..d3b2661 100644 --- a/src/plugins/qmltooling/qmldbg_ost/qostdevice.cpp +++ b/src/plugins/qmltooling/qmldbg_ost/qostdevice.cpp @@ -57,6 +57,8 @@ public: Cancel(); } + TInt& AoFlags() { return ((TInt*)&iStatus)[1]; } + private: void RunL(); void DoCancel(); @@ -65,6 +67,7 @@ private: RUsbOstComm ost; TBuf8<4096> readBuf; QByteArray dataBuf; + TBool inReadyRead; }; QOstDevice::QOstDevice(QObject *parent) : @@ -116,7 +119,11 @@ void QOstDevicePrivate::RunL() ost.ReadMessage(iStatus, readBuf); SetActive(); - emit q->readyRead(); + if (!inReadyRead) { + inReadyRead = true; + emit q->readyRead(); + inReadyRead = false; + } } else { q->setErrorString(QString("Error %1 from RUsbOstComm::ReadMessage()").arg(iStatus.Int())); } @@ -178,3 +185,36 @@ qint64 QOstDevice::bytesAvailable() const Q_D(const QOstDevice); return d->dataBuf.length(); } + +bool QOstDevice::waitForReadyRead(int msecs) +{ + Q_D(QOstDevice); + if (msecs >= 0) { + RTimer timer; + TInt err = timer.CreateLocal(); + if (err) return false; + TRequestStatus timeoutStat; + timer.After(timeoutStat, msecs*1000); + User::WaitForRequest(timeoutStat, d->iStatus); + if (timeoutStat != KRequestPending) { + // Timed out + timer.Close(); + return false; + } else { + // We got data, so cancel timer + timer.Cancel(); + User::WaitForRequest(timeoutStat); + timer.Close(); + // And drop through + } + } else { + // Just wait forever for data + User::WaitForRequest(d->iStatus); + } + + // If we get here we have data + TInt err = d->iStatus.Int(); + d->AoFlags() &= ~3; // This is necessary to clean up the scheduler as you're not supposed to bypass it like this + TRAP_IGNORE(d->RunL()); + return err == KErrNone; +} diff --git a/src/plugins/qmltooling/qmldbg_ost/qostdevice.h b/src/plugins/qmltooling/qmldbg_ost/qostdevice.h index 2c26ff7..200e607 100644 --- a/src/plugins/qmltooling/qmldbg_ost/qostdevice.h +++ b/src/plugins/qmltooling/qmldbg_ost/qostdevice.h @@ -61,10 +61,12 @@ public: bool open(int ostProtocolId); void close(); + bool waitForReadyRead(int msecs); + qint64 bytesAvailable() const; + protected: qint64 readData(char *data, qint64 maxSize); qint64 writeData(const char *data, qint64 maxSize); - qint64 bytesAvailable() const; private: QOstDevicePrivate* d_ptr; |