forked from qt-creator/qt-creator
QmlDebug: Decouple QmlDebugConnection and QmlDebugClient
The protected methods of QmlDebugClient need to be called by QmlDebugConnection already. We also want to call them directly for testing, so we make them public rather than having QmlDebugConnection be a friend. By using a QPointer, we can avoid resetting the connection on each client when it is deleted. Change-Id: I2c0e3d2b8ec19e9acbc6b8f5623b4c28caae319a Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -72,6 +72,9 @@ public:
|
|||||||
virtual quint32 queryObjectsForLocation(const QString &fileName, int lineNumber,
|
virtual quint32 queryObjectsForLocation(const QString &fileName, int lineNumber,
|
||||||
int columnNumber);
|
int columnNumber);
|
||||||
|
|
||||||
|
virtual void stateChanged(State status) override;
|
||||||
|
virtual void messageReceived(const QByteArray &) override;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void newState(QmlDebug::QmlDebugClient::State status);
|
void newState(QmlDebug::QmlDebugClient::State status);
|
||||||
void newObject(int engineId, int objectId, int parentId);
|
void newObject(int engineId, int objectId, int parentId);
|
||||||
@@ -80,9 +83,6 @@ signals:
|
|||||||
void result(quint32 queryId, const QVariant &result, const QByteArray &type);
|
void result(quint32 queryId, const QVariant &result, const QByteArray &type);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void stateChanged(State status) override;
|
|
||||||
virtual void messageReceived(const QByteArray &) override;
|
|
||||||
|
|
||||||
quint32 getId() { return m_nextId++; }
|
quint32 getId() { return m_nextId++; }
|
||||||
|
|
||||||
void decode(QDataStream &d, ContextReference &context);
|
void decode(QDataStream &d, ContextReference &context);
|
||||||
|
@@ -45,7 +45,6 @@ public:
|
|||||||
quint32 setMethodBody(int objectDebugId, const QString &methodName,
|
quint32 setMethodBody(int objectDebugId, const QString &methodName,
|
||||||
const QString &methodBody) override;
|
const QString &methodBody) override;
|
||||||
|
|
||||||
protected:
|
|
||||||
void messageReceived(const QByteArray &data) override;
|
void messageReceived(const QByteArray &data) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -44,7 +44,6 @@ public:
|
|||||||
// ### Qt 4.8: remove if we can have access to qdeclarativecontextdata or id's
|
// ### Qt 4.8: remove if we can have access to qdeclarativecontextdata or id's
|
||||||
void setObjectIdList(const QList<ObjectReference> &objectRoots) override;
|
void setObjectIdList(const QList<ObjectReference> &objectRoots) override;
|
||||||
|
|
||||||
protected:
|
|
||||||
void messageReceived(const QByteArray &) override;
|
void messageReceived(const QByteArray &) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@@ -46,7 +46,6 @@ class QMLDEBUG_EXPORT QDebugMessageClient : public QmlDebugClient
|
|||||||
public:
|
public:
|
||||||
explicit QDebugMessageClient(QmlDebugConnection *client);
|
explicit QDebugMessageClient(QmlDebugConnection *client);
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual void stateChanged(State state) override;
|
virtual void stateChanged(State state) override;
|
||||||
virtual void messageReceived(const QByteArray &) override;
|
virtual void messageReceived(const QByteArray &) override;
|
||||||
|
|
||||||
|
@@ -33,6 +33,8 @@
|
|||||||
#include <qlocalserver.h>
|
#include <qlocalserver.h>
|
||||||
#include <qlocalsocket.h>
|
#include <qlocalsocket.h>
|
||||||
|
|
||||||
|
#include <QPointer>
|
||||||
|
|
||||||
namespace QmlDebug {
|
namespace QmlDebug {
|
||||||
|
|
||||||
const int protocolVersion = 1;
|
const int protocolVersion = 1;
|
||||||
@@ -46,7 +48,7 @@ public:
|
|||||||
QmlDebugClientPrivate();
|
QmlDebugClientPrivate();
|
||||||
|
|
||||||
QString name;
|
QString name;
|
||||||
QmlDebugConnection *connection;
|
QPointer<QmlDebugConnection> connection;
|
||||||
};
|
};
|
||||||
|
|
||||||
class QmlDebugConnectionPrivate
|
class QmlDebugConnectionPrivate
|
||||||
@@ -263,11 +265,7 @@ QmlDebugConnection::QmlDebugConnection(QObject *parent)
|
|||||||
|
|
||||||
QmlDebugConnection::~QmlDebugConnection()
|
QmlDebugConnection::~QmlDebugConnection()
|
||||||
{
|
{
|
||||||
Q_D(QmlDebugConnection);
|
|
||||||
socketDisconnected();
|
socketDisconnected();
|
||||||
QHash<QString, QmlDebugClient*>::iterator iter = d->plugins.begin();
|
|
||||||
for (; iter != d->plugins.end(); ++iter)
|
|
||||||
iter.value()->d_func()->connection = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QmlDebugConnection::isConnected() const
|
bool QmlDebugConnection::isConnected() const
|
||||||
@@ -435,7 +433,6 @@ QAbstractSocket::SocketState QmlDebugConnection::socketState() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
QmlDebugClientPrivate::QmlDebugClientPrivate()
|
QmlDebugClientPrivate::QmlDebugClientPrivate()
|
||||||
: connection(0)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -97,13 +97,10 @@ public:
|
|||||||
QmlDebugConnection *connection() const;
|
QmlDebugConnection *connection() const;
|
||||||
|
|
||||||
virtual void sendMessage(const QByteArray &);
|
virtual void sendMessage(const QByteArray &);
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual void stateChanged(State);
|
virtual void stateChanged(State);
|
||||||
virtual void messageReceived(const QByteArray &);
|
virtual void messageReceived(const QByteArray &);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class QmlDebugConnection;
|
|
||||||
QScopedPointer<QmlDebugClientPrivate> d_ptr;
|
QScopedPointer<QmlDebugClientPrivate> d_ptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -52,6 +52,8 @@ public:
|
|||||||
void blockEngine(int engineId);
|
void blockEngine(int engineId);
|
||||||
void releaseEngine(int engineId);
|
void releaseEngine(int engineId);
|
||||||
|
|
||||||
|
void messageReceived(const QByteArray &) override;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void engineAboutToBeAdded(int engineId, const QString &name);
|
void engineAboutToBeAdded(int engineId, const QString &name);
|
||||||
void engineAdded(int engineId, const QString &name);
|
void engineAdded(int engineId, const QString &name);
|
||||||
@@ -59,7 +61,6 @@ signals:
|
|||||||
void engineRemoved(int engineId, const QString &name);
|
void engineRemoved(int engineId, const QString &name);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void messageReceived(const QByteArray &) override;
|
|
||||||
void sendCommand(CommandType command, int engineId);
|
void sendCommand(CommandType command, int engineId);
|
||||||
|
|
||||||
struct EngineState {
|
struct EngineState {
|
||||||
|
@@ -44,7 +44,6 @@ public:
|
|||||||
// ### Qt 4.8: remove if we can have access to qdeclarativecontextdata or id's
|
// ### Qt 4.8: remove if we can have access to qdeclarativecontextdata or id's
|
||||||
void setObjectIdList(const QList<ObjectReference> &objectRoots) override;
|
void setObjectIdList(const QList<ObjectReference> &objectRoots) override;
|
||||||
|
|
||||||
protected:
|
|
||||||
void messageReceived(const QByteArray &) override;
|
void messageReceived(const QByteArray &) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@@ -52,6 +52,8 @@ public:
|
|||||||
bool isRecording() const;
|
bool isRecording() const;
|
||||||
void setRecording(bool);
|
void setRecording(bool);
|
||||||
quint64 recordedFeatures() const;
|
quint64 recordedFeatures() const;
|
||||||
|
virtual void messageReceived(const QByteArray &) override;
|
||||||
|
virtual void stateChanged(State status) override;
|
||||||
|
|
||||||
void clearData();
|
void clearData();
|
||||||
void sendRecordingStatus(int engineId = -1);
|
void sendRecordingStatus(int engineId = -1);
|
||||||
@@ -68,10 +70,6 @@ signals:
|
|||||||
|
|
||||||
void cleared();
|
void cleared();
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual void stateChanged(State status) override;
|
|
||||||
virtual void messageReceived(const QByteArray &) override;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class QmlProfilerTraceClientPrivate *d;
|
class QmlProfilerTraceClientPrivate *d;
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user