Skip to content

Commit

Permalink
Always reread recent projects before saving new ones
Browse files Browse the repository at this point in the history
Avoids loss of recent projects from menu if working in multiple
QGIS sessions concurrently

(cherry-picked from f45c19c)
  • Loading branch information
nyalldawson committed Mar 4, 2017
1 parent 7738758 commit 9883c7d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
21 changes: 15 additions & 6 deletions src/app/qgisapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1426,14 +1426,9 @@ QgisAppStyleSheet* QgisApp::styleSheetBuilder()
return mStyleSheetBuilder;
}

// restore any application settings stored in QSettings
void QgisApp::readSettings()
void QgisApp::readRecentProjects()
{
QSettings settings;
QString themename = settings.value( "UI/UITheme", "default" ).toString();
setTheme( themename );

// Read legacy settings
mRecentProjects.clear();

settings.beginGroup( "/UI" );
Expand Down Expand Up @@ -1477,6 +1472,16 @@ void QgisApp::readSettings()
mRecentProjects.append( data );
}
settings.endGroup();
}

void QgisApp::readSettings()
{
QSettings settings;
QString themename = settings.value( "UI/UITheme", "default" ).toString();
setTheme( themename );

// Read legacy settings
readRecentProjects();

// this is a new session! reset enable macros value to "ask"
// whether set to "just for this session"
Expand Down Expand Up @@ -3258,6 +3263,10 @@ void QgisApp::updateRecentProjectPaths()
// add this file to the recently opened/saved projects list
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;

// Get canonical absolute path
Expand Down
3 changes: 3 additions & 0 deletions src/app/qgisapp.h
Original file line number Diff line number Diff line change
Expand Up @@ -1472,6 +1472,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 */
void duplicateVectorStyle( QgsVectorLayer* srcLayer, QgsVectorLayer* destLayer );

//! Loads the list of recent projects from settings
void readRecentProjects();

QgisAppStyleSheet *mStyleSheetBuilder;

// actions for menus and toolbars -----------------
Expand Down

0 comments on commit 9883c7d

Please sign in to comment.