Commit Graph

11312 Commits

Author SHA1 Message Date
Edward Welbourne
057329c24c Make feature datetimeparser depend on feature datestring
No client of QDateTimeParser actually uses it unless datestring was
enabled, nor is it any use without datestring. Various methods
conditioned on datestring are broken unless datetimeparser is enabled.
We can't condition public API on datetimeparser, as it's a private
feature, but client code can condition use of it on the private
feature. All string-to-date/time conversions that use a string format
(this includes all locale-specific formats) depend on feature
datetimeparser.

Change #if-ery (or add it) in all client (including test) code to test
the right feature.

Tidied up some code in the process. Killed some already-redundant
textdate #if-ery. Renamed a test whose name claimed it involved
locale, which it doesn't, in the course of #if-ing it.

This simplifies the condition for feature datetimeedit (which overtly
depended on textdate, redundantly since it depends on datestring which
depends on textdate; its dependence on datetimeparser now makes its
dependency on datestring also redundant).

It also removes the need for assorted datestring checks in
QDateTimeParser itself.

Change-Id: I5dfe3a977042134b2cfb16cbcc795070634e7adf
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-07-02 15:35:18 +02:00
Edward Welbourne
c30e0c656f Update tests/auto/corelib/time/'s CMake config
Recent changes in .pro files hadn't been propagated.
Re-ran pro2cmake.py and saved the results.

Change-Id: I91e4cd513329bce10ce8cbd0ddae8240af050213
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-07-02 15:35:17 +02:00
Edward Welbourne
ca8b2a3632 Remove assortee pre-Qt6 code from date/time tests
Assume QT_VERSION >= QT_VERSION_CHECK(6,0,0) throughout.

Change-Id: If70c59f9319f72549de581fc446fd60d32b02521
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-07-02 11:33:01 +02:00
Tor Arne Vestbø
6ff79478a4 Introduce platform API abstraction for QOpenGLContext
The API is available by including qopenglcontext.h as usual,
but scoped in the QPlatformInterface namespace. The namespace
exposes platform specific type-safe interfaces that provide:

 a) Factory functions for adopting native contexts, e.g.

    QCocoaGLContext::fromNative(nsContext, shareContext);

 b) Access to underlying native handles, e.g.

    openGLContext->platformInterface<QCocoaGLContext>->nativeContext()

 c) Platform specific functionality, e.g.

    static QWGLContext::openGLModuleHandle()

    openGLContext->platformInterface<QEGLContext>->doSomething();

The platform interfaces live close to the classes they extend,
removing the need for complex indirection and plumbing, and
avoids kitchen-sink modules and APIs such as the extras modules,
QPlatformFunctions, or QPlatformNativeInterface.

In the case of QOpenGLContext these platform APIs are backed
by the platform plugin, so dynamic_cast is used to ensure the
platform plugin supports the requested interface, but this is
and implementation detail. The interface APIs are agnostic
to where the implementation lives, while still being available
to the user as part of the APIs they extend/augment.

The documentation will be restored when the dust settles.

Task-number: QTBUG-80233
Change-Id: Iac612403383991c4b24064332542a6e4bcbb3293
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2020-07-02 10:27:50 +02:00
Wang Chuan
c513b1214e QTabBar: make sure the tab is repainted after releasing mouse
The tab has to be repainted even f the mouse release event happened
outside the tab bar, otherwise it will look like the tab is still
pressed.

As a drive-by, replace the repaint() call with update(); there is
no need for synchronous painting in an event handler.

Pick-to: 5.15
Fixes: QTBUG-81637
Change-Id: Ia55182be906511ac3b462f00add8a621c6c05fc3
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-07-02 04:17:52 +02:00
Edward Welbourne
da7f4a4c76 Replace a constant with a predicate function using it
Rather than naming a "GMT" string so as to repeatedly test whether a
date-time's string representation ends in it, use a simple lambda to
do the test, so that the string is only used in one place anyway.
Makes the test code more readable.

Change-Id: I5afad9ad5d58702bea7f24e5e5688ea4d738ae0d
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-07-01 16:00:34 +02:00
Alexandru Croitor
5d6705c567 CMake: Skip / ignore failing tests on CMake platforms
Skip crashing tests and ignore failing tests on CMake platforms.

Add missing QTEST_ENVIRONMENT=ci env var assignment to Coin test
instructions. This was hardcoded by the Coin code for qmake
configurations.

Task-number: QTBUG-85364
Change-Id: Id2312e504a0d36b8f8596d4cebaa49c63731406e
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-07-01 14:55:29 +02:00
Volker Hilsheimer
ab6861b01f Fix delivery of MouseMove events to newly opened popup windows
Amend d934fd7f54, which was too naive in
assuming that any change to the popup stack while a popup had been
pressed into should result in mouse move events to be delivered without
buttons.

Instead, add a new flag that is set explicitly when the qt_popup_down
widget is closed, and remove buttons from the move move events only when
that flag is set.

Add the sorely missing test case as well, even if we have to accept that
not all behavior can be tested reliably. Ie. on macOS, the simulated
mouse event differs from the event we do get from the QPA plugin or the
system; on Xcb, some of the behavior depends on the window manager.
This is something we could try to clean up for Qt 6.

Change-Id: Ibf0a0a6fb7d401915057365788947e5a35aa20c3
Fixes: QTBUG-84926
Task-number: QTBUG-82538
Pick-to: 5.15
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Liang Qi <liang.qi@qt.io>
2020-07-01 14:52:49 +02:00
Timur Pocheptsov
37d9e44cd0 QSslConfiguration::setCiphers - introduce the overload taking QString
We had such an overloaded version in QSslSocket, it was deprecated without
providing any alternative. Now this function has some use and may be
introduced in Qt6, as QSslConfiguration::setCiphers(const QString &).
Last but not the least - a useless and strange auto-test was removed
(it was creating a list of 5 QSslCiphers each with isNull() == true).
That's becasue '!MD5' or 'ALL' (for example) is not a cipher to be found
in supportedCiphers.

Change-Id: I47eb4c0faa9b52885e883751dd992cd9cb3d26fe
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-07-01 11:26:15 +02:00
Alexandru Croitor
fb55e1e71e Sql: Fix heap-user-after-free for globally initialized db objects
Becaues the database objects were created as globals, there was a
possible use-after-free issue when deleting the objects on application
exit.

