forked from qt-creator/qt-creator
debugger: code cosmetics QmlAdapter
This commit is contained in:
@@ -45,36 +45,38 @@
|
|||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
namespace Debugger {
|
namespace Debugger {
|
||||||
|
namespace Internal {
|
||||||
|
|
||||||
struct QmlAdapterPrivate {
|
class QmlAdapterPrivate
|
||||||
explicit QmlAdapterPrivate(DebuggerEngine *engine, QmlAdapter *q);
|
{
|
||||||
|
public:
|
||||||
|
explicit QmlAdapterPrivate(DebuggerEngine *engine)
|
||||||
|
: m_engine(engine)
|
||||||
|
, m_qmlClient(0)
|
||||||
|
, m_mainClient(0)
|
||||||
|
, m_connectionAttempts(0)
|
||||||
|
, m_conn(0)
|
||||||
|
{
|
||||||
|
m_connectionTimer.setInterval(200);
|
||||||
|
}
|
||||||
|
|
||||||
QWeakPointer<DebuggerEngine> m_engine;
|
QWeakPointer<DebuggerEngine> m_engine;
|
||||||
Internal::QmlDebuggerClient *m_qmlClient;
|
Internal::QmlDebuggerClient *m_qmlClient;
|
||||||
QDeclarativeEngineDebug *m_mainClient;
|
QDeclarativeEngineDebug *m_mainClient;
|
||||||
|
|
||||||
QTimer *m_connectionTimer;
|
QTimer m_connectionTimer;
|
||||||
int m_connectionAttempts;
|
int m_connectionAttempts;
|
||||||
int m_maxConnectionAttempts;
|
int m_maxConnectionAttempts;
|
||||||
QDeclarativeDebugConnection *m_conn;
|
QDeclarativeDebugConnection *m_conn;
|
||||||
QList<QByteArray> sendBuffer;
|
QList<QByteArray> sendBuffer;
|
||||||
};
|
};
|
||||||
|
|
||||||
QmlAdapterPrivate::QmlAdapterPrivate(DebuggerEngine *engine, QmlAdapter *q) :
|
} // namespace Internal
|
||||||
m_engine(engine)
|
|
||||||
, m_qmlClient(0)
|
|
||||||
, m_mainClient(0)
|
|
||||||
, m_connectionTimer(new QTimer(q))
|
|
||||||
, m_connectionAttempts(0)
|
|
||||||
, m_conn(0)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
QmlAdapter::QmlAdapter(DebuggerEngine *engine, QObject *parent)
|
QmlAdapter::QmlAdapter(DebuggerEngine *engine, QObject *parent)
|
||||||
: QObject(parent), d(new QmlAdapterPrivate(engine, this))
|
: QObject(parent), d(new Internal::QmlAdapterPrivate(engine))
|
||||||
{
|
{
|
||||||
d->m_connectionTimer->setInterval(200);
|
connect(&d->m_connectionTimer, SIGNAL(timeout()), SLOT(pollInferior()));
|
||||||
connect(d->m_connectionTimer, SIGNAL(timeout()), SLOT(pollInferior()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QmlAdapter::~QmlAdapter()
|
QmlAdapter::~QmlAdapter()
|
||||||
@@ -84,18 +86,18 @@ QmlAdapter::~QmlAdapter()
|
|||||||
void QmlAdapter::beginConnection()
|
void QmlAdapter::beginConnection()
|
||||||
{
|
{
|
||||||
d->m_connectionAttempts = 0;
|
d->m_connectionAttempts = 0;
|
||||||
d->m_connectionTimer->start();
|
d->m_connectionTimer.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlAdapter::pauseConnection()
|
void QmlAdapter::pauseConnection()
|
||||||
{
|
{
|
||||||
d->m_connectionTimer->stop();
|
d->m_connectionTimer.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlAdapter::closeConnection()
|
void QmlAdapter::closeConnection()
|
||||||
{
|
{
|
||||||
if (d->m_connectionTimer->isActive()) {
|
if (d->m_connectionTimer.isActive()) {
|
||||||
d->m_connectionTimer->stop();
|
d->m_connectionTimer.stop();
|
||||||
} else {
|
} else {
|
||||||
if (d->m_conn) {
|
if (d->m_conn) {
|
||||||
d->m_conn->disconnectFromHost();
|
d->m_conn->disconnectFromHost();
|
||||||
@@ -108,11 +110,11 @@ void QmlAdapter::pollInferior()
|
|||||||
++d->m_connectionAttempts;
|
++d->m_connectionAttempts;
|
||||||
|
|
||||||
if (connectToViewer()) {
|
if (connectToViewer()) {
|
||||||
d->m_connectionTimer->stop();
|
d->m_connectionTimer.stop();
|
||||||
d->m_connectionAttempts = 0;
|
d->m_connectionAttempts = 0;
|
||||||
} else if (d->m_connectionAttempts == d->m_maxConnectionAttempts) {
|
} else if (d->m_connectionAttempts == d->m_maxConnectionAttempts) {
|
||||||
emit connectionStartupFailed();
|
emit connectionStartupFailed();
|
||||||
d->m_connectionTimer->stop();
|
d->m_connectionTimer.stop();
|
||||||
d->m_connectionAttempts = 0;
|
d->m_connectionAttempts = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -268,7 +270,7 @@ void QmlAdapter::setMaxConnectionAttempts(int maxAttempts)
|
|||||||
}
|
}
|
||||||
void QmlAdapter::setConnectionAttemptInterval(int interval)
|
void QmlAdapter::setConnectionAttemptInterval(int interval)
|
||||||
{
|
{
|
||||||
d->m_connectionTimer->setInterval(interval);
|
d->m_connectionTimer.setInterval(interval);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlAdapter::logServiceStatusChange(const QString &service, QDeclarativeDebugClient::Status newStatus)
|
void QmlAdapter::logServiceStatusChange(const QString &service, QDeclarativeDebugClient::Status newStatus)
|
||||||
|
|||||||
@@ -31,16 +31,15 @@
|
|||||||
**
|
**
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
#ifndef QMLADAPTER_H
|
#ifndef DEBGUGGER_QMLADAPTER_H
|
||||||
#define QMLADAPTER_H
|
#define DEBGUGGER_QMLADAPTER_H
|
||||||
|
|
||||||
|
#include "debugger_global.h"
|
||||||
|
#include "qmldebuggerclient.h"
|
||||||
|
|
||||||
#include <QtCore/QObject>
|
#include <QtCore/QObject>
|
||||||
#include <QtCore/QScopedPointer>
|
#include <QtCore/QScopedPointer>
|
||||||
|
|
||||||
#include "debugger_global.h"
|
|
||||||
|
|
||||||
#include <QtNetwork/QAbstractSocket>
|
#include <QtNetwork/QAbstractSocket>
|
||||||
#include "qmldebuggerclient.h"
|
|
||||||
|
|
||||||
namespace QmlJsDebugClient {
|
namespace QmlJsDebugClient {
|
||||||
class QDeclarativeEngineDebug;
|
class QDeclarativeEngineDebug;
|
||||||
@@ -53,9 +52,9 @@ class DebuggerEngine;
|
|||||||
|
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
class QmlDebuggerClient;
|
class QmlDebuggerClient;
|
||||||
|
class QmlAdapterPrivate;
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|
||||||
struct QmlAdapterPrivate;
|
|
||||||
class DEBUGGER_EXPORT QmlAdapter : public QObject
|
class DEBUGGER_EXPORT QmlAdapter : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -103,9 +102,9 @@ private:
|
|||||||
void flushSendBuffer();
|
void flushSendBuffer();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QScopedPointer<QmlAdapterPrivate> d;
|
QScopedPointer<Internal::QmlAdapterPrivate> d;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Debugger
|
} // namespace Debugger
|
||||||
|
|
||||||
#endif // QMLADAPTER_H
|
#endif // DEBGUGGER_QMLADAPTER_H
|
||||||
|
|||||||
Reference in New Issue
Block a user