forked from qt-creator/qt-creator
Cleanup the finished / unused processes
Change-Id: Ia29e51b7591338cf757ce3a6ddccfcc39fde086b Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -214,6 +214,7 @@ void LauncherSocketHandler::handleProcessFinished()
|
|||||||
packet.stdErr = proc->readAllStandardError();
|
packet.stdErr = proc->readAllStandardError();
|
||||||
packet.stdOut = proc->readAllStandardOutput();
|
packet.stdOut = proc->readAllStandardOutput();
|
||||||
sendPacket(packet);
|
sendPacket(packet);
|
||||||
|
removeProcess(proc->token());
|
||||||
}
|
}
|
||||||
|
|
||||||
void LauncherSocketHandler::handleStopFailure()
|
void LauncherSocketHandler::handleStopFailure()
|
||||||
@@ -221,8 +222,6 @@ void LauncherSocketHandler::handleStopFailure()
|
|||||||
// Process did not react to a kill signal. Rare, but not unheard of.
|
// Process did not react to a kill signal. Rare, but not unheard of.
|
||||||
// Forget about the associated Process object and report process exit to the client.
|
// Forget about the associated Process object and report process exit to the client.
|
||||||
Process * proc = senderProcess();
|
Process * proc = senderProcess();
|
||||||
proc->disconnect();
|
|
||||||
m_processes.remove(proc->token());
|
|
||||||
ProcessFinishedPacket packet(proc->token());
|
ProcessFinishedPacket packet(proc->token());
|
||||||
packet.error = QProcess::Crashed;
|
packet.error = QProcess::Crashed;
|
||||||
packet.exitCode = -1;
|
packet.exitCode = -1;
|
||||||
@@ -263,9 +262,8 @@ void LauncherSocketHandler::handleStopPacket()
|
|||||||
// This can happen if the process finishes on its own at about the same time the client
|
// This can happen if the process finishes on its own at about the same time the client
|
||||||
// sends the request.
|
// sends the request.
|
||||||
logDebug("got stop request when process was not running");
|
logDebug("got stop request when process was not running");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
process->cancel();
|
removeProcess(process->token());
|
||||||
}
|
}
|
||||||
|
|
||||||
void LauncherSocketHandler::handleShutdownPacket()
|
void LauncherSocketHandler::handleShutdownPacket()
|
||||||
@@ -302,6 +300,21 @@ Process *LauncherSocketHandler::setupProcess(quintptr token)
|
|||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LauncherSocketHandler::removeProcess(quintptr token)
|
||||||
|
{
|
||||||
|
const auto it = m_processes.find(token);
|
||||||
|
if (it == m_processes.end())
|
||||||
|
return;
|
||||||
|
|
||||||
|
Process *process = it.value();
|
||||||
|
m_processes.erase(it);
|
||||||
|
process->disconnect();
|
||||||
|
if (process->state() != QProcess::NotRunning)
|
||||||
|
process->cancel();
|
||||||
|
else
|
||||||
|
delete process;
|
||||||
|
}
|
||||||
|
|
||||||
Process *LauncherSocketHandler::senderProcess() const
|
Process *LauncherSocketHandler::senderProcess() const
|
||||||
{
|
{
|
||||||
return static_cast<Process *>(sender());
|
return static_cast<Process *>(sender());
|
||||||
|
@@ -66,6 +66,7 @@ private:
|
|||||||
void sendPacket(const LauncherPacket &packet);
|
void sendPacket(const LauncherPacket &packet);
|
||||||
|
|
||||||
Process *setupProcess(quintptr token);
|
Process *setupProcess(quintptr token);
|
||||||
|
void removeProcess(quintptr token);
|
||||||
Process *senderProcess() const;
|
Process *senderProcess() const;
|
||||||
|
|
||||||
const QString m_serverPath;
|
const QString m_serverPath;
|
||||||
|
Reference in New Issue
Block a user