Commit Graph

13728 Commits

Author SHA1 Message Date
Sona Kurazyan
d0f9e593d4 Rename tst_qlatin1string and switch to using QLatin1StringView
Task-number: QTBUG-98434
Change-Id: Iec477835880263175edbc03f21b40f1ad67dbef0
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-03-19 18:51:08 +01:00
Marc Mutz
c52ebb3aba QRect: add toRectF()
For symmetry with QRectF::toRect().

[ChangeLog][QtCore][QRect] Added toRectF().

Fixes: QTBUG-73160
Change-Id: If2bda64b8fe4bc113191dda927e9bb86ebcb4c69
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-03-19 12:02:24 +01:00
Marc Mutz
5dc570f8b1 QLine/QMargins: add toLineF/toMarginsF()
For symmetry with QLineF::toLine().

[ChangeLog][QtCore][QLine] Added toLineF().

[ChangeLog][QtCore][QMargins] Added toMarginsF().

Task-number: QTBUG-73160
Change-Id: I69051cdd2fe4a3c0a000ab86e363a2918a7aea7c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-03-19 12:02:24 +01:00
Marc Mutz
2fb0135efa QSize/QPoint: add toSizeF/toPointF()
For symmetry with QSizeF::toSize().

[ChangeLog][QtCore][QSize] Added toSizeF().

[ChangeLog][QtCore][QPoint] Added toPointF().

Task-number: QTBUG-73160
Change-Id: I65b088b4f7365ab671ef2f0c75821b707f5ac26d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-03-19 12:02:24 +01:00
Marc Mutz
f97daab7a6 QObject: restore flags printing in dumpObjectTree()
This was lost when QtCore, QtGui and QtWidgets were split up. Restored
now via a virtual function on QObjectPrivate.

Chose to return std::string instead of QString or QByteArray because
its SSO is usually sufficient to hold these flag strings.

[ChangeLog][QtCore][QObject] Restored printing of Qt3-style
information from dumpObjectTree().

[ChangeLog][QtWidgets][QWidget] Restored printing of Qt3-style
information from QWidget::dumpObjectTree().

Fixes: QTBUG-101732
Change-Id: I39ff5728ea5f5abbdbf81b5d7e13b8d16b6ee8b7
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-03-19 12:02:24 +01:00
Marc Mutz
6ec1dc904d QSettings: port key processing to QAnyStringView
... in preparation for replacing the QString keys in the public API
with QAnyStringView ones.

This removes the "important optimization" that avoids a detach in the
common case where the input is the same as the output of
normalization. But that optimization is beside the point, because it
trades a memory allocation avoided in the library for O(N) allocations
inserted into user code for each call to QSettings::value(), the vast
majority of which are calls with string literals.

With the public interface ported to QAnyStringView in the follow-up
patch, we can then internally optimize memory allocations _in a central
place_ (e.g. by returning std::u16string or QVarLengthArray<QChar> from
normalizeKey() instead of QString). But first we need to get rid of all
the unwarranted allocations in user code.

Change-Id: I45fc83d972c552a220c9c29508001d3f172e1162
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2022-03-19 07:09:55 +00:00
Volker Hilsheimer
5e566ab373 When clearing selected items, iterate over a copy of the QSet
Selection change handlers of the items might call a method that
implicitly recreates the selectedItems QSet, which then invalidates
the iterators of the ranged for loop, resulting in crashes.

Iterate over a copy of the set instead.

Add a test case that crashen without the fix.

Fixes: QTBUG-101651
Pick-to: 6.3 6.2
Change-Id: I6da6f4043fe1906b0186931a37283f635cb5a404
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2022-03-18 21:56:19 +01:00
Luca Di Sera
33d62de7c8 Enable move semantics for QTemporaryDir
Add move constructor and move assignment operator.

To allow for the the change to be implemented QTemporaryDir, the
internal d_ptr was modified from a QScopedPointer, which is not movable,
to a raw pointer.

Add member + free swap implementations.

Add tests.

[ChangeLog][QtCore][QTemporaryDir] Enabled move semantics.

Change-Id: I9f196a77c70b4ca0b7f0c06505d00fdd87a9785c
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-03-18 20:56:19 +00:00
Ivan Solovev
30830e0cba Android: use empty Intent to clear clipboard data on API < 28
ClipboardManager didn't have any APIs to clear clipboard data before
API level 28.
As a workaround an empty Intent with MIMETYPE_UNKNOWN is created and
inserted into the clipboard for lower API levels.
This makes the QApplication::clipboard()->clear() method work more or
less as expected.
This allows to unblacklist tst_QPlainTextEdit::copyAvailable().

Task-number: QTBUG-87423
Task-number: QTBUG-89402
Pick-to: 6.3 6.2
Change-Id: I454376199cf3b8eed0fa2ecf2f85b87f40892280
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2022-03-18 18:35:03 +01:00
Marc Mutz
9985cc330a uic: use C string literals for setObjectName()
Because setObjectName() now takes a QAnyStringView, passing C string
literals is much more efficient than using QString::fromUtf8().

This patch only deals with setObjectName() as a known property,
probably from a name attribute. If the objectName property is set by a
<property> element (or so I assume), we still emit a
QString::fromUtf8(). Detecting objectName there would be too much
magic.

Besides, I haven't been able to find why sometimes there's a second
setObjectName call right after the first, when in the XML it seems all
kosher (name attribute and objectName <property> agreeing on the
content).

Change-Id: Icf07bad841ac735a9c744bbd955428ba15758089
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-03-18 18:35:03 +01:00
Janne Juntunen
a5ee74754d tst_qopengl: set surfaceType explicitly
Parent window in sizeLessWindow test was using software pipeline at
least on webOS, causing a QCRITICAL() exit when the test was executed.

Fixes: QTBUG-101869
Pick-to: 6.3
Change-Id: Ie8cc0ea0b6a09729475389be44197e01a45b217f
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2022-03-18 13:02:11 +02:00
Giuseppe D'Angelo
1b14569753 QMutexLocker: strenghten the locking operations
There is no reason to allow relock() on a locked locker, or unlock()
or an unlocked one, just like we don't allow that on a plain mutex
to begin with. The docs already said that e.g. relock() locks an
_unlocked_ locker.

[ChangeLog][QtCore][QMutexLocker] QMutexLocker allowed relock() and
unlock() on an already closed (resp. open) locker object. These
semantics have always been undocumented and are now unsupported
(in both cases they yield undefined behavior.)

Change-Id: Id5f67beb5dc30d6435dae88a3085fba93ec7d96e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-03-18 05:18:28 +01:00
Edward Welbourne
e10d613509 Add QByteArray::percentDecoded() as an instance method
Percent-decoding was previously only present as a static method taking
a QBA parameter; it might as well be an instance method of that
parameter. Change most QBA tests to use it rather the static method.

[ChangeLog][QtCore][QByteArray] percentDecoded() is now available as
an instance method of the byte array to be decoded, equivalent to the
static QByteArray::fromPercentEncoding().

Change-Id: I982101c44bdac5cc4041e85598d52ac101d38fa1
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-03-18 01:22:54 +01:00
Sona Kurazyan
73e7fc2d8e Fix a few more {QString, QByteArray}::count() deprecation warnings
Change-Id: I0be2d5e7a8f6af3bc1077ae6d1f20cc5da8f2266
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-03-17 21:03:08 +01:00
Allan Sandfeld Jensen
173dd2a033 Fix lancebench after lancelot restructuring
Pick-to: 6.3 6.2
Change-Id: I5e17230761ca5482b3376787afab29d15de58dac
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2022-03-17 18:57:47 +01:00
Giuseppe D'Angelo
20d0ff1a39 QMutexLocker: add move semantics
The class is similar to unique_lock in that it allows for unlocking
and relocking. Since the locked state is tracked by QMutexLocker itself,
it's trivial to make it movable.

[ChangeLog][QtCore][QMutexLocker] The class is now movable.

Change-Id: I534044f8024575e996c12efb2236761d493798a3
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-03-17 18:57:47 +01:00
Fabian Kosmale
8f73b25e52 Benchmarks: Do not depend on transitive includes
Change-Id: I1d0dbfca130f43d76de2d6ac585a0f242d490b5a
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-03-17 17:14:37 +01:00
Fabian Kosmale
819e1bf91d Tests: Do not depend on transitive includes
Change-Id: Ibc6a948480a904913a5427e6408d4d296784fb4f
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2022-03-17 17:14:37 +01:00
Giuseppe D'Angelo
5089db0303 QFuture: fix QtFuture::connect corner-cases
Connecting to nullptr, or connecting to a non-signal PMF, would result
in a QFuture which would never finish. Catch these cases and handle
them.

Windows+MSVC for some reason fails the test. I can't entirely understand
why, so I've marked it as XFAIL, with QTBUG-101761 to track it.

Change-Id: I314980e7e9b7156d8cddd3b33d5cbf1d0bcd6116
Pick-to: 6.2 6.3
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2022-03-17 17:14:36 +01:00
Alexey Edelev
8adacba3e6 Add VERBATIM option to add_custom_command calls
Use VERBATIM option to prepare the correct command line for the
add_custom_command. This especially sensitive when using build
directories with names containing special symbols, that cannot be
handled by shell correctly.

Change-Id: I51d7041cb806411135fd59bf6273c04a3c695443
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-03-17 15:15:06 +01:00
Sona Kurazyan
893dd5d7be Add QStringView::localeAwareCompare()
QString already has a localeAwareCompare(QStringView, QStringView)
static method. Use it in QStringView::localeAwareCompare(QStringView).

[ChangeLog][QtCore][QStringView] Added
QStringView::localeAwareCompare().

Task-number: QTBUG-98431
Change-Id: Iec3865a5439d9fb653cc1150da21042186bdee98
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-03-17 14:27:45 +01:00
Sona Kurazyan
b86b22cfde Move localeAwareCompare tests from tst_qstring to tst_qstringapisymmetry
Pick-to: 6.3 6.2
Change-Id: I3c395d989e4659ebfa24b78f34b2a99769b734dc
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-03-17 14:27:45 +01:00
Liang Qi
f08e57540d GUI: add ScreenWindowGrabbing capability
On Wayland, there is no protocol to do it yet.

Task-number: QTBUG-100792
Task-number: QTBUG-101145
Change-Id: Id72625a8161359111a2d0f43f3215e787778ba6b
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-03-17 14:27:44 +01:00
Eirik Aavitsland
9619cec279 Baseline testing: Fix overriding of Project property
Remove some kludgy, redundant and never used functionality for setting
project and test case names, as it also hindered overriding those
properties at runtime.

Pick-to: 6.3 6.2
Change-Id: Ibef7d7d0cb5fc1e462752f2ba2db76cc088dbd48
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-03-17 14:27:44 +01:00
Marc Mutz
9f8da21239 QDateTime: future-proof swap()
In Qt 7 32-bit builds, the ShortData will be larger than the
d-pointer.

So don't swap() the d-pointer, but a) delegate to Data to swap itself
and b) swap the ShortData there, adding a static_assert in the .cpp
file that triggers when the assumption that ShortData is always at
least as large as a pointer is violated.

Found while porting away from overly-generic qSwap(), so done that,
too.

Task-number: QTBUG-97601
Pick-to: 6.3 6.2
Change-Id: I5139da58d99e9491a582ff2cb2f817cd96952044
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-03-17 06:14:58 +00:00
Laszlo Agocs
bc54031d57 Exercise reparenting more in QOpenGLWidget autotest
Change-Id: I771250ba889835e886c2801066ef023d82c5186d
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2022-03-17 05:34:55 +00:00
Giuseppe D'Angelo
979ee48ca1 QObject: add another couple of tests for broken connect()
Connecting to a non-signal should fail, but apparently it doesn't on
Windows+MSVC under certain conditions.

Task-number: QTBUG-101761
Change-Id: I3e014660e4e5b287242e32307f677bb22ab10a39
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-03-17 01:02:15 +00:00
Tatiana Borisova
715420095a Fix has_signaling_NaN usage for INTEGRITY
- The newest GHS compiler versions set the value of has_signaling_NaN to False.
  Add compilation and autotest fix for GHS-compiler 2021/2022 releases.

Task-number: QTBUG-99123
Pick-to: 6.2 6.3
Change-Id: I45e5da6759a15c60c17f896e565002cbba8524ed
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-03-16 20:09:37 +02:00
Marc Mutz
1977c922e9 QFlatMap: make insertion STL-compatible
That is, insert() doesn't overwrite an existing entry, and range
insert inserts the first of equivalent keys' values, not the last.

This allowed this author to optimize the implementation of
makeUnique() to a O(N) algorithm (was: O(N²)). Said optimization would
have been possible with the old semantics, too, but I wrote the
algorithm first and only then noticed the broken insert() behavior is
present on QFlatMap, too, so I decided not to let good code go to
waste and to fix both problems at the same time.

In order to give users a hint of the changed semantics, make the new
API opt-in until Qt 6.5, so Qt 6.4 ships with the both the old and the
new semantics disabled, where they contradict.

Fixes: QTBUG-100092
Change-Id: Ic96d8bfe6bed9068dbe8c0d7171bd8921050fd95
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-03-16 18:28:27 +01:00
Volker Hilsheimer
58a14d9433 Enable tests to turn off Windows Vista animations
Animations in that style depend on the current time, which makes it
impossible to run baseline tests. Introduce a dynamic property that
allows us to set the time that animations use.

This way, tests can turn the animation off, or control which time should
be used.

To keep performance overhead low, check only once whether the dynamic
property is set at all.

Pick-to: 6.3
Change-Id: I9bc57b9867fb0d852e101570eca4c7609e7fe1a8
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2022-03-16 15:56:17 +01:00
Alexandru Croitor
21bffeec90 CMake: Add deployment auto test
Add a cmake test that builds a simple widgets application, installs
it, in a shared Qt build deploys the runtime dependencies and then
runs it to confirm that the app works.
With a static Qt, the installation of the runtime dependencies is
skipped, but the app should still run.

The test is expected to pass only when targeting Windows and macOS
(both when using shared and static Qt).

Pick-to: 6.3
Task-number: QTBUG-98545
Change-Id: I41b616e1e1fc463d57c64be9273ed4dc755e9187
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-03-16 15:56:17 +01:00
Marc Mutz
e74e27e67e QObject: give some TLC to dumpRecursive()
In no particular order:

- use the variable field width feature of QString::asprintf() to
  generate the indentation implicitly, instead of fill()ing a
  QByteArray with the desired number of spaces

- just default-construct 'flags', don't assign an empty string

- use qUtf16Printable() to avoid funneling UTF-16 data through 8-bit
  encodings

- use a C++11 ranged for instead of a counted loop

- remove a pointless isEmpty() guard (the loop won't execute when the
  children().isEmpty())

- avoid copying object->children() (returns by cref, so it's also ok
  to stuff it directly into the ranged for loop).

Add a test.

Pick-to: 6.3
Change-Id: Ie7314713cb48de7e890cdee0760c0361dd24fd18
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-03-16 02:26:56 +00:00
Andreas Buhr
50f6356f8e Repair some of tst_qtableview tests on Android
The test task191545_dragSelectRows relied on the fact
that the view is not scrolling. But on a small screen,
it scrolls automatically.

Fixes: QTBUG-87407
Pick-to: 6.2 6.3
Change-Id: I691361c965ab03d8a012f2b83715c7c96d990ec5
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Reviewed-by: Rami Potinkara <rami.potinkara@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-03-15 21:05:31 +01:00
Marc Mutz
f3c340c276 QStringTokenizer::toContainer(): allow more types of target containers
The previous constraint called for the value_type of the container to
exactly match the value_type of the tokenizer, which means
toContainer() could only ever work on containers of views. But there
is value in allowing QStringList, even though it works only on QL1S
needles (QStringView -> QString isn't implicit). But users may have
other types that for better or worse implicitly convert from views, so
we shouldn't over-constrain the function.

[ChangeLog][QtCore][QStringTokenizer] toContainer() now works on
containers whose value_type can be constructed from the tokenizer's
value_type. It no longer requires an exact match.

Fixes: QTBUG-101702
Change-Id: Ie384cd1c4b51eaa57675f2a014141ceec8651c81
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-03-15 21:05:31 +01:00
Assam Boudjelthia
a818885a3d Android: expect QPlainTextEdit::canPaste() to fail after clipboard clear
Android 9 introduce an API call to clear the clipboard, before that
it wasn't possible to do that, the test QPlainTextEdit::canPaste()
should expect that to fail.

Pick-to: 6.3 6.2
Task-number: QTBUG-100470
Change-Id: Ie2d8aabf77672c62b3a6c72a080a4e37f1696303
Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
2022-03-15 16:09:04 +02:00
Eirik Aavitsland
f46db29d8c Painting: fix overriding and combining different clip types
In a recent improvement (6de36918c0) the
last set clip region or path was stored in separate variables, in
order to be set again if the aliasing mode changed. That solution was
too simplistic, as it would break down as soon as more than one clip
area was set, with the latter either replacing or intersecting the
first. It was also unnecessary to introduce new storing of clip areas
and transforms, as those are already recorded in the clipInfo stack in
the painter state. This patch hence reverts much of that implementation.

However the basic idea of setting the clip area again after AA change
is good, so that part is kept, implementated instead by calling a
pre-existing function to replay the clipInfo stack.

One of the baseline test cases is extended to excercise the
combination of clip areas. As a driveby, support for setClipRectF is
added to the painting baseline test scripts, and the build of the
manual lance tool is fixed.

Fixes: QTBUG-101474
Pick-to: 6.3 6.2
Change-Id: Ide8b70d8cbf138deb06cbb84f69e62f7405886e6
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2022-03-15 12:45:46 +01:00
Volker Hilsheimer
1822550529 QFormLayout: Fix assert when showing with hidden rows
Amends a74cdf778c, after which the
initialization of items in invisible rows is skipped. Since data members
in QFormLayoutItem were lazily initialized, this resulted in out-of-bounds
access of QList entries.

Use member initialization for all QFormLayoutItem fields, and check that
vLayoutIndex is valid before using it to access the list entry. Skip
labels and fields for which it is not initialized.

Add test case. As a drive-by, silence the test's provoked warning
messages via ignoreMessage.

Change-Id: I374b414a51df20b9af3087a2676061fc6b7f23e2
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-03-15 12:45:46 +01:00
Marc Mutz
0aaada0ddc QString::asprintf: check that passing field widths as arguments works
Pick-to: 6.3 6.2 5.15
Change-Id: Ifb36179b9c26ce15378f10c2947c8cb1e38e10d4
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-03-15 11:36:09 +01:00
Marc Mutz
78073f8ab6 Restore C++20-deprecated mixed-enum bitwise operators
C++20 deprecated arithmetic on enum types. For enums used on QFlags<>,
these operators have always been user-defined, but when the two enums
are of different type, such as QFrame::Shape and QFrame::Shadow, the
deprecation warning pops up.

We have in the past fixed these in our headers by manual casts, but
that doesn't help our users when our API requires them to OR together
enums of different type.

Until we can rework these APIs to use a variadic QFlags type, we need
to fix it in an SC and BC way, which is what this patch sets out to
do.

The idea is simply to mark pairs of enums that are designed to be ORed
together and replace the deprecated built-in bitwise operators with
user-defined ones in C++20. To ensure SC and BC, we pass an explicit
result type and use that to check, in C++17 builds, that it matches
the decltype of the result of the built-in operator.

This patch is the first in a series of similar patches. It introduces
said markup macro and applies it to all enum pairs that create
warnings on (my) Linux GCC 11.3 and Clang 10.0.0 builds. It is
expected that more such markups are needed, for other modules, and for
symmetry.

Even with this patch, there is one mixed-enum warning left, in
qxcbwindow.cpp. This appears to be a genuine bug (cf. QTBUG-101306),
so this patch doesn't mark the enums involved in it as designed to be
used together.

This patch also unearthed that QT_TYPESAFE_FLAGS, possibly
unsurprisingly so, breaks several mixed bitwise flags-enum operations
(QTBUG-101344).

Pick-to: 6.3 6.2 5.15
Task-number: QTBUG-99948
Change-Id: I86ec11c1e4d31dfa81e2c3aad031b2aa113503eb
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2022-03-15 11:36:09 +01:00
Marc Mutz
ce83a03cfd QColor: deprecate isValidColor, setNamedColor, string-ish ctors
[ChangeLog][QtGui][QColor] The constructors from string-ish type, as
well as the setNamedColor() and isValidColor() functions, have been
deprecated effective Qt 6.6 in favor of fromString() and
isValidColorName(), resp.

Fixes: QTBUG-101389
Change-Id: I002646bd48c1e4340dc6842fd136fc9f35bb9b61
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-03-15 10:36:09 +00:00
Heikki Halmet
ee0908228f Revert "Blacklist: test cases blacklisted in tst_QXmlStream:"
This reverts commit d3a297c0ab.

Reason for revert: Unnecessary blacklisting

Task-number: QTBUG-101332
Change-Id: I1e2c94585e719199724695347b243dffcde49259
Reviewed-by: Jani Heikkinen <jani.heikkinen@qt.io>
2022-03-15 07:32:32 +00:00
Giuseppe D'Angelo
9b8015ed8d QMutexLocker: add isLocked()
It's basically for free.

[ChangeLog][QtCore][QMutexLocker] Added the isLocked() function.

Change-Id: Idad5fa249ba8f135dcf81c7b7596caa3a888e99c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-03-15 03:32:14 +01:00
Volker Hilsheimer
b2edef557c Baseline: don't compensate for DPRs != 1.0
The resulting blurriness is too significant, and it's hard to see where
the difference comes from. Better to encode the screen DPR into the
appearance ID if it's not 1.0, and warn about the comparison not being
done to the baseline images with a 1.0 DPR.

Pick-to: 6.3
Change-Id: Iceab7b0a4cc50627145bd1267cff22344f7d8e5b
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2022-03-14 23:38:10 +01:00
Volker Hilsheimer
16d154ca5f Baseline: Allow setting git commit through environment variable
Widget tests run in VMs that don't have their own git clone.

Pick-to: 6.3
Change-Id: I20ab32affabfc7ce6dfaa445306b19efb51803e9
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2022-03-14 23:38:09 +01:00
Volker Hilsheimer
ad333b9b87 Baseline testing: make style name explicit
Mangling it into the checksum makes it hard to navigate the available
images.

Pick-to: 6.3
Change-Id: I54dcab5681e747ce1c5fe1b141ef6c4441d1f7eb
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2022-03-14 23:38:09 +01:00
Edward Welbourne
479c95729a Support global data tags in blacklisting identification of test-cases
Previously the blacklisting file format only worked with slot:data or
plain slot names for the items to blacklist. However, tests with
global data report themselves with the global data-row tag in the same
way as function-specific ones do; and tests which have both join the
two as slot(global:data) in the test output name, so the reader is apt
to mistake global:data for a data tag. In any case, it is potentially
desirable to be able to blacklist a function with either or both of
global and local data-row tags specified. Add support for that and
remove a blacklisting that was only needed due to the lack of this
support.

For now, make the new parameter to checkBlackLists() optional, so
that qtdeclarative's qmltest framework can adapt to this change.

Fixes: QTBUG-100870
Change-Id: I9125811ebdab75d3fb462ba8b60561f003426502
Reviewed-by: Pasi Petäjäjärvi <pasi.petajajarvi@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-03-14 20:16:35 +01:00
Edward Welbourne
84984cfce2 Add some %-encoding round-trip tests that use % in the plain-text
This was not previously tested.

Change-Id: Icd287b519f6bc5d450f4490990ac78b0d06774f6
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-03-14 20:16:34 +01:00
Laszlo Agocs
1ea73bc29b Fix losing QOpenGLWidget paints when a child widget is invisible
Pick-to: 6.3 6.2
Change-Id: I136b486d30e31acadd6b1b837dc7e834ee3e23fb
Fixes: QTBUG-101620
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Christian Strømme <christian.stromme@qt.io>
2022-03-14 17:48:52 +01:00
Volker Hilsheimer
fd4186cd23 Fix click position for check box and radio button baseline tests
Some styles override the clickable area.

Pick-to: 6.3
Change-Id: Id6ec9d9aa2faff39489b2baa412af4339779ff5c
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2022-03-14 16:13:06 +01:00
Ville Voutilainen
7f85425cb5 pthread_yield() has been removed in newer linux distros
pthread_yield() is a non-posix extension and was deprecated for a long time.
It's been removed recently at least from Fedora 35. Use sched_yield() instead.

Change-Id: Iae47fa09cc89005aa466446149be87e1b673c074
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-03-14 07:53:34 +02:00
Liang Qi
9c6b986d96 gui: return first default device when seatName isNull
for QInputDevice::primaryKeyboard() and
QPointingDevice::primaryPointingDevice().

This also reverts ae9fefe3c8.

Fixes: QTBUG-100790
Pick-to: 6.3
Change-Id: Id02f277db25f823eb29e939e25801325df8e4076
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2022-03-13 22:08:16 +01:00
David Faure
7382e5735e QCompleter: fix crash when setting the same model twice
Found when retesting the testcase completer.zip from QTBUG-54642

Pick-to: 6.3 6.2 5.15
Change-Id: Id84eefeb3a33dc6d790cfa23755352381cc097a9
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-03-13 16:13:29 +00:00
Axel Spoerl
2140edaaab Add setCurrentId in QWizard
setCurrentId(int id) implemented incl. forward skip warning
respective test added in tst_qwizard

Fixes: QTBUG-99488
Change-Id: Ieaf31698baf1e8ec97484b4a221c8587385c9fb3
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-03-12 13:24:29 +01:00
Sona Kurazyan
6585963583 Deprecate {QString, QByteArray}::count()
And remove their uses.

[ChangeLog][QtCore][Deprecation Notice] Deprecated QString::count()
and QByteArray::count() that take no parameters, to avoid confusion
with the algorithm overloads of the same name. They can be replaced
by size() or length() methods.

Change-Id: I6541e3235ab58cf750d89568d66d3b1d9bbd4a04
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-03-12 01:05:45 +01:00
Laszlo Agocs
68a4c5da9a Compose render-to-texture widgets through QRhi
QPlatformTextureList holds a QRhiTexture instead of GLuint. A
QPlatformBackingStore now optionally can own a QRhi and a
QRhiSwapChain for the associated window.  Non-GL rendering must use
this QRhi everywhere, whereas GL (QOpenGLWidget) can choose to still
rely on resource sharing between contexts. A widget tells that it
wants QRhi and the desired configuration in a new virtual function in
QWidgetPrivate returning a QPlatformBackingStoreRhiConfig. This is
evaluated (among a top-level's all children) upon create() before
creating the repaint manager and the QWidgetWindow.

In QOpenGLWidget what do request is obvious: it will request an
OpenGL-based QRhi. QQuickWidget (or a potential future QRhiWidget)
will be more interesting: it needs to honor the standard Qt Quick
env.vars. and QQuickWindow APIs (or, in whatever way the user
configured the QRhiWidget), and so will set up the config struct
accordingly.

In addition, the rhiconfig and surface type is (re)evaluated when
(re)parenting a widget to a new tlw. If needed, this will now trigger
a destroy - create on the tlw. This should be be safe to do in
setParent. When multiple child widgets report an enabled rhiconfig,
the first one (the first child encountered) wins. So e.g. attempting
to have a QOpenGLWidget and a Vulkan-based QQuickWidget in the same
top-level window will fail one of the widgets (it likely won't
render).

RasterGLSurface is no longer used by widgets. Rather, the appropriate
surface type is chosen.

The rhi support in the backingstore is usable without widgets as well.
To make rhiFlush() functional, one needs to call setRhiConfig() after
creating the QBackingStore. (like QWidget does to top-level windows)

Most of the QT_NO_OPENGL ifdefs are eliminated all over the place.
Everything with QRhi is unconditional code at compile time, except the
actual initialization.

Having to plumb the widget tlw's shareContext (or, now, the QRhi)
through QWindowPrivate is no longer needed.  The old approach does not
scale: to implement composeAndFlush (now rhiFlush) we need more than
just a QRhi object, and this way we no longer pollute everything
starting from the widget level (QWidget's topextra -> QWidgetWindow ->
QWindowPrivate) just to send data around.

The BackingStoreOpenGLSupport interface and the QtGui - QtOpenGL split
is all gone. Instead, there is a QBackingStoreDefaultCompositor in
QtGui which is what the default implementations of composeAndFlush and
toTexture call. (overriding composeAndFlush and co. f.ex. in eglfs
should continue working mostly as-is, apart from adapting to the
texture list changes and getting the native OpenGL texture id out of
the QRhiTexture)

As QQuickWidget is way too complicated to just port as-is, an rhi
manual test (rhiwidget) is introduced as a first step, in ordewr to
exercise a simple, custom render-to-texture widget that does something
using a (not necessarily OpenGL-backed) QRhi and acts as fully
functional QWidget (modeled after QOpenGLWidget). This can also form
the foundation of a potential future QRhiWidget.

It is also possible to force the QRhi-based flushing always,
regardless of the presence of render-to-texture widgets. To exercise
this, set the env.var. QT_WIDGETS_RHI=1. This picks a
platform-specific default, and can be overridden with
QT_WIDGETS_RHI_BACKEND. (in sync with Qt Quick) This can eventually be
extended to query the platform plugin as well to check if the platform
plugin prefers to always do flushes with a 3D API.

QOpenGLWidget should work like before from the user's perspective, while
internally it has to do some things differently to play nice and prevent
regressions with the new rendering architecture. To exercise this
better, the qopenglwidget example gets a new tab-based view (that could
perhaps replace the example's main window later on?). The openglwidget
manual test is made compatible with Qt 6, and gets a counterpart in form
of the dockedopenglwidget manual test, which is a modified version of
the cube example that features dock widgets. This is relevant in
particular because render-to-texture widgets within a QDockWidget has
its own specific quirks, with logic taking this into account, hence
testing is essential.

For existing applications there are two important consequences with
this patch in place:

- Once the rhi-based composition is enabled, it stays active for the
lifetime of the top-level window.

- Dynamically creating and parenting the first render-to-texture
widget to an already created tlw will destroy and recreate the tlw
(and the underlying window). The visible effects of this depend on the
platform.  (e.g. the window may disappear and reappear on some,
whereas with other windowing systems it is not noticeable at all -
this is not really different from similar situtions with reparenting
or when moving windows between screens, so should be acceptable in
practice)

- On iOS raster windows are flushed with Metal (and rhi) from now on
(previously this was through OpenGL by making flush() call
composeAndFlush().

Change-Id: Id05bd0f7a26fa845f8b7ad8eedda3b0e78ab7a4e
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-03-11 21:25:00 +01:00
Tor Arne Vestbø
8ccf1080fc tst_QLocalSocket: Clean up leftover local sockets before listening
If a test crashes it might leave local sockets, causing test failures
on subsequent runs due to the socket already being "in use".

Pick-to: 6.3
Change-Id: Ie1107c414f4819026907071c7b8281b2e27b8541
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-03-11 20:32:08 +01:00
Tor Arne Vestbø
d5b3238def tst_QLocalSocket: Output error when listening fails
Pick-to: 6.3
Change-Id: I742de5f522e4a28794abdee863eea2758536d392
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-03-11 20:32:08 +01:00
Marc Mutz
d743fd0d0a qDecodeDataUrl(): treat ";base64" marker as case-insensitive
RFC2397 doesn't explicitly mention it, but references RFC2045, which,
in Section 2, states:

> All media type values, subtype values, and parameter names as
> defined are case-insensitive.

and goes on, in 6.1:

>   mechanism := "7bit" / "8bit" / "binary" /
>                  "quoted-printable" / "base64" /
>                  ietf-token / x-token
>
>   These values are not case sensitive

So regardless of whether "base64" is a parameter name, or a mechanism,
we need to treat it case-insensitively.

Use QLatin1String::endsWith() instead of QByteArray::endsWith(),
because the former takes Qt::CaseInsensitive while the latter would
need a toLower().

Add a test.

As a drive-by, use the same trick for the existing case-insensitive
comparison with "charset".

As a further drive-by, fix inappropriate uses of QLatin1String (=
where they don't prevent allocations).

[ChangeLog][QtCore][QUrl] Now recognizes the ";base64" marker in
"data:" URLs case-insensitively.

Pick-to: 6.3 6.2
Change-Id: Ife6ba771553aaad3b7c119c1fa631f41ffa8f590
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-03-11 19:15:49 +00:00
Marc Mutz
61e3fe7fd9 Do not assume implicit string-ish → QColor conversion
We want to mark the corresponding QColor ctor(s) explicit.
Use Qt::GlobalColor or the new QColor::fromString() instead.

Change-Id: I68bf75a094e6821b97682de5a0ffd975834d22d0
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2022-03-11 20:15:49 +01:00
Marc Mutz
52092802b7 Rewrite tst_qdataurl as a data-driven test
... to make adding new test cases simpler.

Pick-to: 6.3 6.2 5.15
Change-Id: I54d08cebc7ae4bea9f0397ba3eec1ef6308a5161
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-03-11 20:15:49 +01:00
Marc Mutz
eded55cfbb tst_qflatmap: fix -Wunused-local-typedef (Clang)
False Positive, of course, since it's used in dependent callee
transparent_impl().

Amends 58e8ae5605.

Pick-to: 6.3
Change-Id: I7520fb7cf6bce28a5fd9381783ba349119309132
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-03-11 19:15:49 +00:00
Robert Löhning
0031c5cb79 QStyle: Fix cases when logicalValue is outside range
Change-Id: I410c40425d6677612dbe3a40cbaa1debba998064
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-03-10 12:39:11 +01:00
CI Insignificant Platforms Monitor Bot
797a6ca7e6 Blacklist: test cases blacklisted in tst_QSystemSemaphore:
- initialValue on qnx

Pick-to: 6.2
Pick-to: 6.3
Task-number: QTBUG-101618
Change-Id: Iea5a45690aa2e1225297c3b652d88864cf5f3ddb
Reviewed-by: CI Insignificant Platforms Monitor Bot <ci_insignificant_platforms_monitor_bot@qt.io>
2022-03-10 08:18:42 +00:00
Fabian Kosmale
ba6c1d2785 QProperty: fix threading issues
QObject's cache the binding status pointer to avoid TLS lookups.
However, when an object is moved to a different thread, we need to
update the cached pointer (as the original thread might stop and thus no
longer exist, and to correctly allow setting up bindings in the object's
thread).
Fix this by also storing the binding status in QThreadPrivate and
updating the object's binding status when moved. This does only work
when the thread is already running, though. If it is not running, we
instead treat the QThreadPrivate's status pointer as a pointer to a
vector of pending objects. Once the QThread has been started, we check
if there are pending objects, and update them at this point.

Pick-to: 6.2 6.3
Fixes: QTBUG-101177
Change-Id: I0490bbbdc1a17cb5f85044ad6eb2e1a8c759d4b7
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-03-10 07:21:11 +01:00
Noah Davis
64ffe0aacb Widgets: use QPlatformTheme::ButtonPressKeys for pressing buttons
QComboBox is included because it works like a button when it is not
editable. QGroupBox is included because it has a checkbox and QCheckBox
is a subclass of QAbstractButton.

Change-Id: Iad89259314e77f78c915dce83ec601df94c88941
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2022-03-09 19:13:41 -05:00
Robert Löhning
4b49c2006f QStyle: Fix overflows and crash when converting slider positions
Qt Creator crashes when max is INT_MAX and min is -1, see bugreport.

Change-Id: I441e76c0ff87052083ed3d77e6085b186402e5d8
Fixes: QTBUG-101581
Pick-to: 6.2 6.3
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-03-09 20:38:16 +00:00
Sona Kurazyan
82e12c79b2 Add an overload of QStringView::count() for QLatin1String
Required for the API symmetry between QStringView and QLatin1String.

[ChangeLog][QtCore][QStringView] Added an overload of
QStringView::count() for QLatin1String.

Change-Id: Ic49a4b31e8f6f0969eff0f792654d23a60e06c49
Task-numer: QTBUG-98431
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-03-09 15:58:47 +01:00
Sona Kurazyan
30d28810ee Add QLatin1String::count(needle)
[ChangeLog][QtCore][QLatin1String] Added QLatin1String::count(needle).

Task-number: QTBUG-98433
Change-Id: I31c9fdf14fd81500722ff9f5998eadf0e6cedc5c
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-03-09 15:58:47 +01:00
Marc Mutz
b142d2ad73 tst_qflags: test w/and w/o QT_TYPESAFE_FLAGS
Also contains some fixes which fix the Windows build, amending
e1b8257dee.

Pick-to: 6.3
Fixes: QTBUG-101294
Fixes: QTBUG-101304
Change-Id: I779f50fc705ed32f0314daf28b39b477a7fe925d
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-03-08 11:16:19 +01:00
Marc Mutz
5235b1bdc8 tst_qstringapisymmetry: check expected overloads are selected
Check that the expected overloads are selected in
QString/QAnyStringView overload sets.

Pick-to: 6.3
Change-Id: I38148c20a72eb60cf86844a39fe0ed419d2fa562
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-03-08 06:51:11 +01:00
Marc Mutz
78b6876974 Long live QColor::fromString()!
It is customary for Qt types that can be constructed from string-ish
to provide a fromString() named constructor. QColor didn't, relying
instead on a set of overloaded implicit and explicit constructors.

Add the named constructor, with the intent to deprecate the string-ish
QColor constructors after a grace period.

To prevent new users from using known-to-become-deprecated API, mark
the old functions as \obsolete.

Also rename isValidColor() to isValidColorName(). The only reason why
these are lumped together in single commit is so that their docs can
refer to each other instead of having to temporarily refer to obsolete
API.

[ChangeLog][QtGui][QColor] Added fromString() and isValidColorName(),
both taking QAnyStringView.

Task-number: QTBUG-101389
Change-Id: I2857c728257ad2f14c7c968b45547bdf07c44b63
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-03-08 06:51:10 +01:00
Volker Hilsheimer
3f5a424264 Move cursor out of the way before running test
Without this change, the test fails when run twice in a row. Also, skip
the test if we can't move the cursor.

Pick-to: 6.3
Change-Id: Ic45c073007d114fbd7825cedef6761c1e410b4af
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-03-08 01:52:32 +01:00
Volker Hilsheimer
e27e3ad546 Un-blacklist test that's always skipped on macOS
Pick-to: 6.3
Change-Id: I045e1923b471f6bb1d482f32924f190a94b21d2a
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-03-08 01:52:32 +01:00
CI Insignificant Platforms Monitor Bot
d60e29cab7 Blacklist: test cases blacklisted in tst_QTouchEvent:
- multiPointRawEventTranslationOnTouchPad on windows-11

Pick-to: 6.2
Pick-to: 6.3
Task-number: QTBUG-101519
Change-Id: Idbba677893f559ee239739d8c78aa820d974e120
Reviewed-by: CI Insignificant Platforms Monitor Bot <ci_insignificant_platforms_monitor_bot@qt.io>
2022-03-07 22:14:10 +00:00
Marc Mutz
53890b5d3c qtestmouse.h: compile with QT_TYPESAFE_FLAGS
Also include the comprehensive tests for bool cast compilation which I
originally wrote to confirm that the QTEST_ASSERT() change should be™
correct.

Pick-to: 6.3
Task-number: QTBUG-101406
Change-Id: I9a2871bfd4be9999b7a720bec775bba7aeffbe24
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2022-03-07 18:25:35 +01:00
Tor Arne Vestbø
9e01827193 Add QFileInfo::isAlias() to reflect whether the file is a macOS alias
Change-Id: I772066d0d8e69893f7c4aee1cd2305d46d5834c4
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-03-06 18:46:54 +01:00
Thiago Macieira
49722de995 QWeakPointer: befriend other QWeakPointers
Commit c677b3b8af added move constructors,
which introduced the issue.

Pick-to: 6.2 6.3
Fixes: QTBUG-100795
Change-Id: I74249c52dc02478ba93cfffd16d2c879b923e352
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2022-03-04 19:00:45 -08:00
Sona Kurazyan
f39f539858 Add numeric conversion methods to QLatin1String
[ChangeLog][QtCore][QLatin1String] Added numeric conversion
methods.

Task-number: QTBUG-98433
Change-Id: I414577ae715debe3d5ba9c6a160859aca790e017
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-03-05 02:03:17 +01:00
Edward Welbourne
f0333355dd Add tests for an assertion seen on Windows
QDateTimeEdit's default constructor instantiates the start of
1752-09-14 as its default earliest time; however Friedeman has seen
this triggering an assertion. The QDTE tests should be picking that up
anyway, but let's overtly test it in QDate's startOfDay testing, too.

Change-Id: Ifae87f2695ac3a7993c173a7c21809c87d5daa71
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-03-04 23:26:13 +01:00
Ivan Solovev
5133ed072a Android: skip crashing tst_QPlainTextEdit::ensureCursorVisibleOnInitialShow
The test crashed for some reason, so other testcases are also not
executed. Skip the test for now to enable more tests in the CI

Task-number: QTBUG-89402
Pick-to: 6.3 6.2
Change-Id: I5ad38645d1b8f86c64da7208c0ae4f66d126c7d9
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2022-03-04 22:20:18 +01:00
Ivan Solovev
79dcb2657c Android: unblacklist tst_QPlainTextEdit tests
Most of the blacklisted tests were already fixed earlier.

The tst_QPlainTextEdit::adjustScrollbars() test needed a small fix
to show the window non-fullscreen, so that the scrollbar could appear.

Task-number: QTBUG-87423
Task-number: QTBUG-89402
Pick-to: 6.3
Change-Id: I849f411a5798053742323fc4db3fe30f2b690a8b
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2022-03-04 22:20:18 +01:00
Marc Mutz
1931689c7d tst_qstringapisymmetry: check QString/QAnyStringView overloads w/Q_WEAK_OVERLOAD flipped
This overload set may come in handy to cushion some of the concerns
regarding replacing QString functions with QAnyStringView ones.

Overloading with a Q_WEAK_OVERLOAD QAnyStringView function requires
users to jump through hoops in order to avoid the QString overload,
but with the Q_WEAK_OVERLOAD roles reversed, the QAnyStringView
overload becomes the preferred version, relegating the QString
overload to a fall-back to facilitate sharing where it makes sense
(e.g. for QObject::setObjectName()).

Pick-to: 6.3
Change-Id: Ic65ead505beee627976a306e2d430e800540a600
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2022-03-04 08:39:07 +01:00
Sona Kurazyan
ebfe4318b8 Fix tst_qstringapisymmetry::count* to test all argument combinations
Use two template parameters for the haystack and needle types, to test
all possible combinations of all argument types.

Note that the tests for QByteArray::count() are removed: it doesn't
make sense to have them in tst_qstringapisymmetry, and we already have
the symmetry tests for QByteArray in tst_qbytearrayapisymmetry.

Change-Id: I33901fd135eb7433f0d45300a7248aef4d40324a
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-03-04 04:05:12 +01:00
Sona Kurazyan
b8755e2a4d Fix an error in tst_QStringApiSymmetry::count_impl()
Don't use the haystack as needle when testing count() for QLatin1String.
This wasn't caught earlier, since QLatin1String has no count() yet, and
the codepath was never tested.

Pick-to: 6.3 6.2
Change-Id: I2764070894ddce047eceaea52456e5a521252dab
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-03-04 04:05:12 +01:00
Ivan Solovev
d589f3eefe Android: unblacklist tst_toolsupport::offsets
The test is no longer failing on Android in dev and 6.3, but still
failing in 6.2.
I think it's fixed by 63a35898f4
which is integrated into dev and 6.3

Task-number: QTBUG-87396
Pick-to: 6.3
Change-Id: I82e0aac1547f8e43353f0948cd3f91b4b8f9720e
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2022-03-04 02:37:11 +01:00
Sona Kurazyan
e440fec7fc Add literal operators for QLatin1String and QLatin1Char
The operators are declared in the Qt::Literals::StringLiterals
namespace, to avoid collisions in the global namespace.

[ChangeLog][QtCore][QLatin1String] Added literal operator""_L1 that
converts string literals and chars to QLatin1String and QLatin1Char.

Fixes: QTBUG-98434
Change-Id: Ia945a6acf4b8d4fbbb5f803264e4d79d7b17a8da
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2022-03-04 01:58:10 +01:00
Giuseppe D'Angelo
0deff80eab Associative containers: add a way to obtain a key/value range
Our associative containers' iterator's value_type isn't a destructurable
type (yielding key/value). This means that something like

  for (auto [k, v] : map)

doesn't even compile -- one can only "directly" iterate on the
values. For quite some time we've had QKeyValueIterator to allow
key/value iteration, but then one had to resort to a "traditional" for
loop:

  for (auto i = map.keyValueBegin(), e = keyValueEnd(); i!=e; ++i)

This can be easily packaged in an adaptor class, which is what this
commmit does, thereby offering a C++17-compatible way to obtain
key/value iteration over associative containers.

Something possibly peculiar is the fact that the range so obtained is
a range of pairs of references -- not a range of references to pairs.
But that's easily explained by the fact that we have no pairs to build
references to; hence,

 for (auto &[k, v] : map.asKeyValueRange())

doesn't compile (lvalue reference doesn't bind to prvalue pair).
Instead, both of these compile:

  for (auto [k, v] : map.asKeyValueRange())
  for (auto &&[k, v] : map.asKeyValueRange())

and in *both* cases one gets references to the keys/values in the map.
If the map is non-const, the reference to the value is mutable.

Last but not least, implement pinning for rvalue containers.

[ChangeLog][QtCore][QMap] Added asKeyValueRange().
[ChangeLog][QtCore][QMultiMap] Added asKeyValueRange().
[ChangeLog][QtCore][QHash] Added asKeyValueRange().
[ChangeLog][QtCore][QMultiHash] Added asKeyValueRange().

Task-number: QTBUG-4615
Change-Id: Ic8506bff38b2f753494b21ab76f52e05c06ffc8b
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-03-04 00:21:44 +01:00
Ievgenii Meshcheriakov
16b614f2e1 Network: Use system publicsuffix database copy when available
[ChangeLog][Network][QNetworkCookieJar] It is possible to use
system's copy of publicsuffix database when it is available.
This behavior is enabled by default on Linux and can be
controlled using new command line switches -system-publicsuffix,
-qt-publicsuffix, -no-publicsuffix, and -publicsuffix=all.

Fixes: QTBUG-95889
Change-Id: I911e1a13c1422cdc35851953309fff064e7c5f26
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-03-03 15:56:09 +01:00
Marc Mutz
6f5c78fe3d QFlatMap: add remove_if
The existing API of QFlatMap did not allow efficient removal of
elements:

- std::remove_if does not apply, because it works by moving elements
  back in the range onto those that need to be removed, which doesn't
  work in flat_map's case, because, like for all associative
  containers, the key in value_type is const.

- The node-based erase-loop (over it = cond ? c.erase(it) :
  std::next(it)) works, but, unlike in traditional associative
  containers, is quadratic, because flat_map::erase is a linear
  operation.

According to Stepanov's principle of Efficient Computational Basis
(Elements of Programming, Section 1.4), we're therefore missing API.

Add it.

I couldn't make up my mind about the calling convention for the
predicate and, despite having authored a merged paper about erase_if,
can never remember what the predicate is supposed to take, so be fancy
and accept all: (*it), (it.key(), it.value()), (it.key()). This means
that unary predicates can either not be generic or must be properly
constrained to distinguish between pair<const K, V> and K, but that's
not necessarily a bad thing.

There's no reason to supply a Qt-ified removeIf on top of the standard
name, because this is private API and doubling the names would do
nothing except double the testing overhead.

Fixes: QTBUG-100983
Change-Id: I12545058958fc5d620baa770f92193c8de8b2d26
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-03-03 00:25:14 +01:00
Marc Mutz
b2c7f17b94 tst_qflags: don't suppress deprecation warnings
... if there aren't any.

Pick-to: 6.3
Change-Id: I8531e0c1c3ca41d1b1a9d55c9d11782bd63b6f76
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-03-03 00:18:39 +01:00
Sona Kurazyan
e4aa4d4f3d Add compile-time checks for QLatin1String
Change-Id: If1b10a857275fb53c5d0b230bf6d11ce3e1ff2ca
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-03-02 22:22:36 +01:00
Sona Kurazyan
736213bf66 QLatin1String: add missing APIs for compatibility with Qt string views
As a drive-by, fixed misleading wording used in docs.

[ChangeLog][QtCore][Potentially Source-Incompatible Changes][QLatin1String]
Added QLatin1String(std::nullptr_t) constructor, which makes
QLatin1String(0) call ambiguous. To fix the ambiguity, nullptr
must be passed instead of 0.

Task-number: QTBUG-98433
Change-Id: I2b888aa23469343d78aa640dc39a6028b77165dd
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-03-02 22:22:36 +01:00
Liang Qi
586fd9e034 tests: XFAIL a few in tst_QStaticText on Wayland
Task-number: QTBUG-100982
Pick-to: 6.3 6.2
Change-Id: I18cdb79d9261bac40cc619f9d327d0ef7ed722c4
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-03-02 15:37:33 +01:00
Liang Qi
e49d2daf19 tests: XFAIL tst_QOpenGL::bufferMapRange() on Wayland
Task-number: QTBUG-100918
Pick-to: 6.3 6.2
Change-Id: I1b892a80bcb44e0e4f658ed7073c54900d8a358c
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-03-02 15:37:33 +01:00
Liang Qi
2b3d11383e tests: XFAIL tst_QImageReader::setScaledClipRect() SVG/SVGZ
on Wayland

Task-number: QTBUG-100917
Pick-to: 6.3 6.2
Change-Id: I66c42bb0ceca83fd0531159c606d22c58b18b371
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-03-02 15:37:32 +01:00
Eirik Aavitsland
423b650938 Fix painting clipping glitches with fractional scaling
In QPainter, clipping can only be done on whole pixels. The various
ways of specifying a clipping rectangle to the QPainter API have been
inconsistent in how fractional rectangles (either specified directly,
or as a result of fractional scaling) are mapped (rounded) to integer
coordinates.

Also, the mappings have not made sure to keep the edge-to-edge
property of clip rects under scaling. This is particularly important
when scaling QRegions with multiple rects, as QRegion is designed on
the assumption that an area can be described as a set of edge-to-edge
rects.

The fix rounds a clip rect identically with a fill rect. (Indeed, a
followup plan would be to merge QRasterPaintEngine's
toNormalizedFillRect() with the rectangle rounding function in this
commit).

Notably, a QRectF clip is now interpreted the same as a QPainterPath
clip describing the same area.

This modifies d9cc149995

Task-number: QTBUG-100329
Fixes: QTBUG-95957
Task-number: QTBUG-100343
Pick-to: 6.3
Change-Id: Iaae6464b9b17f8bf3adc69007f6ef8d623bf2c80
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-03-02 13:58:10 +00:00
Andreas Buhr
5a8052f9c1 Activate tst_qxmlstream for Android
tst_qxmlstream was disabled because it crashed. It does not any more.
But it extracted an input zip archive in-place, which is not
possible on Android. To resolve this, input files are
copied to a temporary directory first.
Also, input directories were given to rcc. rcc has a problem
with recursive directories. To circumvent this,
the file list is created in CMake and then given to rcc.

Task-number: QTBUG-87671
Pick-to: 6.2 6.3
Change-Id: I88bb823b9e5c085404e263d4a648d65c9cd6024c
Reviewed-by: Rami Potinkara <rami.potinkara@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2022-03-02 14:55:00 +01:00
Pasi Petäjäjärvi
f8f8c38ec7 CI: Blacklist systemFixedFont for QNX
QNX tests are run under QEMU so have the same problem as b2qt

Pick-to: 6.2 6.3
Task-number: QTBUG-100948
Change-Id: I2abc8a4bca9e8ba414197721301d493296e7ce0b
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2022-03-02 15:27:36 +02:00
Ivan Solovev
e5c23db60c Android: temporary skip tst_QDialog::dialogInGraphicsView
This test crashed and prevents other testcases from execution.
The test requires a proper fix, but that's not trivial, so skipping
to enable more tests in the CI for now.

Task-number: QTBUG-101321
Pick-to: 6.3 6.2
Change-Id: I1bd4b1182cc868a36391a718457eae647675fc17
Reviewed-by: Andreas Buhr <andreas.buhr@qt.io>
2022-03-02 12:14:26 +01:00
Ivan Solovev
ef22545184 Android: skip tst_QDialog::snapToDefaultButton
This test uses the cursor. However we have no cursor support on Android.
Skip the test instead of blacklisting it, because that is the correct
behavior.

Fixes: QTBUG-87389
Pick-to: 6.3 6.2
Change-Id: I1a2d2dd406b3d7da1bc70b51c2072a83d9a29ca5
Reviewed-by: Andreas Buhr <andreas.buhr@qt.io>
2022-03-02 12:14:26 +01:00