Hi devs ***In short: The sortOrder value in QgsProject section:
<attributetableconfig sortOrder="<some value>"> can be any value for some reason (e.g. flexibility for the future) or it is a bug? I would ask to especially to Nyall that git blames is the author of this section: https://github.com/qgis/QGIS/blob/master/src/core/qgsattributetableconfig.cpp#L200 ***Details: during hackmeeting I also worked on: https://issues.qgis.org/issues/15803 in the team we had problem replicating the issue on QGIS 3.x so we discovered that the origin of the problem is in QgsAttributeTableConfig saved in Layer style section of the qgis project. here an example of a project I had with wrong values <attributetableconfig actionWidgetStyle="dropDown" sortExpression="" sortOrder="158"> <columns> <column width="-1" hidden="0" type="field" name="Cell"/> <column width="-1" hidden="0" type="field" name="Time"/> <column width="-1" hidden="0" type="field" name="Value"/> <column width="-1" hidden="1" type="actions"/> </columns> </attributetableconfig> the value is casted to Qt:SortOrder enum with: https://github.com/qgis/QGIS/blob/master/src/core/qgsattributetableconfig.cpp#L200 that is undefined in case sortOrder value does not belong to the enum range, but in the implementation the value is leaved to 158 (as in the example) This generate some side effects in the attribute table => the sortOnTop button does not work because of: https://github.com/qgis/QGIS/blob/master/src/gui/attributetable/qgsattributetablefiltermodel.cpp#L53 and https://github.com/qgis/QGIS/blob/master/src/gui/attributetable/qgsattributetablefiltermodel.cpp#L57 that obviously returns always false The actual patch in: 2.18 - https://github.com/qgis/QGIS/pull/4306 3.x - https://github.com/qgis/QGIS/pull/4444 protect the attribute table from having wrong sortOrder values, but does not try to fix it's value in AttributeTable config that can be a value set for some reason by the user or other components. ***Workaroud a simple workaround is apply a column sort and save the project to fix the wrong value Luigi Pirelli ************************************************************************************************** * Boundless QGIS Support/Development: lpirelli AT boundlessgeo DOT com * LinkedIn: https://www.linkedin.com/in/luigipirelli * Stackexchange: http://gis.stackexchange.com/users/19667/luigi-pirelli * GitHub: https://github.com/luipir * Mastering QGIS 2nd Edition: * https://www.packtpub.com/big-data-and-business-intelligence/mastering-qgis-second-edition ************************************************************************************************** _______________________________________________ QGIS-Developer mailing list QGIS-Developer@lists.osgeo.org List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer