Skip to content
Permalink
Browse files

validate attribute index in editor widget calls

  • Loading branch information
jef-n committed May 28, 2015
1 parent d0bd9a2 commit ecbe0e43f45a9a68f5724f826319f34d02459f4c
Showing with 22 additions and 7 deletions.
  1. +1 −1 src/app/pluginmanager/qgspluginitemdelegate.cpp
  2. +21 −6 src/core/qgsvectorlayer.cpp
@@ -69,7 +69,7 @@ void QgsPluginItemDelegate::paint( QPainter *painter, const QStyleOptionViewItem
if ( !iconPixmap.isNull() )
{
int iconSize = pixelsHigh;
painter->drawPixmap( option.rect.left() + 1.2 * pixelsHigh , option.rect.top() + 0.2 * pixelsHigh, iconSize, iconSize, iconPixmap );
painter->drawPixmap( option.rect.left() + 1.2 * pixelsHigh, option.rect.top() + 0.2 * pixelsHigh, iconSize, iconSize, iconPixmap );
}

// Draw the text
@@ -2124,6 +2124,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() );
}

@@ -2182,7 +2185,7 @@ bool QgsVectorLayer::deleteAttributes( QList<int> attrs )

qSort( attrs.begin(), attrs.end(), qGreater<int>() );

Q_FOREACH ( int attr, attrs )
Q_FOREACH( int attr, attrs )
{
if ( deleteAttribute( attr ) )
{
@@ -2622,13 +2625,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
@@ -2651,11 +2660,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;
}

@@ -2940,7 +2955,7 @@ void QgsVectorLayer::uniqueValues( int index, QList<QVariant> &uniqueValues, int
if ( mEditBuffer )
{
QSet<QString> vals;
Q_FOREACH ( const QVariant& v, uniqueValues )
Q_FOREACH( const QVariant& v, uniqueValues )
{
vals << v.toString();
}
@@ -3748,7 +3763,7 @@ void QgsVectorLayer::invalidateSymbolCountedFlag()

void QgsVectorLayer::onRelationsLoaded()
{
Q_FOREACH ( QgsAttributeEditorElement* elem, mAttributeEditorElements )
Q_FOREACH( QgsAttributeEditorElement* elem, mAttributeEditorElements )
{
if ( elem->type() == QgsAttributeEditorElement::AeTypeContainer )
{
@@ -3757,7 +3772,7 @@ void QgsVectorLayer::onRelationsLoaded()
continue;

QList<QgsAttributeEditorElement*> relations = cont->findElements( QgsAttributeEditorElement::AeTypeRelation );
Q_FOREACH ( QgsAttributeEditorElement* relElem, relations )
Q_FOREACH( QgsAttributeEditorElement* relElem, relations )
{
QgsAttributeEditorRelation* rel = dynamic_cast< QgsAttributeEditorRelation* >( relElem );
if ( !rel )
@@ -3826,7 +3841,7 @@ QDomElement QgsAttributeEditorContainer::toDomElement( QDomDocument& doc ) const
QDomElement elem = doc.createElement( "attributeEditorContainer" );
elem.setAttribute( "name", mName );

Q_FOREACH ( QgsAttributeEditorElement* child, mChildren )
Q_FOREACH( QgsAttributeEditorElement* child, mChildren )
{
elem.appendChild( child->toDomElement( doc ) );
}
@@ -3842,7 +3857,7 @@ QList<QgsAttributeEditorElement*> QgsAttributeEditorContainer::findElements( Qgs
{
QList<QgsAttributeEditorElement*> results;

Q_FOREACH ( QgsAttributeEditorElement* elem, mChildren )
Q_FOREACH( QgsAttributeEditorElement* elem, mChildren )
{
if ( elem->type() == type )
{

0 comments on commit ecbe0e4

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