Skip to content

Commit 9883c7d

Browse files
committed
Always reread recent projects before saving new ones
Avoids loss of recent projects from menu if working in multiple QGIS sessions concurrently (cherry-picked from f45c19c)
1 parent 7738758 commit 9883c7d

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

src/app/qgisapp.cpp

+15-6
Original file line numberDiff line numberDiff line change
@@ -1426,14 +1426,9 @@ QgisAppStyleSheet* QgisApp::styleSheetBuilder()
14261426
return mStyleSheetBuilder;
14271427
}
14281428

1429-
// restore any application settings stored in QSettings
1430-
void QgisApp::readSettings()
1429+
void QgisApp::readRecentProjects()
14311430
{
14321431
QSettings settings;
1433-
QString themename = settings.value( "UI/UITheme", "default" ).toString();
1434-
setTheme( themename );
1435-
1436-
// Read legacy settings
14371432
mRecentProjects.clear();
14381433

14391434
settings.beginGroup( "/UI" );
@@ -1477,6 +1472,16 @@ void QgisApp::readSettings()
14771472
mRecentProjects.append( data );
14781473
}
14791474
settings.endGroup();
1475+
}
1476+
1477+
void QgisApp::readSettings()
1478+
{
1479+
QSettings settings;
1480+
QString themename = settings.value( "UI/UITheme", "default" ).toString();
1481+
setTheme( themename );
1482+
1483+
// Read legacy settings
1484+
readRecentProjects();
14801485

14811486
// this is a new session! reset enable macros value to "ask"
14821487
// whether set to "just for this session"
@@ -3258,6 +3263,10 @@ void QgisApp::updateRecentProjectPaths()
32583263
// add this file to the recently opened/saved projects list
32593264
void QgisApp::saveRecentProjectPath( const QString& projectPath, bool savePreviewImage )
32603265
{
3266+
// first, re-read the recent project paths. This prevents loss of recent
3267+
// projects when multiple QGIS sessions are open
3268+
readRecentProjects();
3269+
32613270
QSettings settings;
32623271

32633272
// Get canonical absolute path

src/app/qgisapp.h

+3
Original file line numberDiff line numberDiff line change
@@ -1472,6 +1472,9 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
14721472
/** Copy a vector style from a layer to another one, if they have the same geometry type */
14731473
void duplicateVectorStyle( QgsVectorLayer* srcLayer, QgsVectorLayer* destLayer );
14741474

1475+
//! Loads the list of recent projects from settings
1476+
void readRecentProjects();
1477+
14751478
QgisAppStyleSheet *mStyleSheetBuilder;
14761479

14771480
// actions for menus and toolbars -----------------

0 commit comments

Comments
 (0)