Commit Graph

11981 Commits

Author SHA1 Message Date
Giuseppe D'Angelo
6702614c97 QStringView test: avoid narrowing
Use '\0' (char) instead of 0 (int).

Change-Id: I866d08e7b07ae555fcf0244a8614e3e04a0bc567
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-11-07 19:33:36 +01:00
Shawn Rutledge
f5c7799f59 Support the markdown underline extension
MarkdownDialectGitHub now includes this feature, so *emph* is italicized
and _emph_ is underlined. This is a better fit for QTextDocument capabilities;
until now, _underlined_ markdown could be read, but would be rendered with
italics, because in CommonMark, *emphasis* and _emphasis_ are the same.
But QTextMarkdownWriter already writes underlining and italics distinctly
in this way.

[ChangeLog][QtGui][Text] By default (with MarkdownDialectGitHub), markdown
_underline_ and *italic* text styles are now distinct.

Fixes: QTBUG-84429
Change-Id: Ifc6defa4852abe831949baa4ce28bae5f1a82265
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-11-07 09:35:11 +01:00
Karsten Heimrich
e9b92c926d QDebug: add op<<(QUtf8StringView)
[ChangeLog][QtCore][QDebug] Added streaming of QUtf8StringViews.

Task-number: QTBUG-88029
Change-Id: Ifcb001cfebddd79ce1cdbfef5bcc19f7c56679ec
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-11-07 09:35:11 +01:00
Karsten Heimrich
7cad91a7df QDebug: add op<<(QByteArrayView)
[ChangeLog][QtCore][QDebug] Added streaming of QByteArrayViews.

Task-number: QTBUG-88029
Change-Id: I66f5cc45a0438dbaacb1754cb3c669b3717f528b
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-11-07 09:35:11 +01:00
Giuseppe D'Angelo
a6903f3da8 Fix a mistake when using QLatin1String::arg
QLatin1String::arg (and QStringView::arg) only support string-like
arguments, and QLatin1String("%1").arg(123) does *not* produce
the string "123" -- 123 gets routed through the QChar(int) constructor
instead. Fix by using QString.

Change-Id: I96371a15e1af957ef8133e30e79eb3e22b3e9d32
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-11-07 06:25:36 +01:00
Shawn Rutledge
9a1a15b42f Introduce QEvent::isSinglePointEvent()
This makes high-level event dispatching easier: for example we often
need to cast an event to access getters like button() and buttons().
We can so far assume that any QPointerEvent that is not a QTouchEvent
is a QSinglePointEvent; but more explicit type-checking looks safer.

Implemented in a similar way as c7f7279969.

Change-Id: I980d759e2a7538b6b30fd3bdc3be0c351ec6c246
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-11-07 06:24:38 +01:00
Alexandru Croitor
b13bad3ab0 tests: Blacklist failing tests on MinGW
Also move redudant Android entries to already existing sections.

Task-number: QTBUG-35109
Task-number: QTBUG-88250
Change-Id: I9d5eaa5a3f11b55566a7c74f84a972a0c272cfea
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2020-11-06 21:03:51 +00:00
Giuseppe D'Angelo
c9b8c2cddb QLineEdit: check a int->QChar conversion, and make it explicit
QStyle::styleHint returns int, and that int was simply used to
build a QChar representing the "password mask" character.
Enforce that it actually fits and then do an explicit cast.

(In general, of course, this is an API flaw; styleHint should
somehow return a QString for this use case).

Change-Id: Ifb6181b229b91cc84859cb9b9d57e21d6748c31a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: David Faure <david.faure@kdab.com>
2020-11-06 10:16:32 +01:00
Giuseppe D'Angelo
ff55b6ed48 qmakelib test: build with qmake
A dependency was missing, causing qduplicatetracker_p not to be found.

Change-Id: I4076d6cf82d804354731c357bcdbfd03c3d42142
Reviewed-by: David Faure <david.faure@kdab.com>
2020-11-06 10:16:31 +01:00
David Skoland
28f7c95e3b Use built-in C++ foreach iteration in tests
Change-Id: I1e4bf9249ce26c034c676d78cfa16231226da05b
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-11-06 10:16:31 +01:00
Morten Johan Sørvig
52ce0c177e Set the url to have the AtNx filename if one is found
There’s no need to convert the file name/path to QUrl,
and then back again to QString before calling qt_findAtNxFile().

Call qt_findAtNxFile first, and then convert to QUrl.
This makes sure the url-name and string-name stays
in sync.

Change-Id: I8b8939eabbdaff473945ebe31faafd408e9c4295
Pick-to: 5.15
Fixes: QTBUG-60793
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
2020-11-06 09:16:30 +00:00
Assam Boudjelthia
039d3fe4e8 Android: blacklist a list of failing tests for android
We want to re-enable Android tests in QTQAINFRA-3867. However,
many tests are failing already preventing that from happening.
QTBUG-87025 is currently keeping track (links) to all of those
failing tests.

The current proposal is to hide those failing tests, and enable
Android test running in COIN for other tests. After, that try
to fix them one by one, and at the same time we can make sure
no more failing tests go unnoticed.

Task-number: QTBUG-87025
Change-Id: Ic1fe9fdd167cbcfd99efce9a09c69c344a36bbe4
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-11-04 12:27:49 +02:00
Lars Knoll
1282c05cdc Rename AllocationPosition enum and its members
Use GrowsAt* and GrowthPosition as that is clearer.

Change-Id: I3c173797dec3620f508156efc0c51b4d2cd3e142
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-11-04 10:22:16 +00:00
Andrei Golubev
8f7016252a Implement QList::emplaceBack as a proper function
My endeavours figuring out why QList::append(elem) gives worst
performance compared to 5.15 ended up into this commit. After some
straightforward fixes, what was left is "everything is uniformly worse"
and takes more CPU cycles

Introduce emplaceBack implementation as append is quite a special case
that could be greatly simplified. This is a "straightforward" part of
the optimizations

While at it, change append(t) to use emplaceBack(t)

For workloads like:
QList<int> list;
forever {
  list.append(0);
}
this gives huge improvement (roughly 30% for 10k+ elements),
movable and complex types also get a tiny speedup

Task-number: QTBUG-87330
Change-Id: I9261084e545c24e5473234220d2a3f2cd26c2b7f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-11-04 11:21:59 +01:00
Lars Knoll
4deb0d1737 Remove the old insert methods in QArrayDataOps
Inline them into the one place they are called from
and remove duplicated code.

Change-Id: Ica88485e98625905083b16c24ee9eaf223a89ae0
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2020-11-04 11:21:54 +01:00
Lars Knoll
b76fbb48fb Clean up out allocation handling
Get rid of the allocation options inside the flags
field of QArrayData, they are really a completely
separate thing.

Change-Id: I823750ab9e4ca85642a0bd0e471ee79c9cde43fb
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-11-04 11:21:46 +01:00
Lars Knoll
419eaa0679 Cleanup QArrayDataOps::reallocate() and related
Don't use QArrayData::GrowsForward/Backward anymore and replace
it with a simple 'bool grow'.

Change-Id: Ifddfef3ae860b11dda4c40854c71ef2aeb29df34
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-11-04 11:21:41 +01:00
Lars Knoll
32a703e277 Don't move data in QArrayDataOps::reallocate()
reallocate() should only ever call realloc(), and only be used to
create more space at the end of the data.

Change-Id: I2ac4dbc90d2afaa571bb620108d7984356712cb2
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2020-11-04 11:21:37 +01:00
Lars Knoll
50ec3252ac Do not move data around on insert neither
The while insertion logic will need further work to make it
more efficient. Currently it does use copy construction and
assignment for internal moving instead of move operations.

Change-Id: I7ae3094daa43a44629d8fa89ab6562c2a21b6cbd
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-11-04 11:21:32 +01:00
Lars Knoll
b99271caa6 Avoid expensive iterator calculations in append()
Avoid moving data inside the array to create free
space at one end. This is a performance bottleneck,
as it required quite a lot of calculations for every
insert. Rather reallocate and grow in this case,
so we only need to do expensive work when we reallocate
the array.

Change-Id: Ifc955fbcf9967c3b66aa2600e0627aac15f0c917
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2020-11-04 11:21:22 +01:00
Andrei Golubev
7eed57511a QArrayDataPointer: redesign (and simplify) growth policy
It looks like we can drastically simplify the way QADP grows without
sacrificing much:
1. append-only use cases should have the same performance as before
2. prepend-only use cases should (with the help of other commits) get
   additional performance speedup
