Core: Save session state on autoSave

If Creator crashes, session information (like open files, bookmarks
etc.) should be restored.

Task-number: QTCREATORBUG-16752
Change-Id: Ife1a2ffb62a3dd9b302e08ad9df9537667173e47
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
Orgad Shaneh
2016-10-10 14:51:55 +03:00
committed by Orgad Shaneh
parent 3517480557
commit eed064c7ed
3 changed files with 6 additions and 0 deletions

View File

@@ -1970,6 +1970,7 @@ void EditorManagerPrivate::autoSave()
if (!errors.isEmpty())
QMessageBox::critical(ICore::mainWindow(), tr("File Error"),
errors.join(QLatin1Char('\n')));
emit m_instance->autoSaved();
}
void EditorManagerPrivate::handleContextChange(const QList<IContext *> &context)

View File

@@ -185,6 +185,7 @@ signals:
void editorsClosed(QList<Core::IEditor *> editors);
void findOnFileSystemRequest(const QString &path);
void aboutToSave(IDocument *document);
void autoSaved();
public slots:
static void saveDocument();

View File

@@ -1061,6 +1061,10 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
connect(ICore::instance(), &ICore::saveSettingsRequested,
dd, &ProjectExplorerPluginPrivate::savePersistentSettings);
connect(EditorManager::instance(), &EditorManager::autoSaved, this, [this] {
if (!dd->m_shuttingDown && !SessionManager::loadingSession())
SessionManager::save();
});
addAutoReleasedObject(new ProjectTreeWidgetFactory);
addAutoReleasedObject(new FolderNavigationWidgetFactory);