Sophie

Sophie

distrib > Mageia > cauldron > x86_64 > media > core-release-src > by-pkgid > 4c532bfb9916518564da5ba2805999f5 > files > 74

qtbase5-5.15.12-3.mga10.src.rpm

From 35d516f5c8818ccb13941b3c7fe5b770c5d23e61 Mon Sep 17 00:00:00 2001
From: Marco Martin <notmart@gmail.com>
Date: Tue, 17 Jan 2023 12:56:36 +0000
Subject: [PATCH 075/147] QToolButton: reimplement the fix for QTBUG-95255

The code in 188d739400e10fc8571bbf2ec86d5cd338b04a5d uses a connect() to
a lambda, passing UniqueConnection to avoid establishing the connection
more than once. The problem is that UniqueConnection does not work
with lambdas; it works only with "regular" PMFs to QObject subclasses.

Re-do the same fix, but without a connection: use the checkStateSet()
virtual from the base class that will notify us if setChecked() is
being called on the tool button, and from there synchronize the state
of the default action.

Change-Id: Id512812c562cd6d20bc1a489753b33c269919d32
Fixes: QTBUG-95255
Pick-to: 6.2 6.1
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(part cherry-picked from c9830c2fb902f26dc8b2df61dfadc2d7a7d2b30e)
---
 src/widgets/widgets/qtoolbutton.cpp | 10 +++++++++-
 src/widgets/widgets/qtoolbutton.h   |  1 +
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/widgets/widgets/qtoolbutton.cpp b/src/widgets/widgets/qtoolbutton.cpp
index e380cb647b..9953db73af 100644
--- a/src/widgets/widgets/qtoolbutton.cpp
+++ b/src/widgets/widgets/qtoolbutton.cpp
@@ -982,7 +982,15 @@ QAction *QToolButton::defaultAction() const
     return d->defaultAction;
 }
 
-
+/*!
+  \reimp
+ */
+void QToolButton::checkStateSet()
+{
+    Q_D(QToolButton);
+    if (d->defaultAction && d->defaultAction->isCheckable())
+        d->defaultAction->setChecked(isChecked());
+}
 
 /*!
   \reimp
diff --git a/src/widgets/widgets/qtoolbutton.h b/src/widgets/widgets/qtoolbutton.h
index 52bd2d5f7a..82b5d7924f 100644
--- a/src/widgets/widgets/qtoolbutton.h
+++ b/src/widgets/widgets/qtoolbutton.h
@@ -118,6 +118,7 @@ protected:
     void changeEvent(QEvent *) override;
 
     bool hitButton(const QPoint &pos) const override;
+    void checkStateSet() override;
     void nextCheckState() override;
     void initStyleOption(QStyleOptionToolButton *option) const;
 
-- 
2.40.1