3. mid-insertion is harder to reason about, but it is either unchanged
   or benefits a bit as there's some free space at both ends now
4. mixed prepend/append cases are weird and would keep excess free
   space around but this is less critical and overall less used AFAIK

Now, QList would actually start to feel like a double-ended container
instead of "it's QVector but with faster prepend". This commit should
help close the performance gap between 6.0 and 5.15 as well

As a drawback, we will most likely have more space allocated in mixed
and mid-insert cases. This needs to be checked

Task-number: QTBUG-86583
Change-Id: I7c6ede896144920fe01862b9fe789c8fdfc11f80
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-11-04 11:21:12 +01:00
Andrei Golubev
02a5928fa5 Add QList/QVector benchmark tests
Added some simple benchmarks for QList insertion of 1 element

Added same tests for QVector (within the same file) for 5.15

Task-number: QTBUG-87330
Task-number: QTBUG-86583
Pick-to: 5.15
Change-Id: I19a851c79cf5ce0329266883e99ecaf2d6b3df19
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-11-04 11:21:01 +01:00
Sona Kurazyan
62a741cd2b Improve QtConcurrent::blockingMapped tests
QtConcurrent::blockingMapped was not able to determine the result
type in case of passing containers that have more than one template
argument. This should be fixed by the parrent commit.

Also fixed some unrelated compiler warnings.

Change-Id: I96618dc955c5e4c3792f28f6436d6851745dc01d
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-11-04 09:40:12 +01:00
Allan Sandfeld Jensen
b26fa9722f Add multi key bindings to QShortcut
This makes it feature comparable with QAction, and makes it possible
to use as a backend for QAction, and fixes a few missing alternative
keybindings in qtwidgets.

Change-Id: Iaefc630b96c4743fc5ef429dc841870ddd99fc64
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-11-04 10:32:38 +02:00
Shawn Rutledge
f6418343f1 Add QEventPoint::normalizedPosition() to replace normalizedPos()
In 4e400369c0 we deprecated
normalizedPos() because we suspect it's a legacy feature that few
users will need.  However Qt developers keep bringing up the continued
usage in autotests over and over.  (It's IMO not wrong to keep testing
deprecated functions in autotests, but the warning keeps attracting
attention.)

Of course it will turn out that normalizedPos() has users; we just
don't know how many.  One way to look at it is: why should they copy
a snippet of code to calculate it, when it costs us so little to
continue to provide this accessor.

It might also turn out that some users will complain that in Qt 5
it was passed through from the device driver (or at least from the
window system API) to the application, and perhaps the replacement will
not always work, for example if availableVirtualGeometry() ends up
wrong, or there is some strange scenario that generates events that are
out-of-bounds for the device that the event professes to come from, so
that the "normalized" coordinates also go outside the [0..1] range.
We reserve the right to put back the storage in QEventPointPrivate if
the need arises; so that's why this function is not inline.

We continue to hope that startNormalizedPos() and lastNormalizedPos()
are used even less and won't be missed much, because it would be
wasteful to store them all the time if only a few users need them.

Change-Id: I23ed78843e3f9e16133c5b6f462884a3845f91b6
Reviewed-by: David Skoland <david.skoland@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-11-03 20:36:35 +01:00
Fabian Kosmale
d3ed7dac8a moc: Handle include in enum, take 2
The existing logic broke down when we reentered the enumerator parsing
loop, and encountered a INCLUDE_MOC_END token in the first handleInclude
call. Fix this by restarting the loop in that case.
Amends d8a2456fbf.

Fixes: QTBUG-88125
Pick-to: 5.15
Change-Id: I87acaa986a81de53730eddc40bc7d48c15328aba
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-11-03 19:36:34 +00:00
Volker Hilsheimer
a50f0f045d Get rid of all instance usage of QFontDatabase
All QFontDatabase APIs are static, use them accordingly.

Task-number: QTBUG-88114
Change-Id: I0e4a7508646037e6e2812611262eed8b6d7ad3de
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2020-11-03 20:36:34 +01:00
Lars Knoll
f8c30759d9 Make the QMultiHash(const QHash &) constructor explicit
And add a QMultiHash::unite(const QHash &) method to avoid
a copy of the data when inserting a QHash into a multi hash.

Change-Id: I864aa9d2b9b7b2c367c3c4d140a2ce2f5408ae09
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-11-03 16:28:14 +01:00
Lars Knoll
a9c52dbdf4 Fix qHash(QMultiHash)
The old code was trying to convert a multi hash to a QHash. While
that worked in Qt 5 it won't compile in Qt 6 anymore.

QHashCombineCommutative also can't be used with a std::pair.
ADL won't find the correct instance with a namespaced build,
as qHash(std::pair) is defined after QHashCommutative. Fix
the code to compile and work correctly.

Change-Id: Ice2bc3ab4244e310cbbb5e0f31fc11eb14f5faf3
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-11-03 16:28:14 +01:00
Fabian Kosmale
a31dde22db QProperty: Fix notification logic for eager properties
This ensurse that we do not do dobule notifications in setValue.
Moerover we avoid needless notifications in markDirtyAndNotifyObservers
when the value did not change. Lastly, if the value did actually change,
we pass that information along to notify, so that we do not evaluate the
eager property twice.
Fixes a test-case which errorneously relied on the old behavior, and
adds a new test which verifies that the fix works.

Change-Id: I8ec6fa2fe8611565dfc603ceab3ba5f92999b26c
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2020-11-03 13:06:15 +01:00
Fabian Kosmale
c1c991c319 Remove std::function from QProperty interface
std::function as a type is rather unfortunate for us, as its SSO buffer
makes it rather large, and we can ensure that the function is never
empty.
Considering that we do need to allocate memory for
QPropertyBindingPrivate anyway, we can get rid of the SSO buffer and
instead coalesce the allocations (similar to how std::make_shared works).
The memory looks then like
[--QPropertyBindingPrivate--][Functor]
and QPropertyBindingPrivate can get a pointer to the functor via
reinterpret_cast<std::byte>(this)+sizeof(QPropertyBindingPrivate).
To actually do anything with the functor, we do however need a "vtable"
which describes how we can call, destroy and move the functor. This is
done by creating a constexpr struct of function pointers, and storing a
pointer to it in QPropertyBindingPrivate.

As a consequence of those changes, we cannot use QESDP anymore, as we
now have to carefully deallocate the buffer we used for both the
QPropertyBindingPrivate and the functor. We introduce a custom
refcounting pointer for that. While we're at it, we make the refcount
non-atomic, as bindings do not work across threads to begin with.

Moreover, we can now make the class non-virtual, as that was only needed
to hack around limitations of QESDP in the context of exported symbols.

Change-Id: Idc5507e4c120e28df5bd5aea717fe69f15e540dc
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-11-03 13:06:14 +01:00
Lars Knoll
aaabdf8457 Rename QContainerTraits namespace to QContainerInfo
We'll need QContainerTraits as a class for changing properties
of our containers, so free up that name. This is not a problem,
as the namespace is new in Qt 6 and has only been used internally
so far.

Change-Id: I6d6b9d9c32b92b77e66323f1fc29b3ddd8baa98f
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2020-11-03 13:06:14 +01:00
Wang Chuan
231be2e0a1 QCombobox: propagate the palette to the embedded line edit
Let the new created embedded QLineEdit use the palette from QCombobox,
when calling [setEditable(true)]

Fixes: QTBUG-81533
Pick-to: 5.15
Change-Id: Ia406dd8122a348e185f0e94d027646b95eeaa76e
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2020-11-02 20:27:00 +08:00
Andreas Buhr
40495ce75c Fix tst_qtimer::zeroTimer unit test
The tst_qtimer::zeroTimer unit test was relying on
QCoreApplication::processEvents processing all pending
events. However, for the glib backend, this is not the case.
For the glib backend, if there is an event of high
priority pending, low priority events are not processed.
This patch changes the test to use the overload with
timeout of processEvents, which does process events
until there are no more events or the timeout is reached.

Fixes: QTBUG-84291
Change-Id: I429141507b8603b57a191efa21f154493d75cc9e
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2020-11-01 01:28:55 +02:00
David Skoland
b379e880a9 Update tst_qcborstreamwriter to use QMetaType
Since the QVariant types are deprecated in Qt6, use QMetaType instead

