Remove out randomly placed testing of invalid byte arrays in
tst_QWidget::saveRestoreGeometry().
Add a separate, data driven test.
Change-Id: I14928537b2dc2b16cbba4a06e39a39d065b8bc14
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
Move the text a little bit further away from the horizontal border.
[ChangeLog][QtWidgets][Styles] PM_ButtonMargin is now respected for
QPushButton in fusion style.
Fixes: QTBUG-94860
Change-Id: I2447de0b8fca048eb2efe1a309969fad61f6bd29
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Avoid double lookups to QRenderRule::styleHints by simply checking if
the returned QVariant from styleHint() is default-constructed.
Pick-to: 6.8
Change-Id: I4ca657662c2af66582fb4fc7c2ed1b77258ab050
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Don't go through the brush's color just to construct a new (solid)
brush. It removes other brush information, unnecessarily constructs
a temporary QBrush object.
Change-Id: I0a02034225f8f1025c7395b31e2f32119f77a37c
Reviewed-by: Doris Verria <doris.verria@qt.io>
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
Assigning a color or style to an existing pen or brush (which we do
frequently in QPainter and elsewhere in Qt) used to implicitly create a
new QPen/QBrush instance and then move-assign that. This involves an
allocation of the new private data, and often also a deallocation of the
old pen or brush private if that wasn't shared (which it often isn't, as
we usually set a temporary object with no further copies).
By implementing specific assignment operators from color and style we
can shortcut this and avoid the allocations.
With this set of changes, the setPen/setBrush benchmarks now compare
to Qt 6.8 as follows:
setPen
6.8: 0.00016 msecs per iteration (total: 89, iterations: 524288)
6.9: 0.000032 msecs per iteration (total: 69, iterations: 2097152)
setBrush
6.8: 0.000078 msecs per iteration (total: 82, iterations: 1048576)
6.9: 0.000017 msecs per iteration (total: 73, iterations: 4194304)
i.e. improve by a factor of >4.5.
Change-Id: Ia9c0229b0f540ecf9afba2a598973c6931712f64
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
The explicit operator==(QBrush, Qt::BrushStyle) does that already, and
more correctly, as it follows the semantics of brush == QBrush(pattern).
Change-Id: I35ce25fe2e895e441ed7974d35bef762c7c533cc
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
Those overloads allow setting of the brush by color without having to
construct a temporary QBrush object just to see if the brush is the
same.
We still impliclty construct a QBrush when assigning the color to the
brush, which could be further optimized by providing an assignment
operator.
Change-Id: Ibcb2b7078563c7308936f6f6f13470d821b2f037
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
Don't construct a QPen just to compare for equality. With the optimized
operator== implementation in QPen, we can directly compare with a color
and style.
We still implicitly construct a QPen when assigning the color to the
pen, which could be further optimized by providing an assignment
operator.
Change-Id: If10222450e40bc9ac9b72edb7c9fa016fc0c3dfc
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
Instead of implicitly creating a QPen or a QBrush from a color or style
just to be able to compare the result with the left-hand side pen or
brush, provide comparesEqual friends that can take a shortcut, avoiding
the allocation that comes with the implicit construction of the types.
operator==(Brush, BrushStyle) needs some extra handling, as we will
create a NoBrush brush if the style alone is not enough anyway.
Change-Id: I06e3d585160ad4fb5d12a46baf8c6a0aaaeeb0b0
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
For the simple case of setting a solid style pen or brush with a color,
which is what we do most in Qt.
Change-Id: Ie90a842ee9638f04941855dfd2e9211235db6cce
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
Add setWindowFlags(Qt::X11BypassWindowManagerHint) to bypass the
creation of the frame. We are checking the geometry of the widget
itself, not of his frame in this test.
Remove the comments preventing that it can be flaky when debugging.
Remove unnecessary QApplication::processEvents().
Remove several unnecessary qWait().
Change-Id: I4a4bcf5cb9522a9a504925c1ae31f0677deae3b1
Pick-to: 6.8 6.7 6.5
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Function generalize the detecting of the latest available Android
platform in the ANDROID_SDK_ROOT directory.
Change-Id: Ib1d064428c414625f24765b50cff500a0ad5d27e
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Since 6.8, QML has popupWindow. When in popupModeMode,
it does not necessarily have a popupWidget.
Not checking whether popWidget is nullptr will cause the
program to crash.
Fixes: QTBUG-131664
Pick-to: 6.8
Change-Id: I624b62ef7185f0ab35215c2c34b0d6e9c80539a0
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
A checked QToolButton should be drawn similar to a checked QPushButton.
As a drive-by avoid calculating the paint rect twice and make the code a
little bit more readable.
Fixes: QTBUG-129439
Fixes: QTBUG-129700
Fixes: QTBUG-130822
Pick-to: 6.8
Change-Id: I573132e804f26b9fa41112267a9f685680cf0864
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Surprisingly, moc had no awareness of constexpr at all. This would still
mostly work, as we were just skipping it, except for the case where
constexpr appears as the last keyword – in which case we'd pick it up as
the type name.
Fix this by adding constexpr as a known token, and add it to the list of things we ignore in testForFunctionModifiers.
Pick-to: 6.5 6.8
Fixes: QTBUG-122609
Change-Id: I0ae0c0477e611ff83fbb841233035bea52216be2
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Is easier to read and more bool-trap safe. Old form header deprecated from 6.10
Fixes: QTBUG-129575
Change-Id: Id785b9ce159007ce745c04120b2112c8bb9b0802
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
The file is used only in the local scope so no need to have it
as a pointer. As a pass-by, use WriteOnly open mode.
Pick-to: 6.8
Change-Id: I9999f4aed0f888af9a3e08ed6c3573432c29d195
Reviewed-by: Petri Virkkunen <petri.virkkunen@qt.io>
Set different icons on the button depending on whether it's checked or
not (since in Qt Quick we always ask for QIcon's pixmap in the "Off"
state), and use Qt Quick Controls and layouts instead of positioners for
proper alignments of labels and text fields.
Change-Id: I1c5bd368560042ec4af8cf4bf1b9104d0257ac40
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
It's good to give a hint about what changed, and it helps behavior of
QQmlDelegateModel when that is used in the view.
Pick-to: 6.8
Fixes: QTBUG-131487
Change-Id: I8478eaf1e8294e101f3fedc285e44f83e600c566
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
According to the CMake documentation we should use the add_dependencies
command to add dependencies on other targets for targets created
using the add_custom_target call.
Adjust the code for the Android targets.
Task-number: QTBUG-131653
Pick-to: 6.5 6.8
Change-Id: Iec9a3036f34f065f067568ecfca838345d35ff93
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
We can detect whether the intent is to require completeness by having
Unique = void. This simplifies QtMocHelpers as well, removing one more
class that needed to be instantiated for each metatype.
Change-Id: I3a256568bb6ce1754399fffd6f61144d0a3e8deb
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
moc no longer generates code using them.
These were not in the QtPrivate namespace, but were undocumented. The
incomplete one was also quite clunky and hard to use, due to the Unique
type.
Change-Id: I27c8f752800756af91eafffd5282bc67becf2d2d
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
There doesn't seem to be any reason that it should require an instance
of QApplication. However, given that the model is by design
asynchronous, it does need to live in a thread that runs an event loop.
Add a note about that to the "Caching and Performance" section, and
apply some drive-by editing.
Amends fb9ec8ad44decba7b2878370f3711b61614f035a
Task-number: QTBUG-66177
Change-Id: Ibe3095e0264ce033732d1c724f59a871e2a0d3b8
Pick-to: 6.5 6.8
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
We want to avoid caling toMSecsSinceEpoch() since it's expensive for
LocalTime (which is presumed to be the common case). We can do so when
both sides have the same offset from UTC (and this can cheaply be
determined) but that's no help for two local times months apart, one
in DST the other not. However, in this case, the difference in millis
is big enough that no plausible difference in offset can overcome it,
so we can again avoid toMSecsSinceEpoch() and simply compare millis.
This should make some previously-expensive comparisons cheap.
Add test-cases to the QDateTime ordering test that verify this doesn't
lead to mis-comparison at the biggest offset-difference known.
Pick-to: 6.8
Fixes: QTBUG-131491
Change-Id: I1afd5d058c8663c908f898d4c50d0837549b87db
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
This change enables running Selenium tests with multithreading.
Change-Id: I2a3e170cb6681142193f33d45bb0d1733034e405
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Reviewed-by: Even Oscar Andersen <even.oscar.andersen@qt.io>
... and QT_REMOVAL_QT8_DEPRECATED_SINCE.
Following up on the discussion from the Qt CS 2024 [0], this patch
introduces a new macro to mark the deprecated APIs that will be
removed in a specific major release. For now, add the macros
for Qt 7 and Qt 8.
The macro should be used instead of the regular
QT_DEPRECATED_SINCE(maj, min) for such type of APIs. The usage
is the same, as with the regular macro:
#if QT_REMOVAL_QT7_DEPRECATED_SINCE(6, 9)
QT_DEPRECATED_VERSION_X_6_9("The reason for the deprecation")
void deprecatedFunc();
#endif
The macro is basically a combination of QT_DEPRECATED_SINCE and
a comparison against a certain Qt major version.
[0]: https://wiki.qt.io/QtCS2024_Deprecate
Task-number: QTBUG-130024
Change-Id: I8efa1920d9d1524250bb00446aefffae65210340
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Documentation of QMetaProperty mentions deprecated members, which
includes type(). Added link to the metaType() to avoid confusion.
Fixes: QTBUG-131446
Pick-to: 6.8
Change-Id: I8d96bcf712c78ca2b9ce609e511d275053cf6cbf
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Since we now support emoji parsing, there is no longer any need
for this ad hoc processing of VS-16. The exception is if Qt is
built without the emoji segmenter, in which case we should keep
it for consistency with previous versions.
Task-number: QTBUG-111801
Change-Id: I3e243b9610fe55dda26eba63ac849e6afa22a185
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This amends 16850709306589a2433c0038605d365a6b6bedad.
In that change, the final pass for looking up fallback
fonts was turned into a lambda so that we could run it
an additional time at the very end. However, when making
a lambda from the code, some of the logic was accidentally
changed.
Specifically, for multi engines the original code would pass
Script_Common instead of the requested script to the match()
function, but it would still pass the actual script to
loadEngine() as well as store it in the key. In the changed
code, Script_Common would be used for all of these when multi
was true.
This change was not intentional and it caused us to fail to
load certain fallback fonts, for instance the Bengali font
on Windows.
Fixes: QTBUG-131632
Change-Id: Id215ee4dc2851e846be27a3a25a31cad57b8f67d
Reviewed-by: Lars Knoll <lars@knoll.priv.no>
Include an example of this in testlib's docs, as an illustration of
how to restore global state after a test that frobs it. Replace
various "restore as the test finishes" approaches with scope guard
forms that also work when the test fails. Add missing restoration to
tests that allowed their changes to leak into later tests. (If these
later tests actually depended on that, they should be amended to
control the default locale for themselves. This both makes the tests
more robust and documents the need for a specific locale.) Always
restore the actual prior default locale, rather than just assuming
it's the system locale (as several tests did).
For tst_QMimeDatabase this replaced a home-grown RAII class.
For tst_rcc, I included similar treatment of an unregistration of a
resource, since that clearly should follow the same pattern.
For tests that set the default locale in initTestCase(), I've moved
that to their constructor as that comes as close as possible to the
sense of doing it in main(), which is the natural place for a global
setting intended to apply to the whole program.
Change-Id: Ia7970a33b14c4fbd67c1d70dcafbba21f2fae3ef
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Use qScopeGuard() to ensure we always restore cleanly. Some of them
didn't even need to set default locale, and one only needed a minor
tweak to save the need for it. Remove tst_QLocale's red-flag comments
about its tests that exercise setDefault(), since they should now be
harmless and not care about their order relative to other tests.
Change-Id: I552218989c66c4e7b238b3a949a6aeae3a7c2825
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
The system locale isn't guaranteed to be the default; indeed, this is
one of the tests that frobs the default, so really shouldn't assume
it. Use the actual default and correct some related variable names in
the process.
This amends commit 3c8181de7006cab3c2d736dfb4adabe9b2ffaf4e.
Change-Id: I45dcdfb4f56295b0d22053937234347d33bbe320
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
While CLDR wants to call it en-US-u-va-posix, my reading of [BCP47]
and the CLDR's relevant filename, en_US_POSIX.xml, leads me to
conclude that (once we omit the territory code as implied by
likely-subtag rules) we should represent and recognize it as en-POSIX.
[BCP47] https://www.rfc-editor.org/rfc/bcp/bcp47.txt
[ChangeLog][QtCore][QLocale] Changed the QLocale::bcp47Name() of the C
locale to "en-POSIX" to distinguish it from plain "en" (from which it
differs materially). This name is now also recognized as a name for
the C locale.
Task-number: QTBUG-81051
Change-Id: I5d2758aede88dd624733daa216a1ad8c0050112a
Reviewed-by: Mate Barany <mate.barany@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
In two of the four test contexts where this code is reused, the call
to comment(), another test function, from within this test function
skips (as it depends on FDO), which was leading to the "have we
failed" check after calling it to misleadingly return early. Instead,
duplicate the (complemented) skip condition in this call to avoid the
skip and let the rest of installNewLocalMimeType() run.
Change-Id: Icee039c0daa271e38b6657300503dd84219034f0
Reviewed-by: David Faure <david.faure@kdab.com>
Tests should not leak changes to global state to the other tests in
their run. If the other tests actually need the changed locale, too,
they should make that overt by setting it themselves (and restoring
when done).
Change-Id: I574ba906da6a95fc894b61ab536b093eede4357a
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Tests should not leak changes to global state to the other tests in
their run. If the other tests actually need the changed locale, too,
they should make that overt by setting it themselves (and restoring
when done).
Change-Id: I132447878f80105d59ca3ccbd43874cbade1cc35
Reviewed-by: Jonas Karlsson <jonas.karlsson@qt.io>
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Add QPainterStateGuard as a small RAII helper class to avoid unbalanced
QPainter::save()/restore() calls.
Change-Id: I618a5d720b7bc9267a0fbac7dcc90e61f5d9cefd
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: David Faure <david.faure@kdab.com>
Merge the drawing code for PE_FrameDockWidget and PE_FrameWindow as they
actually draw the same except for one pen color.
Pick-to: 6.8
Change-Id: I1647474166af6c9a188531fcc0780e388729ab87
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
When drawing an indeterminate progress bar, QPainter::drawLine() is
called very often. Avoid it by first calculating all lines and then call
QPainter::drawLines() once with all lines to draw.
Pick-to: 6.8
Change-Id: I51ce23236b945b30da649fd06aad60676321e403
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Move common tasks into a lambda to improve readabilty and avoid
copy'n'paste errors like it happened for SC_TitleBarContextHelpButton.
Pick-to: 6.8
Task-number: QTBUG-130673
Change-Id: I5cb198b976d459b73e339d066def92d70b71ade5
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Cleanup drawing of PE_IndicatorToolBarSeparator - there is no need to
call QRect::topLeft/bottomRight() and then only use x or y. No need to
stress the optimizer that much.
Pick-to: 6.8
Change-Id: I477dcea6c9bebd981777fdc1eb53963074257e01
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
I had used base classes because that's what I had used for MetaTypeList,
where we did need to store a tuple-like collection of types.
Unfortunately, the side-effect of this is that we instantiate far more
types and this causes a huge increase in compilation times and, for GCC,
memory usage. That is especially an issue for qtopcua's
qopcuanodeids.cpp.
But it turns out we don't need them at all: instead of an collection of
base classes each of which contains a pointer, we can store an array of
pointers in our object. That reduces the number of types instantiated
from n to 1. This massively improves compilation times and memory usage:
| Previously | Now |
Compiler | Memory use | Time to compile | Memory | Time |
GCC 14.2 | 5066096 kB | 56 s | 673164 kB | 7.95s |
Clang 19.1 | ~594000 kB | 85 s | 481748 kB | 4.73s |
Drive-by change some variables to "int" to get overflow checking.
Change-Id: Id918c5597141c3a06ba4fffd58f9c09d9bba2401
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
The snippet, used in qlogging.cpp docs, used the plain t format (which
gets a zone abbreviation, impossible to parse because ambiguous). This
surely dates to when that was the only zone suffix option; we now
support more choices. Use ttt for the ±HH:mm offset format.
Change-Id: I206e40cb3db6efb2eb3594d32a889f5b5dc785ee
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
tst_manual_scrollarea assigns a scrollview that can receive paint
events to a widget.
Manual tests are seldom used and it seems irrelevant.
Remove the manual test.
Task-number: QTQAINFRA-6621
Change-Id: I34574424df98a949ee92291de4026a25b0592f02
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
If the QIcon::themeName matches an installed font, and if the
name of the icon matches a named glyph in the font, then render
that glyph as a painter path.
Overrides of QFontIconEngine::text() take priority.
Amend the manual test to allow specifying an icon theme on the
command line, and render the named glyph also as text, as
some icon fonts will define ligatures that turn the string into
the corresponding icon.
Task-number: QTBUG-102346
Change-Id: I788c6274322359955cbfe58175a2999a57cfce95
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Add private QFontIconEngine that renders the glyphs; the specialized
engines have to specify the font, and implement the mapping of icon name
to glyph sequence (i.e. a QString).
Use it for the Android and Windows icon engines.
Task-number: QTBUG-102346
Change-Id: I6b0f0d6bc0378ed6918ea7cfb9dcce12ac86e8ab
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
The default implementation creates a harfbuzz font and iterates
over all glyphs. The more optimized implementation for CoreText
uses the native API.
Change-Id: I9c5b8115f72fb9ade3892a65ddbed76f7af0a580
Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>