Skip to content
Permalink
Browse files

QgsSettings: pass all keys through the sanitizer (and lower())

  • Loading branch information
elpaso committed Mar 4, 2017
1 parent d50930c commit f0d2f6dcf30df996c2c15a4a0d2c72619d7c78e7
Showing with 10 additions and 10 deletions.
  1. +10 −10 src/core/qgssettings.cpp
@@ -84,10 +84,10 @@ QgsSettings::~QgsSettings()

void QgsSettings::beginGroup( const QString &prefix )
{
mUserSettings->beginGroup( prefix.toLower() );
mUserSettings->beginGroup( sanitizeKey( prefix ) );
if ( mGlobalSettings )
{
mGlobalSettings->beginGroup( prefix.toLower() );
mGlobalSettings->beginGroup( sanitizeKey( prefix ) );
}
}

@@ -152,7 +152,7 @@ QStringList QgsSettings::childGroups() const

QVariant QgsSettings::value( const QString &key, const QVariant &defaultValue, const QgsSettings::Section section ) const
{
QString pKey = prefixedKey( key.toLower(), section );
QString pKey = prefixedKey( key, section );
if ( !mUserSettings->value( pKey ).isNull() )
{
return mUserSettings->value( pKey );
@@ -166,7 +166,7 @@ QVariant QgsSettings::value( const QString &key, const QVariant &defaultValue, c

bool QgsSettings::contains( const QString &key, const QgsSettings::Section section ) const
{
QString pKey = prefixedKey( key.toLower(), section );
QString pKey = prefixedKey( key, section );
return mUserSettings->contains( pKey ) ||
( mGlobalSettings && mGlobalSettings->contains( pKey ) );
}
@@ -183,7 +183,7 @@ void QgsSettings::sync()

void QgsSettings::remove( const QString &key )
{
mUserSettings->remove( key.toLower() );
mUserSettings->remove( sanitizeKey( key ) );
}

QString QgsSettings::prefixedKey( const QString &key, const Section section ) const
@@ -208,18 +208,18 @@ QString QgsSettings::prefixedKey( const QString &key, const Section section ) co
break;
case Section::NoSection:
default:
return sanitizeKey( key.toLower() );
return sanitizeKey( key );
}
return prefix + "/" + sanitizeKey( key.toLower() );
return prefix + "/" + sanitizeKey( key );
}


int QgsSettings::beginReadArray( const QString &prefix )
{
int size = mUserSettings->beginReadArray( prefix.toLower() );
int size = mUserSettings->beginReadArray( sanitizeKey( prefix ) );
if ( 0 == size && mGlobalSettings )
{
size = mGlobalSettings->beginReadArray( prefix.toLower() );
size = mGlobalSettings->beginReadArray( sanitizeKey( prefix ) );
mUsingGlobalArray = ( size > 0 );
}
return size;
@@ -250,7 +250,7 @@ void QgsSettings::setArrayIndex( int i )
void QgsSettings::setValue( const QString &key, const QVariant &value, const QgsSettings::Section section )
{
// TODO: add valueChanged signal
mUserSettings->setValue( prefixedKey( key.toLower(), section ), value );
mUserSettings->setValue( prefixedKey( key, section ), value );
}

// To lower case and clean the path

0 comments on commit f0d2f6d

Please sign in to comment.
You can’t perform that action at this time.