Change-Id: I7bddea15a3f1a534d3c6f6b9e7ddf9585a8423bf
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-10-30 22:18:21 +01:00
Alexandru Croitor
a5ce712d6b CMake: Fix tst_qapplication to respect blacklists in CMake builds
CMake builds are special and need to know the path to the source dir.
This is handled automatically by QTEST_MAIN, but tst_qapplication
doesn't use QTEST_MAIN. Thus we need to call
QTEST_SET_MAIN_SOURCE_PATH manually.

Task-number: QTBUG-87137
Change-Id: Ib2c461f0da0a3d9a2f571f37476b750a606065f7
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-10-30 17:29:25 +01:00
Andreas Buhr
91140eb726 Adapt QDate::fromString() to accept negative year numbers
The documentation states that QDate::fromString() accepts negative
year numbers, but it did not. This patch adds support for negative
year numbers to QDate::fromString() and corresponding unit tests.
Furthermore, tests are added for positive signs (+) in date strings.

Fixes: QTBUG-84334
Task-number: QTBUG-84349
Change-Id: I575291e7b8317055d4bb530011d7b10c9cd37ae1
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2020-10-30 17:19:27 +01:00
Sona Kurazyan
4d9658b7cd Use universal references for passing callables in QtConcurrent
Task-number: QTBUG-87596
Change-Id: I219f08d73b97317820ec6e329ab1e6c89c0545f1
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-10-30 17:19:26 +01:00
Sona Kurazyan
ff0ba7e2d7 Forbid implicit conversions between QFuture and other types
- Remove the casting operator of QFuture<T> to T. It calls
  QFuture::result(), which may lead to undefined behavior if the user
  has moved the results from QFuture via QFuture::takeResult() before
  trying to do the conversion.

- Disable implicit conversion of QFuture<T> to QFuture<void>, by making
  the constructor explicit. If the users really intend to do the
  conversion, they should do it explicitly.

[ChangeLog][Source-Incompatible Changes][QFuture] Implicit conversions
of QFuture<T> to T and to QFuture<void> have been disabled. Use
QFuture::result() or QFuture::takeResult() where you need to convert
QFuture<T> to T. Use the explicit QFuture<void>(const QFuture<T> &)
constructor to convert QFuture<T> to QFuture<void>.

Change-Id: I153d4137d36365b1611ac934fb3ac2eb667fdd6c
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2020-10-30 17:19:26 +01:00
Liang Qi
2731718633 tests: blacklist tst_QTcpSocket::connectToHostError()
on Ubuntu 20.04.

Task-number: QTBUG-88042
Change-Id: Ie63cd26b6885b73073251e20cb4e8ba5da36d906
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2020-10-30 13:27:14 +01:00
Fabian Kosmale
bbb79ae7ab Adjust tst_qdbusmarshall to QVariant changes
Comparing QVariant's containing QDBusArguments does not work anymore in
Qt 6, where QVariant will simply use QMetaType equals. Thus we now do
the comparisons in a more manual way. This is currently only partially
implemented.
Additionally, adjust to changed warning message.

Fixes: QTBUG-87998
Change-Id: Ie63db4e8c8d03d7627234f3c892067d1557454af
Reviewed-by: Liang Qi <liang.qi@qt.io>
2020-10-30 13:27:14 +01:00
Allan Sandfeld Jensen
951274a9b9 Make QVarLengthArray comparisons hidden friends
Task-number: QTBUG-87975
Change-Id: Iaebb237b3d5d3e881caf9a93153e295af051e2ab
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-10-30 13:27:14 +01:00
Andreas Buhr
b0d4d95a29 Add unit tests for QDateTimeParser internals
So far, the internals of QDateTimeParser and especially the handling
of 'Intermediate' values were only tested implicitly by
tst_qdatetimeedit. 'Intermediate' values are values which
are not valid according to the specified format, but could
become valid by adding more characters.
This patch adds unit tests which tests parsing of
these intermediate values directly.
These tests will help implement handling of negative
year numbers, where additional complications arise
because of possible ambiguities between the minus sign '-'
and the separator '-'.

Task-number: QTBUG-84334
Change-Id: Ia6ba08df198288b8b11d3b2d2052c194f04fe8a1
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2020-10-30 10:15:29 +01:00
Jarek Kobus
cc0be95ac7 QtConcurrent: Provide a test for runWithPromise with handlers
Test runWithPromise with "then" and "onCanceled" handlers.
Test the case when QFuture::cancel() is being called when
the task's thread already started, so that a call to
QPromise::isCanceled() from inside the running thread
returns different values in the same task's run. This nicely
proves that communication between QFuture and QPromise
works between different threads.

Task-number: QTBUG-84868
Change-Id: Icb2e0b1f99e2dcd919d881515f1ccd08e2f25b8c
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-10-30 10:14:48 +01:00
Shawn Rutledge
d15d9d49ac Add QPushButton::touchTap autotest
Change-Id: Ibfed43fd4b8fdc3834ee7ca7bd92296504943abe
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-10-29 20:29:21 +01:00
Sona Kurazyan
30a1683f65 Remove the comparison operators of QFuture
These operators don't do what the user might expect and may lead to
confusing results.

[ChangeLog][Source-Incompatible Changes][QFuture] The comparison
operators of QFuture have been removed. They were comparing the
underlying d-ptrs instead of comparing the results (as the users
might expect), which is not very helpful for the users point of view.

Change-Id: I80a887610eac38b60329128cca52cdb5fb515207
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2020-10-29 14:19:35 +01:00
Volker Hilsheimer
387f3e00a8 Workaround gcc compiler bug
For the comparison of a QFuture<int> and an int, gcc creates code that
creates a qfloat16 instance, as can be seen when stepping through this
code:

    QFuture<int> future;
    int five = 5;
    if (future == five)
        return five;

Explicitly get the result of the QFuture to compare as a workaround.

Change-Id: Id2adc2268dbc0ccec7df3a9786c9d29dcdc04da3
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2020-10-29 14:03:38 +01:00
Alexandru Croitor
d2b50a736b CMake: Update usage of add_qt_gui_executable
Change-Id: I8a5e3b4ecdd1c4fa888d4e11dfd09c5116cfb4d4
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-10-29 12:13:34 +01:00
Edward Welbourne
3a1bc4bad5 Purge deprecated language and country codes from QLocale
Requires subsequent re-numbering of the enum tables to eliminate gaps,
before locale data can be regenerated. However, it will work with the
present locale data, since it merely loses the means to use some names
for which the available data was just the name and code. This implies
a transient issue of recognising some codes for which there is no
actual enum member; but relevant code will work as before, finding
nothing but the code and its name. This shall be resolved by a coming
BiC change to resort the language, country and script codes, changing
the numbering (almost) completely.

[ChangeLog][QtCore][QLocale] Various obsolete language and country
codes have been removed. Some lacked locale data, others were obsolete
aliases. All have been deprecated in 5.15.

Task-number: QTBUG-84669
Change-Id: I45fc76a5f2f6c3b0ea3c1bb61e917da984183783
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-10-29 10:44:38 +00:00
David Skoland
7d0faad43c Initialize values in collection tests
This silences a compiler warning

Change-Id: I8d01b5d008ab4f90d5551fef522e2e3c3adb02ba
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-10-28 22:19:05 +01:00
David Skoland
913c0d56e5 Update tst_qspinsbox test to use metaType system
Change-Id: Ib744a1ceb3d90ae443ee754f97c0ef1edbbac52f
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-10-28 22:18:53 +01:00
David Skoland
56a1a645ac Update tst_qguivariant to use QMetaType
Change-Id: I4c789ecfc9f4613bd4820a8a6530249c51344a83
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-10-28 22:18:45 +01:00
Liang Qi
53da9f5816 tests: blacklist tst_QUdpSocket::multicast() on CentOS
Task-number: QTBUG-84254
Change-Id: Icf50e7c85a0434ecdf29ae70776b274789b9eb45
Reviewed-by: Tony Sarajärvi <tony.sarajarvi@qt.io>
2020-10-28 16:13:33 +01:00
Jarek Kobus
c34673e5d9 QtConcurrent: Handle running with promise inside QTaskBuilder
Please note, that in case of run with promise it doesn't make
sense to provide the overload taking the FutureResult, as if we are
going to ignore the returned QFuture object, we can't communicate
with the passed QPromise.

Fixes: QTBUG-87083
Change-Id: I4066506736c2bbeea3e42030b9495f13e06cb27e
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2020-10-28 15:38:52 +01:00
Jarek Kobus
cf043a785a QtConcurrent: Integrate runWithPromise into run
Change-Id: I6eb95aa66ff847e8bb9aac348fded3a5d55015b6
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2020-10-28 15:38:44 +01:00
Timur Pocheptsov
524b19fc23 Selftest - copy XAUTHORITY environment variable
Otherwise XOpenDisplay in a newly spawned process may fail with
a 'No protocol specified' message (as it recently happened in
CentOS 8.1 vm).

