Control the lifetime of SshProcessManager

Make it possible to control when the SshProcessManager is
being constructed / destructed. Expose public constructor.

Since different singletons depend on each other, we need
to control the order of creation and destruction of them.

The order of creation is like that:

1. QCoreApplication
2. ProcessReaper
3. ProcessLauncher
4. SshConnectionManager

The order of destruction must be opposite to the above.

Change-Id: Ice07eb751cd61c03cb461816fa1b74ab040a53de
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
Jarek Kobus
2021-09-09 15:29:28 +02:00
parent 2bdbaaa2fd
commit 33f1a96005
12 changed files with 67 additions and 39 deletions

View File

@@ -96,7 +96,7 @@ void SshDeviceProcess::start(const Runnable &runnable)
d->runnable = runnable;
QSsh::SshConnectionParameters params = device()->sshParameters();
params.x11DisplayName = d->displayName();
d->connection = QSsh::acquireConnection(params);
d->connection = QSsh::SshConnectionManager::acquireConnection(params);
connect(d->connection, &QSsh::SshConnection::errorOccurred,
this, &SshDeviceProcess::handleConnectionError);
connect(d->connection, &QSsh::SshConnection::disconnected,
@@ -364,7 +364,7 @@ void SshDeviceProcess::SshDeviceProcessPrivate::setState(SshDeviceProcess::SshDe
process->disconnect(q);
if (connection) {
connection->disconnect(q);
QSsh::releaseConnection(connection);
QSsh::SshConnectionManager::releaseConnection(connection);
connection = nullptr;
}
}