<div dir="ltr"><div>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.<br></div>The operations to reproduce:<br><ul><li>new project</li><li>add a postgis layer with integer attributes</li><li>open the attribute form and see that everything is OK<br></li><li>edit the layer properties</li><li>have a look at the fields</li><li>click OK (will make sure there are w<font size="1"><span style="font-family:monospace,monospace">idgetv2config </span></font>in the XML)</li><li>save the project somewhere</li><li>open the project<br></li><li>open the attribute form and see that all the integer fields are 0<br></li></ul><p>OK, I'm working on a fix for the widgets that now appears by default.<br></p></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Oct 7, 2016 at 11:27 AM, Patrick Valsecchi <span dir="ltr"><<a href="mailto:patrick.valsecchi@camptocamp.com" target="_blank">patrick.valsecchi@camptocamp.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div><div><div>Hi,<br><br></div>I was investigating a new bug when editing a feature's attribute with the current master.<br></div>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.<br><br></div>The problem must come from a different behavior with Qt5. Before, the field config for text was saved like that:<br><font size="1"><span style="font-family:monospace,monospace"><widgetv2config AllowNull="0" labelOnTop="0" fieldEditable="1" notNull="0"/></span></font><br><br></div>Now, it's saved like that:<br><font size="1"><span style="font-family:monospace,monospace"><widgetv2config Style="" Min="" AllowNull="0" labelOnTop="0" 
constraintDescription="" fieldEditable="1" notNull="0" Max="" Step="" 
constraint=""/></span></font><br><br></div>See? All the non-boolean fields that are not specified are now there with an empty value.<br><br>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:<br><div><div><font size="1"><span style="font-family:monospace,monospace">const QString displayFormat = config( "display_format", QgsDateTimeEditConfig::<wbr>defaultFormat( field().type() ) ).toString();</span></font><br><br></div><div>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).<br><br></div><div>And I'm afraid the edit widgets are not the only ones suffering from those problems.<br><br></div><div>Am I the only one seeing that? What do we do, now?<br><br></div><div>Thanks<br></div></div></div>
</blockquote></div><br></div>