Move the initialization of the database objects into static variables
inside the test constructor.

As a drive-by, also add one missing test to the CMake projects.

Fixes: QTBUG-85357
Change-Id: I2c8f2c5daee96bb9d1d21dae37950a2da5ffdf27
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-07-01 10:03:57 +02:00
Volker Hilsheimer
980795dc55 Let QScreen::grabWindow's winId parameter default to 0 and add test
The platform plugins are implemented to grab the entire screen if
no window ID is provided. They do not grab the entire virtual
screen, just the screen the method is called on.

On macOS, the implementation ignored the window parameter, and
always grabbed the entire virtual screen. This change fixes the
cocoa implementation. The test passes in local tests (with two
displays with different dpr). Since grabbing a screen returns an
image with managed colors, we need to convert it to sRGB color
spec first, otherwise displaying a grabbed image will produce
different results. This will need to be changed once Qt supports
a fully color managed flow.

The test does not cover the case where a window spans multiple
displays, since this is generally not supported at least on macOS.
The code that exists in QCocoaScreen to handle that case is
untested, but with the exception of the optimization it is also
unchanged.

Done-with: Morten Sørvig <morten.sorvig@qt.io>
Change-Id: I8ac1233e56d559230ff9e10111abfb6227431e8c
Fixes: QTBUG-84876
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2020-07-01 07:09:24 +02:00
Jarek Kobus
c70c4e4266 Use QList instead of QVector in corelib docs
Task-number: QTBUG-84469
Task-number: QTBUG-85221
Change-Id: Ieb0ba7d82409e3c053a5788a01e92ea495505643
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2020-06-29 18:00:13 +02:00
Timur Pocheptsov
45c0f45e04 Move QAlertLevel and QAlertType enums into the namespace QSsl
Not to pollute the global namespace with rather generic names
(especially in case QT_NAMESPACE is none); also drop the
(now)redundant 'Q' prefix in the names.

Change-Id: I57ea7e3996cced705f7ddbdbc1e0231191b31c43
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-06-29 17:08:13 +02:00
David Faure
eb54646984 Fix QUrl::toDisplayString(PreferLocalFile) returning an encoded path
It's supposed to return the same as toLocalFile(), for local files,
which means passing QUrl::FullyDecoded just like QUrl::toLocalFile()
does.

But a few code paths were testing component formatting options without masking
other FormattingOptions like RemovePassword, so this had to be fixed.

Fixes: QTBUG-84594
Change-Id: I82f15148b6d93516200f9ad6258d474e7f10924a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-06-29 16:45:31 +02:00
Christian Ehrlicher
ab1e0961d4 QFileDialog: remove deprecated mode QFileDialog::DirectoryOnly
Change-Id: Ia06e80c1bbed3e5bb80793aebd0a4780eb81a36b
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2020-06-26 22:40:34 +02:00
Alexandru Croitor
167741717f CMake: Fix tst_qmake not to hang and re-enable it
We don't really know why, but using the ctest
--force-new-ctest-process flag stops the test from hanging.

Also re-enable the test.

Task-number: QTBUG-78449
Task-number: QTBUG-81365
Change-Id: I33094696dfe3f610dc257089074b1c2a9926f651
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-06-26 22:14:09 +02:00
Joerg Bornemann
9a4391271b Remove superfluous define from tst_qmake
The QMAKE_CROSS_COMPILED define isn't used since 2011.

Change-Id: I9f03791e9f7c0ef439db5e65d930c0b7cb928974
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-06-26 21:24:52 +02:00
Joerg Bornemann
af61b5ca5c CMake: Fix tst_qmake::resources() on Windows
This test calls qmake on a project that generates a .qrc file. On
Windows, where debug_and_release is on by default, the generated qrc
file ends up in a "debug" or "release" subdirectory. On other
platforms the file is generated directly in the build dir.

To guess the right location, the preprocessor defines RELEASE_BUILD
and DEBUG_BUILD were passed to tst_qmake.cpp by the test's .pro file.
While the mapping from debug_and_release was fine for the .pro file,
it was commented out in the automatically converted CMakeLists.txt.

Instead of trying to fix the condition, we're going the easier route
that's used in all other .pro files of tst_qmake: make sure that
debug_and_release doesn't get in the way. In other tests this is done
by setting
    DESTDIR = ./
which doesn't work for the generated qrc file. That's why we simply do
    CONFIG -= debug_and_release
to make sure that everything is generated directly in the build dir.

Change-Id: I557ac4e21d7b385004d369fae8a3f727d76d4d88
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-06-26 21:24:50 +02:00
Alexandru Croitor
554d40da58 CMake: Skip building tst_qprocess test when cross compiling
tst_qprocess hangs on the qemu armv7 configuration.

Task-number: QTBUG-85287
Change-Id: I5a77a81a24bb1bd315edfcf14f3bcbfd5b925e4d
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2020-06-26 14:54:32 +02:00
Laszlo Agocs
db61e43c81 rhi: Enable specifying just an adapter or phys dev
Required by OpenXR. A VkPhysicalDevice or an adapter LUID + feature
level pair should be adoptable while leaving the rest (device, queue,
etc. setup) to QRhi as normal.

Change-Id: Iada0972671b037b4efb03e7831b7c9b8c5f2393d
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2020-06-26 14:42:42 +02:00
Laszlo Agocs
b60f516aca Fix qsizetype fallout in rhi manual tests
Change-Id: I574a2930b5eeb4b3e1f3c6fca6d70dbda64ec324
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2020-06-26 14:42:36 +02:00
Lars Knoll
e81330d327 Add explicit encode()/decode() methods to QStringConverter
The functional style interface is nice, but does feel alien in some
contexts, so better also have explicit encode and decode methods.

Change-Id: Ic07ced15f65cdb3a7f1cf044041e341d2ef87f79
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2020-06-26 14:41:42 +02:00
Robert Loehning
873c099788 Fuzzing: Add fuzz target for QCryptographicHash::result
Pick-to: 5.15
Change-Id: Ifc12358dd8cb932fe62c13975554d753a4f1afd9
Reviewed-by: Albert Astals Cid <albert.astals.cid@kdab.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-06-26 14:41:42 +02:00
Jarek Kobus
0475460102 Use QList instead of QVector in corelib
Applied to headers only. Source file to be changed separately.
Omitted statemachine for now to avoid conflicts.
Omitted qmetatype.h for now - to be handled later.

