Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Aug 13, 2021
1 parent 34c9bd8 commit 35004f6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions src/core/settings/qgssettings.h
Expand Up @@ -266,7 +266,7 @@ class CORE_EXPORT QgsSettings : public QObject
if ( metaEnum.isValid() )
{
// read as string
QByteArray ba = value( key, metaEnum.valueToKey( static_cast<int>( defaultValue ) ), section ).toString().toUtf8();
QByteArray ba = value( key, metaEnum.valueToKey( static_cast<const int>( defaultValue ) ), section ).toString().toUtf8();
const char *vs = ba.data();
v = static_cast<T>( metaEnum.keyToValue( vs, &ok ) );
if ( ok )
Expand All @@ -276,7 +276,7 @@ class CORE_EXPORT QgsSettings : public QObject
// if failed, try to read as int (old behavior)
// this code shall be removed later (probably after QGIS 3.4 LTR for 3.6)
// then the method could be marked as const
v = static_cast<T>( value( key, static_cast<int>( defaultValue ), section ).toInt( &ok ) );
v = static_cast<T>( value( key, static_cast<const int>( defaultValue ), section ).toInt( &ok ) );
if ( metaEnum.isValid() )
{
if ( !ok || !metaEnum.valueToKey( static_cast<int>( v ) ) )
Expand Down Expand Up @@ -309,7 +309,7 @@ class CORE_EXPORT QgsSettings : public QObject
Q_ASSERT( metaEnum.isValid() );
if ( metaEnum.isValid() )
{
setValue( key, metaEnum.valueToKey( static_cast<int>( value ) ), section );
setValue( key, metaEnum.valueToKey( static_cast<const int>( value ) ), section );
}
else
{
Expand Down Expand Up @@ -344,14 +344,14 @@ class CORE_EXPORT QgsSettings : public QObject
if ( metaEnum.isValid() )
{
// read as string
QByteArray ba = value( key, metaEnum.valueToKeys( static_cast< int >( defaultValue ) ) ).toString().toUtf8();
QByteArray ba = value( key, metaEnum.valueToKeys( static_cast< const int >( defaultValue ) ) ).toString().toUtf8();
const char *vs = ba.data();
v = static_cast<T>( metaEnum.keysToValue( vs, &ok ) );
}
if ( !ok )
{
// if failed, try to read as int
const int intValue = value( key, static_cast<int>( defaultValue ), section ).toInt( &ok );
const int intValue = value( key, static_cast<const int>( defaultValue ), section ).toInt( &ok );
if ( metaEnum.isValid() )
{
if ( ok )
Expand Down Expand Up @@ -399,7 +399,7 @@ class CORE_EXPORT QgsSettings : public QObject
Q_ASSERT( metaEnum.isValid() );
if ( metaEnum.isValid() )
{
setValue( key, metaEnum.valueToKeys( static_cast< int >( value ) ), section );
setValue( key, metaEnum.valueToKeys( static_cast< const int >( value ) ), section );
}
else
{
Expand Down
4 changes: 2 additions & 2 deletions tests/src/core/testqgssettingsentry.cpp
Expand Up @@ -101,7 +101,7 @@ void TestQgsSettingsEntry::enumValue()
// Make sure the setting is not existing
QgsSettings().remove( settingsKey, QgsSettings::NoSection );

const QgsSettingsEntryDouble settingsEntryEnum( settingsKey, QgsSettings::NoSection, QgsUnitTypes::LayoutMeters, QStringLiteral( "Layout unit" ) );
const QgsSettingsEntryEnumFlag settingsEntryEnum( settingsKey, QgsSettings::NoSection, QgsUnitTypes::LayoutMeters, QStringLiteral( "Layout unit" ) );

// Check default value
QCOMPARE( settingsEntryEnum.defaultValue(), QgsUnitTypes::LayoutMeters );
Expand Down Expand Up @@ -150,7 +150,7 @@ void TestQgsSettingsEntry::flagValue()
// Make sure the setting is not existing
QgsSettings().remove( settingsKey, QgsSettings::NoSection );

const QgsSettingsEntryDouble settingsEntryFlag( settingsKey, QgsSettings::NoSection, pointAndLine, QStringLiteral( "Filters" ) );
const QgsSettingsEntryEnumFlag settingsEntryFlag( settingsKey, QgsSettings::NoSection, pointAndLine, QStringLiteral( "Filters" ) );

// Check default value
QCOMPARE( settingsEntryFlag.defaultValue(), pointAndLine );
Expand Down

0 comments on commit 35004f6

Please sign in to comment.