Commit Graph

13186 Commits

Author SHA1 Message Date
Marc Mutz
59600a514b QTest: de-inline QVERIFY_THROWS_EXCEPTION message formatting
Extract Method QTest::qCaught() to take the string handling out of the
header. This should help a bit in speeding up compilation of large
unit test files (provided they use QVERIFY_THROWS_EXCEPTION), although
I have no data to support that.

Since we changed the error message, update the selftest accordingly.

Change-Id: Id4a3c8c34d5df8d0c7a861106d269097f4a6de5c
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-11-26 09:57:59 +01:00
Volker Hilsheimer
77de4a9bb4 Fix and complete style sheet support for QToolButton
Amends 2b2e7b2ac5, which rewrote the
rendering to remove the conflation of menu arrows and arrow icons, but
introduced double rendering of the arrow icons if only the border was
styled.

Add a baseline test for style sheets, with a test function for
QToolButton configured in various ways and styled with different style
sheets.
The new test case includes a Qt 5 build system so that we can compare Qt
5.15 with Qt 6.

Fixes: QTBUG-98286
Pick-to: 6.2 6.2.2
Change-Id: I09cdc829c1a7e7913df4c3768dbe44b6dba4778b
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2021-11-26 09:36:07 +01:00
Mitch Curtis
efb283fb7f Add QTest::failOnWarning
This solves the long-standing problem of not being able to easily
fail a test when a certain warning is output.

[ChangeLog][QtTest] Added QTest::failOnWarning. When called in a test
function, any warning that matches the given pattern will cause a test
failure. The test will continue execution when a failure is added.
All patterns are cleared at the end of each test function.

Fixes: QTBUG-70029
Change-Id: I5763f8d4acf1cee8178be43a503619fbfb0f4f36
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-11-26 04:47:24 +01:00
Marc Mutz
1edf153a6b Long live QVERIFY_THROWS_EXCEPTION!
Use variable args macros to swallow any extra commas in the
expression. To use this, the type of the exception has to be first.
Use Eddy's suggestion for a new name to avoid breaking the old macro.

[ChangeLog][QtTest] Added QVERIFY_THROWS_EXCEPTION, replacing
QVERIFY_EXCEPTION_THROWN, which has therefore been deprecated.

Change-Id: I16825c35bae0631c5fad5a9a3ace4d6edc067f83
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-11-26 04:44:26 +01:00
Ievgenii Meshcheriakov
174af05400 QDir: Add support for setting directory permissions to mkdir()
This patch adds an overload of the QDir::mkdir() method that
accepts permissions. This allows setting of the directory
permissions at the time of its creation.

[ChangeLog][QtCore][QDir] Added QDir::mdkir() overload that
accepts permissions argument.

Task-number: QTBUG-79750
Change-Id: Ic9db723b94ff0d2da6e0b819ac2e5d1f9a4e2049
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-11-26 03:39:33 +01:00
Giuseppe D'Angelo
8c9875893b Q(Multi)Map: prevent dangling key/value after detach()
Q(Multi)Map mutating functions that take reference to a key and/or a
value (e.g. insert(), take(), etc.) must make sure that those references
are still valid -- that is, that the referred objects are still alive --
after the detach() call done inside those functions.

In fact, if the key/value are references into *this, one must take extra
steps in order to preserve them across the detach().

Consider the scenario where one has two shallow copies of QMap, each
accessed by a different thread, and each thread calls a mutating
function on its copy, using a reference into the map (e.g.
map.take(map.firstKey())). Let's call the shared payload of this QMap
SP, with its refcount of 2; it's important to note that the argument
(call it A) passed to the mutating function belongs to SP.

Each thread may then find the reference count to be different than 1 and
therefore do a detach() from inside the mutating function. Then this
could happen:

Thread 1:                         Thread 2:

detach()                          detach()
  SP refcount != 1 => true          SP refcount != 1 => true
    deep copy from SP                 deep copy from SP
    ref() the new copy                ref() the new copy
  SP.deref() => 1 => don't dealloc SP
  set the new copy as payload
                                    SP.deref() => 0 => dealloc SP
                                    set the new copy as payload

  use A to access the new copy      use A to access the new copy

The order of ref()/deref() SP and the new copy in each thread doesn't
really matter here. What really matters is that SP has been destroyed
and that means A is a danging reference.

Fix this by keeping SP alive in the mutating functions before doing a
detach(). This can simply be realized by taking a local copy of the map
from within such functions.

