From a8068fc969178cc7c7a2930cb37e8bb618861423 Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Tue, 14 May 2024 12:57:23 +0300 Subject: [PATCH] remove redundant check in QPushButton::sizeHint() QPushButton::setAutoDefault() invalidates the cached size hint Signed-off-by: Ivailo Monev --- src/gui/widgets/qpushbutton.cpp | 6 +++--- src/gui/widgets/qpushbutton_p.h | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/gui/widgets/qpushbutton.cpp b/src/gui/widgets/qpushbutton.cpp index 851b16c2a..5620f878d 100644 --- a/src/gui/widgets/qpushbutton.cpp +++ b/src/gui/widgets/qpushbutton.cpp @@ -330,7 +330,7 @@ bool QPushButton::autoDefault() const { Q_D(const QPushButton); if(d->autoDefault == QPushButtonPrivate::Auto) - return ( d->dialogParent() != 0 ); + return (d->dialogParent() != 0); return bool(d->autoDefault); } @@ -359,9 +359,9 @@ bool QPushButton::isDefault() const QSize QPushButton::sizeHint() const { Q_D(const QPushButton); - if (d->sizeHint.isValid() && d->lastAutoDefault == autoDefault()) + if (d->sizeHint.isValid()) { return d->sizeHint; - d->lastAutoDefault = autoDefault(); + } ensurePolished(); int w = 0, h = 0; diff --git a/src/gui/widgets/qpushbutton_p.h b/src/gui/widgets/qpushbutton_p.h index 3ce54c4fb..274a3cdb4 100644 --- a/src/gui/widgets/qpushbutton_p.h +++ b/src/gui/widgets/qpushbutton_p.h @@ -48,7 +48,9 @@ public: QPushButtonPrivate() : QAbstractButtonPrivate(QSizePolicy::PushButton), autoDefault(Auto), - defaultButton(false), flat(false), menuOpen(false), lastAutoDefault(false) {} + defaultButton(false), flat(false), menuOpen(false) + { + } inline void init() { resetLayoutItemMargins(); } static QPushButtonPrivate* get(QPushButton *b) { return b->d_func(); } @@ -64,7 +66,6 @@ public: bool defaultButton; bool flat; bool menuOpen; - mutable bool lastAutoDefault; }; QT_END_NAMESPACE