Commit 4ad02938 authored by dt's avatar dt
Browse files

Fix crash on session restore

Do the project restore for each project directly after opening and only
then processEvents(). A project might be in a intermediate state between
opening and restoring.
parent b6ee94fb
......@@ -1014,54 +1014,37 @@ QList<Project *> ProjectExplorerPlugin::openProjects(const QStringList &fileName
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
QList<IProjectManager*> projectManagers = pm->getObjects<IProjectManager>();
//QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
// bool blocked = blockSignals(true);
QList<Project*> openedPro;
foreach (const QString &fileName, fileNames) {
if (const Core::MimeType mt = Core::ICore::instance()->mimeDatabase()->findByFile(QFileInfo(fileName))) {
foreach (IProjectManager *manager, projectManagers)
foreach (IProjectManager *manager, projectManagers) {
if (manager->mimeType() == mt.type()) {
if (Project *pro = manager->openProject(fileName))
openedPro += pro;
if (Project *pro = manager->openProject(fileName)) {
if (pro->restoreSettings()) {
connect(pro, SIGNAL(fileListChanged()), this, SIGNAL(fileListChanged()));
d->m_session->addProject(pro);
// Make sure we always have a current project / node
if (!d->m_currentProject && !openedPro.isEmpty())
setCurrentNode(pro->rootProjectNode());
openedPro += pro;
} else {
delete pro;
}
}
d->m_session->reportProjectLoadingProgress();
break;
}
}
}
}
//blockSignals(blocked);
updateActions();
if (openedPro.isEmpty()) {
if (debug)
qDebug() << "ProjectExplorerPlugin - Could not open any projects!";
QApplication::restoreOverrideCursor();
return QList<Project *>();
}
QList<Project *>::iterator it, end;
end = openedPro.end();
for (it = openedPro.begin(); it != end; ) {
if (debug)
qDebug()<<"restoring settings for "<<(*it)->file()->fileName();
if ((*it)->restoreSettings()) {
connect(*it, SIGNAL(fileListChanged()), this, SIGNAL(fileListChanged()));
++it;
} else {
delete *it;
it = openedPro.erase(it);
}
qDebug() << "ProjectExplorerPlugin - Could not open any projects!";
} else {
Core::ModeManager::instance()->activateMode(Core::Constants::MODE_EDIT);
}
d->m_session->addProjects(openedPro);
// Make sure we always have a current project / node
if (!d->m_currentProject && !openedPro.isEmpty())
setCurrentNode(openedPro.first()->rootProjectNode());
updateActions();
Core::ModeManager::instance()->activateMode(Core::Constants::MODE_EDIT);
QApplication::restoreOverrideCursor();
return openedPro;
}
......
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