Skip to content

Commit 6b231a1

Browse files
committedJan 7, 2013
Fix issue 6899: Drag and drop designer uses first field after project reload
idx was not properly initialized at project load.
1 parent 314d144 commit 6b231a1

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed
 

‎src/app/qgsfieldsproperties.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,7 @@ QgsAttributeEditorElement* QgsFieldsProperties::createAttributeEditorWidget( QTr
752752

753753
if ( item->data( 0, Qt::UserRole ) == "field" )
754754
{
755-
int idx = *mLayer->dataProvider()->fieldNameMap().find( item->text( 0 ) );
755+
int idx = *( mLayer->dataProvider()->fieldNameMap() ).find( item->text( 0 ) );
756756
widgetDef = new QgsAttributeEditorField( item->text( 0 ), idx, parent );
757757
}
758758
else

‎src/core/qgsvectorlayer.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3387,7 +3387,9 @@ QgsAttributeEditorElement* QgsVectorLayer::attributeEditorElementFromDomElement(
33873387
}
33883388
else if ( elem.tagName() == "attributeEditorField" )
33893389
{
3390-
newElement = new QgsAttributeEditorField( elem.attribute( "name" ), elem.attribute( "idx" ).toInt(), parent );
3390+
QString name = elem.attribute( "name" );
3391+
int idx = *( dataProvider()->fieldNameMap() ).find( name );
3392+
newElement = new QgsAttributeEditorField( name, idx, parent );
33913393
}
33923394

33933395
return newElement;

‎src/core/qgsvectorlayer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
389389
* @param elem the DOM element
390390
* @param parent the QObject which will own this object
391391
*/
392-
static QgsAttributeEditorElement* attributeEditorElementFromDomElement( QDomElement &elem, QObject* parent );
392+
QgsAttributeEditorElement* attributeEditorElementFromDomElement( QDomElement &elem, QObject* parent );
393393

394394
/** Read the symbology for the current layer from the Dom node supplied.
395395
* @param node node that will contain the symbology definition for this layer.

0 commit comments

Comments
 (0)