Bug report #11244

Invalid values on Date/Time widget editor

Added by Matthias Kuhn almost 6 years ago. Updated almost 2 years ago.

Status:Closed
Priority:Low
Assignee:Denis Rouzaud
Category:Edit widget
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

Description

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.

History

#1 Updated by Denis Rouzaud almost 6 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 almost 6 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.

#3 Updated by Giovanni Manghi over 3 years ago

  • Easy fix? set to No
  • Regression? set to No

#4 Updated by Denis Rouzaud almost 2 years ago

  • Description updated (diff)

Matthias, can this be closed?

#5 Updated by Giovanni Manghi almost 2 years ago

  • Status changed from Open to Feedback

#6 Updated by Matthias Kuhn almost 2 years ago

I don't remember fixing this (but my brain sometimes forgets things)
If it works now, it's probably fixed.

#7 Updated by Jürgen Fischer almost 2 years ago

  • Resolution set to worksforme
  • Status changed from Feedback to Closed

Also available in: Atom PDF