Task-number: QTBUG-84469
Change-Id: I317376037a62467c313467d92955ad0b7473aa97
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2020-06-25 22:30:59 +02:00
Simon Hausmann
b20c7df63a Remove QPropertyMemberChangeHandler again
Adding support for a static notifier within QProperty itself - through a
QProperty "sister" class - is more efficient in terms of memory
consumption and run-time performance.

The MemberChangeHandler permanently takes up at least three pointers,
while the notified properties only cost one pointer in the binding.

Change-Id: Ia1a8c2b66f1f3c2fe13ae0ad9f12cdb6bdcc35ef
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2020-06-25 14:11:56 +02:00
Fabian Kosmale
e18a060c03 QNotifiedProperty: Add guard callback
A guard callback is a predicate which takes the new value set by
setValue or computed as the result of a binding expression. If it
returns false, the value is discarded and the old value is kept.
Note that due to lazyness, when setting a binding, we still notify
everyone as the binding is only evaluated on demand, and the guard can
thus only run when someone actually queries the value.
Note further that a guard is allowed to modify the value that is passed
to it (e.g. to clamp it to a certain range).

Task-number: QTBUG-85032
Change-Id: I3551e4357fe5780fb75da80bf8be208ec152dc2a
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2020-06-25 14:11:56 +02:00
Fabian Kosmale
6a24ac7c4e QNotifiedProperty: pass old value to callback if requested
Check at compile time whether the static callback takes an argument
(which has to be of the same time as the type of the property). If so,
retrieve the old value and pass it to the callback.

Change-Id: Ib1c4c9e05b826b6be492b03f66fa72ad015963ee
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2020-06-25 14:11:56 +02:00
Jarek Kobus
e721ec269e Use QList instead of QVector in other tests
Task-number: QTBUG-84469
Change-Id: I656c9f73bd2364be39ee67747524e7c4a25c0935
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-06-25 10:14:24 +02:00
Jarek Kobus
88cfcd7f3f Use QList instead of QVector in sql tests
Task-number: QTBUG-84469
Change-Id: Id429ce85da027541b53d516045a78b739c2e9745
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-06-25 10:14:15 +02:00
Jarek Kobus
fe5b04346c Use QList instead of QVector in testlib tests
Task-number: QTBUG-84469
Change-Id: I36a69021c8d3491a4fd622f3ecb218e1be8a77bc
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-06-25 10:13:58 +02:00
Jarek Kobus
5accfa1e68 Use QList instead of QVector in widgets tests
Task-number: QTBUG-84469
Change-Id: I490fdb237afad2d8a15954fe34d6b549a83fa4aa
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-06-25 10:13:43 +02:00
Jarek Kobus
74dc89de3e Use QList instead of QVector in benchmarks tests
Task-number: QTBUG-84469
Change-Id: Id61d6036067da0bcd0811b1b97df5f1334007b7e
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-06-25 10:13:31 +02:00
Jarek Kobus
d1612610e6 Use QList instead of QVector in gui tests
Task-number: QTBUG-84469
Change-Id: Ia86f39597de418dde6cd9ae3170ef919bd27416a
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-06-25 10:13:12 +02:00
Sona Kurazyan
d7ccd8cb45 Remove QByteArray's methods taking QString and their uses
[ChangeLog][QtCore][QByteArray] Remove method overloads taking
QString as argument, all of which were equivalent to passing the
toUtf8() of the string instead.

Change-Id: I9251733a9b3711153b2faddbbc907672a7cba190
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-06-25 09:54:16 +02:00
Jarek Kobus
d13b6bd496 Use QList instead of QVector in network tests
Task-number: QTBUG-84469
Change-Id: Ic96dc8d29b5d720810ca636284f5fd37e4307acd
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-06-25 07:54:44 +02:00
Jarek Kobus
273fcd0c05 Use QList instead of QVector in dbus tests
Task-number: QTBUG-84469
Change-Id: I37d169770f188837118b4e33aa3a3894bf7aed2c
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-06-25 07:54:33 +02:00
Lars Knoll
95e84c0ea9 Allow qMin, qMax and qBound for types that can be losslessly converted
Add overloads for qMin and friends where the arguments are of different
type, but one can be easily promoted to the other. Return the promoted
type. Promotions are only allowed if both types are either signed,
unsigned or floating point numbers.

This should simplify writing code in many case (as for example
qMin(myint64, 1)) and also help reduce source incompatibilities between
Qt 5 and Qt 6, where the return types for sizes of our containers changes
from int to qsizetype.

Change-Id: Ia6bcf16bef0469ea568063e7c32f532da610d1cd
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-06-25 06:20:18 +02:00
Volker Hilsheimer
0dbd2dd863 Skip proxy widgets that can't take focus when (back)tabbing
Fixes regression introduced in b4981f9d4c,
due to which it was possible to back-tab into a widget even though it or
its focusProxy had a NoFocus policy.

As a drive-by, split the complicated if-statement up a bit for improved
readability.

Change-Id: Ib0ac2604076e812e340b11534c23ae8ae958d082
Fixes: QTBUG-76924
Pick-to: 5.15 5.12
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2020-06-25 06:20:03 +02:00
Volker Hilsheimer
75638e258f Don't pollute global namespace with #define P
Breaks the build if any global header has

using P = SomeType;

statement, and unnecessary to do so before the headers are included.

Change-Id: I3b8cc705bf662f768b8895e4b3ec1428ab39ef27
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-06-25 06:19:50 +02:00
Thiago Macieira
cb1c66bd20 Fix conversion of QVariant() in QJsonArrays and Objects (through CBOR)
When I wrote the QCborValue to QJsonValue conversion, I used
QJsonValue::Undefined because it allowed to keep some level of
compatibility in CBOR, despite the function documentation saying that
CBOR undefineds became JSON nulls. Which they did.

But when we converted QJson{Array,Object} to be backed by CBOR classes,
that Undefined meant the insertion into the array/object actually
deleted the entry.

