Commit c0b42868 authored by Thorbjørn Lindeijer's avatar Thorbjørn Lindeijer
Browse files

Preserve the user-set build directory for Generic Projects

Previously it would be converted to an absolute path. Preserving the
original path allows it to be set as relative to the project.

Reviewed-by: dt
parent 7215c033
......@@ -215,7 +215,6 @@ bool PathChooser::validatePath(const QString &path, QString *errorMessage)
}
const QFileInfo fi(path);
const bool isDir = fi.isDir();
// Check if existing
switch (m_d->m_acceptingKind) {
......@@ -236,7 +235,7 @@ bool PathChooser::validatePath(const QString &path, QString *errorMessage)
// Check expected kind
switch (m_d->m_acceptingKind) {
case PathChooser::Directory:
if (!isDir) {
if (!fi.isDir()) {
if (errorMessage)
*errorMessage = tr("The path '%1' is not a directory.").arg(path);
return false;
......@@ -244,7 +243,7 @@ bool PathChooser::validatePath(const QString &path, QString *errorMessage)
break;
case PathChooser::File:
if (isDir) {
if (!fi.isFile()) {
if (errorMessage)
*errorMessage = tr("The path '%1' is not a file.").arg(path);
return false;
......
......@@ -89,13 +89,19 @@ ProjectExplorer::Environment GenericBuildConfiguration::environment() const
QString GenericBuildConfiguration::buildDirectory() const
{
QString buildDirectory = m_buildDirectory;
if (buildDirectory.isEmpty()) {
QFileInfo fileInfo(target()->project()->file()->fileName());
// Convert to absolute path when necessary
const QFileInfo projectFile(target()->project()->file()->fileName());
const QDir projectDir(projectFile.path());
return projectDir.absoluteFilePath(m_buildDirectory);
}
buildDirectory = fileInfo.absolutePath();
}
return buildDirectory;
/**
* Returns the build directory unmodified, instead of making it absolute like
* buildDirectory() does.
*/
QString GenericBuildConfiguration::rawBuildDirectory() const
{
return m_buildDirectory;
}
void GenericBuildConfiguration::setBuildDirectory(const QString &buildDirectory)
......
......@@ -51,7 +51,10 @@ public:
virtual ProjectExplorer::Environment environment() const;
virtual QString buildDirectory() const;
QString rawBuildDirectory() const;
void setBuildDirectory(const QString &buildDirectory);
QVariantMap toMap() const;
protected:
......
......@@ -504,7 +504,7 @@ void GenericBuildSettingsWidget::init(BuildConfiguration *bc)
{
m_buildConfiguration = static_cast<GenericBuildConfiguration *>(bc);
m_nameLineEdit->setText(m_buildConfiguration->displayName());
m_pathChooser->setPath(m_buildConfiguration->buildDirectory());
m_pathChooser->setPath(m_buildConfiguration->rawBuildDirectory());
}
void GenericBuildSettingsWidget::configNameEdited(const QString &name)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment