Fix a race in CMakeProjectManager::createXml

This commit is contained in:
dt
2009-10-21 13:45:49 +02:00
parent 7d50aa29b8
commit 1253c55d56
3 changed files with 13 additions and 13 deletions

View File

@@ -435,9 +435,10 @@ void CMakeRunPage::runCMake()
m_output->clear(); m_output->clear();
if (m_cmakeWizard->cmakeManager()->isCMakeExecutableValid()) { if (m_cmakeWizard->cmakeManager()->isCMakeExecutableValid()) {
m_cmakeProcess = cmakeManager->createXmlFile(arguments, m_cmakeWizard->sourceDirectory(), m_buildDirectory, env, generator); m_cmakeProcess = new QProcess();
connect(m_cmakeProcess, SIGNAL(readyRead()), this, SLOT(cmakeReadyRead())); connect(m_cmakeProcess, SIGNAL(readyRead()), this, SLOT(cmakeReadyRead()));
connect(m_cmakeProcess, SIGNAL(finished(int)), this, SLOT(cmakeFinished())); connect(m_cmakeProcess, SIGNAL(finished(int)), this, SLOT(cmakeFinished()));
cmakeManager->createXmlFile(m_cmakeProcess, arguments, m_cmakeWizard->sourceDirectory(), m_buildDirectory, env, generator);
} else { } else {
m_runCMake->setEnabled(true); m_runCMake->setEnabled(true);
m_argumentsLineEdit->setEnabled(true); m_argumentsLineEdit->setEnabled(true);

View File

@@ -99,7 +99,7 @@ bool CMakeManager::hasCodeBlocksMsvcGenerator() const
// we probably want the process instead of this function // we probably want the process instead of this function
// cmakeproject then could even run the cmake process in the background, adding the files afterwards // cmakeproject then could even run the cmake process in the background, adding the files afterwards
// sounds like a plan // sounds like a plan
QProcess *CMakeManager::createXmlFile(const QStringList &arguments, const QString &sourceDirectory, const QDir &buildDirectory, const ProjectExplorer::Environment &env, const QString &generator) void CMakeManager::createXmlFile(QProcess *proc, const QStringList &arguments, const QString &sourceDirectory, const QDir &buildDirectory, const ProjectExplorer::Environment &env, const QString &generator)
{ {
// We create a cbp file, only if we didn't find a cbp file in the base directory // We create a cbp file, only if we didn't find a cbp file in the base directory
// Yet that can still override cbp files in subdirectories // Yet that can still override cbp files in subdirectories
@@ -111,14 +111,12 @@ QProcess *CMakeManager::createXmlFile(const QStringList &arguments, const QStrin
// TODO we need to pass on the same paremeters as the cmakestep // TODO we need to pass on the same paremeters as the cmakestep
QString buildDirectoryPath = buildDirectory.absolutePath(); QString buildDirectoryPath = buildDirectory.absolutePath();
buildDirectory.mkpath(buildDirectoryPath); buildDirectory.mkpath(buildDirectoryPath);
QProcess *cmake = new QProcess; proc->setWorkingDirectory(buildDirectoryPath);
cmake->setWorkingDirectory(buildDirectoryPath); proc->setProcessChannelMode(QProcess::MergedChannels);
cmake->setProcessChannelMode(QProcess::MergedChannels); proc->setEnvironment(env.toStringList());
cmake->setEnvironment(env.toStringList());
const QString srcdir = buildDirectory.exists(QLatin1String("CMakeCache.txt")) ? QString(QLatin1Char('.')) : sourceDirectory; const QString srcdir = buildDirectory.exists(QLatin1String("CMakeCache.txt")) ? QString(QLatin1Char('.')) : sourceDirectory;
cmake->start(cmakeExecutable(), QStringList() << srcdir << arguments << generator); proc->start(cmakeExecutable(), QStringList() << srcdir << arguments << generator);
return cmake;
} }
QString CMakeManager::findCbpFile(const QDir &directory) QString CMakeManager::findCbpFile(const QDir &directory)

View File

@@ -63,7 +63,8 @@ public:
void setCMakeExecutable(const QString &executable); void setCMakeExecutable(const QString &executable);
QProcess* createXmlFile(const QStringList &arguments, void createXmlFile(QProcess *process,
const QStringList &arguments,
const QString &sourceDirectory, const QString &sourceDirectory,
const QDir &buildDirectory, const QDir &buildDirectory,
const ProjectExplorer::Environment &env, const ProjectExplorer::Environment &env,