QDateTimeEditPrivate:: only ask for fieldInfo() if section index is real

On construction, currentSectionIndex has the fake value
FirstSectionIndex, which upsets fieldInfo(), leading to a qWarning().
Make interpret(), when deciding whether to delegate to base or handle
the value itself, treat fake index value as an invalid state.

Task-number: QTBUG-54654
Change-Id: I6d0f71874839abfafcbfaaa0018362288f32a3cd
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
This commit is contained in:
Edward Welbourne 2016-07-08 14:41:49 +02:00
parent ebd1046323
commit bff683416c

View File

@ -2344,7 +2344,9 @@ void QDateTimeEditPrivate::interpret(EmitPolicy ep)
const QValidator::State state = q->validate(tmp, pos);
if (state != QValidator::Acceptable
&& correctionMode == QAbstractSpinBox::CorrectToPreviousValue
&& (state == QValidator::Invalid || !(fieldInfo(currentSectionIndex) & AllowPartial))) {
&& (state == QValidator::Invalid
|| currentSectionIndex < 0
|| !(fieldInfo(currentSectionIndex) & AllowPartial))) {
setValue(value, ep);
updateTimeSpec();
} else {