Fixes: QTBUG-87621
Pick-to: 5.15
Change-Id: Ib6c08c7f154fb2a126d32a4aa52b535e5daa1589
Reviewed-by: Liang Qi <liang.qi@qt.io>
2020-10-28 14:27:37 +00:00
Edward Welbourne
07ff70a0da Remove QItemSelectionRange's operator<()
As advocated in a ### Qt 6 comment.

[ChangeLog][QtCore][QItemSelectionRange] QItemSelectionRange no longer
supports ordering. The prior ordering was inconsistent with equality
and should not be needed.

Task-number: QTBUG-85700
Change-Id: I5eb372c203cae19db40fa67f706d911785652d5f
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-10-28 15:27:37 +01:00
Edward Welbourne
29c113d912 Deprecate ordering on QItemSelectionRange
Ready for removal at Qt 6, as advocated in a ### comment.
It was never done consistently with operator==(), apparently, and
should not be needed in any case.

[ChangeLog][QtCore][QItemSelectionRange] Ordering of
QItemSelectionRange is now deprecated. It was not consistent with
equality and should not be needed.

Task-number: QTBUG-85700
Pick-to: 5.15 5.15.2
Change-Id: Ie99294bd7fc18f2a497598ae08840886b0a6d62d
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-10-28 15:27:37 +01:00
Mårten Nordheim
205629bb62 QByteArray: make (ap|pre)pend(const QByteArray &) consider reserved
Append was previously optimized for lhs being empty but it should've
also taken into account if space had been reserved.
Apply the same optimization to prepend while we're at it.

Change-Id: I5e5d33a3189b9ad88d45e858a2ac412cbc294f79
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-10-28 08:48:23 +02:00
Edward Welbourne
2c4874be40 Deprecate old aliases for two countries and several languages
[ChangeLog][QtCore][QLocale] Deprecated several Language and Country
aliases, ready for removal in Qt 6.0, in favor of their newer names.

Task-number: QTBUG-84669
Pick-to: 5.15 5.15.2
Change-Id: Iebaa0a5a77bfa12f7014de53fab4a25b5f1cc92c
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-10-28 06:26:01 +01:00
Edward Welbourne
2575a8ced3 Deprecate QLocale::Language entries that no locale data relates to
These are languages for which CLDR does not even recognize the claimed
language code (three-letter codes except for bh = Bihari, which might
be an old name for bho = Bhojpuri, which CLDR does give, but provides
no locale data using it).

[ChangeLog][QtCore][QLocale::Language] Many obsolete language names
are now deprecated in preparation for removal at Qt 6.0. No data has
been available for any locale using these languages since CLDR v29 (at
least; Qt now uses v37).

Task-number: QTBUG-84669
Pick-to: 5.15 5.15.2
Change-Id: I2bf2d49211ade7cc511277f35fb1a247e7048b31
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-10-28 06:25:47 +01:00
Volker Hilsheimer
6949bfaa92 Skip flakey dialogs testcase on all platforms except windows
Testing the mouseMoveCount before XFAIL'ing before then testing the
mouseRelaseCount was anyway wrong.

Change-Id: I666f143ff15088562fc63f833f5785f870de6f26
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2020-10-27 21:29:05 +00:00
Fabian Kosmale
331a200b97 Revert "QObject: simplify part of connection logic"
This reverts commit 1918c689d7.
The template gets always instantiated in QObjectPrivate::connect, even
if the connection types is not Qt::(Blocking)QueuedConnection. For
non-queued connections we however support using incomplete types in
connect. The only way to fix this would be to make the connection type a
template parameter of QObjectPrivate::connect (or at lesat pass some
compile time constant indicating "blocking"-ness) along, so that we can
use if constexpr instead of if. As all involved classes are private, we
can postpone investigating this solution to 6.1

Change-Id: Ieffaf015f8e60ca6ac6f85eb9e2756e480060b4f
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-10-27 16:43:12 +01:00
Jarek Kobus
c293ab71bd Fix tst_QDeadlineTimer::stdchrono() flaky test
This patch reverts the last attempt to fix it:
4a1de178c9.
In addition, instead of using imprecise QTest::qSleep()
we trigger a single shot PreciseTimer twice
and gather the measurements in lambdas.
We wait for lambdas to be executed - we give it
twice as much time as is in theory needed.
Afterwards we verify all the data collected in lambdas.

Fixes: QTBUG-82825
Change-Id: Ib691f5f23a92fb8b41a24f7b603981d9c9450ddc
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2020-10-27 17:43:12 +02:00
Shawn Rutledge
da4ac99b12 Expunge WA_GroupLeader
It's been deprecated since Qt 4.1.

Task-number: QTBUG-85816
Change-Id: Iafc6340716556f54fc5472c60035bb57461b842f
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2020-10-27 02:55:59 +01:00
Edward Welbourne
c8d42961a0 Add constructor benchmarks for QLocale, to test likely sub-tag matching
Change-Id: Ib4c1d0ea031a581020c1f050fa4096d5196cc752
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-10-26 15:56:06 +02:00
Sona Kurazyan
4c793e6353 Store std::exception_ptr in QUnhandledException
For historical reasons Qt Concurrent reports QUnhandledException in
case if an exception that is not derived from QException is thrown
from a worker thread. Changing this behavior may not be a good idea,
since the existing user code may rely on it. Changed QUnhandledException
to wrap the std::exception_ptr to the actual exception, so that the
users can obtain the information about the thrown exception if needed.

[ChangeLog][QtCore][QUnhandledException] Improved QUnhandledException to
store the std::exception_ptr to the actual exception thrown from a
QtCocnurrent worker thread.

Change-Id: I30e7c1d3e01aff6e1ed9938c421da0a888f12066
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-10-26 14:27:02 +01:00
Timur Pocheptsov
e2e9ce8109 Make Ubuntu with its non-standard security level happy
Ubuntu changed the default level from 1 to 2 and not accepting our
RSA 1024 anymore. While we are not testing the TLS library's strength,
we re-generate a ceritficiate to shut the thing (the botched, 'fixed' OpenSSL)
up for good.

Task-number: QTBUG-86187
Change-Id: I6151ce5210972ae938e52731157742910363afbe
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-10-26 14:07:54 +01:00
Andy Shaw
d9edad8117 Show the year correctly after it has been edited
When converting the year as an integer via the locale then it can add
in group separators which would not be desired here. Therefore it should
be converted via the QDate approach to get the right output for the year.

Fixes: QTBUG-86307
Fixes: QTBUG-85966
Pick-to: 5.15
Change-Id: I092bd1e5f69e544843fd5f28c96b94c9066490c5
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-10-26 09:43:37 +02:00
Mårten Nordheim
ec258b8291 QSsl: Further work around to pass network test
Our tls certificate/key are a bit on the old side and need to be
updated. But for now let's lower the openssl level. In this case openssl
complains about the server's key used for DHE being too short.

Task-number: QTBUG-86187
Change-Id: I142a7d52f7599f60b8f4f3ff3ac5ce61fed06b4c
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2020-10-26 09:30:36 +02:00
Tor Arne Vestbø
b362c69171 testlib selftest: Spit out stdout/stderr when test crashes
The old test harness used to spit out stderr only, but
to be on the safe side we spit out both.

Change-Id: Ib8e57fd1b0e4d8542ac552a6fe58c07016df7f5f
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-10-24 13:05:02 +02:00
Alexandru Croitor
815f31799c CMake: Fix tst_qmake to work for configs with cross-compiled tools
When cross-building Qt with CMake to target qemu configs in the CI,
we specify the -DQT_BUILD_TOOLS_WHEN_CROSSCOMPILING=ON option to also
cross-build tools (like qmake).

In this case, $prefix/bin/qmake points to the cross-compiled qmake,
and the shell script that wraps the host qmake is called
$prefix/bin/host-qmake instead.

In such a scenario, tst_qmake ends up running the cross-compiled
qmake, which thinks that it's being run on device (via user-space
qemu emulation) and doesn't specify the sysroot when computing include
paths, link paths, etc. This causes the test building to fail in
various ways.

To fix the test, check for the existence of the host-qmake wrapper,
and if it exsists use it instead.

