@@ -251,25 +251,25 @@ class CORE_EXPORT QgsSettings : public QObject
251
251
QByteArray ba = value ( key, metaEnum.valueToKey ( defaultValue ) ).toString ().toUtf8 ();
252
252
const char *vs = ba.data ();
253
253
v = static_cast <T>( metaEnum.keyToValue ( vs, &ok ) );
254
+ if ( ok )
255
+ return v;
254
256
}
255
- if ( !ok )
257
+
258
+ // if failed, try to read as int (old behavior)
259
+ // this code shall be removed later (probably after QGIS 3.4 LTR for 3.6)
260
+ // then the method could be marked as const
261
+ v = static_cast <T>( value ( key, static_cast <int >( defaultValue ), section ).toInt ( &ok ) );
262
+ if ( metaEnum.isValid () )
256
263
{
257
- // if failed, try to read as int (old behavior)
258
- // this code shall be removed later (probably after QGIS 3.4 LTR for 3.6)
259
- // then the method could be marked as const
260
- v = static_cast <T>( value ( key, static_cast <int >( defaultValue ), section ).toInt ( &ok ) );
261
- if ( metaEnum.isValid () )
264
+ if ( !ok || !metaEnum.valueToKey ( static_cast <int >( v ) ) )
262
265
{
263
- if ( !ok || !metaEnum.valueToKey ( static_cast <int >( v ) ) )
264
- {
265
- v = defaultValue;
266
- }
267
- else
268
- {
269
- // found setting as an integer
270
- // convert the setting to the new form (string)
271
- setEnumValue ( key, v, section );
272
- }
266
+ v = defaultValue;
267
+ }
268
+ else
269
+ {
270
+ // found setting as an integer
271
+ // convert the setting to the new form (string)
272
+ setEnumValue ( key, v, section );
273
273
}
274
274
}
275
275
0 commit comments