remove() doesn't suffer from this because its implementation doesn't do
a bare detach() but something slightly smarter.

Change-Id: Iad974a1ad1bd5ee5d1e9378ae90947bef737b6bb
Pick-to: 6.2
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-11-26 02:14:52 +01:00
Edward Welbourne
7039fb1e42 Skip QTimeZone::checkOffset() if there are no valid zones to test
Change-Id: I62df34fe40b8e89b99912e8ad0d1d2f2f11fd71e
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2021-11-26 02:14:52 +01:00
Edward Welbourne
bcc15f36cc Check for relevant zones existing when adding data rows
tst_QDate::startOfDay_endOfDay_data() naively assumed some zones would
exist. They don't on QNX, apparently.

Change-Id: I3a364964d03f59f5869b4b7639f089dd303180b1
Reviewed-by: Andreas Buhr <andreas.buhr@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2021-11-26 02:14:52 +01:00
Edward Welbourne
0cad974d0d Add a note to save the next reader some confusion
I was briefly confused about why an Etc/GMT+3 test was using GMT as
localtime. Fortunately I worked it out before mis-"correcting" it.

Change-Id: I7b0473c7d3974ef186e1170cf4999aca52aaaf45
Reviewed-by: Andreas Buhr <andreas.buhr@qt.io>
2021-11-26 02:14:52 +01:00
Edward Welbourne
6437bd240f Skip test if it has no data-rows
On QNX, tst_QDateTime::fromStringStringFormat_localTimeZone_data()
failed to set up any rows for the data-driven tests to fetch, leading
to an assertion failure on trying to fetch a row.

Change-Id: I7c405b1142a8cb6d445b501ea44fe3d440570cf3
Reviewed-by: Andreas Buhr <andreas.buhr@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2021-11-26 02:14:52 +01:00
Marc Mutz
f4e89d58da QVERIFY_EXCEPTION_THROWN: re-throw unknown exceptions
Swallowing unknown exceptions is dangerous business, as the exception
might be a pthread cancellation token, the swallowing of which would
terminate the program.

Instead of returning from the catch-all-clause, therefore, re-throw
the unknown exception.

Fix tst_verifyexceptionthrown failure cases that use
non-std::exception-derived true negative exceptions to not let the
exception escape from the test function.

As a drive-by, pretty up the macro's docs.

[ChangeLog][QtTest][QVERIFY_EXCEPTION_THROWN] Now re-throws unknown
exceptions (= not derived from std::exception) (was: swallowed them
and returned from the test function), in order to play nice with
pthread cancellation.

Pick-to: 6.2 5.15
Change-Id: Ic036d4a9ed4b7683fa67e27af8bcbae0eefdd0da
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-11-25 13:00:55 +01:00
Fabian Kosmale
925ad78024 tst_qmetatype: Temporarily disable expensive tests on QNX
The compiler runs out of memory and fails to compile tst_qmetatype.cpp.
Set TST_QMETATYPE_BROKEN_COMPILER from a previous compiler workaround
for QNX to disable the most expensive part of the test.

Task-number: QTQAINFRA-4669
Change-Id: I3a99b6b790dc074e9d1db262e758555fb45e4331
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2021-11-25 09:53:34 +01:00
Mårten Nordheim
8f8775adf3 QHash: fix thread race around references and detaching
If we detach from a shared hash while holding a reference to a key from
said shared hash then there is no guarantee for how long the reference
is valid (given a multi-thread environment).

Pick-to: 6.2
Change-Id: Ifb610753d24faca63e2c0eb8836c78d55a229001
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2021-11-25 08:52:39 +00:00
Mårten Nordheim
a92619d950 QAuthenticator: Filter out algorithms we don't support
Which is anything other than MD5

Pick-to: 6.2 5.15
Fixes: QTBUG-98280
Change-Id: Ifbf143f233ee5602fed1594e3316e6b2adec1461
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-11-25 08:52:33 +00:00
Eirik Aavitsland
8a883dea1c Update baseline testing framework
Merge in various minor changes and fixes that have been done to the
branched copy in qtquick3d, and clean out some outdated code.

Mostly just coding style fixes and cleanups, but also:

- adds -keeprunning command line parameter, intended for tests that by
  default exits early if it seems the platform is too unstable
  (e.g. crashing) for a meaningful testrun.

- Changes behaviour for fuzzy matches, from SKIP to PASS. The (mis)use
  of QSKIP was done to force log output; now the output is just
  printed by qInfo() instead.

Pick-to: 6.2
Change-Id: I46e77a94cc5b1980ac420086c2ae88dc9b84ef12
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-11-24 11:47:43 +01:00
Volker Hilsheimer
95907f9be4 Add variations of QPushButton with default property set
Change-Id: Ie928575b131c7031da9a4d735159ba3d14ccad6c
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2021-11-24 07:40:47 +01:00
Thiago Macieira
84c9fcffee tst_QHashSeed: improve quality of the quality() test
We expect to produce all-bits-set in the combined OR'ed value of the
seed, so instead of counting how many bits got set and reporting that,
simply compare to -1 and count how long it took to get that far.

To make sure, I've increased the number of iterations by 50%.

Change-Id: I89446ea06b5742efb194fffd16ba37b2d93c19ef
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-11-23 20:48:08 -08:00
Thiago Macieira
5eda43de89 tst_QHashSeed: reset the global seed in each iteration
QHashSeed is not a random number generator (though it uses one). It
returns the same value over and over again unless you reset it to a new,
random seed.

Fixes: QTBUG-98480
Change-Id: I89446ea06b5742efb194fffd16ba36601f08d794
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-11-23 12:19:32 -08:00
Joerg Bornemann
3f56950862 Move macdeployqt and windeployqt from qttools to qtbase
Having all *deployqt tools in qtbase will allow us to couple deployment
support more tightly with the build system.

Change-Id: I299efdacfa6b66a303bb3996ff3ff84e723210a5
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
2021-11-23 21:11:45 +01:00
Yuhang Zhao
e01c25e859 QtBase: replace windows.h with qt_windows.h
We have some special handling in qt_windows.h,
use it instead of the original windows.h

Change-Id: I12fa45b09d3f2aad355573dce45861d7d28e1d77
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-11-23 12:53:46 +08:00
Sona Kurazyan
102f7d31c4 Add support for combining multiple QFutures
[ChangeLog][QtCore] Added QtFuture::whenAll() and QtFuture::whenAny()
functions, returning a QFuture that becomes ready when all or any of the
supplied futures complete.

Task-number: QTBUG-86714
Change-Id: I2bb7dbb4cdc4f79a7a4fd494142df6a0f93a2b39
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-11-20 10:28:29 +01:00
Marc Mutz
229f356cef Short live q20::ssize()!
Extract the definition of q20::ssize() from tst_qanystringview.cpp,
where it had to be placed for its backport to 6.2.

Change-Id: I3f758c98a4b1efd453f4fc044b8d3f1a89de62d1
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2021-11-20 01:38:41 +00:00
Alexander Volkov
185c8d5adf Skip disabled proxy widgets when (back)tabbing
Fixes: QTBUG-98137
Pick-to: 6.2 5.15
Change-Id: If52053dce361b130ef7dcfaf747710d8ceb9bbcd
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-11-19 23:55:44 +03:00
Øystein Heskestad
18aff2b424 Add more verification when parsing http headers and add tests
Adding tests from QtWebSockets that will reuse QHttpHeaderParser

Task-number: QTBUG-80700
Change-Id: I76294a9156173314a3cf09160d0ca4e0d7c6ef3a
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-11-19 19:31:34 +01:00
Eskil Abrahamsen Blomfeldt
cde562cf6d Properly fix QFontDatabase test on Freetype
Amends 4dd5020fbdfdd34f1e4ec54521217e472942a4b4. I messed up the fix for
the XFAIL condition, since the font engine type we get from a normal QFont
will be QFontEngine::Multi regardless of whether the actual font engines
are Freetype or not. Use NoFontMerging to avoid this.

Pick-to: 6.2
Task-number: QTBUG-97995
Change-Id: I2298c997e6826e667dbb8e3d004821f296625ef7
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2021-11-19 15:59:41 +01:00
Pasi Petäjäjärvi
7490937609 Fix test when accessing patched plugin too fast
At least one OS (QNX) can't dlopen() a library that is still
open for writing elsewhere

Pick-to: 6.2
Change-Id: I2d4425d8c69162cdfa43c2523c7459def7839eb9
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-11-19 13:30:44 +00:00
Marc Mutz
b7f4041669 QAnyStringView: fix broken implicit conversion from QStringBuilder
Need to use QConcatenable<>::ConvertTo for SFINAE, the forwarded type
alias in QStringBuilder itself doesn't work.

[ChangeLog][QtCore][QAnyStringView/QStringBuilder] Implicit conversion
from QStringBuilder to QAnyStringView now works as advertised.

Pick-to: 6.2
Fixes: QTBUG-98138
Change-Id: I1c300675cf43b13017bc56398ae5d8c1c51e64fe
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-11-19 03:32:20 +01:00
Eskil Abrahamsen Blomfeldt
7102aa6b15 Fix assert in QFontComboBox when setting empty font
Don't crash if the font does not have any families set.

Pick-to: 6.2
Task-number: QTBUG-97995
Change-Id: I8dc2f2fc00309b6fff6d4a661ec6d659f30808af
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
2021-11-18 23:41:02 +01:00
Eskil Abrahamsen Blomfeldt
71faedc5b4 Fix deserializing Qt 5.x fonts through QDataStream
In Qt 5, fonts had both singular family and plural families properties,
and both were stored separately when streaming through QDataStream. The
families list was treated as an extension of family in this case, and
the primary font family was always the singular family property.

In Qt 6, it has been merged into one and family() is now just a
convenience for families().at(0).

But when reading files generated with Qt 5, we would ignore the fact
that these were previously separated. We would first read the family
entry into the families list, and then we would later overwrite this
with  an empty families list.

Instead, we detect streams created with Qt 5.15 or lower and make sure
we append the families list instead of overwriting it in this case. In
addition, we need to make sure we split up the list again when
outputting to Qt 5.x.

This adds a file generated with QDataStream in Qt 5.15 to the test to
verify.

[ChangeLog][Fonts] Fixed a problem deserializing the family of fonts
that had been serialized using QDataStream in Qt 5.

Pick-to: 6.2
Fixes: QTBUG-97995
Change-Id: Id3c6e13fc2375685643caee5f8e3009c00918ccb
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
2021-11-18 23:41:02 +01:00
Mike Achtelik
f7fd57075b Introduce Q_APPLICATION_STATIC
QObjects must be deleted if the QCoreApplication is being destroyed.
This was previously done by implementing custom code in qtbase and
other modules. So unify it and introduce a Q_APPLICATION_STATIC,
based on the Q_GLOBAL_STATIC, which centralises the logic.

Since we still have a few remaining living QObjects,
this comes in handy to fix those as well.

Task-number: QTBUG-84234
Change-Id: I3040a2280ff56291f2b1c39948c06a23597865c4
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-11-18 20:53:27 +01:00
Edward Welbourne
f75d36fd18 Fix macOS system locale's formatting of negative years
It leaves off the minus sign.

Change-Id: Iad72349368d8849330524144033453cbd79e9e7c
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2021-11-18 18:13:20 +01:00
Edward Welbourne
8926eb86c6 Fix formatting of dates before 1601 in MS system locale
The relevant MS system calls (say they) don't support date formatting
for years < 1601 (but apparently do in fact) and the year field of the
data structure is unsigned, so can't support years < 0. As a result,
the windows back-end for QSystemLocale failed for negative years.
So replace year < 1601 with a place-holder and substitute after
formatting.

Added new tests (based loosely on one in qtdeclarative that failed) to
verify that this actually works. These reveal that macOS also fails to
handle negative years; marked as expected failure there pending a fix.

Change-Id: I9b63cefd5f0b77a39cf1238549412de3e26ca1bd
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-11-18 18:13:20 +01:00
Marc Mutz
0e245c158f Add an initial tst_QAnyStringView
It's incomplet, but at least something.

Task-number: QTBUG-98138
Pick-to: 6.2
Change-Id: I4630a44b62b190dee8a8cc07822dd6ec67dbdc84
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Øystein Heskestad <oystein.heskestad@qt.io>
2021-11-18 17:13:19 +00:00
Volker Hilsheimer
79b2a43585 Add baseline test that allows comparing the rendering of widgets
Provide basic boiler plate that sets up the baseline (aka lancelot)
framework specifically for comparing the appearance of widgets, and
implement test functions for QSlider and QPushButton.

Widgets should always look the same if the QPA platform, the OS
version, and certain UI-impacting attributes are identical. Ie.
on any macOS 10.15 machine that runs in "Light" mode, widgets
look the same. On a macOS 11 machine, they might look different.
On an OpenSUSE machine using the fusion style things might look
different from a Ubuntu machine.