Task-number: QTBUG-86053
Change-Id: Iaa4afdf11b17f23abef873dd15b1ed950126ab8c
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2020-10-24 13:02:54 +02:00
Andreas Buhr
83fce1931f Add unit tests for qdatetimeparser
The qdatetimeparser was not tested explicitly so far, but only
implicitly in tst_qdate / tst_qdatetime / tst_qdatetimeedit etc.
This made it difficult to test some corner cases, especially in the
context of unfinished dates, i.e. dates which are invalid, but could
become valid by adding more characters. This is used to validate
user input in qdatetimeedit.

Task-number: QTBUG-84334
Change-Id: I27202849abb1b7cad96d3e25f7ac81ce85272b2a
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2020-10-23 20:33:18 +02:00
Friedemann Kleint
f6d09d426b Fix tst_qsslkey to compile when SSL is disabled
Move it to the section requiring SSL tests since it
requires QSslConfiguration.

Change-Id: I5c807976ce75fa5967bddb8edd7788dbfbb89375
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-10-23 11:36:48 +02:00
Karsten Heimrich
216c2ed5ce Remove usage of deprecated QStandardPaths::DataLocation
* Rearrange the documention to match the enumeration order.

Fixes: QTBUG-87037
Change-Id: Iad001351e0f309e694b8bbd503813017e6586a21
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2020-10-23 11:36:47 +02:00
Lars Knoll
11bad61096 Deprecate QVariant::Type
It's been obsolete for a long time already. Make sure
the compiler now warns about it and remove all remaining
uses in qtbase.

Change-Id: I0ff80311184dba52d2ba5f4e2fabe0d47fdc59d7
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-10-23 09:58:57 +02:00
Lars Knoll
a618c260ed Fix and run the qlocalsocket autotest with cmake build
Change-Id: I79691fe97e1373ffdc6a1b9b929f8a3fc2ef863d
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-10-23 09:58:37 +02:00
Lars Knoll
1e0f2be5ac Do not store non relocatable types in QVariants internal storage
This mostly reverts change 76e8e8e9c8.
The reason is that storing non relocatable types inline in
QVariants storage would implicitly make QVariant non relocatable.

Fixes: QTBUG-87686
Change-Id: I2a09b1dcdd907d60085dccf17f987086dcba878c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-10-23 09:50:16 +02:00
Lars Knoll
4175175588 Rename the QMetaType::MovableType flag to RelocatableType
Keep this in sync with the changes we have done in QTypeInfo.

Change-Id: Iaacb0f3cc5c46d3486084a1f6eca480a233d5e1a
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-10-23 09:49:36 +02:00
Allan Sandfeld Jensen
e356ab2c32 Make QPointer comparisons hidden friends
Reduces ADL noise.

Change-Id: Id0aa4b32b7bb6d70ed9106b949452d895d9060a9
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-10-23 09:32:37 +02:00
Andreas Buhr
2516fc935c Add benchmark for QString::number(int)
Add a almost trivial benchmark for QString::number(int).

Change-Id: Ice67eaf28e8d7b235fd5ec5e0b87b3b9053ae61e
Reviewed-by: Karsten Heimrich <karsten.heimrich@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2020-10-23 06:55:35 +02:00
Morten Johan Sørvig
4fed50f4ab Prepare for having multiple highdpi manual tests
Move the existing “kitchen sink” test out of the way,
and rename it to “kitchensink”

Change-Id: I121260e640bb2810a94f8112fcea212e97055fb3
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2020-10-23 00:58:11 +02:00
Andrei Golubev
bfc6e2d69d Use parameter_type in QList methods
QList::parameter_type is defined and used to give better
performance e.g. for arithmetic types. Let's use it consistently
in QList API instead of const T &

Change-Id: I2e12bd83f55679b55a14fbb23ab6172a9cf7bbcc
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-10-22 20:47:10 +02:00
Liang Qi
88f3f33beb tests: blacklist tst_QGraphicsAnchorLayout::layoutDirection()
on Ubuntu 20.04

There is some issue with the glib event dispatcher.

Task-number: QTBUG-87728
Pick-to: 5.15
Change-Id: I4d64206898dd2c8356d5fc51a68c2e5759b38aac
Reviewed-by: Tony Sarajärvi <tony.sarajarvi@qt.io>
2020-10-22 18:06:19 +02:00
Liang Qi
93f19445a4 tests: blacklist tst_QMdiArea::tileSubWindows() on CentOS
Task-number: QTBUG-87768
Change-Id: Iad86e3114e546c0cab92f0fccdc7a265575a687e
Reviewed-by: Tony Sarajärvi <tony.sarajarvi@qt.io>
2020-10-22 18:06:19 +02:00
Andreas Buhr
373fdc9126 Add unit test for malformed RFC2822 dates
RFC2822 requires times to be in the format 'HH:mm' or 'HH:mm:ss'.
We did not have unit tests to check that malformed RFC2822
dates are rejected. This patch adds such unit tests for
truncated hours/minutes/seconds.

Change-Id: Id5b9390112e633e617722439ad59439e6aeba841
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-10-22 13:54:45 +02:00
Shawn Rutledge
0e5bbf3507 Make QEvent::setAccepted() virtual; set QEventPoints state the same
In Qt Quick, when we deliver an item-specific QTouchEvent that contains
only the subset of eventpoints that are inside the Item's bounds,
traditionally the Item can accept the event to tell the delivery logic
that the event is handled and doesn't need to be delivered further.
But an Item cannot be expected to have total scene awareness; so now,
the delivery is "done" only when all eventpoints in the original event
are accepted.  This behavior has been working well enough already due to
logic in QQuickWindow that iterates the points and accepts them if the
event is accepted; but it seems appropriate to move this enforcement
into QPointerEvent itself.  Making setAccepted() virtual gives us a
useful degree of freedom.

Event-handling code should alternatively use QEventPoint:setAccepted()
or QPointerEvent::setExclusiveGrabber() to take resonsibility for only
a subset of the touchpoints.

Another way to put it is that we treat QPointerEvent::setAccepted() as a
convenience method: accepting the QEventPoints is what counts (at least
in Qt Quick).

Change-Id: Icec42dc980f407bb5116f5c0852c051a4521105a
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-10-22 04:54:17 +00:00
Volker Hilsheimer
875a7fad52 Fix a bunch of compiler warnings in event handling test cases
Leave the normalizedPos warnings, there is no equivalent function.

Change-Id: I50c72ab24b4855e36941aafdee30cdb0e94c1684
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2020-10-22 02:43:26 +02:00
Andrei Golubev
a17e05bf20 Fix strange capacity check in tst_QString::append_special_cases
We cannot rely on "QString a; a.insert(0, u'A');" to give
a.capacity() >= 3, this is clearly an implementation detail. Changed
the check to a meaningful one

Task-number: QTBUG-87416
Change-Id: I2e017c1292d360e32b85b903361027485c08ea74
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-10-21 17:56:48 +02:00
Stanislav Yelenskiy
b39b018f4a QTabBar: update index of last visible tab in insertTab
Index of the last visible tab was not updated, if a new tab was inserted
after the current tab and before the last tab.

When the new tab is inserted before the last visible tab, the index of
the last tab increments by one.
When the new tab is inserted after the last visible tab, then the newly
inserted tab becomes the last visible.

Fixes: QTBUG-86898
Change-Id: I2f4b7f705261ec35a5aa7b883ecdddba25f007b7
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-10-21 07:19:36 +00:00
Stanislav Yelenskiy
9f9275f82f QTabBar test: refactor: extract checkPositions helper function
Extract checkPositions helper function to re-use in the new test.


Task-number: QTBUG-86898
Change-Id: I5c8241b5701cd8c8c3e21607c385217d4b75e728
Reviewed-by: Jordi Pujol Foyo <jordi@vikingsoftware.com>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
2020-10-21 07:18:28 +00:00
Piotr Mikolajczyk
a02ea26b46 [Android] Make sure expose events are emitted after window resize
Expose event would not be sent when window was resized

Fixes: QTBUG-69155
Pick-to: 5.15
Change-Id: I81bf2d54f830a0dabf15398e1f25b55ff7ff4479
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Rami Potinkara <rami.potinkara@qt.io>
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
Reviewed-by: Heikki Halmet <heikki.halmet@qt.io>
2020-10-21 07:08:54 +00:00
Shawn Rutledge
9aba868571 QEvent copy constructor: copy the type flags too
Failure to copy m_inputEvent and m_pointerEvent actually left them
uninitialized, and resulted in random behavior in Qt Quick when
Flickable clones a pointer event for later replay.

