forked from qt-creator/qt-creator
QmlDesigner: prevent crash on cleared connection
Change-Id: I3bc0e656ed0682a759e49d60772a233bf33fba66 Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
@@ -49,32 +49,21 @@ void ConnectionManager::setUp(NodeInstanceServerInterface *nodeInstanceServerPro
|
|||||||
processFinished(exitCode, exitStatus, connection.name);
|
processFinished(exitCode, exitStatus, connection.name);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
if (!m_connections.empty() && m_connections.at(0).qmlPuppetProcess)
|
||||||
qDebug() << "Start QMLPuppets from: " << m_connections.at(0).qmlPuppetProcess.get()->program();
|
qDebug() << "Start QMLPuppets from: " << m_connections.at(0).qmlPuppetProcess.get()->program();
|
||||||
const int second = 1000;
|
const int second = 1000;
|
||||||
for (Connection &connection : m_connections) {
|
for (Connection &connection : m_connections) {
|
||||||
int waitConstant = 8 * second;
|
int waitConstant = 5 * second;
|
||||||
if (!connection.qmlPuppetProcess->waitForStarted(waitConstant)) {
|
|
||||||
|
if (!connection.localServer->hasPendingConnections() && !connection.localServer->waitForNewConnection(waitConstant)) {
|
||||||
closeSocketsAndKillProcesses();
|
closeSocketsAndKillProcesses();
|
||||||
showCannotConnectToPuppetWarningAndSwitchToEditMode();
|
showCannotConnectToPuppetWarningAndSwitchToEditMode();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
waitConstant /= 2;
|
|
||||||
|
|
||||||
bool connectedToPuppet = true;
|
|
||||||
if (!connection.localServer->hasPendingConnections())
|
|
||||||
connectedToPuppet = connection.localServer->waitForNewConnection(waitConstant);
|
|
||||||
|
|
||||||
if (connectedToPuppet) {
|
|
||||||
connection.socket.reset(connection.localServer->nextPendingConnection());
|
connection.socket.reset(connection.localServer->nextPendingConnection());
|
||||||
QObject::connect(connection.socket.get(), &QIODevice::readyRead, this, [&] {
|
QObject::connect(connection.socket.get(), &QIODevice::readyRead, this, [&] {
|
||||||
readDataStream(connection);
|
readDataStream(connection);
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
closeSocketsAndKillProcesses();
|
|
||||||
showCannotConnectToPuppetWarningAndSwitchToEditMode();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
connection.localServer->close();
|
connection.localServer->close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user