The helper function removes DPR differences - images are always
scaled to a DPR of 1.0, which allows us to compare the image\
content and not get distracted by them having different dimensions
(and the fuzzy comparison of images might make the system tolerate
scaling artefacts).

Note: For now, this test is meant to be run locally, either when
testing changes to style code, or when checking how QWidget based
UIs would look on newer version of an operating system. In CI the
test is run, but then skipped in CI as the baseline server is
not configured.

Change-Id: Ie33a9d979d934f0df6883757333ce2c5e2f7ef84
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-11-18 03:36:24 +00:00
Kai Köhne
b99adf7a81 Do not include qloggingcategory.h in public headers
Reduce overhead for including qguiapplication.h by splitting
up qnativeinterface.h into a public and a private part.

[ChangeLog][Potentially Source-Incompatible Changes] The
qguiapplication.h header no longer implicitly includes
qloggingcategory.h. If your code depends on the transitive
include, explicitly include <QLoggingCategory> where needed.

Pick-to: 6.2
Task-number: QTBUG-97601
Change-Id: Ic02327a1c3092e21730160af5c59a9d58dc1239c
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-11-16 17:26:04 +00:00
Marc Mutz
61d5783ba8 tst_qsctpsocket: fix compilation
The header for QTestEventLoop hadn't been included.

Pick-to: 6.2
Change-Id: Ife3418d1634c030c421c2aa55469f5a099386d4b
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-11-16 15:07:36 +01:00
Eirik Aavitsland
e8f93e38de Rename and restructure the baseline (lancelot) testing code
In preparation for addition of new baseline tests, establish a new
test category, "baseline". This is similar to the category
"benchmarks" in that it contains tests that use the QTest framework,
but conceptually are not unit tests, in contrast to those under auto/.

Move the existing QPainter baseline test, tst_lancelot, into this new
category, and rename it accordingly.

Baseline tests use the QBaselineTest extension to QTest. Move that
extension too into the tests/baseline directory, allowing the clean
out of the baselineserver directory.

Pick-to: 6.2
Change-Id: I1b527f5867c953b1d22be73798fcf7d1494712ea
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-11-16 14:01:50 +01:00
Zhang Hao
9a131b59ee QFontComboBox don't response qApp fontDatabaseChanged()
If QFontComboBox is instantiated in the form of new and call
QFontDatabase::addApplicationFont, QFontComboBoxPrivate::_q_updateModel()
will be called when the program exits, at this time qApp will crash.
Fix this by when program exiting, QFontComboBoxPrivate don't need
call _q_updateModel().

Fixes: QTBUG-98099
Done-With: Konstantin Ritt <ritt.ks@gmail.com>
Pick-to: 5.15 6.2
Change-Id: I3df3d19c3d1971288d60f2eef386262befbf396b
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2021-11-16 17:21:56 +08:00
Marc Mutz
ab67a6b126 tst_qvariant: fix -Wclass-memaccess
The source was already protected, but the destination wasn't.

Pick-to: 6.2
Change-Id: I300f19c3e65abd8bc1eef4309aefa11852d1c049
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-11-16 06:46:52 +01:00
Assam Boudjelthia
dfb4b7856a Android: check if objectClass() is not null in registerNativeMethods()
In case the class doens't have a default constructor, checking for
object.isValid() will give false because the object won't be created,
however, the class could still be loaded and we could have a valid
jclass.

Pick-to: 6.2
Fixes: QTBUG-96069
Change-Id: I8d59e26d9d7c0e8e363ce443937091a374a24473
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2021-11-15 19:00:21 +00:00
Edward Welbourne
f3e2689106 Revise (recently-added) yearSharingWeekDays() to take a QDate
This lets it avoid a two-digit year that would clash with month or day.
That shall make fixing up system locale date formatting run cleaner.

Add a test for QGregorianCalendar's two extensions.

Change-Id: I77083ff9d5e4035763250904a59fcf416286545b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-11-15 20:00:21 +01:00
Volker Hilsheimer
22634e0079 Make sure we paint overlapped children and siblings when moving far
In paintAndFlush, QWidgetRepaintManager subtracts opaque children if
the target isn't overlapped and isMoved is set to true. So in moveRect,
set isMoved to true after the blitting of movable areas, and reset it to
false if we have overlapped sibling or child regions. Otherwise, moving
so far that sourceRect is invalid (none of the original pixels are
visible after the move) we end up in a code path that sets isMoved to
true even with overlapping children or siblings, which then breaks
paintAndFlush's assumptions.

