forked from qt-creator/qt-creator
Fix a possible crash when reaping a process with callbacks
It may happen that CMakeProcess destructor puts its internal process into the reaper. After this, when the CMakeProcess is already destructed, the internal process may still be working. Since we have set the StdErrLineCallback lambda for the process which accesses the private m_parser field, it may potentially crash. Solve it in a general way, so that whenever we put a process to the reaper we reset its callbacks. In addition, disconnect all the slots connected to process' signals. Fixes: QTCREATORBUG-26220 Change-Id: I63ea0e0ed6a62ef97ac695572f18014458489c5c Reviewed-by: Cristian Adam <cristian.adam@qt.io>
This commit is contained in:
committed by
Cristian Adam
parent
4772253d9d
commit
ebae255e49
@@ -57,10 +57,8 @@ CMakeProcess::CMakeProcess()
|
|||||||
|
|
||||||
CMakeProcess::~CMakeProcess()
|
CMakeProcess::~CMakeProcess()
|
||||||
{
|
{
|
||||||
if (m_process) {
|
if (m_process)
|
||||||
m_process->disconnect();
|
|
||||||
Core::Reaper::reap(m_process.release());
|
Core::Reaper::reap(m_process.release());
|
||||||
}
|
|
||||||
|
|
||||||
m_parser.flush();
|
m_parser.flush();
|
||||||
|
|
||||||
|
@@ -157,6 +157,10 @@ void reap(QtcProcess *process, int timeoutMs)
|
|||||||
if (!process)
|
if (!process)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
process->setStdOutCallback(nullptr);
|
||||||
|
process->setStdErrCallback(nullptr);
|
||||||
|
process->disconnect();
|
||||||
|
|
||||||
QTC_ASSERT(Internal::d, return);
|
QTC_ASSERT(Internal::d, return);
|
||||||
|
|
||||||
new Internal::ProcessReaper(process, timeoutMs);
|
new Internal::ProcessReaper(process, timeoutMs);
|
||||||
|
Reference in New Issue
Block a user