@@ -2124,6 +2124,9 @@ const QString QgsVectorLayer::editorWidgetV2( const QString& fieldName ) const
2124
2124
2125
2125
const QgsEditorWidgetConfig QgsVectorLayer::editorWidgetV2Config ( int fieldIdx ) const
2126
2126
{
2127
+ if ( fieldIdx < 0 || fieldIdx >= mUpdatedFields .count () )
2128
+ return QgsEditorWidgetConfig ();
2129
+
2127
2130
return mEditorWidgetV2Configs .value ( mUpdatedFields [fieldIdx].name () );
2128
2131
}
2129
2132
@@ -2182,7 +2185,7 @@ bool QgsVectorLayer::deleteAttributes( QList<int> attrs )
2182
2185
2183
2186
qSort ( attrs.begin (), attrs.end (), qGreater<int >() );
2184
2187
2185
- Q_FOREACH ( int attr, attrs )
2188
+ Q_FOREACH ( int attr, attrs )
2186
2189
{
2187
2190
if ( deleteAttribute ( attr ) )
2188
2191
{
@@ -2622,13 +2625,19 @@ bool QgsVectorLayer::isModified() const
2622
2625
2623
2626
QgsVectorLayer::EditType QgsVectorLayer::editType ( int idx )
2624
2627
{
2628
+ if ( idx < 0 || idx >= mUpdatedFields .count () )
2629
+ return Hidden;
2630
+
2625
2631
Q_NOWARN_DEPRECATED_PUSH
2626
2632
return QgsLegacyHelpers::convertEditType ( editorWidgetV2 ( idx ), editorWidgetV2Config ( idx ), this , mUpdatedFields [ idx ].name () );
2627
2633
Q_NOWARN_DEPRECATED_POP
2628
2634
}
2629
2635
2630
2636
void QgsVectorLayer::setEditType ( int idx, EditType type )
2631
2637
{
2638
+ if ( idx < 0 || idx >= mUpdatedFields .count () )
2639
+ return ;
2640
+
2632
2641
QgsEditorWidgetConfig cfg;
2633
2642
2634
2643
Q_NOWARN_DEPRECATED_PUSH
@@ -2651,11 +2660,17 @@ void QgsVectorLayer::setEditorLayout( EditorLayout editorLayout )
2651
2660
2652
2661
void QgsVectorLayer::setEditorWidgetV2 ( int attrIdx, const QString& widgetType )
2653
2662
{
2663
+ if ( attrIdx < 0 || attrIdx >= mUpdatedFields .count () )
2664
+ return ;
2665
+
2654
2666
mEditorWidgetV2Types [ mUpdatedFields [ attrIdx ].name ()] = widgetType;
2655
2667
}
2656
2668
2657
2669
void QgsVectorLayer::setEditorWidgetV2Config ( int attrIdx, const QgsEditorWidgetConfig& config )
2658
2670
{
2671
+ if ( attrIdx < 0 || attrIdx >= mUpdatedFields .count () )
2672
+ return ;
2673
+
2659
2674
mEditorWidgetV2Configs [ mUpdatedFields [ attrIdx ].name ()] = config;
2660
2675
}
2661
2676
@@ -2940,7 +2955,7 @@ void QgsVectorLayer::uniqueValues( int index, QList<QVariant> &uniqueValues, int
2940
2955
if ( mEditBuffer )
2941
2956
{
2942
2957
QSet<QString> vals;
2943
- Q_FOREACH ( const QVariant& v, uniqueValues )
2958
+ Q_FOREACH ( const QVariant& v, uniqueValues )
2944
2959
{
2945
2960
vals << v.toString ();
2946
2961
}
@@ -3748,7 +3763,7 @@ void QgsVectorLayer::invalidateSymbolCountedFlag()
3748
3763
3749
3764
void QgsVectorLayer::onRelationsLoaded ()
3750
3765
{
3751
- Q_FOREACH ( QgsAttributeEditorElement* elem, mAttributeEditorElements )
3766
+ Q_FOREACH ( QgsAttributeEditorElement* elem, mAttributeEditorElements )
3752
3767
{
3753
3768
if ( elem->type () == QgsAttributeEditorElement::AeTypeContainer )
3754
3769
{
@@ -3757,7 +3772,7 @@ void QgsVectorLayer::onRelationsLoaded()
3757
3772
continue ;
3758
3773
3759
3774
QList<QgsAttributeEditorElement*> relations = cont->findElements ( QgsAttributeEditorElement::AeTypeRelation );
3760
- Q_FOREACH ( QgsAttributeEditorElement* relElem, relations )
3775
+ Q_FOREACH ( QgsAttributeEditorElement* relElem, relations )
3761
3776
{
3762
3777
QgsAttributeEditorRelation* rel = dynamic_cast < QgsAttributeEditorRelation* >( relElem );
3763
3778
if ( !rel )
@@ -3826,7 +3841,7 @@ QDomElement QgsAttributeEditorContainer::toDomElement( QDomDocument& doc ) const
3826
3841
QDomElement elem = doc.createElement ( " attributeEditorContainer" );
3827
3842
elem.setAttribute ( " name" , mName );
3828
3843
3829
- Q_FOREACH ( QgsAttributeEditorElement* child, mChildren )
3844
+ Q_FOREACH ( QgsAttributeEditorElement* child, mChildren )
3830
3845
{
3831
3846
elem.appendChild ( child->toDomElement ( doc ) );
3832
3847
}
@@ -3842,7 +3857,7 @@ QList<QgsAttributeEditorElement*> QgsAttributeEditorContainer::findElements( Qgs
3842
3857
{
3843
3858
QList<QgsAttributeEditorElement*> results;
3844
3859
3845
- Q_FOREACH ( QgsAttributeEditorElement* elem, mChildren )
3860
+ Q_FOREACH ( QgsAttributeEditorElement* elem, mChildren )
3846
3861
{
3847
3862
if ( elem->type () == type )
3848
3863
{
0 commit comments