diff options
author | Marc Mutz <[email protected]> | 2025-04-03 17:22:28 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <[email protected]> | 2025-04-18 17:41:08 +0000 |
commit | 45e8c81c525cc86924537fe81c9ddfef79e2fee9 (patch) | |
tree | ca7fd2a05012c616d721df1d8a4217a457e02246 | |
parent | 61943ea3e7ad706b498377628427e652ca09072c (diff) |
QAbstractSlider: fix missing "emission" of SliderOrientationChange
QAbstractSlider::sliderChange() is not a signal, but a protected
function, carrying an enum (also protected) to inform subclasses about
changes in the base class.
A user reported (QTBUG-135597) that in 5.15 the function was not
called for SliderOrientationChange. A prior test addition confirmed
that this bug is in all active branches.
Add the missing call in setOrientation().
This _should_ replace the update() call, because the default
sliderChange() implementation already calls it (and setPageStep(),
e.g., relies on this behavior), but since SliderOrientationChange was
not emitted since Qt 5.0, I minimize regression risks and keep the
update() call, just in case a user wrote code where they forgot to
call Base::sliderChange() for SliderOrientationChange (and this never
showed because we never "emitted" that, up to now). The duplicate
update() calls will be merged by Qt's event loop, so are harmless.
A dev-only follow-up change will remove the update().
[ChangeLog][QtWidgets][QAbstractSlider] Fixed the missing "emission"
of protected sliderChange(SliderOrientationChange).
Amends the start of the public history.
Pick-to: 6.5 5.15
Fixes: QTBUG-135597
Change-Id: I4545d47d315a98a9a51134901a00fa369f720754
Reviewed-by: Axel Spoerl <[email protected]>
(cherry picked from commit c35f6851bfe8ba71c26d3896498c1510fcd4e42b)
Reviewed-by: Qt Cherry-pick Bot <[email protected]>
(cherry picked from commit 4b20e23ed7a7c32b6557e526bf88804c48ac8325)
-rw-r--r-- | src/widgets/widgets/qabstractslider.cpp | 1 | ||||
-rw-r--r-- | tests/auto/widgets/widgets/qabstractslider/tst_qabstractslider.cpp | 4 |
2 files changed, 1 insertions, 4 deletions
diff --git a/src/widgets/widgets/qabstractslider.cpp b/src/widgets/widgets/qabstractslider.cpp index 4e65fbac886..d2569c9934d 100644 --- a/src/widgets/widgets/qabstractslider.cpp +++ b/src/widgets/widgets/qabstractslider.cpp @@ -272,6 +272,7 @@ void QAbstractSlider::setOrientation(Qt::Orientation orientation) setSizePolicy(sizePolicy().transposed()); setAttribute(Qt::WA_WState_OwnSizePolicy, false); } + sliderChange(SliderOrientationChange); update(); updateGeometry(); } diff --git a/tests/auto/widgets/widgets/qabstractslider/tst_qabstractslider.cpp b/tests/auto/widgets/widgets/qabstractslider/tst_qabstractslider.cpp index 04b1114c3d7..d0ab97b0afe 100644 --- a/tests/auto/widgets/widgets/qabstractslider/tst_qabstractslider.cpp +++ b/tests/auto/widgets/widgets/qabstractslider/tst_qabstractslider.cpp @@ -2139,12 +2139,8 @@ void tst_QAbstractSlider::sliderChange_impl() sl.setOrientation(sl.orientation() == Qt::Horizontal ? Qt::Vertical /* else */ : Qt::Horizontal); - QEXPECT_FAIL("", "QTBUG-135597", Continue); QCOMPARE(sl.changes.size(), 1U); - if (!sl.changes.empty()) { - QEXPECT_FAIL("", "QTBUG-135597", Continue); QCOMPARE(sl.changes.back(), SliderChange::SliderOrientationChange); - } sl.changes.clear(); sl.setPageStep(1025); // unlikely to be the default ;) |