Do not search for project in directory with Open Workspace

"Open Workspace" should open the selected directory as a workspace,
regardless of whether there is another supported project file in that
directory or not.

Fixes: QTCREATORBUG-31789
Change-Id: Iab86dfa9c8e774eec3624ba703b6686a54ec1458
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Eike Ziller
2024-11-04 09:27:42 +01:00
parent 6384ce6d4a
commit a291d6f021
2 changed files with 8 additions and 8 deletions

View File

@@ -1986,7 +1986,7 @@ void ProjectExplorerPluginPrivate::openWorkspaceAction()
if (filePath.isEmpty()) if (filePath.isEmpty())
return; return;
OpenProjectResult result = ProjectExplorerPlugin::openProject(filePath); OpenProjectResult result = ProjectExplorerPlugin::openProject(filePath, /*searchInDir=*/false);
if (!result) if (!result)
ProjectExplorerPlugin::showOpenProjectError(result); ProjectExplorerPlugin::showOpenProjectError(result);
@@ -2277,9 +2277,9 @@ void ProjectExplorerPlugin::openProjectWelcomePage(const FilePath &filePath)
showOpenProjectError(result); showOpenProjectError(result);
} }
OpenProjectResult ProjectExplorerPlugin::openProject(const FilePath &filePath) OpenProjectResult ProjectExplorerPlugin::openProject(const FilePath &filePath, bool searchInDir)
{ {
OpenProjectResult result = openProjects({filePath}); OpenProjectResult result = openProjects({filePath}, searchInDir);
Project *project = result.project(); Project *project = result.project();
if (!project) if (!project)
return result; return result;
@@ -2327,15 +2327,15 @@ static void appendError(QString &errorString, const QString &error)
errorString.append(error); errorString.append(error);
} }
OpenProjectResult ProjectExplorerPlugin::openProjects(const FilePaths &filePaths) OpenProjectResult ProjectExplorerPlugin::openProjects(const FilePaths &filePaths, bool searchInDir)
{ {
QList<Project*> openedPro; QList<Project*> openedPro;
QList<Project *> alreadyOpen; QList<Project *> alreadyOpen;
QString errorString; QString errorString;
for (const FilePath &fileName : filePaths) { for (const FilePath &fileName : filePaths) {
QTC_ASSERT(!fileName.isEmpty(), continue); QTC_ASSERT(!fileName.isEmpty(), continue);
const FilePath filePath = [fileName] { const FilePath filePath = [fileName, searchInDir] {
if (!fileName.isDir()) if (!fileName.isDir() || !searchInDir)
return fileName.absoluteFilePath(); return fileName.absoluteFilePath();
// For the case of directories, try to see if there is a project file in the directory // For the case of directories, try to see if there is a project file in the directory

View File

@@ -99,8 +99,8 @@ public:
static ProjectExplorerPlugin *instance(); static ProjectExplorerPlugin *instance();
static OpenProjectResult openProject(const Utils::FilePath &filePath); static OpenProjectResult openProject(const Utils::FilePath &filePath, bool searchInDir = true);
static OpenProjectResult openProjects(const Utils::FilePaths &filePaths); static OpenProjectResult openProjects(const Utils::FilePaths &filePaths, bool searchInDir = true);
static void showOpenProjectError(const OpenProjectResult &result); static void showOpenProjectError(const OpenProjectResult &result);
static void openProjectWelcomePage(const Utils::FilePath &filePath); static void openProjectWelcomePage(const Utils::FilePath &filePath);
static void unloadProject(Project *project); static void unloadProject(Project *project);