forked from qt-creator/qt-creator
Don't allow opening the same generic project multiple times
Quick fix by copying code also found in Qt4 and QML project managers. Would be better to have some common solution... Task-number: QTCREATORBUG-1383
This commit is contained in:
@@ -32,8 +32,11 @@
|
||||
#include "genericproject.h"
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/messagemanager.h>
|
||||
#include <coreplugin/uniqueidmanager.h>
|
||||
#include <projectexplorer/projectexplorer.h>
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
#include <projectexplorer/session.h>
|
||||
|
||||
#include <QtDebug>
|
||||
|
||||
@@ -60,14 +63,21 @@ QString Manager::mimeType() const
|
||||
|
||||
ProjectExplorer::Project *Manager::openProject(const QString &fileName)
|
||||
{
|
||||
QFileInfo fileInfo(fileName);
|
||||
if (!QFileInfo(fileName).isFile())
|
||||
return 0;
|
||||
|
||||
if (fileInfo.isFile()) {
|
||||
GenericProject *project = new GenericProject(this, fileName);
|
||||
return project;
|
||||
ProjectExplorer::ProjectExplorerPlugin *projectExplorer = ProjectExplorer::ProjectExplorerPlugin::instance();
|
||||
foreach (ProjectExplorer::Project *pi, projectExplorer->session()->projects()) {
|
||||
if (fileName == pi->file()->fileName()) {
|
||||
Core::MessageManager *messageManager = Core::ICore::instance()->messageManager();
|
||||
messageManager->printToOutputPanePopup(tr("Failed opening project '%1': Project already open")
|
||||
.arg(QDir::toNativeSeparators(fileName)));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
GenericProject *project = new GenericProject(this, fileName);
|
||||
return project;
|
||||
}
|
||||
|
||||
void Manager::registerProject(GenericProject *project)
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace Internal {
|
||||
|
||||
class GenericProject;
|
||||
|
||||
class Manager: public ProjectExplorer::IProjectManager
|
||||
class Manager : public ProjectExplorer::IProjectManager
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
@@ -181,7 +181,7 @@ QString Qt4Manager::mimeType() const
|
||||
return QLatin1String(Qt4ProjectManager::Constants::PROFILE_MIMETYPE);
|
||||
}
|
||||
|
||||
ProjectExplorer::Project* Qt4Manager::openProject(const QString &fileName)
|
||||
ProjectExplorer::Project *Qt4Manager::openProject(const QString &fileName)
|
||||
{
|
||||
Core::MessageManager *messageManager = Core::ICore::instance()->messageManager();
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ public:
|
||||
int projectLanguage() const;
|
||||
|
||||
virtual QString mimeType() const;
|
||||
ProjectExplorer::Project* openProject(const QString &fileName);
|
||||
ProjectExplorer::Project *openProject(const QString &fileName);
|
||||
|
||||
// Context information used in the slot implementations
|
||||
ProjectExplorer::Node *contextNode() const;
|
||||
|
||||
Reference in New Issue
Block a user