forked from qt-creator/qt-creator
QmlJSDebugger: Merge back changes done to the files in qtdeclarative
Change-Id: I722b191035757c60ce103edf74517f5348a91955 Reviewed-on: http://codereview.qt.nokia.com/3945 Reviewed-by: Aurindam Jana <aurindam.jana@nokia.com>
This commit is contained in:
@@ -246,6 +246,14 @@ void QDeclarativeDebugConnection::close()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool QDeclarativeDebugConnection::waitForConnected(int msecs)
|
||||||
|
{
|
||||||
|
QAbstractSocket *socket = qobject_cast<QAbstractSocket*>(d->device);
|
||||||
|
if (socket)
|
||||||
|
return socket->waitForConnected(msecs);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// For ease of refactoring we use QAbstractSocket's states even if we're actually using a OstChannel underneath
|
// For ease of refactoring we use QAbstractSocket's states even if we're actually using a OstChannel underneath
|
||||||
// since serial ports have a subset of the socket states afaics
|
// since serial ports have a subset of the socket states afaics
|
||||||
QAbstractSocket::SocketState QDeclarativeDebugConnection::state() const
|
QAbstractSocket::SocketState QDeclarativeDebugConnection::state() const
|
||||||
@@ -350,7 +358,7 @@ QDeclarativeDebugClient::QDeclarativeDebugClient(const QString &name,
|
|||||||
|
|
||||||
QDeclarativeDebugClient::~QDeclarativeDebugClient()
|
QDeclarativeDebugClient::~QDeclarativeDebugClient()
|
||||||
{
|
{
|
||||||
Q_D(QDeclarativeDebugClient);
|
Q_D(const QDeclarativeDebugClient);
|
||||||
if (d->connection && d->connection->d) {
|
if (d->connection && d->connection->d) {
|
||||||
d->connection->d->plugins.remove(d->name);
|
d->connection->d->plugins.remove(d->name);
|
||||||
d->connection->d->advertisePlugins();
|
d->connection->d->advertisePlugins();
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ class QDeclarativeDebugConnectionPrivate;
|
|||||||
class QMLJSDEBUGCLIENT_EXPORT QDeclarativeDebugConnection : public QIODevice
|
class QMLJSDEBUGCLIENT_EXPORT QDeclarativeDebugConnection : public QIODevice
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
Q_DISABLE_COPY(QDeclarativeDebugConnection)
|
||||||
public:
|
public:
|
||||||
QDeclarativeDebugConnection(QObject * = 0);
|
QDeclarativeDebugConnection(QObject * = 0);
|
||||||
~QDeclarativeDebugConnection();
|
~QDeclarativeDebugConnection();
|
||||||
@@ -55,13 +55,14 @@ public:
|
|||||||
void flush();
|
void flush();
|
||||||
bool isSequential() const;
|
bool isSequential() const;
|
||||||
void close();
|
void close();
|
||||||
|
bool waitForConnected(int msecs = 30000);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void connected();
|
void connected();
|
||||||
void stateChanged(QAbstractSocket::SocketState socketState);
|
void stateChanged(QAbstractSocket::SocketState socketState);
|
||||||
void error(QAbstractSocket::SocketError socketError);
|
void error(QAbstractSocket::SocketError socketError);
|
||||||
|
|
||||||
private:
|
protected:
|
||||||
qint64 readData(char *data, qint64 maxSize);
|
qint64 readData(char *data, qint64 maxSize);
|
||||||
qint64 writeData(const char *data, qint64 maxSize);
|
qint64 writeData(const char *data, qint64 maxSize);
|
||||||
|
|
||||||
@@ -76,6 +77,7 @@ class QMLJSDEBUGCLIENT_EXPORT QDeclarativeDebugClient : public QObject
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_DECLARE_PRIVATE(QDeclarativeDebugClient)
|
Q_DECLARE_PRIVATE(QDeclarativeDebugClient)
|
||||||
|
Q_DISABLE_COPY(QDeclarativeDebugClient)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum Status { NotConnected, Unavailable, Enabled };
|
enum Status { NotConnected, Unavailable, Enabled };
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ class QDeclarativeEngineDebugClient : public QDeclarativeDebugClient
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QDeclarativeEngineDebugClient(QDeclarativeDebugConnection *client, QDeclarativeEngineDebugPrivate *p);
|
QDeclarativeEngineDebugClient(QDeclarativeDebugConnection *client, QDeclarativeEngineDebugPrivate *p);
|
||||||
~QDeclarativeEngineDebugClient();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void statusChanged(Status status);
|
virtual void statusChanged(Status status);
|
||||||
@@ -88,10 +87,6 @@ QDeclarativeEngineDebugClient::QDeclarativeEngineDebugClient(QDeclarativeDebugCo
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
QDeclarativeEngineDebugClient::~QDeclarativeEngineDebugClient()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void QDeclarativeEngineDebugClient::statusChanged(Status status)
|
void QDeclarativeEngineDebugClient::statusChanged(Status status)
|
||||||
{
|
{
|
||||||
if (priv)
|
if (priv)
|
||||||
@@ -445,7 +440,9 @@ QDeclarativeEngineDebug::QDeclarativeEngineDebug(QDeclarativeDebugConnection *cl
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
QDeclarativeEngineDebug::~QDeclarativeEngineDebug() { }
|
QDeclarativeEngineDebug::~QDeclarativeEngineDebug()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
QDeclarativeEngineDebug::Status QDeclarativeEngineDebug::status() const
|
QDeclarativeEngineDebug::Status QDeclarativeEngineDebug::status() const
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -29,8 +29,8 @@
|
|||||||
**
|
**
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
#ifndef QDECLARATIVEDEBUG_H
|
#ifndef QDECLARATIVEENGINEDEBUG_H
|
||||||
#define QDECLARATIVEDEBUG_H
|
#define QDECLARATIVEENGINEDEBUG_H
|
||||||
|
|
||||||
#include "qmljsdebugclient_global.h"
|
#include "qmljsdebugclient_global.h"
|
||||||
#include <QtCore/qobject.h>
|
#include <QtCore/qobject.h>
|
||||||
@@ -368,4 +368,4 @@ Q_DECLARE_METATYPE(QmlJsDebugClient::QDeclarativeDebugObjectReference)
|
|||||||
Q_DECLARE_METATYPE(QmlJsDebugClient::QDeclarativeDebugContextReference)
|
Q_DECLARE_METATYPE(QmlJsDebugClient::QDeclarativeDebugContextReference)
|
||||||
Q_DECLARE_METATYPE(QmlJsDebugClient::QDeclarativeDebugPropertyReference)
|
Q_DECLARE_METATYPE(QmlJsDebugClient::QDeclarativeDebugPropertyReference)
|
||||||
|
|
||||||
#endif // QDECLARATIVEDEBUG_H
|
#endif // QDECLARATIVEENGINEDEBUG_H
|
||||||
|
|||||||
@@ -31,7 +31,8 @@
|
|||||||
|
|
||||||
#include "qpacketprotocol.h"
|
#include "qpacketprotocol.h"
|
||||||
|
|
||||||
#include <QtCore/QBuffer>
|
#include <QtCore/qbuffer.h>
|
||||||
|
#include <QtCore/qelapsedtimer.h>
|
||||||
|
|
||||||
namespace QmlJsDebugClient {
|
namespace QmlJsDebugClient {
|
||||||
|
|
||||||
@@ -105,7 +106,7 @@ class QPacketProtocolPrivate : public QObject
|
|||||||
public:
|
public:
|
||||||
QPacketProtocolPrivate(QPacketProtocol *parent, QIODevice *_dev)
|
QPacketProtocolPrivate(QPacketProtocol *parent, QIODevice *_dev)
|
||||||
: QObject(parent), inProgressSize(-1), maxPacketSize(MAX_PACKET_SIZE),
|
: QObject(parent), inProgressSize(-1), maxPacketSize(MAX_PACKET_SIZE),
|
||||||
dev(_dev)
|
waitingForPacket(false), dev(_dev)
|
||||||
{
|
{
|
||||||
Q_ASSERT(4 == sizeof(qint32));
|
Q_ASSERT(4 == sizeof(qint32));
|
||||||
|
|
||||||
@@ -189,6 +190,7 @@ public Q_SLOTS:
|
|||||||
inProgressSize = -1;
|
inProgressSize = -1;
|
||||||
inProgress.clear();
|
inProgress.clear();
|
||||||
|
|
||||||
|
waitingForPacket = false;
|
||||||
emit readyRead();
|
emit readyRead();
|
||||||
} else
|
} else
|
||||||
return;
|
return;
|
||||||
@@ -202,14 +204,15 @@ public:
|
|||||||
QByteArray inProgress;
|
QByteArray inProgress;
|
||||||
qint32 inProgressSize;
|
qint32 inProgressSize;
|
||||||
qint32 maxPacketSize;
|
qint32 maxPacketSize;
|
||||||
QIODevice * dev;
|
bool waitingForPacket;
|
||||||
|
QIODevice *dev;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Construct a QPacketProtocol instance that works on \a dev with the
|
Construct a QPacketProtocol instance that works on \a dev with the
|
||||||
specified \a parent.
|
specified \a parent.
|
||||||
*/
|
*/
|
||||||
QPacketProtocol::QPacketProtocol(QIODevice * dev, QObject * parent)
|
QPacketProtocol::QPacketProtocol(QIODevice *dev, QObject *parent)
|
||||||
: QObject(parent), d(new QPacketProtocolPrivate(this, dev))
|
: QObject(parent), d(new QPacketProtocolPrivate(this, dev))
|
||||||
{
|
{
|
||||||
Q_ASSERT(dev);
|
Q_ASSERT(dev);
|
||||||
@@ -313,10 +316,53 @@ QPacket QPacketProtocol::read()
|
|||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
Returns the difference between msecs and elapsed. If msecs is -1,
|
||||||
|
however, -1 is returned.
|
||||||
|
*/
|
||||||
|
static int qt_timeout_value(int msecs, int elapsed)
|
||||||
|
{
|
||||||
|
if (msecs == -1)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
int timeout = msecs - elapsed;
|
||||||
|
return timeout < 0 ? 0 : timeout;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
This function locks until a new packet is available for reading and the
|
||||||
|
\l{QIODevice::}{readyRead()} signal has been emitted. The function
|
||||||
|
will timeout after \a msecs milliseconds; the default timeout is
|
||||||
|
30000 milliseconds.
|
||||||
|
|
||||||
|
The function returns true if the readyRead() signal is emitted and
|
||||||
|
there is new data available for reading; otherwise it returns false
|
||||||
|
(if an error occurred or the operation timed out).
|
||||||
|
*/
|
||||||
|
|
||||||
|
bool QPacketProtocol::waitForReadyRead(int msecs)
|
||||||
|
{
|
||||||
|
if (!d->packets.isEmpty())
|
||||||
|
return true;
|
||||||
|
|
||||||
|
QElapsedTimer stopWatch;
|
||||||
|
stopWatch.start();
|
||||||
|
|
||||||
|
d->waitingForPacket = true;
|
||||||
|
do {
|
||||||
|
if (!d->dev->waitForReadyRead(msecs))
|
||||||
|
return false;
|
||||||
|
if (!d->waitingForPacket)
|
||||||
|
return true;
|
||||||
|
msecs = qt_timeout_value(msecs, stopWatch.elapsed());
|
||||||
|
} while (true);
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Return the QIODevice passed to the QPacketProtocol constructor.
|
Return the QIODevice passed to the QPacketProtocol constructor.
|
||||||
*/
|
*/
|
||||||
QIODevice * QPacketProtocol::device()
|
QIODevice *QPacketProtocol::device()
|
||||||
{
|
{
|
||||||
return d->dev;
|
return d->dev;
|
||||||
}
|
}
|
||||||
@@ -396,6 +442,7 @@ QPacket::QPacket()
|
|||||||
buf = new QBuffer(&b);
|
buf = new QBuffer(&b);
|
||||||
buf->open(QIODevice::WriteOnly);
|
buf->open(QIODevice::WriteOnly);
|
||||||
setDevice(buf);
|
setDevice(buf);
|
||||||
|
setVersion(QDataStream::Qt_4_7);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -440,6 +487,14 @@ bool QPacket::isEmpty() const
|
|||||||
return b.isEmpty();
|
return b.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Returns raw packet data.
|
||||||
|
*/
|
||||||
|
QByteArray QPacket::data() const
|
||||||
|
{
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Clears data in the packet. This is useful for reusing one writable packet.
|
Clears data in the packet. This is useful for reusing one writable packet.
|
||||||
For example
|
For example
|
||||||
@@ -471,7 +526,7 @@ void QPacket::clear()
|
|||||||
|
|
||||||
\internal
|
\internal
|
||||||
*/
|
*/
|
||||||
QPacketAutoSend::QPacketAutoSend(QPacketProtocol * _p)
|
QPacketAutoSend::QPacketAutoSend(QPacketProtocol *_p)
|
||||||
: QPacket(), p(_p)
|
: QPacket(), p(_p)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,6 +64,8 @@ public:
|
|||||||
qint64 packetsAvailable() const;
|
qint64 packetsAvailable() const;
|
||||||
QPacket read();
|
QPacket read();
|
||||||
|
|
||||||
|
bool waitForReadyRead(int msecs = 3000);
|
||||||
|
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
QIODevice *device();
|
QIODevice *device();
|
||||||
@@ -87,6 +89,7 @@ public:
|
|||||||
|
|
||||||
void clear();
|
void clear();
|
||||||
bool isEmpty() const;
|
bool isEmpty() const;
|
||||||
|
QByteArray data() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
friend class QPacketProtocol;
|
friend class QPacketProtocol;
|
||||||
|
|||||||
Reference in New Issue
Block a user