forked from qt-creator/qt-creator
Fix Wizard page not offering the right project to add to.
Symptom of file name slashification breakage. Reviewed-by: dt Task-number: QTCREATORBUG-2535
This commit is contained in:
@@ -72,7 +72,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
GeneratedFilePrivate::GeneratedFilePrivate(const QString &p) :
|
GeneratedFilePrivate::GeneratedFilePrivate(const QString &p) :
|
||||||
path(p),
|
path(QDir::cleanPath(p)),
|
||||||
binary(false),
|
binary(false),
|
||||||
attributes(0)
|
attributes(0)
|
||||||
{
|
{
|
||||||
@@ -111,7 +111,7 @@ QString GeneratedFile::path() const
|
|||||||
|
|
||||||
void GeneratedFile::setPath(const QString &p)
|
void GeneratedFile::setPath(const QString &p)
|
||||||
{
|
{
|
||||||
m_d->path = p;
|
m_d->path = QDir::cleanPath(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString GeneratedFile::contents() const
|
QString GeneratedFile::contents() const
|
||||||
@@ -628,7 +628,7 @@ bool BaseFileWizard::postGenerateOpenEditors(const GeneratedFiles &l, QString *e
|
|||||||
if (file.attributes() & Core::GeneratedFile::OpenEditorAttribute) {
|
if (file.attributes() & Core::GeneratedFile::OpenEditorAttribute) {
|
||||||
if (!em->openEditor(file.path(), file.editorId(), Core::EditorManager::ModeSwitch )) {
|
if (!em->openEditor(file.path(), file.editorId(), Core::EditorManager::ModeSwitch )) {
|
||||||
if (errorMessage)
|
if (errorMessage)
|
||||||
*errorMessage = tr("Failed to open an editor for '%1'.").arg(file.path());
|
*errorMessage = tr("Failed to open an editor for '%1'.").arg(QDir::toNativeSeparators(file.path()));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -663,7 +663,7 @@ BaseFileWizard::OverwriteResult BaseFileWizard::promptOverwrite(const QStringLis
|
|||||||
if (fi.exists()) {
|
if (fi.exists()) {
|
||||||
if (!fileNamesMsgPart.isEmpty())
|
if (!fileNamesMsgPart.isEmpty())
|
||||||
fileNamesMsgPart += QLatin1String(", ");
|
fileNamesMsgPart += QLatin1String(", ");
|
||||||
fileNamesMsgPart += fileName.mid(commonExistingPath.size() + 1);
|
fileNamesMsgPart += QDir::toNativeSeparators(fileName.mid(commonExistingPath.size() + 1));
|
||||||
do {
|
do {
|
||||||
if (fi.isDir()) {
|
if (fi.isDir()) {
|
||||||
oddStuffFound = true;
|
oddStuffFound = true;
|
||||||
@@ -687,13 +687,14 @@ BaseFileWizard::OverwriteResult BaseFileWizard::promptOverwrite(const QStringLis
|
|||||||
return OverwriteOk;
|
return OverwriteOk;
|
||||||
|
|
||||||
if (oddStuffFound) {
|
if (oddStuffFound) {
|
||||||
*errorMessage = tr("The project directory %1 contains files which cannot be overwritten:\n%2.").arg(commonExistingPath).arg(fileNamesMsgPart);
|
*errorMessage = tr("The project directory %1 contains files which cannot be overwritten:\n%2.")
|
||||||
|
.arg(QDir::toNativeSeparators(commonExistingPath)).arg(fileNamesMsgPart);
|
||||||
return OverwriteError;
|
return OverwriteError;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString messageFormat = tr("The following files already exist in the directory %1:\n"
|
const QString messageFormat = tr("The following files already exist in the directory %1:\n"
|
||||||
"%2.\nWould you like to overwrite them?");
|
"%2.\nWould you like to overwrite them?");
|
||||||
const QString message = messageFormat.arg(commonExistingPath).arg(fileNamesMsgPart);
|
const QString message = messageFormat.arg(QDir::toNativeSeparators(commonExistingPath)).arg(fileNamesMsgPart);
|
||||||
const bool yes = (QMessageBox::question(Core::ICore::instance()->mainWindow(),
|
const bool yes = (QMessageBox::question(Core::ICore::instance()->mainWindow(),
|
||||||
tr("Existing files"), message,
|
tr("Existing files"), message,
|
||||||
QMessageBox::Yes | QMessageBox::No,
|
QMessageBox::Yes | QMessageBox::No,
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ void AttachGdbAdapter::runEngine()
|
|||||||
{
|
{
|
||||||
QTC_ASSERT(state() == EngineRunRequested, qDebug() << state());
|
QTC_ASSERT(state() == EngineRunRequested, qDebug() << state());
|
||||||
m_engine->notifyEngineRunAndInferiorStopOk();
|
m_engine->notifyEngineRunAndInferiorStopOk();
|
||||||
m_engine->continueInferiorInternal();
|
//m_engine->continueInferiorInternal();
|
||||||
m_engine->showStatusMessage(tr("Attached to process %1.")
|
m_engine->showStatusMessage(tr("Attached to process %1.")
|
||||||
.arg(m_engine->inferiorPid()));
|
.arg(m_engine->inferiorPid()));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -148,7 +148,7 @@ static inline bool createFile(Internal::CustomWizardFile cwFile,
|
|||||||
const QString sourcePath = sourceDirectory + slash + cwFile.source;
|
const QString sourcePath = sourceDirectory + slash + cwFile.source;
|
||||||
// Field replacement on target path
|
// Field replacement on target path
|
||||||
Internal::CustomWizardContext::replaceFields(fm, &cwFile.target);
|
Internal::CustomWizardContext::replaceFields(fm, &cwFile.target);
|
||||||
const QString targetPath = QDir::toNativeSeparators(targetDirectory + slash + cwFile.target);
|
const QString targetPath = targetDirectory + slash + cwFile.target;
|
||||||
if (CustomWizardPrivate::verbose)
|
if (CustomWizardPrivate::verbose)
|
||||||
qDebug() << "generating " << targetPath << sourcePath << fm;
|
qDebug() << "generating " << targetPath << sourcePath << fm;
|
||||||
|
|
||||||
@@ -533,7 +533,8 @@ bool CustomProjectWizard::postGenerateOpen(const Core::GeneratedFiles &l, QStrin
|
|||||||
if (file.attributes() & Core::GeneratedFile::OpenProjectAttribute) {
|
if (file.attributes() & Core::GeneratedFile::OpenProjectAttribute) {
|
||||||
if (!ProjectExplorer::ProjectExplorerPlugin::instance()->openProject(file.path())) {
|
if (!ProjectExplorer::ProjectExplorerPlugin::instance()->openProject(file.path())) {
|
||||||
if (errorMessage)
|
if (errorMessage)
|
||||||
*errorMessage = tr("The project %1 could not be opened.").arg(file.path());
|
*errorMessage = tr("The project %1 could not be opened.").
|
||||||
|
arg(QDir::toNativeSeparators(file.path()));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -184,7 +184,7 @@ Core::GeneratedFiles
|
|||||||
fileInfo.isAbsolute() ?
|
fileInfo.isAbsolute() ?
|
||||||
token :
|
token :
|
||||||
(targetPath + QLatin1Char('/') + token);
|
(targetPath + QLatin1Char('/') + token);
|
||||||
file.setPath(QDir::toNativeSeparators(fullPath));
|
file.setPath(fullPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
file.setAttributes(attributes);
|
file.setAttributes(attributes);
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ struct ProjectEntry {
|
|||||||
int compare(const ProjectEntry &rhs) const;
|
int compare(const ProjectEntry &rhs) const;
|
||||||
|
|
||||||
ProjectNode *node;
|
ProjectNode *node;
|
||||||
QString nativeDirectory; // For matching against wizards' files, which are native.
|
QString directory; // For matching against wizards' files, which are native.
|
||||||
QString fileName;
|
QString fileName;
|
||||||
QString baseName;
|
QString baseName;
|
||||||
Type type;
|
Type type;
|
||||||
@@ -116,13 +116,13 @@ ProjectEntry::ProjectEntry(ProjectNode *n) :
|
|||||||
baseName = fi.baseName();
|
baseName = fi.baseName();
|
||||||
if (fi.suffix() != QLatin1String("pro"))
|
if (fi.suffix() != QLatin1String("pro"))
|
||||||
type = PriFile;
|
type = PriFile;
|
||||||
nativeDirectory = QDir::toNativeSeparators(fi.absolutePath());
|
directory = fi.absolutePath();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sort helper that sorts by base name and puts '*.pro' before '*.pri'
|
// Sort helper that sorts by base name and puts '*.pro' before '*.pri'
|
||||||
int ProjectEntry::compare(const ProjectEntry &rhs) const
|
int ProjectEntry::compare(const ProjectEntry &rhs) const
|
||||||
{
|
{
|
||||||
if (const int drc = nativeDirectory.compare(rhs.nativeDirectory))
|
if (const int drc = directory.compare(rhs.directory))
|
||||||
return drc;
|
return drc;
|
||||||
if (const int brc = baseName.compare(rhs.baseName))
|
if (const int brc = baseName.compare(rhs.baseName))
|
||||||
return brc;
|
return brc;
|
||||||
@@ -140,7 +140,7 @@ inline bool operator<(const ProjectEntry &pe1, const ProjectEntry &pe2)
|
|||||||
|
|
||||||
QDebug operator<<(QDebug d, const ProjectEntry &e)
|
QDebug operator<<(QDebug d, const ProjectEntry &e)
|
||||||
{
|
{
|
||||||
d.nospace() << e.nativeDirectory << ' ' << e.fileName << ' ' << e.type;
|
d.nospace() << e.directory << ' ' << e.fileName << ' ' << e.type;
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -212,7 +212,7 @@ static int findMatchingProject(const QList<ProjectEntry> &projects,
|
|||||||
const int count = projects.size();
|
const int count = projects.size();
|
||||||
for (int p = 0; p < count; p++) {
|
for (int p = 0; p < count; p++) {
|
||||||
// Direct match or better match? (note that the wizards' files are native).
|
// Direct match or better match? (note that the wizards' files are native).
|
||||||
const QString &projectDirectory = projects.at(p).nativeDirectory;
|
const QString &projectDirectory = projects.at(p).directory;
|
||||||
if (projectDirectory == commonPath)
|
if (projectDirectory == commonPath)
|
||||||
return p;
|
return p;
|
||||||
if (projectDirectory.size() > bestMatchLength
|
if (projectDirectory.size() > bestMatchLength
|
||||||
@@ -357,7 +357,7 @@ void ProjectFileWizardExtension::initProjectChoices(const QString &generatedProj
|
|||||||
for (ProjectEntryMap::const_iterator it = entryMap.constBegin(); it != cend; ++it) {
|
for (ProjectEntryMap::const_iterator it = entryMap.constBegin(); it != cend; ++it) {
|
||||||
m_context->projects.push_back(it.key());
|
m_context->projects.push_back(it.key());
|
||||||
projectChoices.push_back(it.key().fileName);
|
projectChoices.push_back(it.key().fileName);
|
||||||
projectToolTips.push_back(it.key().nativeDirectory);
|
projectToolTips.push_back(QDir::toNativeSeparators(it.key().directory));
|
||||||
}
|
}
|
||||||
|
|
||||||
m_context->page->setProjects(projectChoices);
|
m_context->page->setProjects(projectChoices);
|
||||||
|
|||||||
Reference in New Issue
Block a user