forked from qt-creator/qt-creator
MesonProcess: Fix process restart
It looks like MesonProjectParser::m_process may be restarted directly from process' finished() handler - inside MesonProjectParser::processFinished(). In this case the process is directly deleted from its signal handler. Fix it by releasing the old process and deleting it later. Don't pass process reference to the other thread when calling runAsync(). Pass the copy of standard output instead. Change-Id: I163a3cc86fbdbe8a3d9a19c479f96017f5803f76 Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -85,6 +85,8 @@ void MesonProcess::setupProcess(const Command &command,
|
||||
const Environment env,
|
||||
bool captureStdo)
|
||||
{
|
||||
if (m_process)
|
||||
m_process.release()->deleteLater();
|
||||
m_process.reset(new QtcProcess);
|
||||
connect(m_process.get(), &QtcProcess::done, this, &MesonProcess::handleProcessDone);
|
||||
if (!captureStdo) {
|
||||
|
@@ -196,20 +196,18 @@ QList<ProjectExplorer::BuildTargetInfo> MesonProjectParser::appsTargets() const
|
||||
}
|
||||
return apps;
|
||||
}
|
||||
|
||||
bool MesonProjectParser::startParser()
|
||||
{
|
||||
m_parserFutureResult = Utils::runAsync(
|
||||
ProjectExplorer::ProjectExplorerPlugin::sharedThreadPool(),
|
||||
[process = &m_process,
|
||||
introType = m_introType,
|
||||
buildDir = m_buildDir.toString(),
|
||||
srcDir = m_srcDir]() {
|
||||
if (introType == IntroDataType::file) {
|
||||
return extractParserResults(srcDir, MesonInfoParser::parse(buildDir));
|
||||
} else {
|
||||
return extractParserResults(srcDir, MesonInfoParser::parse(process->stdOut()));
|
||||
}
|
||||
});
|
||||
ProjectExplorer::ProjectExplorerPlugin::sharedThreadPool(),
|
||||
[processOutput = m_process.stdOut(), introType = m_introType,
|
||||
buildDir = m_buildDir.toString(), srcDir = m_srcDir] {
|
||||
if (introType == IntroDataType::file)
|
||||
return extractParserResults(srcDir, MesonInfoParser::parse(buildDir));
|
||||
else
|
||||
return extractParserResults(srcDir, MesonInfoParser::parse(processOutput));
|
||||
});
|
||||
|
||||
Utils::onFinished(m_parserFutureResult, this, &MesonProjectParser::update);
|
||||
return true;
|
||||
|
Reference in New Issue
Block a user