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:
Ulf Hermann
2016-04-13 11:15:06 +02:00
parent 9b7fa05bf3
commit 075a8dc831
2 changed files with 5 additions and 15 deletions

View File

@@ -301,7 +301,10 @@ QmlEngine::QmlEngine(const DebuggerRunParameters &startParameters, DebuggerEngin
d->msgClient = new QDebugMessageClient(d->connection);
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,
this, &appendDebugOutput);
}
@@ -1208,18 +1211,6 @@ void QmlEngine::connectionStateChanged(QAbstractSocket::SocketState 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()
{
if (!isConnected()) {
@@ -2472,7 +2463,7 @@ void QmlEnginePrivate::handleLookup(const QVariantMap &response)
void QmlEnginePrivate::stateChanged(State state)
{
engine->clientStateChanged(state);
engine->logServiceStateChange(name(), serviceVersion(), state);
if (state == QmlDebugClient::Enabled) {
/// Start session.

View File

@@ -135,7 +135,6 @@ private:
void connectionErrorOccurred(QAbstractSocket::SocketError socketError);
void connectionStateChanged(QAbstractSocket::SocketState socketState);
void clientStateChanged(QmlDebug::QmlDebugClient::State state);
void checkConnectionState();
void showConnectionStateMessage(const QString &message);
bool isConnected() const;