[ChangeLog][JSON] Fixed a regression from 5.14 that caused values of
default-constructed QVariants in QVariantLists, QVariantMaps and
QVariantHashes to disappear when converting to JSON via
fromVariant{,List,Map,Hash}.

Fixes: QTBUG-84610
Pick-to: 5.15
Change-Id: Ic0987177fe463f352db9bd84993f116e2bdacc75
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-06-24 22:43:57 +02:00
Marc Mutz
82743fb8a2 QPair: add a check that SB works as expected
We have no doubt it does, because it's compiler-synthesized, but
we might want to implement the tuple protocol for QPair in the
future and then this will act as a safety net, emulating what
users are currently already doing with QPair.

Change-Id: Ie37f0214bb1aa64210d25be8a256606f4572febe
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-06-24 17:49:35 +02:00
Edward Welbourne
f6d1be7c66 Use ranged for loops in place of foreach in QTimeZone tests
This (and use of Q_SLOTS for the test slots) makes it possible to
enable QT_NO_KEYWORDS and QT_NO_FOREACH in all the corelib/time/
tests.

Change-Id: I85fd358f3d1a72c9269d5260d0224640c1751f2d
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
2020-06-23 16:59:45 +02:00
Jarek Kobus
a8f531216e Use QList instead of QVector in uic tests
Task-number: QTBUG-84469
Change-Id: I2d3a8e7eb7094844544e841145fa5d2de8c66adb
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2020-06-23 15:06:23 +02:00
Marc Mutz
44da43e8e4 QString: add char8_t overload of fromUtf8()
Use the overload-with-template trick from P1423 to avoid ambiguities
when existing callers pass 0 or nullptr.

Add a qdoc-ignored macro to hide the fact that the overload is a
template.

[ChangeLog][QtCore][QString] Added char8_t overload of fromUtf8().

Change-Id: Iaa2d365bfa161ef36cc73fa3bad50aabf34d01db
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-06-23 06:31:28 +00:00
Thiago Macieira
727fab7d29 QCborMap: remove the optimization not to detach from non-const find()
All our tests were find() == end() or !=, which depends on the
evaluation order of the arguments to operator==(). If end() is called
first, then the detach happens before find() and all is well. But if
find() is called first, it may return end() before end() detaches.

[ChangeLog][QCborMap] Fixed a bug that could cause the iterator returned
from a failing key search with find() not to match end(). Now, every
call to find() will detach in shared QCborMaps; to avoid this, use
constFind() and constEnd().

Fixes: QTBUG-84583
Pick-to: 5.15 5.12
Change-Id: I552d244076a447ab92d7fffd161793496a8d03a8
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-06-23 00:29:50 +00:00
Marc Mutz
ffb73175e6 QVarLengthArray: add missing move special member functions
A QVLA is copyable, so it should be movable, too.

Added a helper function a la P1144's uninitialized_relocate_n to deal
with the QTypeInfoQuery stuff. This way, the code is re-usable
everywhere it's needed. The same cannot be said for QArrayDataOps,
which only a parent can love...

[ChangeLog][QtCore][QVarLengthArray] Added missing move constructor
and move-assignment operator.

Task-number: QTBUG-39111
Change-Id: If0dc2aa78eb29062d73dcd3dc4647ba345ae39e6
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-06-22 17:24:07 +00:00
Jarek Kobus
95a5cd71b6 Use QList instead of QVector in concurrent tests
Task-number: QTBUG-84469
Change-Id: Ia8113ef044a918e46176bfa3f4b34781dc69dd03
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2020-06-22 16:46:01 +02:00
Jarek Kobus
b0792f391d Use QList instead of QVector in moc tests
Task-number: QTBUG-84469
Change-Id: I6a775b32a82658485216a4827a43503b395161c6
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-06-22 16:45:55 +02:00
Timur Pocheptsov
c2bf56fc3a QSslSocket: remove certificate-related setters
They were deprecated with replacements in QSslConfiguration proposed (and
some without alternative, which we'll provide if there is any demand
in such an API). Special thanks to M.N. for a nice hint on how to
amend the test without introducing a new API.

Change-Id: I7841a5b3f30469d8204b61cb65921c34275e0650
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-06-22 12:11:47 +02:00
Shawn Rutledge
29d3e7ce38 Replace "no devices registered" warnings with qCDebug
The idea was to keep nagging us to update all the platform plugins to
do device registration. But besides being annoying, it would cause
test failures if we start adding QTest::ignoreMessage() all over,
and then some platforms start doing device registration properly.

Change-Id: Ia0fbb64cf86f33532be032ec9eebe6e4ad607f20
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2020-06-22 11:22:17 +02:00
Andy Shaw
8ba9d2e022 Change boundValues() to return a QVariantList
This enables the order of boundValues to be consistent as with a QMap
it could have been reordered which can be a problem for positional
bindings.

[ChangeLog][QtSQL] Changed signature of QSqlQuery::boundValues() to
return a QVariantList

Fixes: QTBUG-51609
Change-Id: I1c80fa8522fa7352723420b6fc9ec466406315fb
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-06-22 06:54:16 +02:00
Christian Ehrlicher
26a2266304 Remove deprecated QStyleOption::init()
Even it was not marked as deprecated the replacement function initFrom()
is available since Qt4 times (and init() is deprecated since then)

Change-Id: I09a4ebbf66b01fbe7aec67691dc68d2e42d1cd78
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-06-21 12:51:24 +02:00
Lars Knoll
03326a2fec Move implementation of QVector/List back to qlist.h
And name the main class QList. That's also the one we document.

This gives less porting pain for our users, and a lot less churn
in our API, as we use QList in Qt 5 in 95% of our API.
In addition, it gives more consistent naming with QStringList and
QByteArrayList and disambiguates QList vs QVector(2|3|4)D.

Fixes: QTBUG-84468
Change-Id: I3cba9d1d3179969d8bf9320b31be2230d021d1a9
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-06-20 20:01:33 +02:00
Karsten Heimrich
18ec53156e Move QTextCodec support out of QtCore
* Assume UTF-8 on all Unix like systems
* Export some functions to be able to compile QTextCodec once
  moved to Qt5Compat.

