From 314eca9934c9ac4617dacf920c19b51e730d97e6 Mon Sep 17 00:00:00 2001 From: "Juergen E. Fischer" Date: Thu, 21 Jun 2018 17:02:37 +0200 Subject: [PATCH] fix warnings --- src/core/qgscoordinatereferencesystem.cpp | 3 ++- src/core/qgssettings.h | 32 +++++++++++------------ 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/src/core/qgscoordinatereferencesystem.cpp b/src/core/qgscoordinatereferencesystem.cpp index 1def3c165fd..5684615ac54 100644 --- a/src/core/qgscoordinatereferencesystem.cpp +++ b/src/core/qgscoordinatereferencesystem.cpp @@ -1931,7 +1931,7 @@ int QgsCoordinateReferenceSystem::syncDatabase() QString srsProj4; QString srsDesc; - bool srsDeprecated; + bool srsDeprecated = deprecated; if ( statement.step() == SQLITE_ROW ) { srsProj4 = statement.columnAsText( 0 ); @@ -2133,6 +2133,7 @@ int QgsCoordinateReferenceSystem::syncDatabase() return -1; } + Q_UNUSED( deleted ); QgsDebugMsgLevel( QStringLiteral( "CRS update (inserted:%1 updated:%2 deleted:%3 errors:%4)" ).arg( QString::number( inserted ), QString::number( updated ), QString::number( deleted ), QString::number( errors ) ), 4 ); if ( errors > 0 ) diff --git a/src/core/qgssettings.h b/src/core/qgssettings.h index 9b0f21dfeae..5a0a319ff5d 100644 --- a/src/core/qgssettings.h +++ b/src/core/qgssettings.h @@ -251,25 +251,25 @@ class CORE_EXPORT QgsSettings : public QObject QByteArray ba = value( key, metaEnum.valueToKey( defaultValue ) ).toString().toUtf8(); const char *vs = ba.data(); v = static_cast( metaEnum.keyToValue( vs, &ok ) ); + if ( ok ) + return v; } - if ( !ok ) + + // 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( value( key, static_cast( defaultValue ), section ).toInt( &ok ) ); + if ( metaEnum.isValid() ) { - // 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( value( key, static_cast( defaultValue ), section ).toInt( &ok ) ); - if ( metaEnum.isValid() ) + if ( !ok || !metaEnum.valueToKey( static_cast( v ) ) ) { - if ( !ok || !metaEnum.valueToKey( static_cast( v ) ) ) - { - v = defaultValue; - } - else - { - // found setting as an integer - // convert the setting to the new form (string) - setEnumValue( key, v, section ); - } + v = defaultValue; + } + else + { + // found setting as an integer + // convert the setting to the new form (string) + setEnumValue( key, v, section ); } }