diff options
author | Tom Sutcliffe <ext-thomas.1.sutcliffe@nokia.com> | 2011-05-11 12:09:23 +0200 |
---|---|---|
committer | Kai Koehne <kai.koehne@nokia.com> | 2011-05-12 13:57:58 +0200 |
commit | bcd88f518bcfe2cd71f7778a8e4550bdfb73c043 (patch) | |
tree | b40fb8356bfce1458df92929113e68b0b6c9cdcc /src/plugins/qmltooling/qmldbg_ost/qostdevice.cpp | |
parent | bc83e44dc31cf4688d9b10d0540e61f5d0e37cdc (diff) |
QmlDebug: Fix QmlOstPlugin compilation failure
Implement waitForMessage()/waitForReadyRead functionality required
by bde58ad1e7d2b38d.
Reviewed-by: kkoehne
(cherry picked from commit 7acaea8557c1c6a758d9a26eff3fb1b3ec19084f)
Diffstat (limited to 'src/plugins/qmltooling/qmldbg_ost/qostdevice.cpp')
-rw-r--r-- | src/plugins/qmltooling/qmldbg_ost/qostdevice.cpp | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/src/plugins/qmltooling/qmldbg_ost/qostdevice.cpp b/src/plugins/qmltooling/qmldbg_ost/qostdevice.cpp index 21b0169c81..d3b2661a27 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; +} |