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,
|
||||
int columnNumber);
|
||||
|
||||
virtual void stateChanged(State status) override;
|
||||
virtual void messageReceived(const QByteArray &) override;
|
||||
|
||||
signals:
|
||||
void newState(QmlDebug::QmlDebugClient::State status);
|
||||
void newObject(int engineId, int objectId, int parentId);
|
||||
@@ -80,9 +83,6 @@ signals:
|
||||
void result(quint32 queryId, const QVariant &result, const QByteArray &type);
|
||||
|
||||
protected:
|
||||
virtual void stateChanged(State status) override;
|
||||
virtual void messageReceived(const QByteArray &) override;
|
||||
|
||||
quint32 getId() { return m_nextId++; }
|
||||
|
||||
void decode(QDataStream &d, ContextReference &context);
|
||||
|
@@ -45,7 +45,6 @@ public:
|
||||
quint32 setMethodBody(int objectDebugId, const QString &methodName,
|
||||
const QString &methodBody) override;
|
||||
|
||||
protected:
|
||||
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
|
||||
void setObjectIdList(const QList<ObjectReference> &objectRoots) override;
|
||||
|
||||
protected:
|
||||
void messageReceived(const QByteArray &) override;
|
||||
|
||||
private:
|
||||
|
@@ -46,7 +46,6 @@ class QMLDEBUG_EXPORT QDebugMessageClient : public QmlDebugClient
|
||||
public:
|
||||
explicit QDebugMessageClient(QmlDebugConnection *client);
|
||||
|
||||
protected:
|
||||
virtual void stateChanged(State state) override;
|
||||
virtual void messageReceived(const QByteArray &) override;
|
||||
|
||||
|
@@ -33,6 +33,8 @@
|
||||
#include <qlocalserver.h>
|
||||
#include <qlocalsocket.h>
|
||||
|
||||
#include <QPointer>
|
||||
|
||||
namespace QmlDebug {
|
||||
|
||||
const int protocolVersion = 1;
|
||||
@@ -46,7 +48,7 @@ public:
|
||||
QmlDebugClientPrivate();
|
||||
|
||||
QString name;
|
||||
QmlDebugConnection *connection;
|
||||
QPointer<QmlDebugConnection> connection;
|
||||
};
|
||||
|
||||
class QmlDebugConnectionPrivate
|
||||
@@ -263,11 +265,7 @@ QmlDebugConnection::QmlDebugConnection(QObject *parent)
|
||||
|
||||
QmlDebugConnection::~QmlDebugConnection()
|
||||
{
|
||||
Q_D(QmlDebugConnection);
|
||||
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
|
||||
@@ -435,7 +433,6 @@ QAbstractSocket::SocketState QmlDebugConnection::socketState() const
|
||||
}
|
||||
|
||||
QmlDebugClientPrivate::QmlDebugClientPrivate()
|
||||
: connection(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
@@ -97,13 +97,10 @@ public:
|
||||
QmlDebugConnection *connection() const;
|
||||
|
||||
virtual void sendMessage(const QByteArray &);
|
||||
|
||||
protected:
|
||||
virtual void stateChanged(State);
|
||||
virtual void messageReceived(const QByteArray &);
|
||||
|
||||
private:
|
||||
friend class QmlDebugConnection;
|
||||
QScopedPointer<QmlDebugClientPrivate> d_ptr;
|
||||
};
|
||||
|
||||
|
@@ -52,6 +52,8 @@ public:
|
||||
void blockEngine(int engineId);
|
||||
void releaseEngine(int engineId);
|
||||
|
||||
void messageReceived(const QByteArray &) override;
|
||||
|
||||
signals:
|
||||
void engineAboutToBeAdded(int engineId, const QString &name);
|
||||
void engineAdded(int engineId, const QString &name);
|
||||
@@ -59,7 +61,6 @@ signals:
|
||||
void engineRemoved(int engineId, const QString &name);
|
||||
|
||||
protected:
|
||||
void messageReceived(const QByteArray &) override;
|
||||
void sendCommand(CommandType command, int engineId);
|
||||
|
||||
struct EngineState {
|
||||
|
@@ -44,7 +44,6 @@ public:
|
||||
// ### Qt 4.8: remove if we can have access to qdeclarativecontextdata or id's
|
||||
void setObjectIdList(const QList<ObjectReference> &objectRoots) override;
|
||||
|
||||
protected:
|
||||
void messageReceived(const QByteArray &) override;
|
||||
|
||||
private:
|
||||
|
@@ -52,6 +52,8 @@ public:
|
||||
bool isRecording() const;
|
||||
void setRecording(bool);
|
||||
quint64 recordedFeatures() const;
|
||||
virtual void messageReceived(const QByteArray &) override;
|
||||
virtual void stateChanged(State status) override;
|
||||
|
||||
void clearData();
|
||||
void sendRecordingStatus(int engineId = -1);
|
||||
@@ -68,10 +70,6 @@ signals:
|
||||
|
||||
void cleared();
|
||||
|
||||
protected:
|
||||
virtual void stateChanged(State status) override;
|
||||
virtual void messageReceived(const QByteArray &) override;
|
||||
|
||||
private:
|
||||
class QmlProfilerTraceClientPrivate *d;
|
||||
};
|
||||
|
Reference in New Issue
Block a user