Always reread recent projects before saving new ones

Avoids loss of recent projects from menu if working in multiple
QGIS sessions concurrently
This commit is contained in:
Nyall Dawson 2017-02-23 11:34:13 +10:00
parent 5bbdb1f1c3
commit f45c19cfab
2 changed files with 18 additions and 6 deletions

View File

@ -1536,14 +1536,9 @@ QgisAppStyleSheet* QgisApp::styleSheetBuilder()
return mStyleSheetBuilder; return mStyleSheetBuilder;
} }
// restore any application settings stored in QSettings void QgisApp::readRecentProjects()
void QgisApp::readSettings()
{ {
QSettings settings; QSettings settings;
QString themename = settings.value( QStringLiteral( "UI/UITheme" ), "default" ).toString();
setTheme( themename );
// Read legacy settings
mRecentProjects.clear(); mRecentProjects.clear();
settings.beginGroup( QStringLiteral( "/UI" ) ); settings.beginGroup( QStringLiteral( "/UI" ) );
@ -1587,6 +1582,16 @@ void QgisApp::readSettings()
mRecentProjects.append( data ); mRecentProjects.append( data );
} }
settings.endGroup(); settings.endGroup();
}
void QgisApp::readSettings()
{
QSettings settings;
QString themename = settings.value( QStringLiteral( "UI/UITheme" ), "default" ).toString();
setTheme( themename );
// Read legacy settings
readRecentProjects();
// this is a new session! reset enable macros value to "ask" // this is a new session! reset enable macros value to "ask"
// whether set to "just for this session" // whether set to "just for this session"
@ -3354,6 +3359,10 @@ void QgisApp::updateRecentProjectPaths()
// add this file to the recently opened/saved projects list // add this file to the recently opened/saved projects list
void QgisApp::saveRecentProjectPath( const QString& projectPath, bool savePreviewImage ) void QgisApp::saveRecentProjectPath( const QString& projectPath, bool savePreviewImage )
{ {
// first, re-read the recent project paths. This prevents loss of recent
// projects when multiple QGIS sessions are open
readRecentProjects();
QSettings settings; QSettings settings;
// Get canonical absolute path // Get canonical absolute path

View File

@ -1534,6 +1534,9 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
//! Copy a vector style from a layer to another one, if they have the same geometry type //! Copy a vector style from a layer to another one, if they have the same geometry type
void duplicateVectorStyle( QgsVectorLayer* srcLayer, QgsVectorLayer* destLayer ); void duplicateVectorStyle( QgsVectorLayer* srcLayer, QgsVectorLayer* destLayer );
//! Loads the list of recent projects from settings
void readRecentProjects();
QgisAppStyleSheet *mStyleSheetBuilder = nullptr; QgisAppStyleSheet *mStyleSheetBuilder = nullptr;
// actions for menus and toolbars ----------------- // actions for menus and toolbars -----------------