Make access to LauncherSocket thread safe

Instead of returning a pointer to LauncherSocket instance,
which might get deleted in meantime of just after,
route all calls to the LauncherSocket through the LauncherInterface.
Make all calls to LauncherInterface secured by the
instance mutex.

Change-Id: I751228de5f4263112471098ee08cc73a5245147e
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
Jarek Kobus
2021-08-30 18:21:41 +02:00
parent 236074423c
commit 99cf99579e
4 changed files with 56 additions and 14 deletions

View File

@@ -251,7 +251,7 @@ public:
ProcessLauncherImpl(ProcessMode processMode)
: ProcessInterface(processMode), m_token(uniqueToken())
{
m_handle = LauncherInterface::socket()->registerHandle(token(), processMode);
m_handle = LauncherInterface::registerHandle(token(), processMode);
connect(m_handle, &CallerHandle::errorOccurred,
this, &ProcessInterface::errorOccurred);
connect(m_handle, &CallerHandle::started,
@@ -266,7 +266,7 @@ public:
~ProcessLauncherImpl() override
{
cancel();
LauncherInterface::socket()->unregisterHandle(token());
LauncherInterface::unregisterHandle(token());
}
QByteArray readAllStandardOutput() override { return m_handle->readAllStandardOutput(); }