Skip to content
Permalink
Browse files

validate attribute index in editor widget calls

(cherry picked from commit ecbe0e4)
  • Loading branch information
jef-n committed May 28, 2015
1 parent 8702138 commit 87adfbe8819be399ca3f11ba87a9090de6e7f185
Showing with 15 additions and 0 deletions.
  1. +15 −0 src/core/qgsvectorlayer.cpp
@@ -2115,6 +2115,9 @@ const QString QgsVectorLayer::editorWidgetV2( const QString& fieldName ) const

const QgsEditorWidgetConfig QgsVectorLayer::editorWidgetV2Config( int fieldIdx ) const
{
if ( fieldIdx < 0 || fieldIdx >= mUpdatedFields.count() )
return QgsEditorWidgetConfig();

return mEditorWidgetV2Configs.value( mUpdatedFields[fieldIdx].name() );
}

@@ -2613,13 +2616,19 @@ bool QgsVectorLayer::isModified() const

QgsVectorLayer::EditType QgsVectorLayer::editType( int idx )
{
if ( idx < 0 || idx >= mUpdatedFields.count() )
return Hidden;

Q_NOWARN_DEPRECATED_PUSH
return QgsLegacyHelpers::convertEditType( editorWidgetV2( idx ), editorWidgetV2Config( idx ), this, mUpdatedFields[ idx ].name() );
Q_NOWARN_DEPRECATED_POP
}

void QgsVectorLayer::setEditType( int idx, EditType type )
{
if ( idx < 0 || idx >= mUpdatedFields.count() )
return;

QgsEditorWidgetConfig cfg;

Q_NOWARN_DEPRECATED_PUSH
@@ -2642,11 +2651,17 @@ void QgsVectorLayer::setEditorLayout( EditorLayout editorLayout )

void QgsVectorLayer::setEditorWidgetV2( int attrIdx, const QString& widgetType )
{
if ( attrIdx < 0 || attrIdx >= mUpdatedFields.count() )
return;

mEditorWidgetV2Types[ mUpdatedFields[ attrIdx ].name()] = widgetType;
}

void QgsVectorLayer::setEditorWidgetV2Config( int attrIdx, const QgsEditorWidgetConfig& config )
{
if ( attrIdx < 0 || attrIdx >= mUpdatedFields.count() )
return;

mEditorWidgetV2Configs[ mUpdatedFields[ attrIdx ].name()] = config;
}

0 comments on commit 87adfbe

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