forked from qt-creator/qt-creator
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.
This commit is contained in:
@@ -1014,53 +1014,36 @@ QList<Project *> ProjectExplorerPlugin::openProjects(const QStringList &fileName
|
|||||||
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||||
QList<IProjectManager*> projectManagers = pm->getObjects<IProjectManager>();
|
QList<IProjectManager*> projectManagers = pm->getObjects<IProjectManager>();
|
||||||
|
|
||||||
//QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
|
|
||||||
// bool blocked = blockSignals(true);
|
|
||||||
QList<Project*> openedPro;
|
QList<Project*> openedPro;
|
||||||
foreach (const QString &fileName, fileNames) {
|
foreach (const QString &fileName, fileNames) {
|
||||||
if (const Core::MimeType mt = Core::ICore::instance()->mimeDatabase()->findByFile(QFileInfo(fileName))) {
|
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 (manager->mimeType() == mt.type()) {
|
||||||
if (Project *pro = manager->openProject(fileName))
|
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;
|
openedPro += pro;
|
||||||
|
} else {
|
||||||
|
delete pro;
|
||||||
|
}
|
||||||
|
}
|
||||||
d->m_session->reportProjectLoadingProgress();
|
d->m_session->reportProjectLoadingProgress();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//blockSignals(blocked);
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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();
|
updateActions();
|
||||||
|
|
||||||
|
if (openedPro.isEmpty()) {
|
||||||
|
qDebug() << "ProjectExplorerPlugin - Could not open any projects!";
|
||||||
|
} else {
|
||||||
Core::ModeManager::instance()->activateMode(Core::Constants::MODE_EDIT);
|
Core::ModeManager::instance()->activateMode(Core::Constants::MODE_EDIT);
|
||||||
QApplication::restoreOverrideCursor();
|
}
|
||||||
|
|
||||||
return openedPro;
|
return openedPro;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user