Commit 81b37f02 authored by dt's avatar dt

ProjectExplorer: Always give feedback on failed project loading

Task-Nr: QTCREATORBUG-3435
parent 49655d62
......@@ -71,17 +71,9 @@ QString ProjectFileFactory::displayName() const
Core::IFile *ProjectFileFactory::open(const QString &fileName)
{
Core::IFile *fIFace = 0;
ProjectExplorerPlugin *pe = ProjectExplorerPlugin::instance();
if (!pe->openProject(fileName)) {
Core::ICore::instance()->messageManager()->printToOutputPane(tr("Could not open the following project: '%1'").arg(fileName));
} else if (pe->session()) {
SessionManager *session = pe->session();
if (session->projects().count() == 1)
fIFace = session->projects().first()->file();
}
return fIFace;
pe->openProject(fileName);
return 0;
}
QList<ProjectFileFactory *> ProjectFileFactory::createFactories(QString *filterString)
......
......@@ -887,19 +887,6 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
return true;
}
ProjectFileFactory *ProjectExplorerPlugin::findProjectFileFactory(const QString &filename) const
{
// Find factory
if (const Core::MimeType mt = Core::ICore::instance()->mimeDatabase()->findByFile(QFileInfo(filename))) {
const QString mimeType = mt.type();
foreach (ProjectFileFactory *f, d->m_fileFactories)
if (f->mimeTypes().contains(mimeType))
return f;
}
qWarning("Unable to find project file factory for '%s'", filename.toUtf8().constData());
return 0;
}
void ProjectExplorerPlugin::loadAction()
{
if (debug)
......@@ -923,8 +910,7 @@ void ProjectExplorerPlugin::loadAction()
d->m_projectFilterString);
if (filename.isEmpty())
return;
if (ProjectFileFactory *pf = findProjectFileFactory(filename))
pf->open(filename);
loadProject(filename);
updateActions();
}
......@@ -1110,6 +1096,18 @@ void ProjectExplorerPlugin::savePersistentSettings()
}
}
void ProjectExplorerPlugin::loadProject(const QString &project)
{
if (!openProject(project)) {
QMessageBox box(QMessageBox::Warning,
tr("Failed to open project"),
tr("Failed to open project:\n%1").arg(project),
QMessageBox::Ok,
Core::ICore::instance()->mainWindow());
box.exec();
}
}
bool ProjectExplorerPlugin::openProject(const QString &fileName)
{
if (debug)
......@@ -1161,11 +1159,8 @@ QList<Project *> ProjectExplorerPlugin::openProjects(const QStringList &fileName
}
updateActions();
if (openedPro.isEmpty()) {
qDebug() << "ProjectExplorerPlugin - Could not open any projects!";
} else {
if (!openedPro.isEmpty())
Core::ModeManager::instance()->activateMode(Core::Constants::MODE_EDIT);
}
return openedPro;
}
......@@ -1984,8 +1979,16 @@ void ProjectExplorerPlugin::openRecentProject()
if (!a)
return;
QString fileName = a->data().toString();
if (!fileName.isEmpty())
openProject(fileName);
if (!fileName.isEmpty()) {
if (!openProject(fileName)) {
QMessageBox box(QMessageBox::Warning,
tr("Failed to open project"),
tr("Failed to open project:\n%1").arg(fileName),
QMessageBox::Ok,
Core::ICore::instance()->mainWindow());
box.exec();
}
}
}
void ProjectExplorerPlugin::invalidateProject(Project *project)
......
......@@ -205,7 +205,7 @@ private slots:
void updateDeployActions();
void slotUpdateRunActions();
void loadProject(const QString &project) { openProject(project); }
void loadProject(const QString &project);
void currentModeChanged(Core::IMode *mode, Core::IMode *oldMode);
void updateActions();
void loadCustomWizards();
......@@ -245,7 +245,6 @@ private:
void addToRecentProjects(const QString &fileName, const QString &displayName);
void updateWelcomePage();
Internal::ProjectFileFactory *findProjectFileFactory(const QString &filename) const;
static ProjectExplorerPlugin *m_instance;
ProjectExplorerPluginPrivate *d;
......
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