Remove the comment about copying events being a "bad idea" in Qt 4,
while we're at it.  Copying became more common in Qt 5, and we
probably won't be able to stop doing it now.

Change-Id: I40b6ba5ad696e7aaafbeefbca86eca00cab40616
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-10-21 08:22:36 +02:00
Thiago Macieira
21d3916817 QRandomGenerator: add 64-bit bounded() versions
Unlike the 32-bit version, we can't go to a bigger integer type to do
the multiplication with. So instead accept looping. Both libstdc++ and
libc++ implement std::uniform_int_distribution this way anyway, but in a
far more complex way.

There is no looping if the "highest" is a power of two. The worst-case
scenario is when "highest" is one past a power of two (like 65). In that
case, we'll loop until the number is in range. Since all bits have equal
probability of being zero or one, there's a 50-50 chance that the most
significant useful bit will be set[*], in which case we'll need to loop
and we again get the same probability. So on average, we only need two
iterations to get an acceptable result.

[*] There's also a possibility that the other bits are such that the
number is still in range. For 65, we'd need the other 5 bits to be zero
(64 is a valid result), but the probability of that is only 1/2^5 =
3.125%. The bigger "highest" is, the closer we get to zero, so
approximate by saying that never happens and instead calculate that the
most significant useful bit is the controlling one.

[ChangeLog][QtCore][QRandomGenerator] Added 64-bit versions of the
bounded() functions. They are useful in conjunction with Qt 6's 64-bit
container sizes, so code that used to call bounded(list.size()) in Qt 5
will continue to compile and work in Qt 6.

Fixes: QTBUG-86318
Change-Id: I3eb349b832c14610895efffd16356927fe78fd02
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-10-20 22:45:06 -07:00
Friedemann Kleint
97c3266c6f Auto tests: Fix some MSVC warnings about integer conversions
Change-Id: Ibab8028ccdb9a4b02cadc6d2e85e8a0472f0d96f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-10-21 07:31:27 +02:00
Edward Welbourne
5e43997a70 Use qmetaobject_p.h's MetaObjectFlag in QMetaObjectBuilder
This saves duplicating them with its own flags.

Task-number: QTBUG-85700
Change-Id: I9e938322fd787282cfd9f941f83af8c0d76aaa9d
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-10-20 12:03:44 +02:00
Edward Welbourne
83cae7c9e3 Drop constexpr from QAtomicTraits::isLockFree()
As requested by a ### Qt 6 comment. This then implied a few other
functions weren't constexpr, which broke some tests.

Task-number: QTBUG-85700
Change-Id: I6522a9b2d7a74e117442121400a1d7198d323967
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-10-20 10:49:30 +02:00
Morten Johan Sørvig
3df2448f63 Merge existing tst_qhighdpiscaling into tst_qhgihdpi
Move the factor() test, drop scale() which should be
covered already.

Change-Id: Id2079536a91c7e9f7199960bdf6b33489d0a6670
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2020-10-20 07:27:04 +02:00
Morten Johan Sørvig
d023da8639 Add high-dpi auto test
Use the new screen config feature of the offscreen
platform plugin to run tests on virtual screen setup.

This has the benefit that we can auto-test the QHighDpiScaling
implementation (as well as its usage in QtGui) on any platform
with a fixed mock screen setup which does not rely on physical
screen configuration.

Test the following configurations:
   - three screens: 96 DPI. (reference)
   - three screens: 192 DPI
   - three screens: mixed (high) DPI

Change-Id: I2fac889d896cf30ab2a79c306cee22177ad8f4ac
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2020-10-20 07:26:57 +02:00
Ulf Hermann
2d0a5f7a01 QAssociativeIterable: Unwrap variants on value()
Fixes: QTBUG-87688
Change-Id: I66515eaa1217c34f003648af6423b318b54977c4
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-10-19 22:12:12 +02:00
Ulf Hermann
45c248a011 QAssociativeIterable: Add methods to add/remove keys and values
This way we can actually modify the container. Previously the interface
was rather useless.

Change-Id: I278aae46999862ada115c9066a010d7de5cde4ff
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-10-19 22:12:04 +02:00
Ulf Hermann
37c7ef4f4a QMetaContainer: Consistently coerce types
The high-level iterable interfaces should coerce the types of most
QVariants passed to the expected ones. To do this, move the type
coercion code into qvariant.{h|cpp} so that it is available to the
QVariantRef specializations.

The exception are variants passed to the find() functions of associative
iterables. Here, we should not coerce values we cannot convert to the
default-constructed keys. Instead we return end() in such cases.

Fixes: QTBUG-87687
Change-Id: I0bd4e5c4e4e270dd3bf36cb3fb115794828077f2
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-10-19 22:11:50 +02:00
Edward Welbourne
5a948dd50b Fix [[nodiscard]] compile errors in QLocale benchmark
QString::toUpper() now insists we use its return, so the benchmark
won't compile unless we do so. Also document the helper macro used by
the tests, to explain why it's even there at all.

Change-Id: I830f121d92867bcd09277ecdeb1c764413b34fa6
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2020-10-19 17:45:30 +02:00
Edward Welbourne
78b58d4de1 Tidy up tst_QLocale::ctor(), reduce needless repetition
The test macro's first three parameters were given a QLocale:: prefix
by the macro, but the last three weren't. Save uses of the macro the
need to repeat the prefix in all parameters, thereby making the test
cases easier to read. Also, we can compare enum values, rather than
casting them to int; and, when a test fails, reporting the enum name
is far more informative than reporting the integer that represents it.

Change-Id: Ib0360c51049333b4a00ea84e271c99db6724334f
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-10-19 17:44:43 +02:00
Edward Welbourne
f2cd9d9ddb Fix blatant typo in QTimeZone test
This revealed that the test was always broken; it had simply never
actually been checked.

Done-with: Andreas Buhr <andreas.buhr@qt.io>
Change-Id: I85ac7ba30738fa3b41bf8440a059ee3fabb4726b
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Andreas Buhr <andreas.buhr@qt.io>
2020-10-19 17:44:32 +02:00
Edward Welbourne
229c9736bb Check time-text is long enough while checking for its colons
Added some tests that trigger an assert without this check.
(Drive-by: renamed one QTime test to match its QDate(Time)? counterparts.)

Change-Id: I3d6767605fdcca13a9b4d43a32904f584eb57cf9
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Andreas Buhr <andreas.buhr@qt.io>
2020-10-19 17:44:05 +02:00
Edward Welbourne
9d2a107da2 Remove vacuous tst_QLocale::cleanupTestCase()
Change-Id: I8bf9915045dce434f19de9c3745e1be28a833e8f
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-10-19 17:42:13 +02:00
Ulf Hermann
91ab8c173d QProperty: Add value() and setValue() to QBindable
This simplifies code that would otherwise need to use the setter and
getter in addition to the bindable.

Change-Id: Iec6510b4f578f5b223c63b3a0719257a0cf2463d
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-10-19 16:29:48 +02:00
Shantanu Tushar
927cd268aa Add function to access QLockFile's file name
This is useful in cases like error handling when you need to print the
name of the lock file.

Change-Id: Ife4901ed53ae81d19e68cce7f1c173ef3745d56f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-10-18 20:16:38 +02:00
Giuseppe D'Angelo
9402a351dd tst_containerapisymmetry: code tidies
We now require C++17 and thus C++11 features or standard headers
should no longer be conditional.

Change-Id: I6b72306e809f71ec77acf7ffb97e2ed2ccd96e9d
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-10-18 19:55:42 +02:00
Volker Hilsheimer
d1785f73db Swallow some runtime warnings from tst_qapplication
Change-Id: I226c3b55a1666eb3ccd369a3307919d4c72a2600
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2020-10-18 17:00:34 +02:00
Volker Hilsheimer
87f29754ec Fix compile warning from testing deprecated signal
Silence the warning, and test event delivery in addition.

Change-Id: I59c49a2ac70ecd32429116b76643700a7ad5ce3e
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2020-10-18 17:00:24 +02:00
Lars Knoll
d4b206b246 Split QMutex and QRecursiveMutex
These classes should not inherit from each other
anymore in Qt 6. The reason is that this makes
the 95% case of using a non-recursive mutex
much slower than it has to be.

This way, QMutex can now inline the fast path
and be pretty much as fast as QBasicMutex is
in Qt 5. They actually use the same code paths
now. The main difference is that QMutex allows
calling tryLock() with a timeout, which that
is not allowed for QBasicMutex.