Task-number: QTBUG-75665
Change-Id: I52ec47a848bc0ba72e9c7689668b1bcc5d736c29
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-06-20 02:04:38 +02:00
Giuseppe D'Angelo
3e1d03b1ea Port Q_STATIC_ASSERT(_X) to static_assert
There is no reason for keep using our macro now that we have C++17.
The macro itself is left in for the moment being, as well as its
detection logic, because it's needed for C code (not everything
supports C11 yet).  A few more cleanups will arrive in the next few
patches.

Note that this is a mere search/replace; some places were using
double braces to work around the presence of commas in a macro, no
attempt has been done to fix those.

tst_qglobal had just some minor changes to keep testing the macro.

Change-Id: I1c1c397d9f3e63db3338842bf350c9069ea57639
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-06-19 19:38:23 +02:00
Robert Loehning
96065b7227 Fuzzing: Test svg images
Pick-to: 5.15
Change-Id: I1467d07eaaa1233417cd3a18fd65ec3322181984
Reviewed-by: Albert Astals Cid <albert.astals.cid@kdab.com>
2020-06-19 19:16:28 +02:00
Shawn Rutledge
f25bd998a7 Don't return a touchscreen from QPointingDevice::primaryPointingDevice()
This was causing some bogus failures in Qt Quick autotests.
Existing APIs like QQuickWindow::mouseGrabberItem() are not really
compatible with the idea of a mouse-less system; but perhaps we can
revisit this later.

Task-number: QTBUG-85114
Change-Id: Id1c2e5894e5cf13a79998aaea28d5f42fad920cf
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2020-06-19 08:13:36 +02:00
Shawn Rutledge
28ef8d283d Add QPointingDevice argument to every QWSI input event handler function
We want every QInputEvent to carry a valid device pointer. It may be
some time until all QPA plugins are sending it, but it's necessary to
provide the functions for them to start doing that.

We now try to maintain the same order of arguments to all the functions.
handleTouchEvent(window, timestamp, device, the rest) was already there
(except "device" has changed type now), and is used in a lot of platform
plugins; so it seems easiest to let that set the precedent, and modify
the rest to match. We do that by adding new functions; we can deprecate
the older functions after it becomes clear that the new ones work well.

However the handleGestureEvent functions have only ever been used in
the cocoa plugin, so it's easy to change their argument order right now.

Modify tst_qwindow::tabletEvents() to test new tablet event API.

Task-number: QTBUG-46412
Change-Id: I1828b61183cf51f3a08774936156c6a91cfc9a12
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2020-06-18 18:53:40 +02:00
Andrei Golubev
68de38ded1 Document QPromise API
Documented QPromise. Added snippets under auto tests
to ensure they are compiled and run in CI.

Task-number: QTBUG-81586
Change-Id: I20084e38f9d2f6fc8540f95ee03ec3d2827177e8
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2020-06-18 18:28:41 +03:00
Simon Hausmann
b0f445a152 Add support for QNotifiedProperty to the moc
Change the meaning of Q_PRIVATE_QPROPERTY to imply that the property is
implemented using a QNotifiedProperty. That requires passing the owner
object instance to the value and binding setters.

Similarly, detect QNotifiedProperty members like QProperty.

Change-Id: If49bbb04c8ccd4a661973888c50d2d556c25034f
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2020-06-18 17:26:11 +02:00
Lars Knoll
7b5d5faae1 Remove unused functionality from QTypeInfo
Change-Id: I10fe4cde7a18047599e656cc3bb67b0dfe18a986
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-06-18 12:02:51 +02:00
Shawn Rutledge
f04cb9ed63 Begin writing tst_QInputDevice autotest
...starting with a new feature: registering different devices at
different seats and verifying their capabilities and that we can get
them back again.

Change-Id: I8e58a49080633753d02a76e5fdc4932f5c674e0a
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
2020-06-18 08:05:44 +02:00
Shawn Rutledge
9b72900834 Update QTabletEvent device_information manual test
- stop using deprecated accessors in QTabletEvent and QMouseEvent
- position() and globalPosition() provide high resolution so
  we don't need to display hi-res global pos separately
- keep a pointer to the last-seen QPointingDevice instance
  rather than copying fields out of it; it will only be deleted
  if the platform plugin does that (usually only at exit or
  when it's unplugged)
- show seat ID
- show platform-specific device ID

Change-Id: Ic34e1d1256d6956867992db831c2e66bdda7001e
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2020-06-17 09:12:20 +02:00
Shawn Rutledge
6589f2ed0c Introduce QInputDevice hierarchy; replace QTouchDevice
We have seen during the Qt 5 series that QMouseEvent::source() does
not provide enough information: if it is synthesized, it could have
come from any device for which mouse events are synthesized, not only
from a touchscreen. By providing in every QInputEvent as complete
information about the actual source device as possible, we will enable
very fine-tuned behavior in the object that handles each event.

Further, we would like to support multiple keyboards, pointing devices,
and named groups of devices that are known as "seats" in Wayland.

In Qt 5, QPA plugins registered each touchscreen as it was discovered.
Now we extend this pattern to all input devices.  This new requirement
can be implemented gradually; for now, if a QTWSI input event is
received wtihout a device pointer, a default "core" device will be
created on-the-fly, and a warning emitted.

In Qt 5, QTouchEvent::TouchPoint::id() was forced to be unique even when
multiple devices were in use simultaneously. Now that each event
identifies the device it came from, this hack is no longer needed.

A stub of the new QPointerEvent is added; it will be developed further
in subsequent patches.

[ChangeLog][QtGui][QInputEvent] Every QInputEvent now carries a pointer
to an instance of QInputDevice, or the subclass QPointingDevice in case
of mouse, touch and tablet events. Each platform plugin is expected to
create the device instances, register them, and provide valid pointers
with all input events. If this is not done, warnings are emitted and
default devices are created as necessary. When the device has accurate
information, it provides the opportunity to fine-tune behavior depending
on device type and capabilities: for example if a QMouseEvent is
synthesized from a touchscreen, the recipient can see which touchscreen
it came from. Each device also has a seatName to distinguish users on
multi-user windowing systems. Touchpoint IDs are no longer unique on
their own, but the combination of ID and device is.

Fixes: QTBUG-46412
Fixes: QTBUG-72167
Task-number: QTBUG-69433
Task-number: QTBUG-52430
Change-Id: I933fb2b86182efa722037b7a33e404c5daf5292a
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2020-06-16 22:06:56 +02:00
Laszlo Agocs
9b8d4a9e45 rhi manual tests: Prevent warnings with MSVC
The QPair changes trigger warnings about size_t vs. quint32.

We made offsets and sizes 32-bit in the QRhi API to emphasize that
some of the graphics APIs are using 32-bit sizes still. It's a bit
unfortunate that pairs now generate warnings when the size does not
match. Just cast as needed.

Change-Id: I88504eed8be6f4bdb2205b3671e2c2a9db9fcb1e
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2020-06-15 15:34:05 +02:00
Laszlo Agocs
ed231455cc Relax tst_qvulkan::vulkanVersionRequest to make it compatible with 1.1
The Vulkan spec changed the behavior for VkApplicationInfo::apiVersion
in 1.1, conveniently breaking compatibility with all existing 1.0 logic.

We can no longer assume that the 1.0 behavior, which was failing instance
creation with VK_ERROR_INCOMPATIBLE_DRIVER for an unsupported version,
is always in place. So do not rely on this in the test, and add a
reminder in QVulkanInstance docs as well.

Fixes: QTBUG-85040
Change-Id: I8f5c7a7830877b72d106c444aebfaea191083ee0
Reviewed-by: Christian Strømme <christian.stromme@qt.io>
2020-06-15 15:33:46 +02:00
Robert Loehning
927a82f5e0 Fuzzing: Don't try to load huge valid images
They are justified in using huge memory.

Pick-to: 5.15
Change-Id: Id16d2ea67cfac0e031d05258173391e222b41097
Reviewed-by: Albert Astals Cid <albert.astals.cid@kdab.com>
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2020-06-15 09:31:56 +00:00
Mårten Nordheim
306ebe03ea Http: Fix POST-to-GET redirects still uploading or transmitting CL
CL = Content-Length

The uploadByteDevice was kept after a redirect which caused the
internals to assume that we had to upload the data. Even if this was
not the case we still transmitted the Content-Length header from the
first request which was now stored in two places.

Fixes: QTBUG-84162
Pick-to: 5.15
Change-Id: Ic86b1ef0766ffcc50beeed96c1c915b721d40209
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2020-06-12 16:11:55 +02:00
Lars Knoll
5caf7ef3b1 Remove deprecated methods
Those aren't part of Qt 6 anymore.

Change-Id: I9ea7de07d89156e8d0fb6ae9deeb24e0de5fa429
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-06-12 15:50:08 +02:00
Timur Pocheptsov
8a65cd8dcd long_name_onDemandCerts_static - stop testing/using the deprecated API
Pick-to: 5.15
Change-Id: Ia937fc393b2dbc2602a93f2b3a71328a805ec1a6
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-06-12 14:09:23 +02:00
Timur Pocheptsov
b7724048f9 long_name_onDemandCerts_member - stop testing/using the deprecated API
Pick-to: 5.15
Change-Id: I3d7ea78627afcd0225e717d243da49fd70b58461
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-06-12 14:09:04 +02:00
Timur Pocheptsov
56187f1e45 tst_qsslcertificate - suppress a deprecation warning
In Qt 5 we have to work with the esisting API (QSslCertificate::verify),
taking only the peer's chain and the name. We already have a private
API to have a CA's list as an additional parameter, the proper fix
in Qt6 will also introduce a public complement for this.

Pick-to: 5.15
Change-Id: Ib1f75c3056b135c6e6d42f977b5a7034fca658ee
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-06-12 14:08:55 +02:00
Marc Mutz
3f6142f5a1 Rename new slice() method sliced()
The recently-added slice() method has the problem that it's a noun
as well as a verb in the imperative. Like std::vector::empty, which
is both an adjective and a verb in the imperative, this may cause
confusion as to what the function does. Using the passive voice form
of slice(), sliced(), removes the confusion. While it can be read as
an adjective, too, that doesn't change the meaning compared to the
verb form.

Change-Id: If0aa01acb6cf5dd5eafa8226e3ea7f7a0c9da4f1
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-06-11 19:14:03 +00:00
Lars Knoll
d0689ec867 Get rid of the obsolete isEditable flag for properties
Change-Id: I54411bd8e223671523c9c8fad5c80bfa6b5b7097
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2020-06-11 19:39:56 +02:00
Fabian Kosmale
630c7b4811 Cleanups in QMetaProperty
This changes the layout of the meta object data, so
also bump the meta object revision.

Original-patch-by: Lars Knoll <lars.knoll@qt.io>
Change-Id: I176fb16c207e8ebe59e358e69554be813406232f
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2020-06-11 19:39:54 +02:00
Lars Knoll
5603be705e Qt6: remove support for property flags being functions
Property flags should be compile time booleans, not something to
be determined at runtime.

We've been using this to dynamically disable some properties in QWidget
based classes dependent on the state of a different property, but this
should better get implemented on top of our widgets.

Change-Id: I6296e8761303ecdf24d9e842142e8596304c015d
Reviewed-by: Simon Hausmann <hausmann@gmail.com>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2020-06-11 19:39:53 +02:00
Lars Knoll
8ea11e0cf7 Remove most overloads taking a QStringRef from the QString API
Add QStringView overloads where they were missing. This keeps things
almost 100% source compatible.

Task-number: QTBUG-84319
Change-Id: Ica8ee773b2ce655e9597097786117959e34b236e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-06-11 15:52:25 +02:00
Volker Hilsheimer
f9940b15f7 Fix breakage of QPushButton on macOS when a style sheet was set
Amends comment 6e1d70ae12, which
introduced SE_PushButtonBevel so that QPushButton could ignore clicks
outside of the button's bevel.

In the macOS style, make sure that the framerect we pass to
NSButton::alignmentRectForFrame is the rect we receive from QPushButton
in the style options. The frame property of the shared NSButton* object
might not be initialized.

In the style sheet style, handle SE_PushButtonBevel the same ways as
Contents and FocusRect, as it is not a separately styleable property.

Change-Id: I12eb1b046c864a02b34d276e6352e2e16d44231e
Fixes: QTBUG-84852
Fixes: QTBUG-84879
Task-number: QTBUG-81452
Pick-to: 5.15
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2020-06-11 15:52:25 +02:00
Marc Mutz
c549ff3fd4 Also check QStringView(std::nullptr_t) for constexpr'ness
Pick-to: 5.15
Change-Id: I85967caa014fa93d2cd3f26b63e4a85414f6a803
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-06-11 08:24:13 +02:00
Lars Knoll
ecacb3c62f Port QLocale::quoteString from QStringRef to QStringView
Task-number: QTBUG-84319
Change-Id: I29726ebfda7a5f51a0a6ee29e905b0b904256c8d
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-06-11 02:50:16 +02:00
Timur Pocheptsov
7d98964815 tst_QSslSocket - stop using qrand (to suppress a warning)
Whoever wrote this test, was a PROPER hacker: trying to force a TLS implementation
not to properly compress some data, they generated a sequence of bytes in a very fancy manner,
something like 255 0 0 0 255 0 0 0 123 0 0 0 255 0 0 0 - yeah, it's really a random sequence
of bytes, surely, it's impossible to compress! Meh.

Pick-to: 5.15
Change-Id: Ia10ae18a40b5b8f006c45147b06fe5be6efcb129
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-06-10 22:55:49 +02:00
Shawn Rutledge
84e76c37a5 Restore default role names in QStandardItemModel::roleNames()
Amends 32b586864e, which added an override
of QStandardItemModel::roleNames().  It's good for it to have its own
QHash so that roles can be added, and because
QStandardItemModel::setItemRoleNames() remains un-deprecated; but before
that change, they were the roles that QAbstractItemModel had initialized
from QAbstractItemModelPrivate::defaultRoleNames().  In particular, we
need "display" to map to Qt::DisplayRole by default; several tests in
qtdeclarative depend on that.

Change-Id: I58b2d6aa6b6c78b1d618335ddc4ecb834af57274
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-06-10 19:58:48 +02:00
Giuseppe D'Angelo
8e98a161e9 Long live std::pair!
Make QPair an alias for std::pair, and qMakePair just a forwarder
towards std::make_pair.

Why? Fundamentally to ditch a bunch of NIH code; gain for free
structured bindings, std::tuple and std::reference_wrapper
compatibility, and so on.

Breakages:

* Some that code manually forward declares QPair.
We don't care about it (<QContainerFwd> is the proper way).

* Some code that overloads on std::pair and QPair. Luckily
it's mostly centralized: debug, metatypes, testing macros.
Just remove the QPair overload.

* Usages of qMakePair forcing the template type parameters.
There are a handful of these in qtbase, but only one was actually
broken.

* std::pair is NOT (and will never likely be) trivially copiable.
This is agreed to be a mistake done by practically all implementations
in C++11, can can't be fixed without breaking ABI.
Some code using QPair assuming it's trivially copiable may break;
exactly one occurrence was in qtbase.

* QMetaType logic extracts the type names in two different ways,
one by looking at the source code string (e.g. extracted by moc)
and one via some ad-hoc reflection in C++. We need to make
"QPair" (as spelled in the source code) be the same as "std::pair"
(gathered via reflection, which will see through the alias)
when compared. The way it's already done e.g. for QList is
by actually replacing the moc-extracted name with the name
of the actual type used in C++; do the same here.
On libc++, std::pair is actually in an inline namespace --
i.e. std::__1::pair; the reflection will extract and store
"std::__1::pair" so we need an ad-hoc fix to QMetaType.

[ChangeLog][QtCore][QPair] QPair is now an alias to std::pair,
and does not exist as a class in Qt any more. This may break
code such as functions overloaded for both QPair and std::pair.
Usually, the overload taking a QPair can be safely discarded,
leaving only the one taking a std::pair. QPair API has not changed,
and qMakePair is still available for compatibility (although
new code is encouraged to use std::pair and std::make_pair
directly instead).

Change-Id: I7725c751bf23946cde577b1406e86a336c0a3dcf
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-06-10 16:49:08 +02:00
Timur Pocheptsov
d9b2115060 tst_QSslSocket - do not test the deprecated API
We deprecated several setters on QSslSocket, no need to test
them then (and I'm removing them in Qt 6 anyway, so changing
the test is the phase 1).

Pick-to: 5.15
Change-Id: I5807abfb280cbacd4fcc19468793f9d1f3b2ff20
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-06-10 16:47:48 +02:00
Eirik Aavitsland
56f40cdca6 Remove the openglextensions module
[ChangeLog][General] The QtOpenglExtensions module has been
discontinued. It provided only convenience functionality for certain
direct OpenGL usage. With the new RHI graphics API abstraction, that
is no longer a primary use case. Applications that still need to
access that API have a number of alternative options, including
QOpenGLExtraFunctions.

Fixes: QTBUG-84085
Change-Id: I272af61c69ebcec207b576d67d08b59623d485ec
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2020-06-10 09:35:04 +02:00
Lars Knoll
d2833a3ce5 Ensure left/right/mid behave in a compatible way
QString and QStringRef did bounds checking for left/right/mid, whereas
QStringView was asserting on out of bounds.

Relax the behavior for QStringView and do bounds checking on pos/n
as well. This removes a source of potentially hidden errors when porting
from QStringRef (or QString) to QStringView.

Unfortunately, one difference remains, where QByteArray::left/right()
behaves differently (and somewhat more sane) than QString and
QStringRef. We're keeping the difference here, as it has been around
for many years.

Mark left/right/mid as obsolete and to be replaced with the new
first/last/slice methods.

Change-Id: I18c203799ba78c928a4610a6038089f27696c22e
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-06-09 16:51:16 +02:00
Andrei Golubev
385f0732d9 Add QPromise implementation
QPromise and QFuture created from it share the same internal state
(namely, QFutureInterface object). QPromise provides high-level
management of the shared resource, ensuring thread-safe behavior
on construction and destruction (also taking into account
QFuture::waitForFinished() semantics).

QFuture acts as a primary controller of QPromise via action
initiating methods such as suspend() or cancel(). QPromise is
equipped with methods to check the status, but the actual
handling of QFuture action "requests" is user-defined.

[ChangeLog][QtCore][QPromise] Added QPromise class to accompany
QFuture. It allows one to communicate computation results and
progress to the QFuture via a shared state.

Task-number: QTBUG-81586
Change-Id: Ibab9681d35fe63754bf394ad0e7923e2683e2457
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2020-06-09 17:21:38 +03:00
Fabian Kosmale
4c32443bc9 metatype: Do not try analyze T in Q*Pointer<T> if T is incomplete
Change-Id: I41737ce470f6d2b071ad5e85f8cad1da3869241c
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2020-06-09 14:20:31 +02:00
Alexandru Croitor
db1de48291 CMake: Fix failing plugin tests on MinGW
MinGW plugins should not have the lib prefix in the shared library
names. Do this manually for a couple of libraries, and also for the
generic qt_add_cmake_library function.

Amends 9b0e23ef8a

Change-Id: I1cfaf8fc046f86edd3e755adfa599aa0aa854ee3
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-06-09 09:34:17 +02:00
Volker Hilsheimer
44fb925f50 Phase 2 of removing QDesktopWidget
Remove QDestopWidget public header, simplify the implementation that
maintains a Qt::Desktop type QWidget for each QScreen, and turn
QWidget's initial target screen into a QScreen pointer.

QApplication::desktop() now takes an optional QScreen pointer, and
returns a QWidget pointer, so that applications and widgets can get
access to the root widget for a specific screen without having to
resort to private APIs.

QDesktopWidgetPrivate implementations to look up a screen for an index,
widget, or point are now all inline functions that thinly wrap
QGuiApplication::screens/screenAt calls. We should consider adding those
as convenience APIs to QScreen instead.

Note that QWidget::screen is assumed to return a valid pointer; there is
code that handles the case that it returns nullptr (but also code that
trusts that it never is nullptr), so this needs to be defined, verified
with tests, and asserted. We can then simplify the code further.

Change-Id: Ifc89be65a0dce265b6729feaf54121c35137cb94
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2020-06-08 20:29:49 +02:00
Shawn Rutledge
a061a64642 Replace calls to deprecated QEvent accessor functions
Many of these were generated by clazy using the new qevent-accessors check.

Change-Id: Ie17af17f50fdc9f47d7859d267c14568cc350fd0
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-06-08 19:11:51 +02:00
Eskil Abrahamsen Blomfeldt
078c3b7d68 Remove deprecated text-related enums
Fixes: QTBUG-82367
Change-Id: Iff2645759657f8e350754e90e791dbd583017671
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-06-08 15:04:19 +02:00
Eskil Abrahamsen Blomfeldt
18e8519dcd Win: Choose a suitable font in tst_QTextLayout::textWidthVsWIdth
The default font on Windows 10 (Segoe UI) will return the
wrong minimum right bearing at some sizes, which will cause
us to skip the textWidthVsWIdth() test at some scale factors,
since we cannot trust the layout to be perfect in this case.

Based on experiment, Arial is more accurate, so in order to
avoid skipping the test, we default to this on Windows instead.
(Note: The problem has not been observed with the default fonts
on Linux or macOS, so we only do this for Windows specifically.)

Task-number: QTBUG-84415
Pick-to: 5.15
Change-Id: I8cdb5d0d9922915a6ed1574d62a561dda0e1dc5d
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2020-06-08 13:03:48 +00:00
Lars Knoll
38096a3d70 Implement first/last/from and slice() for string-like classes
These methods are scheduled as a replacement for left/right/mid()
in Qt 6 with a consistent, narrow contract that does not allow
out of bounds indices, and therefore does permit faster
implementations.

Change-Id: Iabf22e8d4f3fef3c5e69a17f103e6cddebe420b1
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-06-08 13:17:32 +02:00
Eskil Abrahamsen Blomfeldt
3279c8e7d7 Move some flaky text tests into Lancelot
There are some slight differences between normal drawText()
and QGlyphRuns/QStaticText for decoration widths in certain
fonts. We decided to accept this and tried working around it
in the test by using ForceIntegerMetrics (since the difference
is < 0.5 pixel). This enum has been deprecated, so we move
the tests into Lancelot instead, since the idea here is to
test for regressions, not to compare the two painter commands.

Note that there is something off about decorations with
drawGlyphRuns() and drawStaticText() which is exposed
(not caused) by this, perhaps related to using a matrix
for positioning, since that was untested before.

This also takes the liberty of moving the emoji test string
from text.qps, since this was not in the statictext.qps yet.

Change-Id: Ib2d697095cbd11829cdd50b3c0268c85e9607c78
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2020-06-08 06:45:49 +02:00
Oliver Wolff
45b0f1be68 Remove winrt
Macros and the await helper function from qfunctions_winrt(_p).h are
needed in other Qt modules which use UWP APIs on desktop windows.

Task-number: QTBUG-84434
Change-Id: Ice09c11436ad151c17bdccd2c7defadd08c13925
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2020-06-06 20:25:49 +02:00
Giuseppe D'Angelo
c0f7ecab20 QVariant: remove UB and fix semantics in a test
The code was reading from uninitialized memory when creating a
variant. Fixing that reveals that the test semantics
are broken: when dealing with datatypes without a registered
operator==, QVariant resorts to memcmp, so the two objects
would've actually compared equal. Amend that.

Change-Id: I36bad7ee6a45154d5d534b7dd8b618cc0a900126
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-06-06 13:29:34 +02:00
Marc Mutz
ee63557112 QString/View: add tokenize() member functions
[ChangeLog][QtCore][QString, QStringView, QLatin1String] Added tokenize().

Change-Id: I5fbeab0ac1809ff2974e565129b61a6bdfb398bc
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-06-06 02:07:28 +00:00
Allan Sandfeld Jensen
999c79863c Remove QThreadPool::cancel()
Deprecated in 5.9

Change-Id: Ib6e2a5da1e7ee2664fb6fa496bdc880fab870901
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
2020-06-05 20:57:32 +02:00
Eskil Abrahamsen Blomfeldt
a389001710 Fix compilation of lance tool
The QLayout::setMargin(x) call has been deprecated since Qt 5.13.
It was an alias for setContentsMargins(x, x, x, x) so we just
replace it with that.

Change-Id: I1c89eebfe776e0e3c8d0bdc19244bd452db4ef3c
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2020-06-05 14:26:41 +02:00