Bug report #11244
Invalid values on Date/Time widget editor
|Affected QGIS version:||2.4.0||Regression?:||No|
|Operating System:||Easy fix?:||No|
|Pull Request or Patch supplied:||No||Resolution:||worksforme|
|Crashes QGIS or corrupts data:||No||Copied to github as #:||19547|
When a DateTime editor widget is populated with an invalid value, a NULL value is returned instead (even if NULL values are turned off in the edit widget).
E.g. The data has a date "2014-00-19" (which is kind of meaningless) and will not be able to interpret this. Just shortly opening this form in the dual view will result in the field being set to NULL.
I am not 100% sure how to deal with this situation, but I think that it would be more appropriate to just leave the field value untouched if the user does not touch it. Having the widget wrapper return an invalid QVariant instead of a NULL QVariant should fix it this way.
#1 Updated by Denis Rouzaud over 5 years ago
The problem you raise occurs when widget is badly configured.
The only way I see to bypass this, would be to save the date in a private var, modify it when needed and return it for the value() method.
This bug is very likely to arise since the widget was badly configured in 2.4 (when importing older projects). Anyway, it's more likely that harm has been done and projects already fixed.
Not sure it is worth adding such trick in there.
What do you think?
#2 Updated by Matthias Kuhn over 5 years ago
- Priority changed from Normal to Low
I relaized that there are other widgets as well that don't behave fine.
In an optimal scenario, widgets would only change the data below them if touched. They are allowed to return an invalid QVariant to specify that. So they don't need to remember the original value but just need to remember if they have been changed.