forked from qt-creator/qt-creator
QmlDebugger: Log status of different services
Reviewed-by: Christiaan Janssen
This commit is contained in:
@@ -143,6 +143,16 @@ void QmlAdapter::connectionErrorOccurred(QAbstractSocket::SocketError socketErro
|
||||
emit connectionError(socketError);
|
||||
}
|
||||
|
||||
void QmlAdapter::clientStatusChanged(QDeclarativeDebugClient::Status status)
|
||||
{
|
||||
QString serviceName;
|
||||
if (QDeclarativeDebugClient *client = qobject_cast<QDeclarativeDebugClient*>(sender())) {
|
||||
serviceName = client->name();
|
||||
}
|
||||
|
||||
logServiceStatusChange(serviceName, status);
|
||||
}
|
||||
|
||||
void QmlAdapter::connectionStateChanged()
|
||||
{
|
||||
switch (d->m_conn->state()) {
|
||||
@@ -165,6 +175,7 @@ void QmlAdapter::connectionStateChanged()
|
||||
|
||||
if (!d->m_mainClient) {
|
||||
d->m_mainClient = new QDeclarativeEngineDebug(d->m_conn, this);
|
||||
logServiceStatusChange(QLatin1String("QmlObserver"), static_cast<QDeclarativeDebugClient::Status>(d->m_mainClient->status()));
|
||||
}
|
||||
|
||||
createDebuggerClient();
|
||||
@@ -185,11 +196,15 @@ void QmlAdapter::createDebuggerClient()
|
||||
{
|
||||
d->m_qmlClient = new Internal::QmlDebuggerClient(d->m_conn);
|
||||
|
||||
connect(d->m_qmlClient, SIGNAL(newStatus(QDeclarativeDebugClient::Status)),
|
||||
this, SLOT(clientStatusChanged(QDeclarativeDebugClient::Status)));
|
||||
connect(d->m_engine.data(), SIGNAL(sendMessage(QByteArray)),
|
||||
d->m_qmlClient, SLOT(slotSendMessage(QByteArray)));
|
||||
connect(d->m_qmlClient, SIGNAL(messageWasReceived(QByteArray)),
|
||||
d->m_engine.data(), SLOT(messageReceived(QByteArray)));
|
||||
|
||||
logServiceStatusChange(d->m_qmlClient->name(), d->m_qmlClient->status());
|
||||
|
||||
//engine->startSuccessful(); // FIXME: AAA: port to new debugger states
|
||||
}
|
||||
|
||||
@@ -237,4 +252,24 @@ void QmlAdapter::setConnectionAttemptInterval(int interval)
|
||||
d->m_connectionTimer->setInterval(interval);
|
||||
}
|
||||
|
||||
void QmlAdapter::logServiceStatusChange(const QString &service, QDeclarativeDebugClient::Status newStatus)
|
||||
{
|
||||
switch (newStatus) {
|
||||
case QDeclarativeDebugClient::Unavailable: {
|
||||
showConnectionErrorMessage(tr("Error: Cannot connect to debug service '%1'. Debugging functionality will be limited.").arg(service));
|
||||
emit serviceConnectionError(service);
|
||||
break;
|
||||
}
|
||||
case QDeclarativeDebugClient::Enabled: {
|
||||
showConnectionStatusMessage(tr("Connected to debug service '%1'.").arg(service));
|
||||
break;
|
||||
}
|
||||
|
||||
case QDeclarativeDebugClient::NotConnected: {
|
||||
showConnectionStatusMessage(tr("Not connected to debug service '%1'.").arg(service));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Debugger
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
#include "debugger_global.h"
|
||||
|
||||
#include <QtNetwork/QAbstractSocket>
|
||||
#include "qmldebuggerclient.h"
|
||||
|
||||
namespace QmlJsDebugClient {
|
||||
class QDeclarativeEngineDebug;
|
||||
@@ -72,15 +73,19 @@ public:
|
||||
void setMaxConnectionAttempts(int maxAttempts);
|
||||
void setConnectionAttemptInterval(int interval);
|
||||
|
||||
void logServiceStatusChange(const QString &service, QDeclarativeDebugClient::Status newStatus);
|
||||
|
||||
signals:
|
||||
void aboutToDisconnect();
|
||||
void connected();
|
||||
void disconnected();
|
||||
void connectionStartupFailed();
|
||||
void connectionError(QAbstractSocket::SocketError socketError);
|
||||
void serviceConnectionError(const QString serviceName);
|
||||
|
||||
private slots:
|
||||
void connectionErrorOccurred(QAbstractSocket::SocketError socketError);
|
||||
void clientStatusChanged(QDeclarativeDebugClient::Status status);
|
||||
void connectionStateChanged();
|
||||
void pollInferior();
|
||||
|
||||
|
||||
@@ -43,6 +43,11 @@ QmlDebuggerClient::~QmlDebuggerClient()
|
||||
{
|
||||
}
|
||||
|
||||
void QmlDebuggerClient::statusChanged(Status status)
|
||||
{
|
||||
emit newStatus(status);
|
||||
}
|
||||
|
||||
void QmlDebuggerClient::messageReceived(const QByteArray &data)
|
||||
{
|
||||
emit messageWasReceived(data);
|
||||
|
||||
@@ -44,12 +44,14 @@ public:
|
||||
virtual ~QmlDebuggerClient();
|
||||
|
||||
signals:
|
||||
void newStatus(QDeclarativeDebugClient::Status status);
|
||||
void messageWasReceived(const QByteArray &data);
|
||||
|
||||
private Q_SLOTS:
|
||||
void slotSendMessage(const QByteArray &message);
|
||||
|
||||
protected:
|
||||
virtual void statusChanged(Status status);
|
||||
virtual void messageReceived(const QByteArray &data);
|
||||
};
|
||||
|
||||
|
||||
@@ -218,6 +218,12 @@ void QmlEngine::connectionError(QAbstractSocket::SocketError socketError)
|
||||
plugin()->showMessage(tr("QML Debugger: Remote host closed connection."), StatusBar);
|
||||
}
|
||||
|
||||
|
||||
void QmlEngine::serviceConnectionError(const QString &serviceName)
|
||||
{
|
||||
plugin()->showMessage(tr("QML Debugger: Couldn't connect to service '%1'.").arg(serviceName), StatusBar);
|
||||
}
|
||||
|
||||
void QmlEngine::runEngine()
|
||||
{
|
||||
QTC_ASSERT(state() == EngineRunRequested, qDebug() << state());
|
||||
@@ -327,6 +333,7 @@ void QmlEngine::setupEngine()
|
||||
d->m_adapter->setConnectionAttemptInterval(ConnectionAttemptDefaultInterval);
|
||||
connect(d->m_adapter, SIGNAL(connectionError(QAbstractSocket::SocketError)),
|
||||
SLOT(connectionError(QAbstractSocket::SocketError)));
|
||||
connect(d->m_adapter, SIGNAL(serviceConnectionError(QString)), SLOT(serviceConnectionError(QString)));
|
||||
connect(d->m_adapter, SIGNAL(connected()), SLOT(connectionEstablished()));
|
||||
connect(d->m_adapter, SIGNAL(connectionStartupFailed()), SLOT(connectionStartupFailed()));
|
||||
|
||||
|
||||
@@ -117,6 +117,7 @@ private slots:
|
||||
void connectionEstablished();
|
||||
void connectionStartupFailed();
|
||||
void connectionError(QAbstractSocket::SocketError error);
|
||||
void serviceConnectionError(const QString &service);
|
||||
|
||||
private:
|
||||
void expandObject(const QByteArray &iname, quint64 objectId);
|
||||
|
||||
@@ -65,8 +65,14 @@ ClientProxy::ClientProxy(Debugger::QmlAdapter *adapter, QObject *parent)
|
||||
void ClientProxy::connectToServer()
|
||||
{
|
||||
m_designClient = new QmlJSObserverClient(m_adapter->connection(), this);
|
||||
|
||||
if (m_designClient->status() == QDeclarativeDebugClient::Enabled)
|
||||
emit connected();
|
||||
|
||||
m_adapter->logServiceStatusChange(m_designClient->name(), m_designClient->status());
|
||||
|
||||
connect(m_designClient, SIGNAL(connectedStatusChanged(QDeclarativeDebugClient::Status)),
|
||||
this, SLOT(clientStatusChanged(QDeclarativeDebugClient::Status)));
|
||||
connect(m_designClient, SIGNAL(currentObjectsChanged(QList<int>)),
|
||||
SLOT(onCurrentObjectsChanged(QList<int>)));
|
||||
connect(m_designClient, SIGNAL(colorPickerActivated()),
|
||||
@@ -90,9 +96,24 @@ void ClientProxy::connectToServer()
|
||||
reloadEngines();
|
||||
}
|
||||
|
||||
void ClientProxy::clientStatusChanged(QDeclarativeDebugClient::Status status)
|
||||
{
|
||||
QString serviceName;
|
||||
if (QDeclarativeDebugClient *client = qobject_cast<QDeclarativeDebugClient*>(sender())) {
|
||||
serviceName = client->name();
|
||||
}
|
||||
|
||||
m_adapter->logServiceStatusChange(serviceName, status);
|
||||
|
||||
if (status == QDeclarativeDebugClient::Enabled)
|
||||
emit connected();
|
||||
}
|
||||
|
||||
void ClientProxy::disconnectFromServer()
|
||||
{
|
||||
if (m_designClient) {
|
||||
disconnect(m_designClient, SIGNAL(connectedStatusChanged(QDeclarativeDebugClient::Status)),
|
||||
this, SLOT(clientStatusChanged(QDeclarativeDebugClient::Status)));
|
||||
disconnect(m_designClient, SIGNAL(currentObjectsChanged(QList<int>)),
|
||||
this, SLOT(onCurrentObjectsChanged(QList<int>)));
|
||||
disconnect(m_designClient, SIGNAL(colorPickerActivated()),
|
||||
@@ -164,7 +185,7 @@ void ClientProxy::onCurrentObjectsChanged(const QList< int >& debugIds, bool req
|
||||
|
||||
void ClientProxy::setSelectedItemsByObjectId(const QList<QDeclarativeDebugObjectReference> &objectRefs)
|
||||
{
|
||||
if (isConnected() && m_designClient)
|
||||
if (isConnected())
|
||||
m_designClient->setSelectedItemsByObjectId(objectRefs);
|
||||
}
|
||||
|
||||
@@ -285,7 +306,7 @@ QDeclarativeDebugExpressionQuery *ClientProxy::queryExpressionResult(int objectD
|
||||
|
||||
void ClientProxy::clearComponentCache()
|
||||
{
|
||||
if (isDesignClientConnected())
|
||||
if (isConnected())
|
||||
m_designClient->clearComponentCache();
|
||||
}
|
||||
|
||||
@@ -365,7 +386,7 @@ void ClientProxy::objectTreeFetched(QDeclarativeDebugQuery::State state)
|
||||
buildDebugIdHashRecursive(it);
|
||||
emit objectTreeUpdated();
|
||||
|
||||
if (isDesignClientConnected()) {
|
||||
if (isConnected()) {
|
||||
if (!m_designClient->selectedItemIds().isEmpty())
|
||||
onCurrentObjectsChanged(m_designClient->selectedItemIds(), false);
|
||||
|
||||
@@ -410,76 +431,70 @@ void ClientProxy::buildDebugIdHashRecursive(const QDeclarativeDebugObjectReferen
|
||||
|
||||
void ClientProxy::reloadQmlViewer()
|
||||
{
|
||||
if (isDesignClientConnected())
|
||||
if (isConnected())
|
||||
m_designClient->reloadViewer();
|
||||
}
|
||||
|
||||
void ClientProxy::setDesignModeBehavior(bool inDesignMode)
|
||||
{
|
||||
if (isDesignClientConnected())
|
||||
if (isConnected())
|
||||
m_designClient->setDesignModeBehavior(inDesignMode);
|
||||
}
|
||||
|
||||
void ClientProxy::setAnimationSpeed(qreal slowdownFactor)
|
||||
{
|
||||
if (isDesignClientConnected())
|
||||
if (isConnected())
|
||||
m_designClient->setAnimationSpeed(slowdownFactor);
|
||||
}
|
||||
|
||||
void ClientProxy::changeToColorPickerTool()
|
||||
{
|
||||
if (isDesignClientConnected())
|
||||
if (isConnected())
|
||||
m_designClient->changeToColorPickerTool();
|
||||
}
|
||||
|
||||
void ClientProxy::changeToZoomTool()
|
||||
{
|
||||
if (isDesignClientConnected())
|
||||
if (isConnected())
|
||||
m_designClient->changeToZoomTool();
|
||||
}
|
||||
void ClientProxy::changeToSelectTool()
|
||||
{
|
||||
if (isDesignClientConnected())
|
||||
if (isConnected())
|
||||
m_designClient->changeToSelectTool();
|
||||
}
|
||||
|
||||
void ClientProxy::changeToSelectMarqueeTool()
|
||||
{
|
||||
if (isDesignClientConnected())
|
||||
if (isConnected())
|
||||
m_designClient->changeToSelectMarqueeTool();
|
||||
}
|
||||
|
||||
void ClientProxy::createQmlObject(const QString &qmlText, int parentDebugId,
|
||||
const QStringList &imports, const QString &filename)
|
||||
{
|
||||
if (isDesignClientConnected())
|
||||
if (isConnected())
|
||||
m_designClient->createQmlObject(qmlText, parentDebugId, imports, filename);
|
||||
}
|
||||
|
||||
void ClientProxy::destroyQmlObject(int debugId)
|
||||
{
|
||||
if (isDesignClientConnected())
|
||||
if (isConnected())
|
||||
m_designClient->destroyQmlObject(debugId);
|
||||
}
|
||||
|
||||
void ClientProxy::reparentQmlObject(int debugId, int newParent)
|
||||
{
|
||||
if (isDesignClientConnected())
|
||||
if (isConnected())
|
||||
m_designClient->reparentQmlObject(debugId, newParent);
|
||||
}
|
||||
|
||||
void ClientProxy::setContextPathIndex(int contextIndex)
|
||||
{
|
||||
if (isDesignClientConnected())
|
||||
if (isConnected())
|
||||
m_designClient->setContextPathIndex(contextIndex);
|
||||
}
|
||||
|
||||
|
||||
bool ClientProxy::isDesignClientConnected() const
|
||||
{
|
||||
return (m_designClient && m_adapter->isConnected());
|
||||
}
|
||||
|
||||
void ClientProxy::reloadEngines()
|
||||
{
|
||||
if (m_engineQuery) {
|
||||
@@ -518,7 +533,8 @@ Debugger::QmlAdapter *ClientProxy::qmlAdapter() const
|
||||
|
||||
bool ClientProxy::isConnected() const
|
||||
{
|
||||
return m_adapter->isConnected();
|
||||
return m_designClient && m_designClient->status() == QDeclarativeDebugClient::Enabled
|
||||
&& m_client && m_client->status() == QDeclarativeEngineDebug::Enabled;
|
||||
}
|
||||
|
||||
void ClientProxy::newObjects()
|
||||
|
||||
@@ -125,6 +125,7 @@ public slots:
|
||||
private slots:
|
||||
void disconnectFromServer();
|
||||
void connectToServer();
|
||||
void clientStatusChanged(QDeclarativeDebugClient::Status status);
|
||||
|
||||
void contextChanged();
|
||||
|
||||
@@ -135,7 +136,6 @@ private slots:
|
||||
void newObjects();
|
||||
|
||||
private:
|
||||
bool isDesignClientConnected() const;
|
||||
void reloadEngines();
|
||||
|
||||
QList<QDeclarativeDebugObjectReference> objectReferences(const QDeclarativeDebugObjectReference &objectRef) const;
|
||||
|
||||
@@ -55,6 +55,11 @@ QmlJSObserverClient::QmlJSObserverClient(QDeclarativeDebugConnection *client,
|
||||
{
|
||||
}
|
||||
|
||||
void QmlJSObserverClient::statusChanged(Status status)
|
||||
{
|
||||
emit connectedStatusChanged(status);
|
||||
}
|
||||
|
||||
void QmlJSObserverClient::messageReceived(const QByteArray &message)
|
||||
{
|
||||
QDataStream ds(message);
|
||||
|
||||
@@ -80,6 +80,8 @@ public:
|
||||
void clearComponentCache();
|
||||
|
||||
signals:
|
||||
void connectedStatusChanged(QDeclarativeDebugClient::Status status);
|
||||
|
||||
void currentObjectsChanged(const QList<int> &debugIds);
|
||||
void selectedColorChanged(const QColor &color);
|
||||
void colorPickerActivated();
|
||||
@@ -92,6 +94,7 @@ signals:
|
||||
void contextPathUpdated(const QStringList &path);
|
||||
|
||||
protected:
|
||||
virtual void statusChanged(Status);
|
||||
virtual void messageReceived(const QByteArray &);
|
||||
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user