Bug report #13960

Edit widget configuration is stored twice

Added by Médéric RIBREUX over 8 years ago. Updated about 8 years ago.

Status:Closed
Priority:Normal
Assignee:Matthias Kuhn
Category:Edit widget
Affected QGIS version:master Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:
Crashes QGIS or corrupts data:No Copied to github as #:21975

Description

Hello,

since at least QGIS 2.4 (and probably in earlier versions), the XML configuration of the edit widgets is stored twice in the project file (.qgs).
Edit widget configuration is stored under <edittypes> tag. There are two <edittypes> tags in the project file:

  • the first is at the beginning of the layer definition (<maplayer> tag), after the <map-layer-style-manager> tag:
    <maplayer minimumScale="-4.65661e-10" maximumScale="1e+08" simplifyDrawingHints="0" minLabelScale="0" maxLabelScale="1e+08" simplifyDrawingTol="1" geometry="Point" simplifyMaxScale="1" type="vector" hasScaleBasedVisibilityFlag="0" simplifyLocal="1" scaleBasedLabelVisibilityFlag="0">
          <id>TEST_PATHS20151208112226506</id>
          <datasource>./DATA/TEST_PATHS.shp</datasource>
          <title></title>
          <abstract></abstract>
          <keywordList>
            <value></value>
          </keywordList>
          <layername>TEST_PATHS</layername>
          <srs>
            <spatialrefsys>
              <proj4>+proj=lcc +lat_1=46.8 +lat_0=46.8 +lon_0=0 +k_0=0.99987742 +x_0=600000 +y_0=200000 +a=6378249.2 +b=6356515 +towgs84=-168,-60,320,0,0,0,0 +pm=paris +units=m +no_defs</proj4>
              <srsid>2422</srsid>
              <srid>27562</srid>
              <authid>EPSG:27562</authid>
              <description>NTF (Paris) / Lambert Centre France</description>
              <projectionacronym>lcc</projectionacronym>
              <ellipsoidacronym></ellipsoidacronym>
              <geographicflag>false</geographicflag>
            </spatialrefsys>
          </srs>
          <provider encoding="System">ogr</provider>
          <previewExpression>COALESCE( "id", '&lt;NULL>' )</previewExpression>
          <vectorjoins/>
          <expressionfields/>
          <map-layer-style-manager current="">
            <map-layer-style name=""/>
          </map-layer-style-manager>
          <edittypes>
            <edittype widgetv2type="TextEdit" name="id">
              <widgetv2config IsMultiline="0" fieldEditable="1" UseHtml="0" labelOnTop="0"/>
            </edittype>
            <edittype widgetv2type="FileName" name="PATH">
              <widgetv2config fieldEditable="1" labelOnTop="0"/>
            </edittype>
          </edittypes>
    
  • the second tag is at the end of the maplayer tag after the <conditionalstyles> tag:
    </editforminitcode>
          <featformsuppress>0</featformsuppress>
          <annotationform></annotationform>
          <editorlayout>generatedlayout</editorlayout>
          <excludeAttributesWMS/>
          <excludeAttributesWFS/>
          <attributeactions/>
          <conditionalstyles>
            <rowstyles/>
            <fieldstyles/>
          </conditionalstyles>
          <edittypes>
            <edittype widgetv2type="TextEdit" name="id">
              <widgetv2config IsMultiline="0" fieldEditable="1" UseHtml="0" labelOnTop="0"/>
            </edittype>
            <edittype widgetv2type="FileName" name="PATH">
              <widgetv2config fieldEditable="1" labelOnTop="0"/>
            </edittype>
          </edittypes>
        </maplayer>
    

For layers with a lot of attributes this can be problematic for the size of the project file.

It seems that QgsEditorWidgetRegistry::writeMapLayer is called twice (I haven't made any test, just read the code)...

Associated revisions

Revision 9f87f4d0
Added by Jürgen Fischer about 8 years ago

editor widgets: avoid duplicate saving of edit types (fixes #13960)

TODO: resolve duplicate read via QgsProject::readMapLayer and
QgsVectorLayer::readCustomSymbology signals

History

#1 Updated by Jürgen Fischer about 8 years ago

  • Status changed from Open to Closed

Also available in: Atom PDF