mirror of
https://github.com/Kitware/CMake.git
synced 2026-08-09 09:12:00 +00:00
cmake-gui: fix receiving directory path from file dialogs
System file dialogs might return directory path with trailing slash,
which is a problem for source path, because then the ${sourceDirName} in
presets evaluates to empty string. Resolve that by stripping the
trailing slashes from source and binary dirs.
This commit is contained in:
@@ -25,6 +25,16 @@
|
||||
# include "qt_windows.h" // For SetErrorMode
|
||||
#endif
|
||||
|
||||
static QString sanitizedDirPath(QString const& dir)
|
||||
{
|
||||
QString result = QString::fromStdString(
|
||||
cmSystemTools::GetActualCaseForPath(dir.toStdString()));
|
||||
if (result.size() > 1 && result.endsWith(QDir::separator())) {
|
||||
result = result.left(result.size() - 1);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
QCMake::QCMake(QObject* p)
|
||||
: QObject(p)
|
||||
, StartEnvironment(QProcessEnvironment::systemEnvironment())
|
||||
@@ -75,8 +85,7 @@ void QCMake::loadCache(QString const& dir)
|
||||
|
||||
void QCMake::setSourceDirectory(QString const& _dir)
|
||||
{
|
||||
QString dir = QString::fromStdString(
|
||||
cmSystemTools::GetActualCaseForPath(_dir.toStdString()));
|
||||
QString dir = sanitizedDirPath(_dir);
|
||||
if (this->SourceDirectory != dir) {
|
||||
this->SourceDirectory = QDir::fromNativeSeparators(dir);
|
||||
emit this->sourceDirChanged(this->SourceDirectory);
|
||||
@@ -92,8 +101,7 @@ void QCMake::setSourceDirectory(QString const& _dir)
|
||||
|
||||
void QCMake::setBinaryDirectory(QString const& _dir)
|
||||
{
|
||||
QString dir = QString::fromStdString(
|
||||
cmSystemTools::GetActualCaseForPath(_dir.toStdString()));
|
||||
QString dir = sanitizedDirPath(_dir);
|
||||
|
||||
QString absDir = dir;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user