QmlDesigner: Keep qml2puppet alive, if local socket is not processed

In case Qt Creator did not process the events from local socket,
e.g. when a modal dialog was executed, we did kill the qml2puppet.

In this patch we first check if there are really no pending data
anymore. If there was pending data we restart the timers for each qml2puppet.

Change-Id: If19161636ee05835e01f082dd992e49f39d366bd
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
This commit is contained in:
Thomas Hartmann
2019-10-16 16:09:35 +02:00
parent 0bde9b14cb
commit 0942f2e1ec
2 changed files with 39 additions and 3 deletions

View File

@@ -216,9 +216,13 @@ NodeInstanceServerProxy::NodeInstanceServerProxy(NodeInstanceView *nodeInstanceV
if (QmlDesignerPlugin::instance()->settings().value(DesignerSettingsKey::
DEBUG_PUPPET).toString().isEmpty()) {
connect(&m_firstTimer, SIGNAL(timeout()), this, SLOT(processFinished()));
connect(&m_secondTimer, SIGNAL(timeout()), this, SLOT(processFinished()));
connect(&m_thirdTimer, SIGNAL(timeout()), this, SLOT(processFinished()));
connect(&m_firstTimer, &QTimer::timeout, this,
[this](){ NodeInstanceServerProxy::puppetTimeout(FirstPuppetStream); });
connect(&m_secondTimer, &QTimer::timeout, this,
[this](){ NodeInstanceServerProxy::puppetTimeout(SecondPuppetStream); });
connect(&m_thirdTimer, &QTimer::timeout, this,
[this](){ NodeInstanceServerProxy::puppetTimeout(ThirdPuppetStream); });
}
#endif
}
@@ -359,6 +363,37 @@ void NodeInstanceServerProxy::processFinished()
processFinished(-1, QProcess::CrashExit);
}
void NodeInstanceServerProxy::puppetTimeout(PuppetStreamType puppetStreamType)
{
switch (puppetStreamType) {
case FirstPuppetStream:
if (m_firstSocket->waitForReadyRead(10)) {
m_firstTimer.stop();
m_firstTimer.start();
return;
}
break;
case SecondPuppetStream:
if (m_secondSocket->waitForReadyRead(10)) {
m_secondTimer.stop();
m_secondTimer.start();
return;
}
break;
case ThirdPuppetStream:
if (m_thirdSocket->waitForReadyRead(10)) {
m_thirdTimer.stop();
m_thirdTimer.start();
return;
}
break;
default:
break;
}
processFinished();
}
static void writeCommandToIODecive(const QVariant &command, QIODevice *ioDevice, unsigned int commandCounter)
{
if (ioDevice) {

View File

@@ -96,6 +96,7 @@ signals:
private slots:
void processFinished();
void puppetTimeout(PuppetStreamType puppetStreamType);
void processFinished(int exitCode, QProcess::ExitStatus exitStatus);
void readFirstDataStream();
void readSecondDataStream();