From 158aba25c9878c0790717f1c7e88f2a4f90c96ee Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Tue, 22 Sep 2020 14:41:38 +0200 Subject: Eliminate QDateTimeParser's mutable parameters at last I noticed that QDTP has a mutable member, text, which gets set at the end of each call to parse(); this makes all the in-out parameters redundant, since relevant methods can simply access - and modify - text, if it's set *at the start* of parse instaed. (There are no early returns to complicate matters.) This also makes StateNode::input redundant. At the same time, rename the mutable member, as several methods shadow it with parameter or local variable names; it is too generic. Change-Id: I2259cd87de5c84201b25c9633d11e59a4a4d57a1 Reviewed-by: Andrei Golubev Reviewed-by: Thiago Macieira --- src/widgets/widgets/qdatetimeedit.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/widgets/widgets/qdatetimeedit.cpp') diff --git a/src/widgets/widgets/qdatetimeedit.cpp b/src/widgets/widgets/qdatetimeedit.cpp index 5697c96791..e57d1f9db5 100644 --- a/src/widgets/widgets/qdatetimeedit.cpp +++ b/src/widgets/widgets/qdatetimeedit.cpp @@ -2037,13 +2037,14 @@ QDateTime QDateTimeEditPrivate::validateAndInterpret(QString &input, int &positi } StateNode tmp = parse(input, position, value.toDateTime(), fixup); + // Take note of any corrections imposed during parsing: + input = m_text; // Impose this widget's spec: tmp.value = tmp.value.toTimeSpec(spec); // ... but that might turn a valid datetime into an invalid one: if (!tmp.value.isValid() && tmp.state == Acceptable) tmp.state = Intermediate; - input = tmp.input; position += tmp.padded; state = QValidator::State(int(tmp.state)); if (state == QValidator::Acceptable) { -- cgit v1.2.3