Reuse the test case written by Sergiy Korobov <tiamatenko@gmail.com> in
earlier attempts to fix this bug.

Fixes: QTBUG-26269
Pick-to: 6.2
Change-Id: If7443863f5eee79a80220cd587522122f42a21e4
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2021-11-15 18:25:50 +01:00
Li Xi
a0e7fbd4d5 Test result of qobject_cast before dereferencing
Since QMainWindow::setMenuWidget accepts a QWidget (allowing users to
implement their own menu widget), we need to use qobject_cast on the
stored widget to see if it is a QMenuBar before calling QMenuBar APIs.

This qobject_cast may return nullptr.

Pick-to: 6.2
Fixes: QTBUG-98247
Change-Id: Iff1dbd24fa7ca09098fe49c179770356c966251d
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-11-15 16:51:14 +01:00
Volker Hilsheimer
61aa482241 QTabBar: Support scrolling with a kinetic wheel
QTabBar implements wheelEvent to move the current index up or down. This
is useful for clicky mouse wheels, but a bad user experience when using
a kinetic wheel or touch pad, as every pixel movement will change the
current index.

Instead, scroll the entire tab bar when the wheel event comes from a
device that supports scroll phases, without changing the current index.

As drive-by's, fix the test introduced in aa09bea00c to
not leak memory or leave a test-specific style set on the QApplication
instance, which can break other tests.
Also, make relevant layout code in QTabBar respect the usesScrollButtons
property, const'ify local variables, and return an accepted QWheelEvent
if the event resulted in a change.

[ChangeLog][QtWidgets][QTabBar] Scrolling with a kinetic wheel or touch
pad scrolls the entire tab bar, without changing the current index.

Change-Id: I990e51466dd25c741877bbf0e197449f897a9efb
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2021-11-15 16:23:42 +01:00
Marc Mutz
ee4f69205a QReadWriteLocker: also benchmark recursive mode
Change-Id: Ic2e357f4702d05220cf6c96717672dcabacd78d6
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-11-15 15:17:26 +01:00
Volker Hilsheimer
6ff07ec23b macOS: make the slider knob big enough for BigSur and Monterey
The slider is very touch friendly from macOS 11 on, and the knob is quite
large. Give it some extra pixels, and adjust the test accordingly.

Pick-to: 6.2
Task-number: QTBUG-98093
Change-Id: Iedf6db1081cdd4013ca29ce760aea1e0361b1123
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2021-11-15 09:30:25 +01:00
Sona Kurazyan
eab40726be QFuture: support cancellation of continuation chain through parent
This change allows canceling the chain of continuations attached to a
future through canceling the future itself at any point of execution of
the chain.

[ChangeLog][QtCore][Important Behavior Changes] The chain of
continuations attached to a future now can be cancelled through
cancelling the future itself at any point of the execution of the chain,
as it was documented. Previously canceling the future would cancel the
chain only if it was done before the chain starts executing, otherwise
the cancellation would be ignored. Now the part of the chain that wasn't
started at the moment of cancellation will be canceled.

Task-number: QTBUG-97582
Change-Id: I4c3b3c68e34d3a044243ac9a7a9ed3c38b7cb02e
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-11-13 18:13:08 +01:00
Mårten Nordheim
3446313c7a Teach QOperatingSystemVersion to handle new OS entries in patch releases
Adding new entries to QOperatingSystemVersion in patch releases
was previously breaking our BC guarantees because the entries are
exported, thus users cannot freely switch between different
patch-releases without a recompile if they adopted the new entries.

Move the data itself to a base class so that the entries can be
constructed inline.

Task-number: QTBUG-97808
Change-Id: Ic44f07488af8a04a3bedc10bebb740c4d68f43f3
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-11-12 18:06:44 +01:00
Andreas Buhr
838edd9c48 Fix QMultiHash::operator== crash
QMultiHash::operator== crashes when comparing two unequal objects.
This patch fixes it.

Pick-to: 6.2
Fixes: QTBUG-98265
Change-Id: Ibf9fef3372a2b4581843be5f25e65cc9a55ef64d
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-11-11 22:44:10 +01:00
Thiago Macieira
090c7e3262 QDuplicateTracker: add clear()
I'll need it in QFactoryLoader.

Pick-to: 6.2
Change-Id: Ice04365c72984d07a64dfffd16b47f68d25252b4
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-11-11 13:26:14 -08:00