[Qgis-developer] A different behavior in Qt5 beaks a lot of things.

Patrick Valsecchi patrick.valsecchi at camptocamp.com
Fri Oct 7 03:27:29 PDT 2016


hummm... in fact I start to think the problem is there from the start. I've
just made it more visible with my "better default widget" feature.
The operations to reproduce:

   - new project
   - add a postgis layer with integer attributes
   - open the attribute form and see that everything is OK
   - edit the layer properties
   - have a look at the fields
   - click OK (will make sure there are widgetv2config in the XML)
   - save the project somewhere
   - open the project
   - open the attribute form and see that all the integer fields are 0

OK, I'm working on a fix for the widgets that now appears by default.

On Fri, Oct 7, 2016 at 11:27 AM, Patrick Valsecchi <
patrick.valsecchi at camptocamp.com> wrote:

> Hi,
>
> I was investigating a new bug when editing a feature's attribute with the
> current master.
> For example, if you don't touch the configuration of a layer containing
> integer fields, save the project, exit, re-open the project, when you edit
> the attribute of this layer, all the integer fields are forced to 0.
>
> The problem must come from a different behavior with Qt5. Before, the
> field config for text was saved like that:
> <widgetv2config AllowNull="0" labelOnTop="0" fieldEditable="1"
> notNull="0"/>
>
> Now, it's saved like that:
> <widgetv2config Style="" Min="" AllowNull="0" labelOnTop="0"
> constraintDescription="" fieldEditable="1" notNull="0" Max="" Step=""
> constraint=""/>
>
> See? All the non-boolean fields that are not specified are now there with
> an empty value.
>
> My guess is that QDomElement::setAttribute was a no-op for QString::null
> and now it adds an attribute with an empty string. I don't know. But it's a
> mess now. Code in the QgsEditorWrapper will end up not using default values
> when they do stuff like:
> const QString displayFormat = config( "display_format",
> QgsDateTimeEditConfig::defaultFormat( field().type() ) ).toString();
>
> The config entry being always there, but empty when not specified, the
> default will never be taken. It's then same for range widget's min and max
> values then ends up being 0 (my original bug).
>
> And I'm afraid the edit widgets are not the only ones suffering from those
> problems.
>
> Am I the only one seeing that? What do we do, now?
>
> Thanks
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20161007/67e079a6/attachment.html>


More information about the Qgis-developer mailing list