forked from qt-creator/qt-creator
Qml Debugger: Eliminate client state callback
The sender()/qobject_cast construct is ugly, unnecessary and it doesn't work if the method is called directly, rather than through a signal. Change-Id: I0ac09ad04b956fb4cac38a89162a9dc0055d1831 Reviewed-by: hjk <hjk@theqtcompany.com>
This commit is contained in:
@@ -301,7 +301,10 @@ QmlEngine::QmlEngine(const DebuggerRunParameters &startParameters, DebuggerEngin
|
|||||||
|
|
||||||
d->msgClient = new QDebugMessageClient(d->connection);
|
d->msgClient = new QDebugMessageClient(d->connection);
|
||||||
connect(d->msgClient, &QDebugMessageClient::newState,
|
connect(d->msgClient, &QDebugMessageClient::newState,
|
||||||
this, &QmlEngine::clientStateChanged);
|
this, [this](QmlDebugClient::State state) {
|
||||||
|
logServiceStateChange(d->msgClient->name(), d->msgClient->serviceVersion(), state);
|
||||||
|
});
|
||||||
|
|
||||||
connect(d->msgClient, &QDebugMessageClient::message,
|
connect(d->msgClient, &QDebugMessageClient::message,
|
||||||
this, &appendDebugOutput);
|
this, &appendDebugOutput);
|
||||||
}
|
}
|
||||||
@@ -1208,18 +1211,6 @@ void QmlEngine::connectionStateChanged(QAbstractSocket::SocketState socketState)
|
|||||||
showConnectionStateMessage(QmlDebugConnection::socketStateToString(socketState));
|
showConnectionStateMessage(QmlDebugConnection::socketStateToString(socketState));
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlEngine::clientStateChanged(QmlDebugClient::State state)
|
|
||||||
{
|
|
||||||
QString serviceName;
|
|
||||||
float version = 0;
|
|
||||||
if (QmlDebugClient *client = qobject_cast<QmlDebugClient*>(sender())) {
|
|
||||||
serviceName = client->name();
|
|
||||||
version = client->serviceVersion();
|
|
||||||
}
|
|
||||||
|
|
||||||
logServiceStateChange(serviceName, version, state);
|
|
||||||
}
|
|
||||||
|
|
||||||
void QmlEngine::checkConnectionState()
|
void QmlEngine::checkConnectionState()
|
||||||
{
|
{
|
||||||
if (!isConnected()) {
|
if (!isConnected()) {
|
||||||
@@ -2472,7 +2463,7 @@ void QmlEnginePrivate::handleLookup(const QVariantMap &response)
|
|||||||
|
|
||||||
void QmlEnginePrivate::stateChanged(State state)
|
void QmlEnginePrivate::stateChanged(State state)
|
||||||
{
|
{
|
||||||
engine->clientStateChanged(state);
|
engine->logServiceStateChange(name(), serviceVersion(), state);
|
||||||
|
|
||||||
if (state == QmlDebugClient::Enabled) {
|
if (state == QmlDebugClient::Enabled) {
|
||||||
/// Start session.
|
/// Start session.
|
||||||
|
@@ -135,7 +135,6 @@ private:
|
|||||||
void connectionErrorOccurred(QAbstractSocket::SocketError socketError);
|
void connectionErrorOccurred(QAbstractSocket::SocketError socketError);
|
||||||
void connectionStateChanged(QAbstractSocket::SocketState socketState);
|
void connectionStateChanged(QAbstractSocket::SocketState socketState);
|
||||||
|
|
||||||
void clientStateChanged(QmlDebug::QmlDebugClient::State state);
|
|
||||||
void checkConnectionState();
|
void checkConnectionState();
|
||||||
void showConnectionStateMessage(const QString &message);
|
void showConnectionStateMessage(const QString &message);
|
||||||
bool isConnected() const;
|
bool isConnected() const;
|
||||||
|
Reference in New Issue
Block a user