From 9341f2e3d0a877b50ba851ff22b0d6ce192faf84 Mon Sep 17 00:00:00 2001 From: Wang Yu Date: Thu, 26 Nov 2020 16:22:10 +0800 Subject: [PATCH] Reduce the scope of variable in focusInEvent() The scope of the variable 'frm' can be reduced if the variable 'd->formatExplicitlySet' is true. So declare the variable when the variable 'd->formatExplicitlySet' is false. Change-Id: I27cea412af827d30ad9188106b7f14025e5ddb68 Reviewed-by: Volker Hilsheimer --- src/widgets/widgets/qdatetimeedit.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/widgets/widgets/qdatetimeedit.cpp b/src/widgets/widgets/qdatetimeedit.cpp index e57d1f9db5..ddab5ea762 100644 --- a/src/widgets/widgets/qdatetimeedit.cpp +++ b/src/widgets/widgets/qdatetimeedit.cpp @@ -1295,9 +1295,9 @@ void QDateTimeEdit::focusInEvent(QFocusEvent *event) { Q_D(QDateTimeEdit); QAbstractSpinBox::focusInEvent(event); - QString *frm = nullptr; const int oldPos = d->edit->cursorPosition(); if (!d->formatExplicitlySet) { + QString *frm = nullptr; if (d->displayFormat == d->defaultTimeFormat) { frm = &d->defaultTimeFormat; } else if (d->displayFormat == d->defaultDateFormat) {