forked from qt-creator/qt-creator
QmlDebugClient: Check for gotHello to determine if connection is open
The isConnected() method was misleading as it only checked for the network socket to be connected. Sending data before the hello message arrives is a pretty stupid idea and the debug clients need a way to detect that. The new isOpen method stresses that it's about the logical protocol, not the network socket. Change-Id: I84f093d91d7a21d20a8f3d14730c9f189ec35bde Reviewed-by: Kai Koehne <kai.koehne@digia.com>
This commit is contained in:
@@ -235,7 +235,7 @@ QList<int> DeclarativeToolsClient::currentObjects() const
|
|||||||
|
|
||||||
void DeclarativeToolsClient::setCurrentObjects(const QList<int> &debugIds)
|
void DeclarativeToolsClient::setCurrentObjects(const QList<int> &debugIds)
|
||||||
{
|
{
|
||||||
if (!m_connection || !m_connection->isConnected())
|
if (!m_connection || !m_connection->isOpen())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (debugIds == m_currentDebugIds)
|
if (debugIds == m_currentDebugIds)
|
||||||
@@ -289,7 +289,7 @@ void DeclarativeToolsClient::setObjectIdList(
|
|||||||
|
|
||||||
void DeclarativeToolsClient::clearComponentCache()
|
void DeclarativeToolsClient::clearComponentCache()
|
||||||
{
|
{
|
||||||
if (!m_connection || !m_connection->isConnected())
|
if (!m_connection || !m_connection->isOpen())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QByteArray message;
|
QByteArray message;
|
||||||
@@ -308,7 +308,7 @@ void DeclarativeToolsClient::reload(const QHash<QString,
|
|||||||
{
|
{
|
||||||
Q_UNUSED(changesHash);
|
Q_UNUSED(changesHash);
|
||||||
|
|
||||||
if (!m_connection || !m_connection->isConnected())
|
if (!m_connection || !m_connection->isOpen())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QByteArray message;
|
QByteArray message;
|
||||||
@@ -324,7 +324,7 @@ void DeclarativeToolsClient::reload(const QHash<QString,
|
|||||||
|
|
||||||
void DeclarativeToolsClient::setDesignModeBehavior(bool inDesignMode)
|
void DeclarativeToolsClient::setDesignModeBehavior(bool inDesignMode)
|
||||||
{
|
{
|
||||||
if (!m_connection || !m_connection->isConnected())
|
if (!m_connection || !m_connection->isOpen())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QByteArray message;
|
QByteArray message;
|
||||||
@@ -341,7 +341,7 @@ void DeclarativeToolsClient::setDesignModeBehavior(bool inDesignMode)
|
|||||||
|
|
||||||
void DeclarativeToolsClient::setAnimationSpeed(qreal slowDownFactor)
|
void DeclarativeToolsClient::setAnimationSpeed(qreal slowDownFactor)
|
||||||
{
|
{
|
||||||
if (!m_connection || !m_connection->isConnected())
|
if (!m_connection || !m_connection->isOpen())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QByteArray message;
|
QByteArray message;
|
||||||
@@ -359,7 +359,7 @@ void DeclarativeToolsClient::setAnimationSpeed(qreal slowDownFactor)
|
|||||||
|
|
||||||
void DeclarativeToolsClient::setAnimationPaused(bool paused)
|
void DeclarativeToolsClient::setAnimationPaused(bool paused)
|
||||||
{
|
{
|
||||||
if (!m_connection || !m_connection->isConnected())
|
if (!m_connection || !m_connection->isOpen())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QByteArray message;
|
QByteArray message;
|
||||||
@@ -376,7 +376,7 @@ void DeclarativeToolsClient::setAnimationPaused(bool paused)
|
|||||||
|
|
||||||
void DeclarativeToolsClient::changeToSelectTool()
|
void DeclarativeToolsClient::changeToSelectTool()
|
||||||
{
|
{
|
||||||
if (!m_connection || !m_connection->isConnected())
|
if (!m_connection || !m_connection->isOpen())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QByteArray message;
|
QByteArray message;
|
||||||
@@ -394,7 +394,7 @@ void DeclarativeToolsClient::changeToSelectTool()
|
|||||||
|
|
||||||
void DeclarativeToolsClient::changeToSelectMarqueeTool()
|
void DeclarativeToolsClient::changeToSelectMarqueeTool()
|
||||||
{
|
{
|
||||||
if (!m_connection || !m_connection->isConnected())
|
if (!m_connection || !m_connection->isOpen())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QByteArray message;
|
QByteArray message;
|
||||||
@@ -412,7 +412,7 @@ void DeclarativeToolsClient::changeToSelectMarqueeTool()
|
|||||||
|
|
||||||
void DeclarativeToolsClient::changeToZoomTool()
|
void DeclarativeToolsClient::changeToZoomTool()
|
||||||
{
|
{
|
||||||
if (!m_connection || !m_connection->isConnected())
|
if (!m_connection || !m_connection->isOpen())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QByteArray message;
|
QByteArray message;
|
||||||
@@ -430,7 +430,7 @@ void DeclarativeToolsClient::changeToZoomTool()
|
|||||||
|
|
||||||
void DeclarativeToolsClient::showAppOnTop(bool showOnTop)
|
void DeclarativeToolsClient::showAppOnTop(bool showOnTop)
|
||||||
{
|
{
|
||||||
if (!m_connection || !m_connection->isConnected())
|
if (!m_connection || !m_connection->isOpen())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QByteArray message;
|
QByteArray message;
|
||||||
@@ -449,7 +449,7 @@ void DeclarativeToolsClient::createQmlObject(const QString &qmlText,
|
|||||||
const QStringList &imports,
|
const QStringList &imports,
|
||||||
const QString &filename, int order)
|
const QString &filename, int order)
|
||||||
{
|
{
|
||||||
if (!m_connection || !m_connection->isConnected())
|
if (!m_connection || !m_connection->isOpen())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QByteArray message;
|
QByteArray message;
|
||||||
@@ -472,7 +472,7 @@ void DeclarativeToolsClient::createQmlObject(const QString &qmlText,
|
|||||||
|
|
||||||
void DeclarativeToolsClient::destroyQmlObject(int debugId)
|
void DeclarativeToolsClient::destroyQmlObject(int debugId)
|
||||||
{
|
{
|
||||||
if (!m_connection || !m_connection->isConnected())
|
if (!m_connection || !m_connection->isOpen())
|
||||||
return;
|
return;
|
||||||
QByteArray message;
|
QByteArray message;
|
||||||
QDataStream ds(&message, QIODevice::WriteOnly);
|
QDataStream ds(&message, QIODevice::WriteOnly);
|
||||||
@@ -487,7 +487,7 @@ void DeclarativeToolsClient::destroyQmlObject(int debugId)
|
|||||||
|
|
||||||
void DeclarativeToolsClient::reparentQmlObject(int debugId, int newParent)
|
void DeclarativeToolsClient::reparentQmlObject(int debugId, int newParent)
|
||||||
{
|
{
|
||||||
if (!m_connection || !m_connection->isConnected())
|
if (!m_connection || !m_connection->isOpen())
|
||||||
return;
|
return;
|
||||||
QByteArray message;
|
QByteArray message;
|
||||||
QDataStream ds(&message, QIODevice::WriteOnly);
|
QDataStream ds(&message, QIODevice::WriteOnly);
|
||||||
@@ -506,7 +506,7 @@ void DeclarativeToolsClient::reparentQmlObject(int debugId, int newParent)
|
|||||||
|
|
||||||
void DeclarativeToolsClient::applyChangesToQmlFile()
|
void DeclarativeToolsClient::applyChangesToQmlFile()
|
||||||
{
|
{
|
||||||
if (!m_connection || !m_connection->isConnected())
|
if (!m_connection || !m_connection->isOpen())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
@@ -514,7 +514,7 @@ void DeclarativeToolsClient::applyChangesToQmlFile()
|
|||||||
|
|
||||||
void DeclarativeToolsClient::applyChangesFromQmlFile()
|
void DeclarativeToolsClient::applyChangesFromQmlFile()
|
||||||
{
|
{
|
||||||
if (!m_connection || !m_connection->isConnected())
|
if (!m_connection || !m_connection->isOpen())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ QmlDebugConnectionPrivate::QmlDebugConnectionPrivate(QmlDebugConnection *c)
|
|||||||
|
|
||||||
void QmlDebugConnectionPrivate::advertisePlugins()
|
void QmlDebugConnectionPrivate::advertisePlugins()
|
||||||
{
|
{
|
||||||
if (!q->isConnected() || !gotHello)
|
if (!q->isOpen())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QPacket pack;
|
QPacket pack;
|
||||||
@@ -230,9 +230,9 @@ QmlDebugConnection::~QmlDebugConnection()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QmlDebugConnection::isConnected() const
|
bool QmlDebugConnection::isOpen() const
|
||||||
{
|
{
|
||||||
return socketState() == QAbstractSocket::ConnectedState;
|
return socketState() == QAbstractSocket::ConnectedState && d->gotHello;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlDebugConnection::close()
|
void QmlDebugConnection::close()
|
||||||
@@ -340,9 +340,7 @@ float QmlDebugClient::serviceVersion() const
|
|||||||
QmlDebugClient::State QmlDebugClient::state() const
|
QmlDebugClient::State QmlDebugClient::state() const
|
||||||
{
|
{
|
||||||
Q_D(const QmlDebugClient);
|
Q_D(const QmlDebugClient);
|
||||||
if (!d->connection
|
if (!d->connection || !d->connection->isOpen())
|
||||||
|| !d->connection->isConnected()
|
|
||||||
|| !d->connection->d->gotHello)
|
|
||||||
return NotConnected;
|
return NotConnected;
|
||||||
|
|
||||||
if (d->connection->d->serverPlugins.contains(d->name))
|
if (d->connection->d->serverPlugins.contains(d->name))
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ public:
|
|||||||
|
|
||||||
void connectToHost(const QString &hostName, quint16 port);
|
void connectToHost(const QString &hostName, quint16 port);
|
||||||
|
|
||||||
bool isConnected() const;
|
bool isOpen() const;
|
||||||
QAbstractSocket::SocketState socketState() const;
|
QAbstractSocket::SocketState socketState() const;
|
||||||
void close();
|
void close();
|
||||||
QString errorString() const;
|
QString errorString() const;
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ QList<int> QmlToolsClient::currentObjects() const
|
|||||||
|
|
||||||
void QmlToolsClient::setCurrentObjects(const QList<int> &debugIds)
|
void QmlToolsClient::setCurrentObjects(const QList<int> &debugIds)
|
||||||
{
|
{
|
||||||
if (!m_connection || !m_connection->isConnected())
|
if (!m_connection || !m_connection->isOpen())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (debugIds == m_currentDebugIds)
|
if (debugIds == m_currentDebugIds)
|
||||||
@@ -153,7 +153,7 @@ void QmlToolsClient::setObjectIdList(
|
|||||||
|
|
||||||
void QmlToolsClient::clearComponentCache()
|
void QmlToolsClient::clearComponentCache()
|
||||||
{
|
{
|
||||||
if (!m_connection || !m_connection->isConnected())
|
if (!m_connection || !m_connection->isOpen())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QByteArray message;
|
QByteArray message;
|
||||||
@@ -168,7 +168,7 @@ void QmlToolsClient::clearComponentCache()
|
|||||||
|
|
||||||
void QmlToolsClient::reload(const QHash<QString, QByteArray> &changesHash)
|
void QmlToolsClient::reload(const QHash<QString, QByteArray> &changesHash)
|
||||||
{
|
{
|
||||||
if (!m_connection || !m_connection->isConnected())
|
if (!m_connection || !m_connection->isOpen())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_reloadQueryId = m_requestId;
|
m_reloadQueryId = m_requestId;
|
||||||
@@ -185,7 +185,7 @@ void QmlToolsClient::reload(const QHash<QString, QByteArray> &changesHash)
|
|||||||
|
|
||||||
void QmlToolsClient::setDesignModeBehavior(bool inDesignMode)
|
void QmlToolsClient::setDesignModeBehavior(bool inDesignMode)
|
||||||
{
|
{
|
||||||
if (!m_connection || !m_connection->isConnected())
|
if (!m_connection || !m_connection->isOpen())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QByteArray message;
|
QByteArray message;
|
||||||
@@ -203,7 +203,7 @@ void QmlToolsClient::setDesignModeBehavior(bool inDesignMode)
|
|||||||
|
|
||||||
void QmlToolsClient::setAnimationSpeed(qreal slowDownFactor)
|
void QmlToolsClient::setAnimationSpeed(qreal slowDownFactor)
|
||||||
{
|
{
|
||||||
if (!m_connection || !m_connection->isConnected())
|
if (!m_connection || !m_connection->isOpen())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QByteArray message;
|
QByteArray message;
|
||||||
@@ -244,7 +244,7 @@ void QmlToolsClient::changeToZoomTool()
|
|||||||
|
|
||||||
void QmlToolsClient::showAppOnTop(bool showOnTop)
|
void QmlToolsClient::showAppOnTop(bool showOnTop)
|
||||||
{
|
{
|
||||||
if (!m_connection || !m_connection->isConnected())
|
if (!m_connection || !m_connection->isOpen())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QByteArray message;
|
QByteArray message;
|
||||||
@@ -262,7 +262,7 @@ void QmlToolsClient::createQmlObject(const QString &qmlText,
|
|||||||
const QStringList &imports,
|
const QStringList &imports,
|
||||||
const QString &filename, int order)
|
const QString &filename, int order)
|
||||||
{
|
{
|
||||||
if (!m_connection || !m_connection->isConnected())
|
if (!m_connection || !m_connection->isOpen())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QByteArray message;
|
QByteArray message;
|
||||||
@@ -284,7 +284,7 @@ void QmlToolsClient::createQmlObject(const QString &qmlText,
|
|||||||
|
|
||||||
void QmlToolsClient::destroyQmlObject(int debugId)
|
void QmlToolsClient::destroyQmlObject(int debugId)
|
||||||
{
|
{
|
||||||
if (!m_connection || !m_connection->isConnected())
|
if (!m_connection || !m_connection->isOpen())
|
||||||
return;
|
return;
|
||||||
QByteArray message;
|
QByteArray message;
|
||||||
QDataStream ds(&message, QIODevice::WriteOnly);
|
QDataStream ds(&message, QIODevice::WriteOnly);
|
||||||
@@ -299,7 +299,7 @@ void QmlToolsClient::destroyQmlObject(int debugId)
|
|||||||
|
|
||||||
void QmlToolsClient::reparentQmlObject(int debugId, int newParent)
|
void QmlToolsClient::reparentQmlObject(int debugId, int newParent)
|
||||||
{
|
{
|
||||||
if (!m_connection || !m_connection->isConnected())
|
if (!m_connection || !m_connection->isOpen())
|
||||||
return;
|
return;
|
||||||
QByteArray message;
|
QByteArray message;
|
||||||
QDataStream ds(&message, QIODevice::WriteOnly);
|
QDataStream ds(&message, QIODevice::WriteOnly);
|
||||||
@@ -315,7 +315,7 @@ void QmlToolsClient::reparentQmlObject(int debugId, int newParent)
|
|||||||
|
|
||||||
void QmlToolsClient::applyChangesToQmlFile()
|
void QmlToolsClient::applyChangesToQmlFile()
|
||||||
{
|
{
|
||||||
if (!m_connection || !m_connection->isConnected())
|
if (!m_connection || !m_connection->isOpen())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
@@ -323,7 +323,7 @@ void QmlToolsClient::applyChangesToQmlFile()
|
|||||||
|
|
||||||
void QmlToolsClient::applyChangesFromQmlFile()
|
void QmlToolsClient::applyChangesFromQmlFile()
|
||||||
{
|
{
|
||||||
if (!m_connection || !m_connection->isConnected())
|
if (!m_connection || !m_connection->isOpen())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
|
|||||||
@@ -243,7 +243,7 @@ void QmlProfilerClientManager::connectToClient()
|
|||||||
|
|
||||||
bool QmlProfilerClientManager::isConnected() const
|
bool QmlProfilerClientManager::isConnected() const
|
||||||
{
|
{
|
||||||
return d->connection && d->connection->isConnected();
|
return d->connection && d->connection->isOpen();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlProfilerClientManager::disconnectClient()
|
void QmlProfilerClientManager::disconnectClient()
|
||||||
@@ -260,7 +260,7 @@ void QmlProfilerClientManager::tryToConnect()
|
|||||||
{
|
{
|
||||||
++d->connectionAttempts;
|
++d->connectionAttempts;
|
||||||
|
|
||||||
if (d->connection && d->connection->isConnected()) {
|
if (d->connection && d->connection->isOpen()) {
|
||||||
d->connectionTimer.stop();
|
d->connectionTimer.stop();
|
||||||
d->connectionAttempts = 0;
|
d->connectionAttempts = 0;
|
||||||
} else if (d->connectionAttempts == 50) {
|
} else if (d->connectionAttempts == 50) {
|
||||||
|
|||||||
Reference in New Issue
Block a user