@@ -107,7 +107,7 @@ const QgsSettingsEntryBool *QgsSettingsRegistryCore::settingsLayerTreeShowFeatur
107
107
108
108
const QgsSettingsEntryBool *QgsSettingsRegistryCore::settingsEnableWMSTilePrefetching = new QgsSettingsEntryBool( QStringLiteral( " enable_wms_tile_prefetch" ), QgsSettingsTree::sTreeWms , false , QStringLiteral( " Whether to include WMS layers when rendering tiles adjacent to the visible map area" ) );
109
109
110
- const QgsSettingsEntryStringList *QgsSettingsRegistryCore::settingsMapScales = new QgsSettingsEntryStringList( QStringLiteral( " scales " ), QgsSettingsTree::sTreeMap , Qgis::defaultProjectScales().split( ' ,' ) );
110
+ const QgsSettingsEntryStringList *QgsSettingsRegistryCore::settingsMapScales = new QgsSettingsEntryStringList( QStringLiteral( " default_scales " ), QgsSettingsTree::sTreeMap , Qgis::defaultProjectScales().split( ' ,' ) );
111
111
112
112
113
113
QgsSettingsRegistryCore::QgsSettingsRegistryCore ()
@@ -150,10 +150,41 @@ void QgsSettingsRegistryCore::migrateOldSettings()
150
150
pal::Pal::settingsRenderingLabelCandidatesLimitLines->copyValueFromKey ( QStringLiteral ( " core/rendering/label_candidates_limit_lines" ), true );
151
151
pal::Pal::settingsRenderingLabelCandidatesLimitPolygons->copyValueFromKey ( QStringLiteral ( " core/rendering/label_candidates_limit_polygons" ), true );
152
152
153
+ // handle bad migration - Fix profiles for old QGIS versions (restore the Map/scales key on windows)
154
+ // TODO: Remove this from QGIS 3.36
155
+ // PR Link: https://github.com/qgis/QGIS/pull/52580
156
+ if ( QgsSettings ().contains ( QStringLiteral ( " Map/scales" ) ) )
157
+ {
158
+ const QStringList oldScales = QgsSettings ().value ( QStringLiteral ( " Map/scales" ) ).toStringList ();
159
+ if ( ! oldScales.isEmpty () && !oldScales.at ( 0 ).isEmpty () )
160
+ QgsSettings ().setValue ( QStringLiteral ( " Map/scales" ), oldScales.join ( ' ,' ) );
161
+ else
162
+ QgsSettings ().setValue ( QStringLiteral ( " Map/scales" ), Qgis::defaultProjectScales () );
163
+ }
164
+
153
165
// migrate only one way for map scales
154
166
if ( !settingsMapScales->exists () )
155
- settingsMapScales->setValue ( QgsSettings ().value ( QStringLiteral ( " Map/scales" ) ).toString ().split ( ' ,' ) );
156
-
167
+ {
168
+ // Handle bad migration. Prefer map/scales over Map/scales
169
+ // TODO: Discard this part starting from QGIS 3.36
170
+ const QStringList oldScales = QgsSettings ().value ( QStringLiteral ( " map/scales" ) ).toStringList ();
171
+ if ( ! oldScales.isEmpty () && !oldScales.at ( 0 ).isEmpty () )
172
+ {
173
+ // If migration has failed before (QGIS < 3.30.2), all scales might be
174
+ // concatenated in the first element of the list
175
+ QStringList actualScales;
176
+ for ( const QString &element : oldScales )
177
+ {
178
+ actualScales << element.split ( " ," );
179
+ }
180
+ settingsMapScales->setValue ( actualScales );
181
+ }
182
+ // TODO: keep only this part of the migration starting from QGIS 3.36
183
+ else if ( QgsSettings ().contains ( QStringLiteral ( " Map/scales" ) ) )
184
+ {
185
+ settingsMapScales->setValue ( QgsSettings ().value ( QStringLiteral ( " Map/scales" ) ).toString ().split ( ' ,' ) );
186
+ }
187
+ }
157
188
158
189
// digitizing settings - added in 3.30
159
190
{
0 commit comments