[ChangeLog][QtCore][QMutex] QMutex does not support
recursive locking anymore. Use QRecursiveMutex for that
purpose. QRecursiveMutex does not inherit QMutex anymore
in Qt 6.

Change-Id: I10f9bab6269a9181a2e9f534fb72ce65bc76d989
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-10-17 12:02:56 +02:00
Lars Knoll
77d812683f Refactor QMutexLocker to be able to handle recursive mutexes
Since we're going to split QMutex and QRecursiveMutex into
separate classes, make sure QMutexLocker is prepared for that.

Change-Id: Id5e9a955d1db7c8ee663dd3811ad6448dad0aeae
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-10-17 12:02:49 +02:00
Lars Knoll
2732231182 Cleanup remaining QVariant::Type uses in Qt Sql
Change-Id: Ibcaa678cd9f9c957392a75b477fa6821f9a69127
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-10-17 12:01:54 +02:00
Friedemann Kleint
008343a05e qmake: Fix qHash-related integer conversion warnings
Use size_t instead of uint.

Change-Id: I1dc38f61653f9bfc4ddeddcc65b0271aa4ad1256
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-10-17 11:56:59 +02:00
Volker Hilsheimer
b61d67f897 Fix compile warnings from ignored return value
The return value can be ignored here, so make intention clear.

Change-Id: I116869c47039b159db96f133b5850a2215873c2f
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-10-17 08:21:52 +02:00
Andreas Buhr
16e4ae01bb Move file of test helpers out of directory for qtconcurrentmap tests
The test helpers are used both in the qtconcurrentmap tests and in the
qtconcurrentfilter tests. In the future, they should also be used
in generated tests. This patch moves the function out of the
qtconcurrentmap folder as it is not specific to 'map'.

Change-Id: Ie79a7ae3040a7eab7364a3aabf934158c7527b5a
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2020-10-16 18:49:01 +02:00
Allan Sandfeld Jensen
986c09f815 Test QImage move semantics
Tests the move semantics of QImage in Qt6.

Change-Id: Ia4d95f0b88ca7dde0daf85a0f53049b42b5be1a5
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2020-10-16 18:49:01 +02:00
Volker Hilsheimer
d72ff6ffd0 Fix some compiler warnings from tests
For iterators that return a value, don't use reference in ranged for,
and cast numeric literal to correct size type for QCOMPARE.

Change-Id: Idfd09dbc2ef3ab1bf025c7859ea6e2e9572bc9a1
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-10-16 13:53:04 +02:00
Volker Hilsheimer
0f1008a593 QAbstractItemView: don't lose items if model only allows MoveAction
If a model only allows MoveAction, then calls in the view/widget subclasses'
dropEvent implementation to set the event's drop action to CopyAction
will fail. QAbstractItemView will then remove the item when QDrag::exec
returns.

Instead of abusing the event actions for this, store explicitly that the
dropEvent implementation already moved the item. If the flag is set,
don't remove the item.

In QListView, which uses moveRow to move items in the dropEvent handler,
handle the case that the model might not implement moveRows. In that
case, or when dropping an item onto another item (to overwrite data),
fall back to the default implementation of QAbstractItemView. Sadly, it
is impossible to know whether a model doesn't implement moveRows, or
whether the move failed for other reasons, so this requires a bit of
extra special case handling. QListView in IconMode is particularly odd
in that it moves the item in the view, but not in the model.

This follows up on fd894fd68e and fixes
additional issues discovered during debugging. Extend the existing unit
test; since drag'n'drop runs a modal, native event loop on most systems,
it still only runs on the Xcb platform.

Change-Id: I6c5377e2b097c8080001afe904d6d3e4aed33df4
Pick-to: 5.15
Fixes: QTBUG-87057
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
2020-10-16 13:53:03 +02:00
Volker Hilsheimer
faf7fd577f Fix warning in test: unused capture in lambda
Change-Id: Ifa9bab843feb670f8400c26fd78f96db55bfd79e
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: David Skoland <david.skoland@qt.io>
2020-10-16 13:53:03 +02:00
Andrei Golubev
7332d3937d Rename QPromise starting and finishing methods to start and finish
Proposed during API review

Change-Id: I9c43e1915c50803ab69bfe07a91c05d2224b86c4
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2020-10-16 09:48:10 +02:00
Andrei Golubev
3ca600bd2d Make QPromise::addResult() return boolean status of operation
Changed QPromise::addResult() to return bool value. True is returned
when result is added and false is returned when e.g. promise is in final
state (canceled or finished) or when addResult() is called twice with
the same index as argument (in which case new value is rejected)

Updated QFutureInterface::reportFinished() that accepts optional result
as argument to align with other result adding methods. This function
is "internal" only (as of now), so no documentation update is needed

Change-Id: I2d63069246e5e5c8cf04529c22bb296faaaae53d
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2020-10-16 09:48:10 +02:00
Timur Pocheptsov
10893c984b QSslSocket (autotest) - defuse a time bomb
Interesting, it only exploded now - initially we were too fast (faster than
500 ms) so never noticed. Now that more tests with the similar event loop
handling were introduced, the last one was catching a single-shot timer
signal, accessing long dead object).

Fixes: QTBUG-87612
Change-Id: I52446fa7b08ef90a4742af3662da7837a8602941
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-10-16 05:21:34 +02:00
Volker Hilsheimer
862bdcd09c Fix warning: helper functions are only used on some platforms
Tag them as [[maybe_unused]] to silence compiler on platforms where they
are not used.

Change-Id: I12243c0409c66863617f073f968e50f913c58a67
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2020-10-16 04:44:22 +02:00
Volker Hilsheimer
215594d664 Purge QDesktopWidget
It's no longer used; the only calls to QApplicationPrivate::desktop
pass the default nullptr for QScreen, so all we need is a Qt::Desktop
type toplevel widget.

Include changes documentation about both the class and QApplication::desktop
being gone in Qt 6.

Change-Id: I22d6e93cabc6aaaefffe5e96942886a2ef4e0609
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2020-10-16 04:44:13 +02:00
Alex Trotsenko
53b4556332 QLocalSocket/Win: prevent writing to broken pipe
When a peer closes the connection, the device remains opened for reading
purposes. However, we should disable writing on disconnected socket.
Otherwise, if the user issues a write() call, a new pipe writer object
will be created and the write call occurs with invalid handle value.

Pick-to: 5.15
Change-Id: Id136798c7663df1fce7ed0aa4e3c6f5c65218a11
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
2020-10-15 22:56:35 +03:00
Friedemann Kleint
a8b687b101 Manual tablet test: Add a window showing the devices
Task-number: QTBUG-46412
Change-Id: I9cb9bb3493728186e1e6b140308c292ca9662e55
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2020-10-15 21:55:03 +02:00
Laszlo Agocs
63790184c7 rhi: Fix up vertex inputs with matrices
In order to prevent too much voodoo in backends like D3D11, the input
layout is expected to specify the slice index for vecX that are part of
an unrolled matrix.

Also deoptimize the instancing manual test to exercise a matrix too
instead of just vectors.

Change-Id: If2dcbcbc483645ce2420b2f87dda765b95da6e80
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2020-10-14 22:35:19 +02:00
Lars Knoll
fa93f1aeb0 Fix compile time type normalization code
Use a simpler constexpr to generate type name on gcc This
works around an ICE on gcc in release mode when compiling
with PCH enabled. As the type we're getting from Q_FUNC_INFO is
already in a somewhat normalized form, this requires significanlty
less processing and esp. not a recursive constexpr method which
I suspect triggers the ICE.

Fix integer type conversions to also properly normalize long long
values (to q(u)longlong. Make sure the mapping also works on
MSVC, where long long types get mapped to __int64. Also, normalize
unsigned short and unsigned char to ushort and uchar, respectively, to
follow the convention set by uint and ulong.

Add some test cases to verify the mappings.

Change-Id: I3dec5764450bf22ab6f066597803c3f46c2cd5ac
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2020-10-14 21:37:39 +02:00
Mårten Nordheim
51faa0700d Schannel: TLS1.3 support
It's not possible to connect to microsoft.com with Schannel TLS 1.3 for
some reason (also tested with Internet Explorer), but other sites work
fine. Must be something they have to iron out for later.

In my experience this needs a preview release of Windows. One of my
machines is opted into the dev channel of Windows where they enabled TLS
1.3 by default, and it works well in my tests except for the part above.
On my other machine, after enabling TLS 1.3 through the registry, I fail
to complete the handshake with any site. So around March/April next year
is when this code would activate for most people.

MinGW apparently defines NTDDI_VERSION as the one for Windows Server
2003, so it currently doesn't build the new TLS 1.3 code. In Qt (as a
project) we could consider setting this higher, but that's out of scope
for this patch!

