From 9211d04730da7495fd2584e6768b73c3f86aba00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Thu, 25 Mar 2021 13:58:00 +0100 Subject: [PATCH 1/4] QSemaphore: move suspect increment of waiter count We might return false a few lines down, without decreasing the count. Change-Id: I0a90c07f279860987e41539e9d5f3b5d2cb15207 Reviewed-by: Thiago Macieira --- src/corelib/thread/qsemaphore.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/corelib/thread/qsemaphore.cpp b/src/corelib/thread/qsemaphore.cpp index ee4cee5281..5111d80ac6 100644 --- a/src/corelib/thread/qsemaphore.cpp +++ b/src/corelib/thread/qsemaphore.cpp @@ -246,13 +246,13 @@ template bool futexSemaphoreTryAcquire(QBasicAtomicInteger> 32) == 0x7fffffff) return false; // overflow! + + // increase the waiter count + u.fetchAndAddRelaxed(oneWaiter); curValue += oneWaiter; // Also adjust nn to subtract oneWaiter when we succeed in acquiring. From 37f9f2e7afb2539ead355f1115e10835c2df9f92 Mon Sep 17 00:00:00 2001 From: Doris Verria Date: Tue, 30 Mar 2021 10:58:17 +0200 Subject: [PATCH 2/4] Fix label margins for pulldowns with custom styled menu indicator on macOS Don't apply the QMacStyle's pulldownButton titlemargins to the QPushButton's contents rect if the button has a custom styled menu indicator. This causes the button's text/icon to be misaligned. Fixes: QTBUG-86134 Pick-to: 5.15 6.0 6.1 Change-Id: I6ef95d51071c1d79f1cc07425a46958f50091b7e Reviewed-by: Volker Hilsheimer Reviewed-by: Richard Moe Gustavsen --- src/widgets/styles/qstylesheetstyle.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index 6efba358c0..b9c0aaa199 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -5855,6 +5855,13 @@ QRect QStyleSheetStyle::subElementRect(SubElement se, const QStyleOption *opt, c case SE_PushButtonBevel: case SE_PushButtonFocusRect: if (const QStyleOptionButton *btn = qstyleoption_cast(opt)) { + if (btn->features & QStyleOptionButton::HasMenu + && hasStyleRule(w, PseudoElement_PushButtonMenuIndicator)) { + QStyleOptionButton btnOpt(*btn); + btnOpt.features &= ~QStyleOptionButton::HasMenu; + return rule.baseStyleCanDraw() ? baseStyle()->subElementRect(se, &btnOpt, w) + : QWindowsStyle::subElementRect(se, &btnOpt, w); + } if (rule.hasBox() || !rule.hasNativeBorder()) { return visualRect(opt->direction, opt->rect, se == SE_PushButtonBevel ? rule.borderRect(opt->rect) From 0eb0fc87014b8de06473055bd2298b2423d480f6 Mon Sep 17 00:00:00 2001 From: Doris Verria Date: Tue, 30 Mar 2021 14:03:43 +0200 Subject: [PATCH 3/4] Fix incorrectly-drawn menu indicator for QPushButton on macOS Because the QPushButton's bevel rect is smaller than its actual widget's rect, custom styled menu indicators are drawn outside the bevel frame on macOS. Fix this by drawing the menu indicator inside the bevel's rect instead of the widget's rect. Fixes: QTBUG-90250 Pick-to: 5.15 6.0 6.1 Change-Id: Ie63d68d8f564a4a640bdb8e7564f028784faab97 Reviewed-by: Volker Hilsheimer Reviewed-by: Richard Moe Gustavsen --- src/widgets/styles/qstylesheetstyle.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index b9c0aaa199..71a8914091 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -3542,7 +3542,8 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q if (btn->features & QStyleOptionButton::HasMenu) { QRenderRule subRule = renderRule(w, opt, PseudoElement_PushButtonMenuIndicator); - QRect ir = positionRect(w, rule, subRule, PseudoElement_PushButtonMenuIndicator, opt->rect, opt->direction); + QRect ir = positionRect(w, rule, subRule, PseudoElement_PushButtonMenuIndicator, + baseStyle()->subElementRect(SE_PushButtonBevel, btn, w), opt->direction); if (subRule.hasDrawable()) { subRule.drawRule(p, ir); } else { From 595b4e1a9b436a8190964dc41f79621400f5a6be Mon Sep 17 00:00:00 2001 From: Fabian Kosmale Date: Mon, 29 Mar 2021 14:13:46 +0200 Subject: [PATCH 4/4] QList: Satisfy contiguous_range requirements With C++20, there is a new iterator_category: contiguous_iterator, for containers whose elements are stored contiguously in memory. In Qt 6, QList satisfies this requirement. However, we still need to tell the standard machinery about it. Step one is to mark the iterators as contiguous_iterator; as that exists only in C++20, we have to ifdef accordingly. We also have to ensure that the iterators satisfy pointer_traits by defining element_type due to how contiguous_range is specified. As this runs afoul of LWG 3346, we check for known bad _GLIBCXX_RELEASE versions. Change-Id: I8c134544e694ba937e4d912393eb72fa75b49e3d Reviewed-by: Lars Knoll Reviewed-by: Giuseppe D'Angelo --- src/corelib/tools/qlist.h | 17 +++++++++++++++-- tests/auto/corelib/tools/qlist/tst_qlist.cpp | 20 ++++++++++++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h index 841deb02a1..61a02f795b 100644 --- a/src/corelib/tools/qlist.h +++ b/src/corelib/tools/qlist.h @@ -132,9 +132,16 @@ public: class iterator { T *i = nullptr; public: - using iterator_category = std::random_access_iterator_tag; using difference_type = qsizetype; using value_type = T; + // libstdc++ shipped with gcc < 11 does not have a fix for defect LWG 3346 +#if __cplusplus >= 202002L && (!defined(_GLIBCXX_RELEASE) || _GLIBCXX_RELEASE >= 11) + using iterator_category = std::contiguous_iterator_tag; +#else + using iterator_category = std::random_access_iterator_tag; +#endif + using element_type = value_type; + using pointer = T *; using reference = T &; @@ -167,9 +174,15 @@ public: class const_iterator { const T *i = nullptr; public: - using iterator_category = std::random_access_iterator_tag; using difference_type = qsizetype; using value_type = T; + // libstdc++ shipped with gcc < 11 does not have a fix for defect LWG 3346 +#if __cplusplus >= 202002L && (!defined(_GLIBCXX_RELEASE) || _GLIBCXX_RELEASE >= 11) + using iterator_category = std::contiguous_iterator_tag; +#else + using iterator_category = std::random_access_iterator_tag; +#endif + using element_type = const value_type; using pointer = const T *; using reference = const T &; diff --git a/tests/auto/corelib/tools/qlist/tst_qlist.cpp b/tests/auto/corelib/tools/qlist/tst_qlist.cpp index 96a1a35968..d6ff25b830 100644 --- a/tests/auto/corelib/tools/qlist/tst_qlist.cpp +++ b/tests/auto/corelib/tools/qlist/tst_qlist.cpp @@ -33,6 +33,26 @@ #include #include + +#if __cplusplus >= 202002L && (!defined(_GLIBCXX_RELEASE) || _GLIBCXX_RELEASE >= 11) +# if __has_include() +# include +# if defined(__cpp_concepts) + static_assert(std::contiguous_iterator::iterator>); + static_assert(std::contiguous_iterator::const_iterator>); +# endif +# endif +# if __has_include() +# include +# if defined(__cpp_lib_ranges) + namespace rns = std::ranges; + + static_assert(rns::contiguous_range>); + static_assert(rns::contiguous_range>); +# endif +# endif +#endif + struct Movable { Movable(char input = 'j') : i(input)