Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
validate attribute index in editor widget calls
(cherry picked from commit ecbe0e4)
  • Loading branch information
jef-n committed Jun 29, 2015
1 parent 8702138 commit 87adfbe
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/core/qgsvectorlayer.cpp
Expand Up @@ -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() );
}

Expand Down Expand Up @@ -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
Expand All @@ -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;
}

Expand Down

0 comments on commit 87adfbe

Please sign in to comment.