Fixes: QTBUG-81294
Change-Id: If329959c3a30ecbfbb8c0d335cc39ccb6d012890
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2020-10-14 15:58:16 +02:00
Liang Qi
844318f54a tests: blacklist two tests on Ubuntu 20.04
tst_QApplication::sendEventsOnProcessEvents() and
tst_QItemDelegate::editorKeyPress()

There is some issue with the glib event dispatcher.

Task-number: QTBUG-87137
Pick-to: 5.15
Change-Id: I79a983192edef3c3560a4296cc9dea2dfc2ee1b0
Reviewed-by: Tony Sarajärvi <tony.sarajarvi@qt.io>
2020-10-14 15:58:16 +02:00
Volker Hilsheimer
1c76aa077e Get rid of all usage of QApplication:desktop
Use QScreen APIs instead.

Change-Id: Ie99af94fe4292223dbb165b3f5c1b74e8fe0498b
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2020-10-14 06:38:43 +02:00
Andrei Golubev
ba511b2fa4 Reject overwrites by the same index in QPromise::addResult()
One can call addResult(value, index) twice and consequently set the
value twice by the same index. This seems rather strange and probably
should not be allowed. This commit rejects setting results when there's
already a valid result by that index. Consequently, this fixes memory
leaks caused by N-times-called addResult(..., index)

Fixes: QTBUG-86828
Change-Id: I77494f2cb73ce727ffad721cfcdcaa420899eb25
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2020-10-13 17:04:16 +02:00
Sona Kurazyan
d5c53554e5 Loosen the requirements on the container passed to QtConcurrent::map*
Using std::begin() and std::end() forces the user to have const begin()
and end() member functions being defined for the passed container. This
is because std::declval<T>() returns rvalue which forces the compiler
to select std::{begin, end}()(const Container &c) overloads and an test
for a presence of const {begin, end}() methods.

Change-Id: I9d96d9f73891ece53224f1741a1334500f7b35ad
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-10-13 09:49:51 +02:00
Volker Hilsheimer
044231c4d2 Remove timeStep parameter from QAnimationDrive::advanceAnimation
This reverts commit 7544c242cb, which
reverted the first removal of the parameter under the assumption
that it caused flakiness in tests.

The flakiness was instead caused by changes to the wait functions
in QTest, so remove the parameter again.

Change-Id: I98154d5d7268375aebbcb09de757e75d9b765c5f
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-10-13 08:44:42 +02:00
Fabian Kosmale
b83225fcc3 qDebug: Avoid implicit QVariant conversion
This commit restricts operator<<(QDebug lhs, QVariant rhs) to only work
if rhs is actually of type QVariant (instead of any type convertible to
QVariant). This is especially important as
a) we check in QMetaType whether (slightly simplified) QDebug{} <<
   std::declval<T>() is valid, and if so, register a function which
   simply uses the operator.
b) In QVariant, we ask the metatype system for the contained types
   registered debug function and then use it.
If a type now does not have its own operator<< for QDebug, but is
implicitly convertible to QVariant containing itself, this would lead to
an infinite recursion, when trying to use qDebug with that type. The
registered function in a) would just convert the type to QVariant, and
then ask the QVariant to print itself.
Disallowing implicit conversions in qDebug in general was considered
(i.e. adding template<typename T> operator<<(T) = delete in QDebug ),
but discarded as it breaks too much code relying on conversions.

Fixes: QTBUG-87122
Change-Id: Ib709297670cbc6cc307efd0dfd8e5b0279df9414
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-10-13 08:06:18 +02:00
Andy Shaw
bdc9d272ee Fallback to using the family when doing an exact match
If the difference between the families sizes is just 1 where one of them
is 0 in size then we can fallback to the family in that case.

Pick-to: 5.15
Fixes: QTBUG-87267
Change-Id: I62b25b06c88000b4d7defe91871c07873b1fc792
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2020-10-12 14:08:06 +02:00
Sona Kurazyan
4a981b9bdb Enable some-of the QtConcurrent test cases
QtConcurrent::filtered test-cases for move-only containers were failing
to compile, because it is assumed that the passed container should have
value_type defined.

Change-Id: I3e9e5ebc07704cb98a15b125ae8bd5b5a84d497a
Reviewed-by: Andreas Buhr <andreas.buhr@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2020-10-12 13:51:45 +02:00
Sona Kurazyan
3d040267f4 Temporarily disable QFuture::takeResult() method
QFuture::takeResult() currently returns std::vector instead of QList,
because QList does not support move-only types. Disable this method
until QList is fixed to work with move-only types in Qt 6.1.

Also did minor doc-fixes.

Change-Id: I87feaf75d9433a3b540edd00039c3e21d6994985
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2020-10-12 13:51:34 +02:00
Fabian Kosmale
2f3cd3b1a8 Handle notifier list modification during iteration
As propertyobservers can execute arbitrarily complex code, they can also
modify the obsever list in multiple ways. To protect against list
corruption resulting from this, we introduce a protection scheme which
makes the list resilient against modification.
A detailed description of the scheme can be found as a comment in
QPropertyObserverPointer::notify.

Task-number: QTBUG-87153
Change-Id: I9bb49e457165ddc1e4c8bbdf3d3c9fbf5ff27e94
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-10-12 13:01:29 +02:00
Allan Sandfeld Jensen
a0deaf42e2 Improve QRectF::toRect()
Implement the better rounding mechanism that was previously blocked
by requiring C++14 to be constexpr.

Change-Id: I4e5b179ce0703f5c0b41c3f0ea00d28dfe53740c
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-10-12 13:00:43 +02:00
Laszlo Agocs
2189e0f2fc rhi: Make the new direct buffer update available for non-uniform buffers
The original restriction to UniformBuffer was due to the GL backend
where there is no GL buffer object for QRhiBuffers with usage
UniformBuffer. However, we can still implement this for cases when
there is a true GL buffer object underneath. With other backends it
should all work as-is already.

This becomes useful when one has buffers with usage Vertex that need
full updates every frame. (f.ex. instance data)

Unfortunately this involves renaming the function. But while at it, add
an autotest case as well.

Change-Id: Iff59e4509a8bae06654cc92fe8428bd79eb012fb
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2020-10-12 07:55:37 +02:00
Laszlo Agocs
0eb8a332af rhi: Regenerate shaders for some manual tests
The qsb files seem to be out of date for those two.

Change-Id: Id832e872667cac4d364e13c440011109a6dbdc7f
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2020-10-11 10:58:56 +02:00
Laszlo Agocs
f26e329c47 rhi: Add a many cubes manual test
Draw 25000 cubes while doing a uniform buffer update for each.

Change-Id: I2216641c8bf7c6ea147fe3edd679317b472e1f04
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2020-10-11 10:58:44 +02:00
Andrei Golubev
c22aabe9bc Clear pending results in ResultStore
Pending results were never cleared by result store. This led to memory
leaks when the results never transitioned to "visible" results

Change-Id: I674302eb51542ad5f4d918da68d616428c73ae9f
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2020-10-09 16:26:01 +02:00
Edward Welbourne
df1309c83a Clean up tst_QLocale::testNames(), give better message on failure
It was previously casting enum values to int, which produced unhelpful
answers when a test failed. Better to have them as enum values that
get printed as their names, which are actually informative.

Change-Id: I1bf2971b1426bdbbc321bb48f45ee3e5799e76ec
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-10-09 14:40:37 +02:00
Edward Welbourne
92f0f99c23 Check validity before adding to a QDateTime
QDateTime's addDays(), addMonths() and addYears() neglected to check
for validity before doing their job, with the result that they could
produce "valid" (but wildly inappropriate) results if used on an
invalid date-time.  Added tests for this case (and the boundary).

Change-Id: I7b0d638501cb5d875a678cde213547a83ed7529e
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-10-09 01:11:20 +02:00
Edward Welbourne
2a6f2fe9ef Check against {und,ov}erflow in more QDateTime methods
QDateTime's range of possible values is wider than anyone generally
needs, but let's not do confusing things when someone does overflow
it.

Change-Id: Ifbaf7a0f02cd3afe7d3d13c829bf0887eba29f7f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2020-10-09 01:11:00 +02:00