diff --git a/src/plugins/qmldesigner/designercore/instances/nodeinstanceclientproxy.cpp b/src/plugins/qmldesigner/designercore/instances/nodeinstanceclientproxy.cpp index 62bdb948c3c9889b50de7de345c816119aaffc00..606218b520baf3db2ac8bebb12b761e99b627c1e 100644 --- a/src/plugins/qmldesigner/designercore/instances/nodeinstanceclientproxy.cpp +++ b/src/plugins/qmldesigner/designercore/instances/nodeinstanceclientproxy.cpp @@ -74,6 +74,8 @@ NodeInstanceClientProxy::NodeInstanceClientProxy(QObject *parent) : QObject(parent), m_nodeInstanceServer(0), m_blockSize(0), + m_writeCommandCounter(0), + m_lastReadCommandCounter(0), m_synchronizeId(-1) { if (QCoreApplication::arguments().at(2) == QLatin1String("previewmode")) { @@ -94,9 +96,12 @@ NodeInstanceClientProxy::NodeInstanceClientProxy(QObject *parent) void NodeInstanceClientProxy::writeCommand(const QVariant &command) { + static unsigned int commandCounter = 0; QByteArray block; QDataStream out(&block, QIODevice::WriteOnly); out << quint32(0); + out << quint32(m_writeCommandCounter); + m_writeCommandCounter++; out << command; out.device()->seek(0); out << quint32(block.size() - sizeof(quint32)); @@ -168,6 +173,13 @@ void NodeInstanceClientProxy::readDataStream() if (m_socket->bytesAvailable() < m_blockSize) break; + quint32 commandCounter; + in >> commandCounter; + bool commandLost = !((m_lastReadCommandCounter == 0 && commandCounter == 0) || (m_lastReadCommandCounter + 1 == commandCounter)); + if (commandLost) + qDebug() << "client command lost: " << m_lastReadCommandCounter << commandCounter; + m_lastReadCommandCounter = commandCounter; + QVariant command; in >> command; m_blockSize = 0; diff --git a/src/plugins/qmldesigner/designercore/instances/nodeinstanceclientproxy.h b/src/plugins/qmldesigner/designercore/instances/nodeinstanceclientproxy.h index a1630908537587cc180c8a7be6510c8c4e5c38b8..113cfb4f24a2fa9e9df128643f6edb336dcd2330 100644 --- a/src/plugins/qmldesigner/designercore/instances/nodeinstanceclientproxy.h +++ b/src/plugins/qmldesigner/designercore/instances/nodeinstanceclientproxy.h @@ -104,6 +104,8 @@ private: QLocalSocket *m_socket; NodeInstanceServerInterface *m_nodeInstanceServer; quint32 m_blockSize; + quint32 m_writeCommandCounter; + quint32 m_lastReadCommandCounter; int m_synchronizeId; }; diff --git a/src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.cpp b/src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.cpp index 8fbb33e8ebbf304c76b3063bf6fed9caaea4622e..0cbc7a9c716a049fa8ea083f3800219e8f44d237 100644 --- a/src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.cpp +++ b/src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.cpp @@ -78,6 +78,10 @@ NodeInstanceServerProxy::NodeInstanceServerProxy(NodeInstanceView *nodeInstanceV m_firstBlockSize(0), m_secondBlockSize(0), m_thirdBlockSize(0), + m_writeCommandCounter(0), + m_firstLastReadCommandCounter(0), + m_secondLastReadCommandCounter(0), + m_thirdLastReadCommandCounter(0), m_runModus(runModus), m_synchronizeId(-1) { @@ -220,12 +224,13 @@ NodeInstanceClientInterface *NodeInstanceServerProxy::nodeInstanceClient() const return m_nodeInstanceView.data(); } -static void writeCommandToSocket(const QVariant &command, QLocalSocket *socket) +static void writeCommandToSocket(const QVariant &command, QLocalSocket *socket, unsigned int commandCounter) { if(socket) { QByteArray block; QDataStream out(&block, QIODevice::WriteOnly); out << quint32(0); + out << quint32(commandCounter); out << command; out.device()->seek(0); out << quint32(block.size() - sizeof(quint32)); @@ -236,16 +241,17 @@ static void writeCommandToSocket(const QVariant &command, QLocalSocket *socket) void NodeInstanceServerProxy::writeCommand(const QVariant &command) { - writeCommandToSocket(command, m_firstSocket.data()); - writeCommandToSocket(command, m_secondSocket.data()); - writeCommandToSocket(command, m_thirdSocket.data()); - + writeCommandToSocket(command, m_firstSocket.data(), m_writeCommandCounter); + writeCommandToSocket(command, m_secondSocket.data(), m_writeCommandCounter); + writeCommandToSocket(command, m_thirdSocket.data(), m_writeCommandCounter); + m_writeCommandCounter++; if (m_runModus == TestModus) { static int synchronizeId = 0; synchronizeId++; SynchronizeCommand synchronizeCommand(synchronizeId); - writeCommandToSocket(QVariant::fromValue(synchronizeCommand), m_firstSocket.data()); + writeCommandToSocket(QVariant::fromValue(synchronizeCommand), m_firstSocket.data(), m_writeCommandCounter); + m_writeCommandCounter++; while(m_firstSocket->waitForReadyRead()) { readFirstDataStream(); @@ -271,6 +277,7 @@ void NodeInstanceServerProxy::processFinished(int /*exitCode*/, QProcess::ExitSt void NodeInstanceServerProxy::readFirstDataStream() { + static unsigned int lastCommandCounter = 0; QList<QVariant> commandList; while (!m_firstSocket->atEnd()) { @@ -286,6 +293,14 @@ void NodeInstanceServerProxy::readFirstDataStream() if (m_firstSocket->bytesAvailable() < m_firstBlockSize) break; + quint32 commandCounter; + in >> commandCounter; + bool commandLost = !((m_firstLastReadCommandCounter == 0 && commandCounter == 0) || (m_firstLastReadCommandCounter + 1 == commandCounter)); + if (commandLost) + qDebug() << "server command lost: " << m_firstLastReadCommandCounter << commandCounter; + m_firstLastReadCommandCounter = commandCounter; + + QVariant command; in >> command; m_firstBlockSize = 0; @@ -300,6 +315,7 @@ void NodeInstanceServerProxy::readFirstDataStream() void NodeInstanceServerProxy::readSecondDataStream() { + static unsigned int lastCommandCounter = 0; QList<QVariant> commandList; while (!m_secondSocket->atEnd()) { @@ -315,6 +331,14 @@ void NodeInstanceServerProxy::readSecondDataStream() if (m_secondSocket->bytesAvailable() < m_secondBlockSize) break; + quint32 commandCounter; + in >> commandCounter; + bool commandLost = !((m_secondLastReadCommandCounter == 0 && commandCounter == 0) || (m_secondLastReadCommandCounter + 1 == commandCounter)); + if (commandLost) + qDebug() << "server command lost: " << m_secondLastReadCommandCounter << commandCounter; + m_secondLastReadCommandCounter = commandCounter; + + QVariant command; in >> command; m_secondBlockSize = 0; @@ -344,6 +368,14 @@ void NodeInstanceServerProxy::readThirdDataStream() if (m_thirdSocket->bytesAvailable() < m_thirdBlockSize) break; + quint32 commandCounter; + in >> commandCounter; + bool commandLost = !((m_thirdLastReadCommandCounter == 0 && commandCounter == 0) || (m_thirdLastReadCommandCounter + 1 == commandCounter)); + if (commandLost) + qDebug() << "server command lost: " << m_thirdLastReadCommandCounter << commandCounter; + m_thirdLastReadCommandCounter = commandCounter; + + QVariant command; in >> command; m_thirdBlockSize = 0; diff --git a/src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.h b/src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.h index 2c60d5daa24e10953a5bb8037980f7656c5b925e..3131d5c005c81240bc441662278451fecc3f9a13 100644 --- a/src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.h +++ b/src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.h @@ -97,6 +97,10 @@ private: quint32 m_firstBlockSize; quint32 m_secondBlockSize; quint32 m_thirdBlockSize; + quint32 m_writeCommandCounter; + quint32 m_firstLastReadCommandCounter; + quint32 m_secondLastReadCommandCounter; + quint32 m_thirdLastReadCommandCounter; RunModus m_runModus; int m_synchronizeId; };