Commit 47317eff authored by Ulf Hermann's avatar Ulf Hermann

QmlDebug: Rename some members of QmlDebugConnection

This is to adopt the naming to the code in src/qmldebug in
qtdeclarative. Once we can require a version of Qt that has qmldebug
for building QtCreator we can then remove our own version of this code.

Change-Id: I573f0703871b5812789c5c7a6287567d5c2875e6
Reviewed-by: default avatarJoerg Bornemann <joerg.bornemann@theqtcompany.com>
parent a3e4a28b
......@@ -232,7 +232,7 @@ void DeclarativeToolsClient::reload(const QHash<QString,
{
Q_UNUSED(changesHash);
if (!m_connection || !m_connection->isOpen())
if (!m_connection || !m_connection->isConnected())
return;
QByteArray message;
......@@ -248,7 +248,7 @@ void DeclarativeToolsClient::reload(const QHash<QString,
void DeclarativeToolsClient::setDesignModeBehavior(bool inDesignMode)
{
if (!m_connection || !m_connection->isOpen())
if (!m_connection || !m_connection->isConnected())
return;
QByteArray message;
......@@ -265,7 +265,7 @@ void DeclarativeToolsClient::setDesignModeBehavior(bool inDesignMode)
void DeclarativeToolsClient::changeToSelectTool()
{
if (!m_connection || !m_connection->isOpen())
if (!m_connection || !m_connection->isConnected())
return;
QByteArray message;
......@@ -283,7 +283,7 @@ void DeclarativeToolsClient::changeToSelectTool()
void DeclarativeToolsClient::changeToSelectMarqueeTool()
{
if (!m_connection || !m_connection->isOpen())
if (!m_connection || !m_connection->isConnected())
return;
QByteArray message;
......@@ -301,7 +301,7 @@ void DeclarativeToolsClient::changeToSelectMarqueeTool()
void DeclarativeToolsClient::changeToZoomTool()
{
if (!m_connection || !m_connection->isOpen())
if (!m_connection || !m_connection->isConnected())
return;
QByteArray message;
......@@ -319,7 +319,7 @@ void DeclarativeToolsClient::changeToZoomTool()
void DeclarativeToolsClient::showAppOnTop(bool showOnTop)
{
if (!m_connection || !m_connection->isOpen())
if (!m_connection || !m_connection->isConnected())
return;
QByteArray message;
......
......@@ -89,7 +89,7 @@ QmlDebugConnectionPrivate::QmlDebugConnectionPrivate(QmlDebugConnection *c)
void QmlDebugConnectionPrivate::advertisePlugins()
{
if (!q->isOpen())
if (!gotHello)
return;
QPacket pack(currentDataStreamVersion);
......@@ -113,7 +113,7 @@ void QmlDebugConnectionPrivate::disconnected()
QHash<QString, QmlDebugClient*>::iterator iter = plugins.begin();
for (; iter != plugins.end(); ++iter)
iter.value()->stateChanged(QmlDebugClient::NotConnected);
emit q->closed();
emit q->disconnected();
}
delete protocol;
protocol = 0;
......@@ -191,7 +191,7 @@ void QmlDebugConnectionPrivate::readyRead()
newState = QmlDebugClient::Enabled;
iter.value()->stateChanged(newState);
}
emit q->opened();
emit q->connected();
}
while (protocol && protocol->packetsAvailable()) {
......@@ -292,7 +292,7 @@ QmlDebugConnection::~QmlDebugConnection()
iter.value()->d_func()->connection = 0;
}
bool QmlDebugConnection::isOpen() const
bool QmlDebugConnection::isConnected() const
{
// gotHello can only be set if the connection is open.
return d->gotHello;
......@@ -300,7 +300,7 @@ bool QmlDebugConnection::isOpen() const
bool QmlDebugConnection::isConnecting() const
{
return !isOpen() && d->device;
return !isConnected() && d->device;
}
void QmlDebugConnection::close()
......@@ -309,6 +309,11 @@ void QmlDebugConnection::close()
d->device->close(); // will trigger disconnected() at some point.
}
float QmlDebugConnection::serviceVersion(const QString &serviceName) const
{
return d->serverPlugins.value(serviceName, -1);
}
void QmlDebugConnectionPrivate::flush()
{
QAbstractSocket *socket = qobject_cast<QAbstractSocket*>(device);
......@@ -387,22 +392,22 @@ QString QmlDebugClient::name() const
return d->name;
}
int QmlDebugClient::remoteVersion() const
float QmlDebugClient::serviceVersion() const
{
Q_D(const QmlDebugClient);
// The version is internally saved as float for compatibility reasons. Exposing that to clients
// is a bad idea because floats cannot be properly compared. IEEE 754 floats represent integers
// exactly up to about 2^24, so the cast shouldn't be a problem for any realistic version
// numbers.
if (d->connection && d->connection->d->serverPlugins.contains(d->name))
return static_cast<int>(d->connection->d->serverPlugins.value(d->name));
if (d->connection)
return d->connection->serviceVersion(d->name);
return -1;
}
QmlDebugClient::State QmlDebugClient::state() const
{
Q_D(const QmlDebugClient);
if (!d->connection || !d->connection->isOpen())
if (!d->connection || !d->connection->isConnected())
return NotConnected;
if (d->connection->d->serverPlugins.contains(d->name))
......
......@@ -59,14 +59,15 @@ public:
int currentDataStreamVersion() const;
void setMaximumDataStreamVersion(int maximumVersion);
bool isOpen() const;
bool isConnected() const;
bool isConnecting() const;
void close();
float serviceVersion(const QString &serviceName) const;
signals:
void opened();
void connected();
void disconnected();
void error(QDebugSupport::Error);
void closed();
void stateMessage(const QString &message);
void errorMessage(const QString &message);
......@@ -91,7 +92,7 @@ public:
~QmlDebugClient();
QString name() const;
int remoteVersion() const;
float serviceVersion() const;
State state() const;
QmlDebugConnection *connection() const;
......
......@@ -106,7 +106,7 @@ void QmlToolsClient::setObjectIdList(
void QmlToolsClient::reload(const QHash<QString, QByteArray> &changesHash)
{
if (!m_connection || !m_connection->isOpen())
if (!m_connection || !m_connection->isConnected())
return;
m_reloadQueryId = m_requestId;
......@@ -123,7 +123,7 @@ void QmlToolsClient::reload(const QHash<QString, QByteArray> &changesHash)
void QmlToolsClient::setDesignModeBehavior(bool inDesignMode)
{
if (!m_connection || !m_connection->isOpen())
if (!m_connection || !m_connection->isConnected())
return;
QByteArray message;
......@@ -156,7 +156,7 @@ void QmlToolsClient::changeToZoomTool()
void QmlToolsClient::showAppOnTop(bool showOnTop)
{
if (!m_connection || !m_connection->isOpen())
if (!m_connection || !m_connection->isConnected())
return;
QByteArray message;
......
......@@ -297,11 +297,11 @@ QmlEngine::QmlEngine(const DebuggerRunParameters &startParameters, DebuggerEngin
this, &QmlEngine::showConnectionErrorMessage);
connect(d->connection, &QmlDebugConnection::error,
this, &QmlEngine::connectionErrorOccurred);
connect(d->connection, &QmlDebugConnection::opened,
connect(d->connection, &QmlDebugConnection::connected,
&d->connectionTimer, &QTimer::stop);
connect(d->connection, &QmlDebugConnection::opened,
connect(d->connection, &QmlDebugConnection::connected,
this, &QmlEngine::connectionEstablished);
connect(d->connection, &QmlDebugConnection::closed,
connect(d->connection, &QmlDebugConnection::disconnected,
this, &QmlEngine::disconnected);
d->msgClient = new QDebugMessageClient(d->connection);
......@@ -398,7 +398,7 @@ void QmlEngine::beginConnection(quint16 port)
if (runParameters().qmlServerPort > 0)
port = runParameters().qmlServerPort;
if (!d->connection || d->connection->isOpen())
if (!d->connection || d->connection->isConnected())
return;
d->connection->connectToHost(host, port);
......@@ -1236,7 +1236,7 @@ void QmlEngine::clientStateChanged(QmlDebugClient::State state)
float version = 0;
if (QmlDebugClient *client = qobject_cast<QmlDebugClient*>(sender())) {
serviceName = client->name();
version = client->remoteVersion();
version = client->serviceVersion();
}
logServiceStateChange(serviceName, version, state);
......@@ -1252,7 +1252,7 @@ void QmlEngine::checkConnectionState()
bool QmlEngine::isConnected() const
{
return d->connection->isOpen();
return d->connection->isConnected();
}
void QmlEngine::showConnectionStateMessage(const QString &message)
......
......@@ -714,7 +714,7 @@ void QmlInspectorAgent::clientStateChanged(QmlDebugClient::State state)
float version = 0;
if (QmlDebugClient *client = qobject_cast<QmlDebugClient*>(sender())) {
serviceName = client->name();
version = client->remoteVersion();
version = client->serviceVersion();
}
m_qmlEngine->logServiceStateChange(serviceName, version, state);
......
......@@ -136,9 +136,9 @@ void QmlProfilerClientManager::connectClient(quint16 port)
this, &QmlProfilerClientManager::logState);
connect(d->connection, &QmlDebugConnection::errorMessage,
this, &QmlProfilerClientManager::logState);
connect(d->connection, &QmlDebugConnection::opened,
connect(d->connection, &QmlDebugConnection::connected,
this, &QmlProfilerClientManager::qmlDebugConnectionOpened);
connect(d->connection, &QmlDebugConnection::closed,
connect(d->connection, &QmlDebugConnection::disconnected,
this, &QmlProfilerClientManager::qmlDebugConnectionClosed);
connect(d->connection, &QmlDebugConnection::error,
this, &QmlProfilerClientManager::qmlDebugConnectionError);
......@@ -208,7 +208,7 @@ void QmlProfilerClientManager::disconnectClientSignals()
void QmlProfilerClientManager::connectToClient()
{
if (!d->connection || d->connection->isOpen() || d->connection->isConnecting())
if (!d->connection || d->connection->isConnected() || d->connection->isConnecting())
return;
d->connection->connectToHost(d->tcpHost, d->tcpPort);
......@@ -216,7 +216,7 @@ void QmlProfilerClientManager::connectToClient()
bool QmlProfilerClientManager::isConnected() const
{
return d->connection && d->connection->isOpen();
return d->connection && d->connection->isConnected();
}
void QmlProfilerClientManager::disconnectClient()
......@@ -233,7 +233,7 @@ void QmlProfilerClientManager::tryToConnect()
{
++d->connectionAttempts;
if (d->connection && d->connection->isOpen()) {
if (d->connection && d->connection->isConnected()) {
d->connectionTimer.stop();
d->connectionAttempts = 0;
} else if (d->connectionAttempts == 50) {
......@@ -276,7 +276,7 @@ void QmlProfilerClientManager::qmlDebugConnectionClosed()
void QmlProfilerClientManager::qmlDebugConnectionError(QDebugSupport::Error error)
{
logState(tr("Debug connection error %1").arg(error));
if (d->connection->isOpen()) {
if (d->connection->isConnected()) {
disconnectClient();
emit connectionClosed();
} else {
......@@ -295,7 +295,7 @@ void QmlProfilerClientManager::logState(const QString &msg)
void QmlProfilerClientManager::retryMessageBoxFinished(int result)
{
if (d->connection) {
QTC_ASSERT(!d->connection->isOpen(), return);
QTC_ASSERT(!d->connection->isConnected(), return);
if (d->connection->isConnecting())
d->connection->disconnect();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment