Commit Graph

4520 Commits

Author SHA1 Message Date
Mårten Nordheim
246e712548 Move-enable QByteDataBuffer::{append,prepend}
Change-Id: I2fd342465475e3a694c8459a54957149f8b418a9
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-08-01 10:51:21 +02:00
Mårten Nordheim
5d7be66fd7 QList: Add a append(QList &&) overload
We already had append(const QList &) and now there's an overload
taking an rvalue reference.

Change-Id: Id2fbc6c57badebebeee7b80d15bb333270fa4e19
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-08-01 00:01:52 +02:00
Thiago Macieira
95afe6b244 QSharedPointer: do allow calling deleters on null pointers
I don't know why std::shared_ptr allows this, but why not.

[ChangeLog][Important Behavior Changes] QSharedPointer objects will now
call custom deleters even when the pointer being tracked was null. This
behavior is the same as std::shared_ptr.

Fixes: QTBUG-85285
Pick-to: 5.15
Change-Id: I24006db8360041f598c5fffd161c260df0313b55
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2020-07-31 10:40:25 -07:00
Thiago Macieira
fe9e6b2ceb QString::vasprintf: fix 't' modifier for integers on 64-bit
‘t’
     Specifies that the argument is a ‘ptrdiff_t’.
     This modifier was introduced in ISO C99.

We use qsizetype, which is the same width as ptrdiff_t, so it makes no
difference in va_arg().

Change-Id: Iea47e0f8fc8b40378df7fffd16255730109413a5
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-07-31 10:36:33 -07:00
Edward Welbourne
a6b3a1e459 Remove deprecated binary json feature
Deprecated in 5.15 in favor of CBOR.

Fixes: QTBUG-81239
Change-Id: I711d4bd7dd1247f58e77ac9fa53304cbe5028918
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-07-31 17:12:48 +02:00
Allan Sandfeld Jensen
0792188440 Add float->qfloat16 rounding and fix the tests
Our hardware optimized conversions of float to qfloat16 rounds to even
where our table based conversion truncated to zero.

The rounding is not in this patch exactly round to even like the
hardware implementation but much closer.

Change-Id: I4c5e72c15fef9079d3660680b2727ff7ba4e768a
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-07-31 16:50:30 +02:00
Linus Jahn
5d69aa3ee1 QCryptographicHash: Add BLAKE2b and BLAKE2s hashing algorithms
BLAKE2 does not specify requirements about specific hash sizes and
since QCryptographicHash does not support dynamic hash sizes, only the
most common hash sizes could be covered by this.

The supported hash sizes were chosen to match the ones supported by the
Linux kernel.

The new hashing algorithms for QCryptographicHash are:
 * BLAKE2b (160 bit, 256 bit, 384 bit, 512 bit)
 * BLAKE2s (128 bit, 160 bit, 224 bit, 256 bit)

[ChangeLog][QtCore][QCryptographicHash] Added BLAKE2b and BLAKE2s
hashing algorithms.

Fixes: QTBUG-78198
Change-Id: Id9e0180a974093982fdf1cdd6180988a2e5e9f4f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-07-31 15:05:18 +02:00
Fabian Kosmale
cb80720287 Expose QMetaTypeInterface::alignof in QMetaType
We already have the information in the QMetaTypeInterface, and provide
functions to access sizeof. Adding alignof support seems natural, and
should make it easier to handle over-aligned types.
This should also be helpful in QVariant.

Change-Id: I166be76f4b7d2d2e524a3a1e513bd2f361e887c1
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-07-31 09:46:54 +02:00
Tor Arne Vestbø
e7ade60925 Add missing override in tst_QSortFilterProxyModel
Change-Id: I8ffe92cd5a68bf86688e1d942d079ac6ff115d11
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-07-29 14:33:48 +02:00
Tor Arne Vestbø
b535a67910 Fix warning when comparing qsizetype to size_t
Change-Id: I4ea7ccb4daf05c735c831964f94c120d179521dd
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-07-29 12:33:33 +00:00
Tor Arne Vestbø
9023791a45 Fix warnings about unused expression results in tests
Change-Id: I401ec8a3742a5bb51a1b8b291c53395c3880117c
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-07-29 14:33:29 +02:00
Tor Arne Vestbø
6f17509ad9 Fix warnings about unused members in tests
Change-Id: I741cf08c26f8a2e297926cc01968ff09e70462a2
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-07-29 14:33:24 +02:00
Tor Arne Vestbø
dfeedc17a2 Disable deprecation warnings in some tests
The tests are testing deprecated functionality, which we
still want to test.

Change-Id: Iad6ed35800896170c17fe019c7a6ecda22398ac3
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-07-29 14:33:23 +02:00
Tor Arne Vestbø
57337f21c7 Add missing braces when constructing BigConvertible in tst_qvariant
Change-Id: Ia571e8950aa28721080dc7434921b79ffda913f4
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-07-29 14:33:20 +02:00
Allan Sandfeld Jensen
d782df4861 Make qfloat16 helper functions consistent with float/double versions
Infinite is only when the mantissa is 0, everything else is NaN.

std::isnormal returns false on zero.

Pick-to: 5.15
Change-Id: I897fc0dc3b8a9c557bb1922ea7ca8df501e91859
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-07-28 18:12:07 +02:00
Edward Welbourne
f4323889f1 QLine: purge deprecated API
Since 5.14: intersect(), angle().  Also removed definition of M_2PI
from test, since its last use was in the tests being removed.

Change-Id: Ie3a12247e3760e8bfdd3a659cd06245c86b198c2
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2020-07-27 11:26:08 +02:00
Edward Welbourne
d3c8757731 Purge redundant recoding of URL fragments from QByteArray
QUrl::fromEncodedComponent_helper() only existed to support some old
methods deprecated since 5.0, that I recently removed.
It was the only caller of qt_urlRecodeByteArray() aside from that
function's own autotest.
Both were private.

Task-number: QTBUG-85700
Change-Id: I5d09fd44e768847ce51a1ae7043150922cb5314c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2020-07-27 11:25:49 +02:00
Tor Arne Vestbø
bd3088ceb3 Fix warnings about unused variables and functions in tests
Change-Id: Ia758a91384083c13fb4d743f500fef7a6629dfd5
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-07-26 18:06:46 +02:00
Tor Arne Vestbø
f418a96f9b Disable warning about self-move and self-assign-overload
Change-Id: I1d20d3f424eced5cc5787934663b9d243f75d46e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-07-26 18:06:34 +02:00
Tor Arne Vestbø
d1fd2ff11f Fix warning when comparing qsizetype to result of sizeof
warning: comparison of integers of different signs: 'qsizetype' (aka 'long long') and 'unsigned long'

Change-Id: I03acb1f7aed782169a0a42cd8afc84b85991cd1e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-07-26 18:06:21 +02:00
Tor Arne Vestbø
d96193b0ec Fix warning when printing of qsizetype
warning: format specifies type 'int' but the argument has type 'qsizetype' (aka 'long long')

Change-Id: I6099b53efecea46d191d5dc019c986f99e49c1f1
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-07-26 17:39:31 +02:00
Edward Welbourne
f16ab166bc QLogging: purge deprecated qInstallMsgHandler(QtMsgHandler)
Deprecated since 5.0.  Renamed a function in a manual test that no
longer needs to say it's Qt5-specific.

Change-Id: I6f2159c702f389d378a0e4d86bd4fe633298b100
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
2020-07-23 11:05:53 +02:00
Tor Arne Vestbø
15a5d1996f tst_QPluginLoader: Fix MachO stub tests
The -arch_blank argument to lipo is no longer supported.

Pick-to: 5.15
Pick-to: 5.12
Change-Id: I47efcb3633f23b7a18d66211bc16d5c9dbc067c8
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-07-22 02:04:15 +02:00
Edward Welbourne
e4e4bb78b7 tst_QLine: use qmath.h's constants instead of local versions
Change-Id: I41313f7e7caf3c364ae900a0b100c661aafb290d
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2020-07-21 17:05:01 +02:00
Edward Welbourne
f12132ff23 QCommandLineOption: purge deprecated API
Since 5.8: setHidden(), isHidden()
Part of the QCommandLineParser test also used setHidden().

Change-Id: I05a1c63ff3beb1167ed75632c1b71d7fff17f09e
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-07-20 16:06:28 +02:00
Edward Welbourne
0a961129f0 QUrl: purge deprecated API
Since 5.0: QUrl's image of the QUrlQuery API
Remove deprecation-suppression from tst_qurl.cpp, too.

Change-Id: Ide826283cb4e177fb34fb4080502f5a4620bd5d7
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2020-07-20 16:06:28 +02:00
Edward Welbourne
996a7fc6f1 QChar: purge deprecated API
Since 5.3 joining() and old Joining type
Replaced by JoiningType joiningType()

Change-Id: Iefee50aaf94cec6d67b5fc004b3e68357b2015c5
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
2020-07-20 16:06:28 +02:00
Lars Schmertmann
76d02d895a Fix compiler warning in tst_qstringlistmodel
Warning: redundant move in return statement [-Wredundant-move]

Change-Id: I426c8c41c52b43ae3863f5aaf86027cabb961388
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2020-07-20 09:38:58 +02:00
Edward Welbourne
d853816307 Fix handling of Suzhou numbering system
This only arises when the system locale tells us to use its zero as
our zero digit, since no CLDR locale uses it by default. Adapt an
MS-specific QLocale::system() test to use Suzhou numbering, so as to
test this.

While updating the locale-restoration code to also restore the digits
being set in that test, add restore code for the long time format,
where previously only the short time format was restored. Add a
comment to make it less likely one of those shall be missed in future.

Fixes: QTBUG-85409
Change-Id: I343324bb563ee0e455dfe77d4825bf8c3082ca30
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-07-17 12:19:01 +02:00
Edward Welbourne
d6502614d0 Deprecate QTimeLine's curveShape in favor of its easingCurve
QEasingCurve has a richer variety of curves and curveShape was already
implemented by changing the easingCurve property.

[ChangeLog][QtCore][QTimeLine] Deprecated QTimeLine's curveShape
property in favor of the easingCurve property.

Pick-to: 5.15
Change-Id: I7261c0f24d7e02bc94624f0b74d699df62de1a52
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2020-07-16 17:39:11 +02:00
Volker Hilsheimer
124590850b Don't test for equality if types can't be compared
For types that don't have an operator==(), always trigger the binding
and the changed notification.

Task-number: QTBUG-85578
Change-Id: I41374f6d13c88106f4de83864e82172f3a248150
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-07-15 16:16:53 +02:00
Fabian Kosmale
ca54b741d6 qtypeinfo: Improve container check
Smart pointers like QSharedPointer<T> do have a value_type, but their
equality does not depend on T being comparable. Therefore, instead of
simply checking for T::value_type, test for a few other container
requirements.
This also required to add an additional check for std::optional, as that
one has an unconstrained operator== on MSVC.

Change-Id: Iefd048f7aa360f4713ecd79f80acd7dae72ee18c
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-07-14 17:06:47 +02:00
Edward Welbourne
bb6a73260e Support digit-grouping correctly
Read three more values from CLDR and add a byte to the bit-fields at
the end of QLocaleData, indicating the three group sizes. This adds
three new parameters to various low-level formatting functions. At the
same time, rename ThousandsGroup to GroupDigits, more faithfully
expressing what this (internal) option means.

This replaces commit 27d1391280 with a
fuller implementation that handles digit-grouping in any of the ways
that CLDR supports. The formerly "Indian" formatting now also applies
to at least some locales for Bangladesh, Bhutan and Sri Lanka.

Fixed Costa Rica currency formatting test that wrongly put a separator
after the first digit; the locale (in common with several Spanish
locales) requires at least two digits before the first separator.

[ChangeLog][QtCore][Important Behavior Changes] Some locales require
more than one digit before the first grouping separator; others use
group sizes other than three. The latter was partially supported (only
for India) at 5.15 but is now systematically supported; the former is
now also supported.

Task-number: QTBUG-24301
Fixes: QTBUG-81050
Change-Id: I4ea4e331f3254d1f34801cddf51f3c65d3815573
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-07-14 14:52:08 +02:00
Edward Welbourne
3f8eae848e Fix floating-point 'g'-format's choice between 'e' and 'f' forms
During review of a refactor (coming shortly), Thiago wondered what the
magic numbers were. On closer examination, I concluded that they were
wrong and wrote some tests to prove it. This commit adds those tests;
replaces the misguided old code with something that passes them; and
documents the reasons for the various parts of its decisions.

In the process, tidy up QLocaleData::doubleToString() somewhat and
rename some of its variables to conform to Qt coding style.

Change-Id: Ibee43659b1bdb0707639cdb444cfe941c31d409f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-07-14 14:52:08 +02:00
Jarek Kobus
cd787dbac9 QtConcurrent: Get rid of multi-inheritance inside RunFunctionTaskBase
Use aggregation instead. Prepare for using QPromise instead of QFutureInterface.

Task-number: QTBUG-84702
Change-Id: Ic88564dca8c83a178a281cb843032292210a6d25
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2020-07-14 14:52:08 +02:00
Edward Welbourne
72be9bdd37 tst_QCollator: avoid an unused variable warning
Change-Id: Ib173df3e9b92f06935aa4de5a1d423118877ad22
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-07-13 12:03:21 +02:00
Sona Kurazyan
361dc074f2 Move QRegExp and its remaining mentions out of QtCore
Task-number: QTBUG-85235
Change-Id: Ibd6c98d952c1bb9916b64715c6430fb0d3fe3843
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-07-13 10:53:23 +02:00
Giuseppe D'Angelo
43fa292ff6 QVariant::setValue(): enable move semantics
Given we optimize for the case where the new value is of the
same type of the one already stored in the variant, enable move
assignment for that case.

As a drive-by, avoid a path to detach() for data() if we know
we're detached.

Change-Id: I9abbdc10637ce77ebb747b49d83e1ef914d997bb
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-07-13 01:32:53 +02:00
Lars Knoll
9f33ad904a Move all the QProperty related code into one compilation unit
And mark some methods as inline.

Performance is critical for our new property system. Compiling
it in one unit makes it possible for the compiler to do a much
better job at inlining and generating optimized code.

Improves performance of binding evaluations by another 20%.

Change-Id: I5a2aa93c74d2b68418b0a9d2e34d8199bb71e3ad
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2020-07-10 15:07:22 +02:00
Lars Knoll
bbfecdee1e Significantly improve performance of binding evaluation
Avoid any QVariant or type dependent code in the cpp files.
Instead, let the binding wrapper determine if the value
has changed and return true/false accordingly.

This required also some reworking of the guard mechanism
for notified properties, where the guard function wrapper
now calls first the binding evaluation function and then
passes the result to the guard.

Change-Id: I350d07a508ccc0c5db7054a0efa4f270b6a78ec3
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-07-10 15:07:12 +02:00
Lars Knoll
be1ce6b269 Separate the error case when evaluating bindings
There's no point in returning a usually empty error when
evaluating bindings, adding overhead to the regular code
path.

Instead, the error can be set on the currently evaluating
binding if required. This streamlines the functor used to
wrap the binding and should thus expand to less code and
execute faster in the regular case.

To achieve this, expose a pointer to the currently evaluating
binding in the private API (as QtQml needs it to be able to
report errors).

The error case now requires one additional TLS lookup, but
we don't really care about performance in that case anyway.

Change-Id: Iecb450e765244930a41d813fcf8eb4013957a6a3
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-07-10 15:07:07 +02:00
Lars Knoll
0d1208f0f0 Cleanup QPropertyBindingError
Remove location(). The method would always return an empty value. If you need the location,
the binding itself has it.

Remove setDescription() and require that the description gets passed
in the constructor. Never create a d pointer if type is NoError, so we
can quickly check for it inline.

Change-Id: I7eb8a94786281069d6ea2d82567c09aa50c52ef6
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-07-10 15:07:02 +02:00
Friedemann Kleint
773a6bffd7 Tests: Use QVERIFY instead of QCOMPARE for empty lists
Pick-to: 5.15
Change-Id: I4da02fa11583eca3844bf42efcdf818b8bbd6a94
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2020-07-10 14:30:58 +02:00
Sona Kurazyan
577558daf5 Fix QByteArray::count implementation for longer data
The issue has been introduced when refactoring QByteArray::count
implementation (see 631127126c).

Because the last argument of QByteArrayMatcher::indexIn() method
has a defult value, it has been compiling without issues, but was being
called with incorrect size parameter. Fixed it to pass the length of the
input data correctly.

Change-Id: Ic9c2f33733131ec17276aa889f2d7ea40ec79b01
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-07-09 18:38:33 +02:00
Alexandru Croitor
db397d1113 CMake: Regenerate subdir test projects
And generate a few more test projects that were missing.

Change-Id: I5df51106549aa5ae09bc3c42360e14b143719547
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2020-07-09 09:38:39 +02:00
Alexandru Croitor
e9a328bc0e CMake: Regenerate tests with new qt_ prefixed APIs
Use pro2cmake with '--api-version 2' to force regenerate
projects to use the new prefixed qt_foo APIs.

Change-Id: I055c4837860319e93aaa6b09d646dda4fc2a4069
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-07-09 09:38:35 +02:00
Alexandru Croitor
5417f1e40c CMake: Regenerate tests
This is in preparation for regenerating them with the new qt_foo
prefixed APIs.

Change-Id: Iff34932d642b1c0186ee39f952adf3ad367fd602
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-07-09 09:38:31 +02:00
Fabian Kosmale
986d89c2ee Automatically register comparison operators in QMetaType
This removes the fully manual registration of comparison operators in
QMetaType and replaces it with an automatic registration through
Q_DECLARE_METATYPE().

[ChangeLog][QMetaType] The QMetaType::registerComparator() and
QMetaType::registerEqualsComparator() have been removed.
Q_DECLARE_METATYPE() now automatically registers any
operator==() and/or operator<() for a type visible where
it is used on that type, as part of declaring its meta-type.

Change-Id: I3df451b652b735c093533838bf32f3cc785439f8
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2020-07-08 14:13:59 +02:00
Lars Knoll
16bc995fd1 Add type traits to safely determine the existence of comparison operators
Containers often define an operator==() or operator<() which is very useful
for generic code. But those operators can usually not be instantiated if
the template argument doesn't implement the operator.

This sometimes leads to the compiler trying all possible template expansions
and implicit conversions for the type, giving extremely long error
messages. The traits support can be used to safely constrain those
operators.

Being able to safely detect this will also allow us to fold the comparison
support that is currently a large cludge for user types directly into
QMetaType.

Change-Id: Ib84afb5348c3eb0be5161d6ba9d5fe237709c65f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-07-08 14:13:55 +02:00
Sona Kurazyan
631127126c Introduce QByteArrayView
Created a QByteArrayView in symmetry with QStringView.
Added the basic tests symmetrical to QStringView tests.

Moved the implementations of non-modifying methods of QByteArray to
namespace QtPrivate, to be reused inline from both QByteArray and
QByteArrayView. Changed QByteArray's counterparts of those methods to
take QByteArrayView as argument instead of QByteArray. Removed
QByteArray's operator QNoImplicitBoolCast(), because it was causing
ambiguity when calling those methods with QByteArray argument (it was
there to perevnt if(!ba)/if(ba) from compiling, but currently that would
be ambiguous and won't compile anyway).

[ChangeLog][QtCore][QByteArrayView] New class.

Task-number: QTBUG-84321
Change-Id: I05f92e654cf65c95f2bb31b9c9018746ac110426
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-07-08 08:45:49 +02:00
Sona Kurazyan
a55e938fb4 Add tst_QByteArrayApiSymmetry test
Created tst_QByteArrayApiSymmetry test for the common APIs  of
QByteArray and QByteArrayView. Moved the tests for startsWith(),
endsWith(), indexOf(), lastIndexOf(), compare(), from tst_QByteArray
to tst_QByteArrayApiSymmetry and adapted them to check different
QByteArray/QByteArrayView combinations. Added tests for first(),
last(), sliced(), chopped(), chop(), truncate(), count(), contains()
(test inputs are taken from corresponding tst_QStringApiSymmetry
tests).

Task-number: QTBUG-84321
Change-Id: I4e712b1692e3c1271d51ddcda6c9eb8bb01e11d4
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-07-08 08:45:14 +02:00
Tor Arne Vestbø
e255146183 Replace use of deprecated Q_OS_MACX in favor of Q_OS_MACOS
Change-Id: I1059d56f67be28a4cc1a66b744e81df6d0b5d00d
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-07-08 01:09:38 +02:00
Giuseppe D'Angelo
1e8d623340 QThread::create: remove the pre-C++17 codepaths
As we require C++17 now. The configure-time test checking for
future/async is left in for the moment being.

Change-Id: Ifde39d420673f70a2277f5a645bfaad30935a381
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2020-07-07 20:54:12 +02:00
Lars Schmertmann
6ce2f3f26b Add ; to Q_UNUSED
This is required to remove the ; from the macro with Qt 6.

Task-number: QTBUG-82978
Change-Id: I3f0b6717956ca8fa486bed9817b89dfa19f5e0e1
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2020-07-07 11:51:48 +02:00
Jarek Kobus
989fca660c Use QList instead of QVector in corelib tests
Task-number: QTBUG-84469
Change-Id: Ic80fde5517aed363f17d0da55cadcc958c3c8895
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2020-07-07 11:48:45 +02:00
Lars Knoll
9117e3850b Rename from() to sliced()
After API discussions, agreement was that from(n) is a bad name
for the method. Let's go with sliced(n) instead.

Change-Id: I0338cc150148a5008c3ee72bd8fda96fb93e9c35
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-07-06 21:31:35 +02:00
Lars Knoll
792cb3989a Add support for first(n), last(n) and sliced() to QList
This keeps the API symmetric with what we have in our string
classes.

Change-Id: I94c5b39b718ca2472f9ca645e7a42e4314636f67
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-07-06 21:31:25 +02:00
Lars Knoll
9a9a1a2a2e Port QString to qsizetype
Change-Id: Id9477ccfabadd578546bb265a9483f128efb6736
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-07-06 21:31:20 +02:00
Lars Knoll
df853fed66 Use qsizetype in QList
The change creates a slight source incompatibility. The main
things to take care of are

* code using printf statements on list.size(). Using qsizetype in
printf statements will always require a cast to work on both 32
and 64 bit.
* A few places where overloads now get ambiguous. One example is
QRandomGenerator::bounded() that has overloads for int, uint and
double, but not int64.
* Streaming list.size() to a QDataStream will change the format
depending on the architecture.

[ChangeLog][QtCore][QList] QList now uses qsizetype to index into
elements.

Change-Id: Iaff562a4d072b97f458417b670f95971bd47cbc6
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-07-06 21:31:14 +02:00
Lars Knoll
215ca73534 Allow allocating more than 2G items in a vector
Also adjust qCalculateBlockSize() to be able to handle large
allocations.

QVector::length() is currently still limited to 2G items, that will
get changed in a later commit.

Change-Id: I3a92fbfd7f281d30844c5fafa3b9a474bc347c19
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-07-06 21:31:01 +02:00
Lars Knoll
fbce2e58e6 Get rid of QArrayData::sharedNull()
Remove the last places where those got used and avoid
allocations when we resize to 0.

Change-Id: Ib553f4e7ce7cc24c31da15a55a86d18bdf1cc5c3
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-07-06 21:30:33 +02:00
Lars Knoll
f8a53388a7 Get rid of unused flags in QArrayData
Change-Id: I3ea754b44fb33e33baba0781d9ae15b7f3b3d8eb
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-07-06 21:30:19 +02:00
Lars Knoll
a46caf087c Simplify Q_ARRAY_LITERAL
And clean up some unused pieces of code.

Change-Id: I285b6862dc67b7130af66d3e08f652b1a56b990e
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-07-06 21:30:06 +02:00
Lars Knoll
76004502ba Get rid of shared null for QByteArray, QString and QVector
As a side effect, data() can now return a nullptr. This
has the potential to cause crashes in existig code. To work
around this, return an empty string from QString::data()
and QByteArray::data() for now.

For Qt 6 (and once all our internal issues are fixed), data()
will by default return a nullptr for a null QString, but we'll
offer a #define to enable backwards compatible behavior.

Change-Id: I4f66d97ff1dce3eb99a239f1eab9106fa9b1741a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-07-06 21:29:58 +02:00
Lars Schmertmann
11b3092cc4 Refactor tst_Collections
This improves the readability and avoids code duplication
in tst_Collections::forwardDeclared. Also some warnings
are fixed:
* qSort is deprecated.
* The = operator for LargeStatic needs to be implemented
  explicitly when a copy constructor is given.
* QMap::insertMulti is deprecated, a MultiMap is required.

Task-number: QTBUG-82978
Change-Id: I577f851394edfaa30154bd3417ce391635cc546d
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2020-07-06 09:42:36 +00:00
Lars Schmertmann
ae890390e5 Avoid use of Q_UNUSED by eliminating the parameter names
This change only happens to files touched
by the commit to add missing ; to Q_UNUSED.

Task-number: QTBUG-82978
Change-Id: I10e6993a2bb3952cf9a262708b8573550e0dbe63
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2020-07-03 21:10:09 +02:00
Lars Schmertmann
d4c04acc65 Remove deprecated empty macro
Change-Id: Ib2a646ee22a7f97dae584e6f068f17378fe2b494
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2020-07-02 20:51:52 +02:00
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
Edward Welbourne
5f8c6f1760 Rework testing of qstr*cmp() functions
Previously only qstr*icmp() were tested and the test data was sent via
QString and {en,de}coding. Use a local data-type to package pointers
to actual string literals for passing to these functions that take
them.  Fold the various tests involving null pointers and empty
strings into the general testing, removing from "singularity" tests,
and combine the remainders of those tests into a single test of
singular cases for QByteArray::ompare.  Move all these tests to
alongside the existing tests for QByteArray::compare.  Use nullptr
rather than 0 as the null string.

Change-Id: Ie6d01e839c330c2f960af4bcc95e5633539337d6
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-06-05 12:13:05 +02:00
Alexandru Croitor
4ada40c08d CMake: Fix tst_quuid to pass on macOS
The helper executable needs to be a bundle, because that's
what the test expects.

Change-Id: I7c3f72f12b7a744478b4832685d032abfc679e5b
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-06-04 23:21:09 +02:00
Alexandru Croitor
f52a48d963 CMake: Fix tst_qregexp test
It was missing the resource files.

Change-Id: Iaa97922eaedc8ba55ef4e568a6abfcffd19509fa
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-06-04 23:20:49 +02:00
Fabian Kosmale
1a3c9df90a tst_qobject: fix build when exceptions are disabled
Change-Id: Id98d39b4cc14608661a53df7e5c5bba5fb875022
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-06-04 22:43:59 +02:00
Sona Kurazyan
37cfc3c6d2 Deprecate the pause-related APIs of QFuture* classes
Deprecated the pause-related APIs of QFuture* classes and
added alternatives having "suspend" in the name instead.

With 2f15927f01 new
isSuspended()/suspended() APIs have been added to QFuture* classes for
checking if pause/suspension is still in progress or it already took
effect. To keep the naming more consistent, renamed:

 - setPaused() -> setSuspended()
 - pause() -> suspend()
 - togglePaused() -> toggleSuspended()
 - QFutureWatcher::paused() -> QFutureWatcher::suspending()

Note that QFuture*::isPaused() now corresponds to (isSuspending() ||
isSuspended()).

[ChangeLog][Deprecation Notice] Deprecated pause-related APIs of
QFuture and QFutureWatcher. Added alternatives having "suspend" in
the name instead.

Change-Id: Ibeb75017a118401d64d18b72fb95d78e28c4661c
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2020-06-04 22:32:43 +02:00
Volker Hilsheimer
94dcb5454f Remove the deprecated QDirModel
QFileSystemModel is the documented replacement. It uses threads to
populate the model, which QDirModel doesn't.

Change-Id: I7818ecd8f849eb566ac176612f382e17a0471c47
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2020-06-04 19:11:19 +02:00
Giuseppe D'Angelo
77a8005dcb QStringBuilder: code tidies in the tests
Including other headers, while defining very questionable macro
names, can and will result in trouble. Stop doing that.

While at it, move from including <QtTest> to include-what-you-use,
and clean up the code a bit.

Change-Id: Idb02ef2b612c0805baecac3ce6edd435609aca4c
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-06-04 15:58:02 +02:00
Edward Welbourne
9dd8e655cd Limit QByteArray's 8-bit support to ASCII
Previously it handled Latin-1, which made it incompatible with UTF-8,
which is now our preferred 8-bit encoding. For Qt6 it is limited to
ASCII. Adjusted tests to match. QLatin1String::compare() turned out
to be relying on qstrnicmp()'s Latin-1 handling.

Removed some spurious Q_UNLIKELY()s and tidied up code a little in the
process.

[ChangeLog][QtCore][Important Behavior Changes] Encoding-dependent
features of QByteArrray are now limited to ASCII, where previously
they worked for the whole of Latin-1. This affects case-insensitive
comparison, notably including qstricmp() and qstrnicmp(), and
case-transforming functions.

Fixes: QTBUG-84323
Change-Id: I2925d9908f8654599195a2860847b17083911b41
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2020-06-04 10:39:53 +02:00
Marc Mutz
6a3c6f939f Long live QStringTokenizer!
This class is designed as C++20-style generator / lazy sequence, and
the new return value of QString{,View}::tokenize().

It thus is more similar to a hand-coded loop around indexOf() than
QString::split(), which returns a container (the filling of which
allocates memory).

The template arguments of QStringTokenizer intricately depend on the
arguments with which it is constructed, so QStringTokenizer cannot be used
directly without C++17 CTAD. To work around this issue, add a factory
function, qTokenize().

LATER:
- ~Optimize QLatin1String needles (avoid repeated L1->UTF16 conversion)~
  (out of scope for QStringTokenizer, should be solved in the respective
  indexOf())
- Keep per-instantiation state:
  * Boyer-Moore table

[ChangeLog][QtCore][QStringTokenizer] New class.

[ChangeLog][QtCore][qTokenize] New function.

Change-Id: I7a7a02e9175cdd3887778f29f2f91933329be759
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2020-06-03 19:13:54 +02:00
Ulf Hermann
07ded4912f Fix and compactify QNotifiedProperty
The static observer can live in a union with the inline observers. We
only need to take care of calling the ctors and dtors manually then.

In order for any observers to be called in the presence of a static
observer, the static observer has to be called after the other
observers.

Change-Id: I2f56fa64f3fe6fcd7f06cc403929362da7d86f65
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-06-03 18:53:40 +02:00
Fabian Kosmale
47c6466d0a QMetaType: create metatype for void
Create a QMetaTypeInterface for void. This allows us differentiate
QMetaType::Unknown from QMetaType::Void. In addition, this will enable
the usage of QMetaMethod::metaReturnType in QMetaMethod::returnType,
and will facilitate using metaReturnType in declarative, which needs to
distinguish between Unknown and Void.

Change-Id: I83296b49587f3deb7ec73e25a33f0d8c98cf8da0
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-06-02 22:42:15 +02:00
Fabian Kosmale
649d834443 add unit test for QMetaMethod::revision
Change-Id: I724702d8ac9a75fefd848afccf4f4de9fc0ba4af
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
2020-06-02 22:42:15 +02:00
Fabian Kosmale
fa987d4441 MetaObject: Store the QMetaType of the methods
This does the analog of 46f407126e for the
methods we care about (signals, slots, Q_INVOKABLEs). In addition to the
actual QMetaType, we store an array with offsets so that we later can do
a mapping from methodIndex to metatype.

The newly added QMetaMethod::{return,parameter}MetaType methods can then
be used to retrieve the metatypes.

This does however require that all involved types are complete. This is
unfortunately not a feasible requirement. Thus, we only populate the
metatype array on a best effort basis. For any incomplete type, we store
QMetaType::Unknown. Then, when accessing the metatype, we fall back to
the old string based code base if it's Unknown.

Squashes "moc: support incomplete types" and  "Fix compile failures
after QMetaMethod change"


Fixes: QTBUG-82932
Change-Id: I6b7a587cc364b7cad0c158d6de54e8a204289ad4
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-06-02 22:42:15 +02:00
Lars Knoll
4c5f6eb74c Stabilize autotest
calling emplace() on a std::vector with a reference
pointing into the same vector is undefined behavior.
Fix this by using a temporary inbetween.

Change-Id: I47c28700dffa2107fb0cba302168c86b659eafb3
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-06-01 20:57:55 +02:00
Lars Knoll
aac39167b7 Add QStringView::split() methods
Since QString::split() is not going away in Qt 6, we should aim
to provide API symmetry here, and ease porting existing code from
QString(Ref) to use QStringView.

This is easier than having to port everything to use tokenize() at
the same time. tokenize() will however lead to better performance
and thus should be preferred.

Change-Id: I1eb43300a90167c6e9389ab56f416f2bf7edf506
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-06-01 20:43:21 +02:00
David Faure
4f1ebf666e QMimeType::suffixForFileName shouldn't lowercase the file suffix
It was returning a lowercased suffix because it was extracting it from
the pattern (*.txt) rather than from the filename ("README.TXT").

This broke expectations on the application side, since this method is
documented to return a suffix from the given filename.

Ref: https://bugs.kde.org/show_bug.cgi?id=402388

Change-Id: I7dae13db31280249d3f592fa9592c4067804e22d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-06-01 13:36:05 +02:00
Giuseppe D'Angelo
529f052add Port QRegularExpression to QStringView, drop QStringRef
The idea is pretty simple -- add QRegularExpression matching over
QStringView. When matching over a QString, keep the string
alive (by taking a copy), and set the view onto that string.
Otherwise, just use the view provided by the user (who is then
responsible for ensuring the data stays valid while matching).

Do just minor refactorings to support this use case in a cleaner
fashion.

In QRegularExpressionMatch drop the QStringRef-returning methods, as
they cannot work any more -- in the general case there won't be a
QString to build a QStringRef from.

[ChangeLog][QtCore][QRegularExpression] All the APIs dealing
with QStringRef have been ported to QStringView, following
QStringRef deprecation in Qt 6.0.

Change-Id: Ic367991d9583cc108c045e4387c9b7288c8f1ffd
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-05-31 21:46:32 +02:00
Lars Knoll
a1056096fc Add support for count() to QStringView
Make the API more symmetric with regards to both QString and QStringRef.

Change-Id: Ia67c53ba708f6c33874d1a127de8e2857ad9b5b8
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-05-30 23:11:09 +02:00
Lars Knoll
beaef85b8d Add toInt() and friends to QStringView
Make the API more symmetric with regards to both QString and QStringRef.
Having this available helps making QStringView more of a drop-in
replacement for QStringRef. QStringRef is planned to get removed in Qt 6.

Change-Id: Ife036c0b55970078f42e1335442ff9ee5f4a2f0d
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-05-29 19:01:58 +02:00
Sona Kurazyan
2f15927f01 Add a way of notifying QFutureWatcher when pause is in effect
Because setting QFutureInterface to paused state does not mean that
the computations that are already in progress will stop immediately,
it may be useful to get notified when pause actually takes effect.

Introduced the QFutureWatcher::suspended() signal, to be emitted when
there are no more computations in progress, and no more result ready
or progress reporting signals will be emitted, i.e. when pause took
effect. Added {QFuture, QFutureWatcher}::isSuspended() methods for
checking if pause took effect.

QtConcurrent will now to send QFutureCallOutEvent::Suspended event
when the state is paused and there are no more active threads.

[ChangeLog][QtCore][QFutureWatcher] Added a new QFutureWatcher::suspended()
signal, to be emitted when pause took effect, meaning that there are no
more computations in progress. Added {QFuture, QFutureWatcher}::isSuspended()
methods for checking if pause took effect.

Fixes: QTBUG-12152
Change-Id: I88f2ad24d800cd6293dec63977d45bd35f9a09f0
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2020-05-29 16:58:43 +02:00
Edward Welbourne
948511a143 Turn badly-named test into two data rows of another test
Since ancient times, tst_QDateTime::fromString_LOCALE_ILDATE() has
claimed to be Windows-only, although there is nothing MS-specific
about it; its name also purports to implicate locale, which it
doesn't. Turn it into two data rows for the more general
fromStringDateFormat() test, with no extra #if-ery about it.

Change-Id: I239c0f80f8f7fa42d498a0f801cc8edfb1db3d8c
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2020-05-29 16:58:43 +02:00
Simon Hausmann
36f6922925 Implement support for QProperty<T> with a static observer
A common pattern in Qt Quick will be QProperty members that are
connected to a callback that needs to perform something when the value
changes, for example emitting a compatibility signal or marking scene
graph node data dirty.

To make such a pattern more efficient, a new QNotifiedProperty type is
introduced that offers the same API as QProperty<T>, with two changes:

    (1) The template instantiation not only takes the property type as
    parameter but also a callback pointer-to-member.

    (2) Since that member itself cannot be called without an instance
    and to avoid storing an instance pointer permanently, the API for
    setBinding and setValue are adjusted to also take the instance
    pointer. For the former it gets stored in the binding, for the
    latter it is used to invoke the callback after setting the new
    value.

Change-Id: I85cc1d1d1c0472164c4ae87808cfdc0d0b1475e1
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2020-05-28 21:08:51 +00:00
Edward Welbourne
449b347644 Rework QLocale and QDateTime tests that expect CET abbreviation
The name CET is locale-dependent; but QLocale doesn't know about
localization of time zone names. Such abbreviated zone names are, in
any case, potentially ambiguous - various zones around the world have
collisions - so they can't be relied on.

QTimeZone's various backends have differing handlings of how to
abbreviate zone names (MS's provides no abbreviated names at all); and
it appears macOS actually follows the relevant localizations.

So it is hopeless to hard-code the expected zone abbreviations.
Changed the tests to consult QTimeZone for the abbreviation and
compare what it gets with the results of checks which should match
this. This is less stringent, but it is at least robustly correct,
thereby getting rid of assorted kludges and #if-ery.

Pick-to: 5.15
Task-number: QTBUG-70149
Change-Id: I0c565de3fd8b5987c8f5a3f785ebd8f6e941e055
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2020-05-28 15:15:17 +02:00
Andrei Golubev
cfbb30decd Make QDateTimeParser recognize local time offsets
Fixes: QTBUG-84209
Pick-to: 5.15
Change-Id: Iedbc7beafcaa55c72fec3ac5a5f519c6ed5f7770
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2020-05-28 11:48:57 +03:00
Ulf Hermann
a64a0ce331 Add a QPropertyAlias
A property alias is the equivalent of the "alias" keyword in QML. It
provides the same API as QProperty, but redirects any access to the
QProperty it was initialized with. When the original property is
destroyed the binding becomes invalid and ignores any further acccess.

Task-number: QTBUG-84370
Change-Id: I0aef8d50e73a2aa9e7703d51194d4c5480573578
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-05-27 14:41:52 +02:00
Volker Hilsheimer
ee92ee7a3c Remove deprecated QProcess methods
Add default parameter for arguments in start, startDetached, and
execute for better source compatibility with Qt 5.15. This has the risk
of then hiding incorrect calls to the previous overload taking a single
"command" strings if code is ported from pre-5.15 or ignores deprecation
warnings. This is acceptable, given that the alternative is that all
calls to these functions would require a default constructed QStringList
as the second parameter.

Change-Id: I1ba4df97ac4894d007da5083c8359015d784ddbb
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-05-27 11:55:06 +02:00
Ulf Hermann
524d781607 QProperty: Support multiple observers
Previously, only the first observer would get notified. Also, make sure
that the notifiers are always retained when switching between bindings
and values.

Change-Id: I9c25c0f2e288dac3a335b68e618f7ddeb44be25a
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-05-27 11:54:30 +02:00
Ulf Hermann
36bd34dbdc QProperty: Apply coding style and avoid warnings
Change-Id: I14efdb293a4be39b3849b34bd8013fdab016ce7e
Reviewed-by: Simon Hausmann <hausmann@gmail.com>
2020-05-27 11:54:16 +02:00
Sona Kurazyan
d7d6a1fe32 Don't queue events in QFutureWatcher when pause is requested
When QFutureWatcher (or QFutureInterface) is paused, it doesn't
mean that it will take effect immediately: the pending tasks may
still be in progress and keep reporting results. At the moment
QFutureWatcher will queue those events and report only with the
next resume. This behavior is wrong, QFutureWatcher should not
decide when to report events, the sender should decide when is the
right time. There's no benefit in reporting already happened events
with delay. Because of this, even the pause event itself was being
reported after resume.

Fixed the behavior by removing the logic of queueing events when
the state is set to "paused". It seems unlikely that the users of
QFutureWatcher rely on reporting events with delay.

[ChangeLog][Important Behavior Changes][QtCore] QFutureWatcher will not
immediately stop delivering progress and result ready signals when the
future is paused. At the moment of pausing there may be still computations
that are in progress and cannot be stopped. Signals for such computations
will be still delivered after pause, instead of being postponed and
reported only after next resume.

Fixes: QTBUG-12152
Change-Id: I9f0b545ac096578c52cc72d60575c018c01e3368
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
2020-05-27 11:53:28 +02:00
Giulio Camuffo
7db527dbdd Add a property to QSFPM to show children of accepted items
[ChangeLog][QtCore][QSortFilterProxyModel] Add a 'autoAcceptChildRows'
property to always show children rows of accepted rows.

Change-Id: I2402469ece438179d0f19888b9775cc27cf5c749
Reviewed-by: David Faure <david.faure@kdab.com>
2020-05-26 15:11:40 +02:00
Tony Sarajärvi
623670d243 Blacklist tst_QTimer::zeroTimer on Ubuntu 20.04
Task-number: QTBUG-84291
Change-Id: I198cfe813617a5bb65b0e1059a43b6933d610720
Reviewed-by: Liang Qi <liang.qi@qt.io>
2020-05-25 05:16:00 +00:00
Kari Oikarinen
afdfb08e3a Remove references to deleted file shift-jis.txt
Amends 33bb695a28.

Change-Id: I7a7d90dc406ffbf015e760a7c41534564bfbe13e
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-05-24 22:24:47 +03:00
Lars Knoll
2f05aa82e7 Adjust resize() behavior of QString and QByteArray to match Qt 5
resize() to a smaller size does not reallocate in Qt 5 if the container
is not shared. Match this here.

As a drive-by also fix resize calls on raw data strings to ensure
they are null terminated after the resize.

Change-Id: Ic4d8830e86ed3f247020d7ece3217cebd344ae96
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-05-21 17:59:31 +02:00
Liang Qi
2cd6d76d68 Merge remote-tracking branch 'origin/5.15' into dev
Conflicts:
	src/corelib/text/qbytearray.cpp

Change-Id: I63706409464d31391012bacdadfd1f6300509787
2020-05-18 08:52:33 +02:00
Marc Mutz
3df3bdcdb3 QTaggedPointer: verify constexpr'ness of some ctors
Change-Id: I44196ba3a823ce04b7c82aacfb9da301cc0f1886
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-05-16 08:55:28 +02:00
Sona Kurazyan
1a5cc8d13d Add support of cancellation handler callbacks to QFuture
Added QFuture::onCanceled() method, for attaching handlers to be called
when the QFuture gets canceled.

Change-Id: I1f01647d6173ba0c1db6641e14140108b33ac7c4
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-05-15 22:35:30 +02:00
Sona Kurazyan
612f6999c8 Add support of connecting signals to QFuture
Introduced QtFuture::connect(sender, signal) function returning a
QFuture object, which is resolved when the signal is emitted.

Task-number: QTBUG-81589
Change-Id: Idbe301eb247b468b9b34f3470c3359d6a7af2f3a
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-05-15 22:35:06 +02:00
Fabian Kosmale
794150e5bd QMetaType: Support char16_t and char32_t
Change-Id: Ieec6d4bc64967d875ea12b31638aab05bc682ea3
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-05-15 18:46:39 +02:00
Marc Mutz
b655734965 QString: fix an aliasing issue in remove(QString)
Even in Qt 5, remove() can be passed an alias to *this. In Qt 6, with
the advent of substring sharing, this will become even more
pronounced. Use the same fix as was already used in QString::insert().

Pick-to: 5.15
Change-Id: I1a0d3d99fd7dff6e727661646d2cbfdc94df2682
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2020-05-15 03:00:45 +00:00
Marc Mutz
3b7f278d38 tst_qstringref: remove some wtf?
As best as I can guess, this used the QString::operator=(char), which
I locally removed. Before that lands in Qt, remove this ... wtf?

Pick-to: 5.15
Change-Id: Ie083fe69500d6b5b633416f89f5dd1d7068c20b2
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2020-05-14 20:30:35 +00:00
Giuseppe D'Angelo
9e1dc1e8a9 QStringView: add converting constructor from array-like containers
Centralize, rather than keeping adding constructors from any
array-like container.

A more robust implementation, likely following the converting
constructor for std::span ([span.cons]), is out of scope for C++17
and will require C++20's ranges and concepts.

[ChangeLog][QtCore][QStringView] QStringView can now be constructed
from any contiguous container, as long as they hold string-like data.
For instance, it's now possible to create a QStringView object
from a std::vector<char16_t>, a QVarLengthArray<ushort> and so on.

Change-Id: I7043eb194f617e98bd1f8af1237777a93a6c5e75
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
2020-05-14 12:19:47 +00:00
Giuseppe D'Angelo
594abde1a2 Enforce that statically allocated array-like containers have 0 capacity
It has been the case for both QStringLiteral and QByteArrayLiteral
since Qt 5.0, and Q_ARRAY_LITERAL since Qt 6.0.

Since it's definitely surprising, add a note in the docs, which
is "somehow" consistent with the interpretation of capacity as
the biggest possible size before we reallocate. Since it's 0,
any manipulation of the size will cause a reallocation.
(Alternatively: the capacity() is for how many elements memory was
requested from the free store. No memory was allocated, so 0...)

Task-number: QTBUG-84069
Change-Id: I5c7d21a22d1bd8b8d9b71143e33d537ca0224acd
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-05-14 14:19:47 +02:00
Lars Knoll
45ed28a9d3 Remove QRegExp from QVariant
Add an operator QVariant() to QRegExp to keep things at source compatible
as possible.

Add a hack to QVariant::load/save() to recognize the old typeid
for QRegExp and stream them correctly as long as the streaming operators
for QRegExp are registered.

Also move the datastream test for QRegExp to tst_qregexp, and adjust it to
the qvariant changes.

Change-Id: I120b38a7541b43ec07a21b17f7f35c55f071eb75
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-05-14 12:19:47 +00:00
Lars Knoll
b2ee684a13 Remove QRegExp support from QString and StringList
Replacement methods do now exist in QRegExp, or
for QRegularExpression when porting to it.

Remove all autotests associated with the old methods.

Change-Id: I3ff1e0da4b53adb64d5a48a30aecd8b960f5e633
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-05-14 14:19:47 +02:00
Lars Knoll
7370b60cfe Move methods using QRegExp in QString(List) over to QRegExp
The prepares for the removal of those methods from QString and
QStringList. The new methods in QRegExp are left as a porting help.

Change-Id: Ieffa33a79caf53b83029e9b070c4eb5cadca1418
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-05-14 14:19:47 +02:00
Qt Forward Merge Bot
76fe36645e Merge remote-tracking branch 'origin/5.15.0' into 5.15
Change-Id: I06396fa0a3d1687a0935e48d290358edbb0e59e8
2020-05-14 14:01:32 +02:00
Lars Knoll
57037145f5 Streamline the code in the conversion to and from utf8
Move pre/and post condition handling out of the main loop
to make that one as fast as possible.

Remove special handling of a corner case when the input length
is zero, where the utf8 decoder did something else than all
other decoders.

Change-Id: I94992767ea15405b38f7953adadaa6ff98b20b6f
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-05-14 07:51:45 +02:00
Lars Knoll
2b8863a98c Get rid of some QTextCodec leftovers
There's no real dependency to QTextCodec in those files anymore.

Change-Id: Ifaf19ab554fd108fa26095db4e2bd4a3e9ea427f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-05-14 07:51:20 +02:00
Lars Knoll
9515d45f88 Remove QTextCodec dependency from test
Change-Id: Ie546065c3179d475df46b284ca7df502c4465b93
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-05-14 07:50:49 +02:00
Lars Knoll
124d587bb9 Document the string converter classes
Document QStringConverter, QStringDecoder and QStringEncoder.

In addition, do some touches to the API, renaming one enum value,
add a flags argument to one constructor and make some members private.

Change-Id: I8f99dc3d98fb8860cf6fa46301e34b7eb400511b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-05-14 07:50:29 +02:00
Lars Knoll
4d67b9dcfb Get rid of QTextCodec in QTextStream
Use QStringConverter instead. Also change the default
encoding of QTextStream to utf8.

Change-Id: I30682e75fe0462d1a937539f773640c83a2d82e1
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-05-14 07:50:19 +02:00
Lars Knoll
33bb695a28 Start porting QTextStream away from QTextCodec
As a first step add setEncoding/encoding() methods that use the
QStringConverter::Encoding enum, and port all uses of setCodec()/
codec() over to the new API.

Internally QTextStream still uses QTextCodec, this will be ported
over to QStringConverter in a follow-up change.

Change-Id: Icd764cf47b449b57f4ebd010c2dad89e6717d6c0
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-05-14 07:50:13 +02:00
Lars Knoll
b8db123341 Add a method to determine the encoding for encoded HTML data
This is a replacement for Qt::codecForHtml().

Change-Id: I31f03518fd9c70507cbd210a8bcf405b6a0106b1
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-05-14 07:49:05 +02:00
Lars Knoll
13af1312f7 Add QStringConverter::encodingForData()
Add method that tries to determine the encoding of the data
from an initial byte order mark.

Change-Id: I348c51a3d4db9b434af53359b739a7e17acfc760
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-05-14 07:48:55 +02:00
Lars Knoll
a639bcda1e Add methods to convert between encoding and name to QStringConverter
Add static methods that allow converting between a name for an
encoding and the Encoding enum.

Change-Id: I12bc503cf757ea31d3ca8d5e1f1216efddcb16d4
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-05-14 07:48:49 +02:00
Lars Knoll
3ce9162ab5 Construct a string converter by name
Add a constructor, that allows constructing a string converter by
name. This is required in some cases and also makes it possible to
(in the future) extend the API to 3rd party encodings.

Also add a name() accessor.

Change-Id: I606d6ce9405ee967f76197b803615e27c5b001cf
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-05-14 07:48:42 +02:00
Lars Knoll
a383d79772 Get rid of QSettings::iniCodec()
Always encodee INI files as utf-8 in Qt6. This is mostly backwards
compatible, as old ini files would encode all non ascii characters.

[ChangeLog][Important behavioral changes] QSettings will now always
encode INI files as utf-8 (and the iniCodec/setIniCode methods are
removed). This is a change from Qt 5 and earlier, where QSettings would
by default escape all non ascii characters. The behavior is equivalent to
what you got in Qt5 by setting a utf-8 iniCodec on the settings object.
Settings files written in Qt 5 will still be readable in Qt 6 (unless
an iniCodec different from utf-8 was used), but to read Qt6 based ini
files in Qt 5 applications, setting the iniCodec to utf-8 is required.

Change-Id: Ic7dffcca17779bd5e3dae50d42ce633170289f6c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2020-05-14 07:48:28 +02:00
Lars Knoll
940665eff5 Add some incremental tests
Feed the data one by one to the encoder or decoder to
verify that the handling of incremental decoding is
correct.

Change-Id: I565e4f1872e00859026334f7662b6778772e159d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-05-14 07:48:13 +02:00
Lars Knoll
cab0d57d1e Clean up the Flag handling in QStringConverter
IgnoreHeader was a rather badly defined enum, in addition the
utf8 and utf16 codecs where handling BOMs somewhat different
for stateless decoding.

Fix this by introducing explicit flags for writing a bom when
encoding and not skipping the initial bom when decoding.

Source compatibility for QTextCodec is done with a couple of
static constexpr variables.

Change-Id: I0b2d94f84c937cec1e0494c16ef448c00382691d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-05-14 07:47:33 +02:00
Lars Knoll
2c7f9565ed Always write XML documents as UTF-8
Remove support for setting a codec different from UTF-8
for writing XML files.

All XML readers today can handle UTF-8, and there is no
reason anymore to write a file in a different encoding.

Change-Id: If89fb2d2474a2b55644d9bed7473c11ad91033eb
Reviewed-by: Simon Hausmann <hausmann@gmail.com>
2020-05-14 07:47:06 +02:00
Lars Knoll
f64a6bd638 Start work on a new API to replace QTextCodec
The new QStringEncoder and QStringDecoder classes
(with a common QStringConverter base class) are
there to replace QTextCodec in Qt 6.

It currently uses a trivial wrapper around the utf
encoding functionality.

Added some autotests, mostly copied from the text codec
tests.

Change-Id: Ib6eeee55fba918b9424be244cbda9dfd5096f7eb
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-05-14 07:46:14 +02:00
Marc Mutz
a504f63f2e Port qt_punycodeEncoder() to QStringView
Change-Id: I264e67bc08413f8a39e2d16c774bfd2c76c320ac
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-05-13 13:22:09 +00:00
Marc Mutz
90f864a4c5 QString: remove op+=(char) and op+=(QChar::SpecialCharacter)
The former messes in bad ways with the overload set (it, fatally,
attracts char16_t, e.g.). The latter was probably added in response to
ambiguities between (char) and (QChar). While it's harmless now,
remove it, since it no longer pulls its weight.

The no-ascii warning is now coming from QChar(char), so the protection
isn't lost.

[ChangeLog][QtCore][QString] The += operators taking char and
QChar::SpecialCharacter have been removed as they cause adding a
char16_t to QString to call the char overload, losing information. The
append() function was not affected.

Change-Id: I57116314bcc71c0d9476159513c0c10048239db3
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-05-13 14:38:48 +02:00
Marc Mutz
b49314af1d Port qt_check_std3rules() to QStringView
Also port its callees. These functions scream to the QStringView-ified...

Change-Id: I13c95d65941eb8d02223306d80efd1437b4bd9b7
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-05-13 08:04:40 +02:00
Marc Mutz
548dcef089 Port qt_urlRecode() to QStringView
It's about time :)

Change-Id: I27e597516318382850d4c193fd5b66a35fb9c316
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-05-12 23:04:42 +02:00
Andrei Golubev
bed25fdf60 Teach QDateTimeParser some common time-zone offset formats
Fixes: QTBUG-83687
Fixes: QTBUG-83844
Pick-to: 5.15
Change-Id: Ia1c827017b93cf8277aa5a0266805d773d2d9818
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2020-05-12 12:45:58 +03:00
Marc Mutz
23849826b4 Sweep of int-ish → char-ish types near calls to QString::fromU*()
The fromUtf16(ushort*) and fromUcs4(uint*) overloads are going
to be deprecated. Use the newer fromUtf16(char16_t*) and
fromUcs4(char32_t*) overloads.

As a drive-by, use std::end()/std::size() where applicable.

Change-Id: I5a93e38cae4a2e33d49c90d06c5f14f7cb7ce90c
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-05-12 05:43:37 +00:00
Marc Mutz
b62bff2ef3 Use QChar::fromUcs4() more
Change-Id: I02be41de92d84145186de9ac5f5ea3541a941964
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-05-12 07:43:34 +02:00
Andrei Golubev
b428e98052 Make qtbase compile without QT_CONFIG(timezone)
Fixes: QTBUG-83795
Pick-to: 5.15
Change-Id: I05eaaf57d87a9111d3609ebab81bc707f8af98f0
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2020-05-11 14:42:00 +03:00
Marc Mutz
928d57d8da QChar: add fromUcs{2,4}()
The fromUcs2() named ctor is designed to replace all the non-char
integral-type constructors of QChar which make it very hard to control
the implicit QChar conversions, which have caused a few bugs in Qt
itself. As a classical named contructor, it simply returns QChar.

The fromUcs4() named "ctor", however, needs to expand surrogate pairs,
and thus can't just return QChar. Instead, it returns a small struct
that contains one or two char16_t's, can be iterated over and be
implicitly converted to QStringView.  To avoid bikeshedding the name
(FromUcs4Result, of course :), it's defined inline and thus can't be
named outside the function. This function replaces most uses of
QChar::requiresSurrogates() in QtBase.

[ChangeLog][QtCore][QChar] Added fromUcs2(), fromUcs4().

Change-Id: I803708c14001040f75cb599e33c24a3fb8d2579c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-05-09 06:26:08 +00:00
Marc Mutz
2a11940b2a tst_stringview: remove dead code
wchar_t hasn't been QStringView's storage_type for a very long time
(at least since 5.10). And in Qt 6, we require char16_t support not
only in the compiler, but also in the stdlib, so drop the guards and
the alternative code paths.

Change-Id: I99f28b575f61c16a2497840708beaa4b54a80f57
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-05-08 21:11:17 +02:00
Marc Mutz
dd4e96df52 tst_qstringview: modernize functions in help namespace
They don't work with std::span, since std::span has neither
const_iterator nor cbegin()/cend().

To fix, perfectly forward the return type with decltype(auto) instead
of mentioning T::const_iterator, and rely on the const-qualfication of
the help::c{r,}{begin,end}() functions' arguments to select the
correct T::{r,}{begin,end}() overload.

Change-Id: I4992d4bd521d2dc0f9ea51ae70cde8286ae543a5
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-05-08 16:53:04 +02:00
Marc Mutz
d67551ff5b tst_qstringapisymmetry: test split() with char16_t seps
Change-Id: I6744291b88d5334764da78375899313ac771294b
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-05-08 16:52:59 +02:00
Edward Welbourne
e325bd68fd Catch overflow in QDateTime::fromSecsSinceEpoch()
It's documented to be undefined if the number of seconds is outside
the allowed range, but it doesn't hurt for that undefined behavior to
happen to be that the result is invalid. Added a simple test.

Change-Id: I20c3f680c7948b3904f213452272133be77e4d62
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-05-08 09:51:24 +02:00
Edward Welbourne
5ba66c5622 Remove all locale-dependence from Q(Date|Time)+
[ChangeLog][Important Behavior Changes][QDateTime] Removed all
locale-dependence from QDate, QTime and QDateTime, including the
Qt::DateFormat members that select the formats of the default and
system locales and the toString(Qt::DateFormat, QCalendar) overload,
which only used its calendar for these formats.  All toString()
methods now use, and all fromString() methods only recognize, the C
locale's names for days and months.  Use QLocale's methods if you need
to take locale into account.

Fixes: QTBUG-80441
Change-Id: I3a8968438741afb00f44262f79659c51e9b06c35
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-05-08 09:50:51 +02:00
Edward Welbourne
48e5a37536 Move a test of QLocale's methods out of tst_QDateTime
It clearly belonged in tst_QDate::toDateTime(), for which it adds a
few more test-case and in which it inspires some further testing.
The new testing of case-insensitivity doesn't work if the format
contains stray non-format characters, so added a new data column to
take care of that.

Pick-to: 5.15
Change-Id: I73619be02091c97024a84cb963c7029e9fd0569a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-05-08 09:50:24 +02:00
Edward Welbourne
1f13a0fbec Condition some date-time tests on feature textdate
They use the Qt::TextDate format, so do depend on the feature.
Rename one in the process; nothing in its test has anything to do with
de_DE locale.

Pick-to: 5.15
Change-Id: I2adae5c46e6009c13b433993ed2c3c761a500bfb
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-05-08 09:50:16 +02:00
Thiago Macieira
798492ccee QCborValue: catch overflow in QByteArray when decoding chunked strings
We checked against integer overflow, but not against overflowing the
QByteArray size limit. That caused a std::bad_alloc to be thrown, which
is bad when decoding unknown data. QCborStreamReader wasn't affected,
since it doesn't merge chunks.

Change-Id: I99ab0f318b1c43b89888fffd160c36f495fada87
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-05-07 07:39:26 -07:00
Volker Hilsheimer
9b4b406142 Handle disk full situations by skipping QFile::moveToTrash test
If any of the temporary directories and files can't be created, skip the
test. Otherwise, the cleanup routine would recursively delete "/".

Change-Id: I51f908a468be8fd2ebd523ff7ce27a7c78d1b4e2
Fixes: QTBUG-83863
Pick-to: 5.15
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-05-07 14:27:17 +02:00
Volker Hilsheimer
a033c23ddf QFile::moveToTrash: work with relative file paths on Windows
The system APIs expect an absolute "display name" of the file path,
so make it absolute.

The test was overly tolerant in accepting failure, as a QStorageInfo
initialized with a file path that doesn't exist is invalid, and thus
always different from the QStorageInfo of the home directory. Fix the
test to compare only valid QStorageInfo objects, and postpone the check
until the file we want to move has been created.

[ChangeLog][QtCore][QFile] moveToTrash supports relative file paths
on Windows

Change-Id: I94c8cd40c60fde469e38f76a98f867f20c6a0b15
Fixes: QTBUG-84015
Pick-to: 5.15
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-05-07 14:27:09 +02:00
Thiago Macieira
83223ca3ef Remove Perforce commands from setupSuite.sh
This file mustn't have changed at all, aside from the copyright headers,
since we switched to Git in October 2008.

Quick check shows the data from W3C is still online:
 https://dev.w3.org/cvsweb/2001/XML-Test-Suite/

I didn't check that the CVS server is actually running because none of
my machines even has the cvs command anymore...

Pick-To: 5.15
Change-Id: I4e559af2a9a1455ab770fffd15f4e740114a2433
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-05-05 12:24:38 -07:00
Thiago Macieira
c377bb385c tst_QProcess: create a more reliable crashing
Turns out that crashing on purpose is more difficult than it seems. It
should be easy, given how often we do it accidentally...

Let the null pointer dereferencing be the fall back. Some compilers are
too smart for their own good and remove the fault. Instead, let's rely
on raise(SIGABRT) on Unix and on the UD2 instruction on Windows.

Pick-To: 5.15
Change-Id: Ibdc95e9af7bd456a94ecfffd1603f1c9b73b167d
Reviewed-by: Simon Hausmann <hausmann@gmail.com>
2020-05-05 12:24:35 -07:00
Thiago Macieira
d0c028e898 tst_QResourceEngine: fix the order of arguments to QCOMPARE
Expected and actual were inverted.

Pick-To: 5.15
Change-Id: Idc3fae4d0f614c389d27fffd15e9fa6a0a8f25e6
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-05-05 12:23:43 -07:00
Marc Mutz
900e8b023b QChar: make std::hash'able
Change-Id: I2164df19cd17ab96a39020de66a3fe9fec838a36
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-05-05 18:58:26 +02:00
Edward Welbourne
ca222646ff Purge from Q(Date|Time)+ most things marked to go at Qt 6
Change-Id: Ib3f48c74132b47649dc7b4cbacf2cefed5a57687
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-05-05 15:34:15 +02:00
Qt Forward Merge Bot
5e94fdc488 Merge "Merge remote-tracking branch 'origin/5.15' into dev" 2020-05-04 23:12:40 +02:00
Sona Kurazyan
ed6fbeffb2 Port more tests from qtbase/tests/auto/corelib/io/ to CMake
Change-Id: I56427e3e1908047a0674c8c80c24eeda80e947c2
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-05-04 19:21:15 +02:00
Qt Forward Merge Bot
0f7987f0c9 Merge remote-tracking branch 'origin/5.15' into dev
Conflicts:
	src/corelib/text/qlocale.cpp
	src/network/access/qnetworkaccessmanager.cpp

Regenerated tests/auto/testlib/selftests/float/CMakeLists.txt

Change-Id: I5a8ae42511380ca49a38b13c6fa8a3c5df8bed01
2020-05-04 17:38:40 +02:00
Lars Knoll
52053a8994 Remove useless code
We don't rely on a latin1 locale anymore for the test,
and the other code was not doing anything.

Change-Id: I08bc08d200c9e037884d8b680dfbb24c129f3d2e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2020-05-01 18:52:15 +02:00
Lars Knoll
55dc178271 Remove QTextStream dependency from tst_qfile
Change-Id: I83cb05da8c094185b50e9cedea2e705ad1c7f948
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2020-05-01 18:52:15 +02:00
David Faure
f0ea852d4d QCommandLineParser: Wrap very long option names to leave room for descriptions
Fixes: QTBUG-79926
Change-Id: I3302e0ed5b58949a35ccb001c71b22a6400a6c81
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-05-01 10:53:55 +02:00
Simon Hausmann
709648993c Fix crash when using QProperty<T>::setBinding(Functor ...)
We must move the functor properly into the binding object, otherwise we
end up with stale pointers as pointed out by ASAN.

Change-Id: Icd84f4c113dd48e1e3e2d744abac0902cdf9339e
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-04-30 19:39:42 +02:00
Thiago Macieira
821e71fded QCborValue: check parsing of invalid URL
QUrl will reject invalid URLs for us, so we don't get normalization. The
original junk should be retrievable, of course.

Change-Id: Ibdc95e9af7bd456a94ecfffd160610f5b2c8e1a2
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2020-04-30 08:01:28 -03:00
Thiago Macieira
8366c06d46 QCborValue: add tests of parsing invalid ISO date-time strings
We rely on QDateTime::fromString being proper, so this is not extensive
testing.

Change-Id: Ibdc95e9af7bd456a94ecfffd160610cdac5d62e1
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2020-04-30 04:01:05 -07:00
Thiago Macieira
2a53017df4 QCborValue: add an extra check against producing invalid ISO dates
By QCborValue design, we store the textual representation in ISO format,
equivalent of CBOR tag 0, which isn't allowed to have negative years or
beyond year 10000.

Change-Id: Ibdc95e9af7bd456a94ecfffd16060ccff359c296
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2020-04-30 04:00:47 -07:00
Thiago Macieira
52a2505672 QCborValue: avoid signed integer oveflows when decoding time_t
QDateTime::fromSecsSinceEpoch() multiplies by 1000 but does not check
for overflow. That means we must do so in QCborValue validation. We
can't use mul_overflow<qint64> on 32-bit platforms, so we do a compare-
and-branch there. For 64-bit platforms, we prefer to do the
multiplication with checked overflow, as the common case is that it will
not overflow and we'll need the multiplication anyway.

Change-Id: Ibdc95e9af7bd456a94ecfffd16060cba6f1c86b8
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2020-04-30 11:00:29 +00:00
Alexandru Croitor
49212cb55a CMake: Fix build of qlogging test on MinGW
The linker doesn't have a -rdynamic option. Otherwise the build
fails with
g++.exe error unrecognized command line option '-rdynamic'

Task-number: QTBUG-75578
Change-Id: Ie89a19fd25e90bef14e64d1d98fd973fa0315997
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-04-30 10:13:22 +02:00
Sona Kurazyan
3a34fdf72a Port more tests from tests/auto/corelib/tools to CMake
Also removed add_subdirectory calls for subdirs which no longer exist.

Change-Id: I759f408ca812e1721dde495b0e23feffdeeb9c60
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-04-29 22:48:45 +02:00
Sona Kurazyan
7e1dacc27a Port qtbase/tests/auto/corelib/text tests to CMake
Task-number: QTBUG-78220
Change-Id: I497da6ed489854bdee5a1ead9a3f34118c78d001
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-04-27 14:34:51 +02:00
Marc Mutz
3238445b27 QString: add append, op+=, prepend, insert taking QStringView
[ChangeLog][QtCore][QString] Now supports appending, prepending
and inserting QStringViews.

Change-Id: I7538c050c67590f27d91443eda0b94a4b80b62f2
Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-04-24 10:45:09 +00:00
Vitaly Fanaskov
9ba0715f08 QFuture: the result type doesn't have to be a default-constructible
Added asserts to insure the invariant declared in the documentation.
Canceled future object is not valid, hence we don't need to handle
this case separately.

Fixes: QTBUG-83389
Change-Id: Ib0653ef40cd3135574a91740e4ce2c6dc4da8a71
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2020-04-23 17:09:52 +02:00
Eirik Aavitsland
9e83d268d6 Fix data corruption regression in QJsonObject::erase()
The internal removeAt(index) method was implemented as taking cbor
indexes directly, in contrast to the other ...At(index) methods.

Fixes: QTBUG-83695
Change-Id: I16597eb6db1cf71e1585c041caa81bf8f7a75303
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-04-23 13:42:01 +02:00
Qt Forward Merge Bot
7f895553ac Merge remote-tracking branch 'origin/5.15' into dev
Change-Id: Iaa439ba7dff19a17e3716b3d30f49f60fa6e38f8
2020-04-23 01:00:36 +02:00
Qt Forward Merge Bot
c6128fc67c Merge "Merge remote-tracking branch 'origin/5.15' into dev" 2020-04-22 19:17:52 +02:00
Qt Forward Merge Bot
efd7757154 Merge remote-tracking branch 'origin/5.15' into dev
Conflicts:
	src/widgets/widgets/qabstractbutton.cpp
	src/widgets/widgets/qbuttongroup.cpp
	src/widgets/widgets/qbuttongroup.h
	src/widgets/widgets/qsplashscreen.cpp
	tests/auto/widgets/widgets/qbuttongroup/tst_qbuttongroup.cpp
        tests/benchmarks/opengl/main.cpp

  Needed update:
	src/plugins/platforms/cocoa/CMakeLists.txt

Change-Id: I7be4baebb63844ec2b3e0de859ca9de1bc730bb5
2020-04-22 15:28:01 +02:00
Andrei Golubev
7605451604 Handle specified time-spec in date-time parsing
When a date-time was parsed from a string, the result was equal (as a
date-time) to the correct value, but had (at least in some cases) the
wrong spec, where it should have had a spec reflecting the zone
specifier parsed.

The time-spec imposed for the benefit of QDateTimeEdit is now moved
from QDateTimeParser to QDateTimeEditPrivate, which takes over
responsibility for imposing it. QDateTimeParser assumes Qt::LocalTime
in member functions (where applicable) and uses the time-spec parsed
from the string when constructing the date-time.

QDateTime::fromString() and QLocale::toDateTime() are updated to
use the full QDateTime returned by QDateTimeParser.

Fixes: QTBUG-83075
Done-With: Edward Welbourne <edward.welbourne@qt.io>
Change-Id: I8b79add2c7fc13a200e1252d48dbfa70b36757bf
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2020-04-22 14:14:30 +03:00
Friedemann Kleint
26a0a89421 Fix assigning int QFlag-type properties
Ensure they are handled as enumerations in QMetaType.

This is required for handling QFlag-type properties in Qt Designer

Fixes: QTBUG-83689
Change-Id: Ifbfb5c5b5cd34fce462e299505d063e22e725c2e
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
2020-04-22 09:49:48 +02:00
Sona Kurazyan
a7264d9b8c Make continuations work with move-only types
Use the move-only versions of result reporting and getting operations,
if the type of QFuture is not copyable.

Task-number: QTBUG-81941
Change-Id: Ic9fa978380e2c24e190e68d974051a650b0e5571
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Vitaly Fanaskov <vitaly.fanaskov@qt.io>
2020-04-18 12:17:41 +02:00
Edward Welbourne
300aaec2f9 Fix digit grouping when digits are surrogat pairs
This is a follow-up to commit ed2b110b6a
to fix indexing errors. Added the test that should have accompanied
that commit, which found some bugs, and refined the Indian number
formatting test (on which it's based).

Make variable i in the loops that insert grouping characters in a
number be consistently a *character* offset - which, when each digit
is a surrogate pair, isn't the same as an index into the
QString. Apply the needed scaling when indexing with it, not when
setting it or decrementing it. Don't assume the separator has the same
width as a digit.

Differences in index no longer give the number of digits between two
points in a string, so actively track how many digits we've seen in a
group when converting a numeric string to the C locale. Partially
cleaned up the code for that in the process (more shall follow when I
sort out digit grouping properly, without special-casing India).

Change-Id: I13d0f24efa26e599dfefb5733e062088fa56d375
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-04-17 13:43:50 +02:00
Lars Knoll
90f17d8584 Clean up memory
And remove a test failure when compiling with asan enabled.

Change-Id: I2b8e676665572adcbbac6a910983d5b209bf6d23
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2020-04-17 11:24:35 +02:00
Simon Hausmann
f395cedc5b Simplify signature of untyped property bindings
Instead of requiring the implementation to do the compare dance, let's
do this in the library. This reduces the amount of duplicated code
slightly and makes it easier to generate binding code from qml files.

Change-Id: Ia3b16cf9769e74d076b669efe4119ab84af3cdf0
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-04-17 11:24:10 +02:00
Lars Knoll
83f5c3c26a Remove QString::from/toAscii()
These methods have been deprecated since 5.0

Change-Id: I3ceed57a364ea59a63ccc51452ab3b4da7140ce4
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2020-04-16 23:14:57 +02:00
Mårten Nordheim
487dd80bce Introduce QSocketNotifier::activate(QSocketDescriptor, QSN::Type)
The pre-existing overload passes an int, but this can mean the
descriptor gets truncated in compilations where the descriptor
is 64-bit.

The old overload with int is visible when querying the metaobject system
so string-based connects still work as before, and connecting to it will
produce a deprecation warning in the output.
At the same time the PMF-based connect will, on recompile, pick the
QSocketDescriptor overload. As an added improvement it also comes with
the notification type, removing the need for separate slots where the
code would be mostly shared anyway.

The QSocketDescriptor type can be implicitly converted to and from
qintptr to ensure existing code still compiles. It can also be
constructed from Qt::HANDLE on Windows.

In this same patch I also update the existing string-based connects in
this module, which then includes updating the parameters for some slots
as well.

[ChangeLog][QtCore][QSocketNotifier] Added
QSocketNotifier::activated(QSocketDescriptor, QSocketNotifier::Type).
This replaces the activated(int) signal which in 64-bit environments
could truncate the socket descriptor. If you use "activated" with the
string-based connect() then you need to update the parameter type of the
signal and slot if it had one. If you use it with the pointer to member
function based connect() then all you need to do is update your slot's
parameter type if it has one. If you need to compile your source code
with multiple versions of Qt then connect() to this function using
pointer to member function and update the slot's parameter type if
needed.

Task-number: QTBUG-70441
Change-Id: Ic43d6bc4c5bcb4040867b2ffad8d36fb01eed8af
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2020-04-16 13:52:11 +02:00
Giuseppe D'Angelo
bb0a616260 QObject: overhaul narrowing detection
Use P0608's trick to detect convertibility without narrowing;
and now that we can depend on C++17, use its features.

First, this moves the burden of detecting a narrowing conversion on
the compiler, rather than us maintaining a complicated series
of checks. Of course, this exposes

* bugs in compilers (e.g. GCC < 9 thinks that float->bool is not
  narrowing;

* behavior still not (widely) implemented (pointer to bool
  conversions are narrowing, P1957);

* interesting compiler choices, e.g. GCC 9 thinks that unscoped
  enumerations are non-narrowing convertible to a datatype big
  enum to contain all the _enumerators_, even if the underlying
  type of the enum (and/or its sizeof()) is wider than the target
  datatype.

Second, it allows to detect conversions that have a narrowing
conversion as an intermediate step. Given a type like

  struct Bad { operator double() const; };

then an object of type Bad is implictly convertible to a type
like int via a narrowing conversion. Therefore, a connection
is possible between a signal carrying a Bad and a slot accepting
an int. We can now detect and block this.

Tests regarding scoped enumerations have been dropped,
for the simple reason that a scoped enumeration is not
implictly convertible to an integral type, so we don't have
that detection (it would constantly fail). Scoped enumerations
do not take part in narrowing conversions anyhow, cf. [dcl.init.list].

[ChangeLog][QtCore][QObject] The detection of narrowing conversions
when calling QObject::connect() when
QT_NO_NARROWING_CONVERSIONS_IN_CONNECT now takes also
into account user-defined implicit conversions that undergo
through a narrowing conversion.

Change-Id: Ie09d59203fe6283378b36dfbc54de1d58098ef51
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-04-15 15:20:45 +02:00
Lars Knoll
eb349930ee Remove QRegExp support from QSortFilterProxyModel
Map setFilterWildcard() and setFilterFixedString() to now use
QRegularExpression.

Change-Id: I2dff2015234decb2badfd306975dcff8553cdd7f
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2020-04-15 14:38:40 +02:00
Lars Knoll
ea6c69bd6a Port test over to use QRegularExpression
Change-Id: I7f69fbbdb9e327059cd978b0989eee2c75c5a24b
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2020-04-13 09:40:38 +02:00
Qt Forward Merge Bot
58a4289800 Merge remote-tracking branch 'origin/5.15' into dev
Conflicts:
	tests/auto/network/socket/platformsocketengine/platformsocketengine.pri

Change-Id: I22daf269a8f28f80630b5f521b91637531156404
2020-04-11 14:59:13 +02:00
Thiago Macieira
bfb9b02d3b QCborValue: fix the move-assignment operator
The double-swap technique I used was flawed and broke on
self-assignment. What I had meant to use was the move-and-swap
technique. Thanks to Peppe for pointing it out.

This also fixes a compiler bug in the Green Hills compiler. It was
finding the wrong "swap" function in qSwap:

    using std::swap;
    swap(value1, value2);

It's supposed to find swap(QCborValue &, QCborValue &) due to argument-
dependent lookup. It's instead finding std::swap<QCborValue>, which
recurses.

Fixes: QTBUG-83390
Change-Id: Ibdc95e9af7bd456a94ecfffd1603e1bee90cd107
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2020-04-11 12:04:25 +00:00
Lars Knoll
f14559790b Change qHashBits to use MurmurHash2
The old implementation was either using CRC32 on modern processors
or a trivial, but rather slow implementation.

We can't continue with CRC32, as that implementation can only
give us 32bit hashes, where we now need to support 64bit in Qt 6.

Change the implementation to use MurmurHash, as public domain
implementation that is both very fast and leads to well distributed hashes.

This hash function is about as fast as the SSE optimized CRC32 implementation
but works everywhere and gives us 64 bit hash values.

Here are some numbers (time for 10M hashes):

                                         14 char     16 char
                                         QByteArray  QString  float
old qHash (non CRC32)                    127ms       134ms    48ms
old qHash (using SSE CRC32 instructions  60ms        62ms     46ms
new qHash                                52ms        43ms     46ms

Unfortunately MurmurHash is not safe against hash table DoS attacks, as
potential hash collisions are indepenent of the seed. This will get
addressed in followup commit, where we use SipHash or an SSE optimized
AES based hashing algorithm that does not have those issues.

Change-Id: I4fbc0ac299215b6db78c7a0a2a1d7689b0ea848b
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-04-09 20:03:45 +02:00
Lars Knoll
0375757bfb Implement emplace() for QHash and QMultiHash
At the same time use the opportunity to refactor the
insertion code inside the implementation of QHash to
avoid copy and move constructors as much as possible
and always construct nodes in place.

Change-Id: I951b4cf2c77a17f7db825c6a776aae38c2662d23
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-04-09 20:03:32 +02:00
Lars Knoll
c6cdf38e75 Change qHash() to work with size_t instead of uint
This is required, so that QHash and QSet can hold more
than 2^32 items on 64 bit platforms.

The actual hashing functions for strings are still 32bit, this will
be changed in a follow-up commit.

Change-Id: I4372125252486075ff3a0b45ecfa818359fe103b
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-04-09 20:03:25 +02:00
Lars Knoll
e1e573cee8 new QCache implementation
Make use of the new features available in QHash and do a more
performant implementation than the old one.

Change-Id: Ie74b3cdcc9871cd241aca205672093dc395d04a7
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-04-09 20:03:03 +02:00
Lars Knoll
5b7c3e31b5 New QHash implementation
A brand new QHash implementation using a faster and more memory efficient data
structure than the old QHash.

A new implementation for QHash. Instead of a node based approach as the old
QHash, this implementation now uses a two stage lookup table. The total
amount of buckets in the table are divided into spans of 128 entries.
Inside each span, we use an array of chars to index into a storage area
for the span.

The storage area for each span is a simple array, that gets (re-)allocated
with size increments of 16 items. This gives an average memory overhead of
8*sizeof(struct{ Key; Value; }) + 128*sizeof(char) + 16 for each span.

To give good performance and avoid too many collisions, the array keeps its
load factor between .25 and .5 (and grows and rehashes if the load factor goes
above .5).

This design allows us to keep the memory overhead of the Hash very small, while
at the same time giving very good performance. The calculated overhead for a
QHash<int, int> comes to 1.7-3.3 bytes per entry and to 2.2-4.3 bytes for
a QHash<ptr, ptr>.

The new implementation also completely splits the QHash and QMultiHash classes.

One behavioral change to note is that the new QHash implementation will not
provide stable references to nodes in the hash when the table needs to grow.

Benchmarking using https://github.com/Tessil/hash-table-shootout shows
very nice performance compared to many different hash table implementation.
Numbers shown below are for a hash<int64, int64> with 1 million entries. These
numbers scale nicely (mostly in a linear fashion with some variation due to
varying load factors) to smaller and larger tables. All numbers are in seconds,
measured with gcc on Linux:

Hash table              random     random     random  random reads   full
                        insertion  insertion  full    full   after   iteration
                                   (reserved) deletes reads  deletes
------------------------------------------------------------------------------
std::unordered_map      0,3842     0,1969     0,4511  0,1300 0,1169  0,0708
google::dense_hash_map  0,1091     0,0846     0,0550  0,0452 0,0754  0,0160
google::sparse_hash_map 0,2888     0,1582     0,0948  0,1020 0,1348  0,0112
tsl::sparse_map         0,1487     0,1013     0,0735  0,0448 0,0505  0,0042
old QHash               0,2886     0,1798     0,5065  0,0840 0,0717  0,1387
new QHash               0,0940     0,0714     0,1494  0,0579 0,0449  0,0146

Numbers for hash<std::string, int64>, with the string having 15 characters:

Hash table              random     random     random  random reads
                        insertion  insertion  full    full   after
                                   (reserved) deletes reads  deletes
--------------------------------------------------------------------
std::unordered_map      0,4993     0,2563     0,5515  0,2950 0,2153
google::dense_hash_map  0,2691     0,1870     0,1547  0,1125 0,1622
google::sparse_hash_map 0,6979     0,3304     0,1884  0,1822 0,2122
tsl::sparse_map         0,4066     0,2586     0,1929  0,1146 0,1095
old QHash               0,3236     0,2064     0,5986  0,2115 0,1666
new QHash               0,2119     0,1652     0,2390  0,1378 0,0965

Memory usage numbers (in MB for a table with 1M entries) also look very nice:

Hash table        Key   int64      std::string (15 chars)
                  Value int64      int64
---------------------------------------------------------
std::unordered_map      44.63      75.35
google::dense_hash_map  32.32      80,60
google::sparse_hash_map 18.08      44.21
tsl::sparse_map         20.44      45,93
old QHash               53.95      69,16
new QHash               23.23      51,32

Fixes: QTBUG-80311
Change-Id: I5679734144bc9bca2102acbe725fcc2fa89f0dff
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-04-09 20:02:55 +02:00
Thiago Macieira
7cd2d2b751 tst_QFileInfo: fix running with systems without /etc/passwd
Clear Linux containers running as root may have no /etc/passwd. But
they'll have /etc/machine-id because systemd creates that. Also test
/proc/version (a Linux-specific file) because that isn't writeable even
by root.

Take the opportunity to check with access() instead of assuming root and
only root can write to the file.

Change-Id: Ibdc95e9af7bd456a94ecfffd1603e8359604752b
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-04-09 10:55:25 -03:00
Thiago Macieira
954d66e572 QCborArray: fix operator[] that extends the array
This was never tested. The infinite loop in QCborContainerPrivate::grow
is the proof.

[ChangeLog][QtCore][QCborArray] Fixed an infinite loop when operator[]
was called with with an index larger than the array's size plus 1.

Change-Id: Ibdc95e9af7bd456a94ecfffd1603df3855c73f20
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2020-04-09 09:41:56 -03:00
Thiago Macieira
57a57fda78 QCborMap: fix assigning elements from the map to itself
Similar to the QJsonObject issue of the previous commit (found with the
same tests, but not the same root cause). One fix was that copying of
byte data from the QByteArray to itself won't work if the array
reallocates. The second was that

  assign(*that, other.concrete());

fails to set other.d to null after moving. By calling the operator=, we
get the proper sequence of events.

[ChangeLog][QtCore][QCborMap] Fixed some issues relating to assigning
elements from a map to itself.

Note: QCborMap is not affected by the design flaw discovered in
QJsonObject because it always appends elements (it's unsorted), so
existing QCborValueRef references still refer to the same value.

Task-number: QTBUG-83366
Change-Id: Ibdc95e9af7bd456a94ecfffd1603df846f46094d
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2020-04-09 09:41:40 -03:00
Thiago Macieira
ddc7b3c156 QJsonObject: add missing detach2() calls
The refactoring to use CBOR missed two places where we could assign from
the same object and thus cause corruption. In fixing this issue, I found
a design flaw in QJsonObject, see Q_EXPECT_FAILing unit test and task
QTBUG-83398.

[ChangeLog][QtCore][QJsonObject] Fixed a regression from 5.13 that
incorrect results when assigning elements from an object to itself.

Fixes: QTBUG-83366
Change-Id: Ibdc95e9af7bd456a94ecfffd1603df24b06713aa
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2020-04-09 09:41:06 -03:00
Thiago Macieira
135d98134f tst_QSaveFile: skip test that fails when run as root
FAIL!  : tst_QSaveFile::retryTransactionalWrite() '!file.open(QIODevice::WriteOnly)' returned FALSE. ()
   Loc: [/home/tjmaciei/src/qt/qt5/qtbase/tests/auto/corelib/io/qsavefile/tst_qsavefile.cpp(156)]

strace reveals:
access("/TEMPDIR/outfile.ro", W_OK) = 0

Change-Id: Ibdc95e9af7bd456a94ecfffd1603eb371aadb02b
Reviewed-by: David Faure <david.faure@kdab.com>
2020-04-08 19:55:41 -03:00
Thiago Macieira
36feab8bf4 QTemporaryFile/Linux: don't cut the root dir's slash
Normally people shouldn't create temporary files on /, but if you're
running as root, why not?

Caught when running tst_qtemporaryfile as root:

 openat(AT_FDCWD, "", O_RDWR|O_CLOEXEC|O_TMPFILE, 0600) = -1 ENOENT (No such file or directory)

Change-Id: Ibdc95e9af7bd456a94ecfffd1603ebfc17cea220
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: David Faure <david.faure@kdab.com>
2020-04-08 19:55:00 -03:00
Qt Forward Merge Bot
8823bb8d30 Merge remote-tracking branch 'origin/5.15' into dev
Conflicts:
	examples/opengl/doc/src/cube.qdoc
	src/corelib/global/qlibraryinfo.cpp
	src/corelib/text/qbytearray_p.h
	src/corelib/text/qlocale_data_p.h
	src/corelib/time/qhijricalendar_data_p.h
	src/corelib/time/qjalalicalendar_data_p.h
	src/corelib/time/qromancalendar_data_p.h
	src/network/ssl/qsslcertificate.h
	src/widgets/doc/src/graphicsview.qdoc
	src/widgets/widgets/qcombobox.cpp
	src/widgets/widgets/qcombobox.h
	tests/auto/corelib/tools/qscopeguard/tst_qscopeguard.cpp
	tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
	tests/benchmarks/corelib/io/qdiriterator/qdiriterator.pro
	tests/manual/diaglib/debugproxystyle.cpp
	tests/manual/diaglib/qwidgetdump.cpp
	tests/manual/diaglib/qwindowdump.cpp
	tests/manual/diaglib/textdump.cpp
	util/locale_database/cldr2qlocalexml.py
	util/locale_database/qlocalexml.py
	util/locale_database/qlocalexml2cpp.py

Resolution of util/locale_database/ are based on:
https://codereview.qt-project.org/c/qt/qtbase/+/294250
and src/corelib/{text,time}/*_data_p.h were then regenerated by
running those scripts.

Updated CMakeLists.txt in each of
	tests/auto/corelib/serialization/qcborstreamreader/
	tests/auto/corelib/serialization/qcborvalue/
	tests/auto/gui/kernel/
and generated new ones in each of
	tests/auto/gui/kernel/qaddpostroutine/
	tests/auto/gui/kernel/qhighdpiscaling/
	tests/libfuzzer/corelib/text/qregularexpression/optimize/
	tests/libfuzzer/gui/painting/qcolorspace/fromiccprofile/
	tests/libfuzzer/gui/text/qtextdocument/sethtml/
	tests/libfuzzer/gui/text/qtextdocument/setmarkdown/
	tests/libfuzzer/gui/text/qtextlayout/beginlayout/
by running util/cmake/pro2cmake.py on their changed .pro files.

Changed target name in
	tests/auto/gui/kernel/qaction/qaction.pro
	tests/auto/gui/kernel/qaction/qactiongroup.pro
	tests/auto/gui/kernel/qshortcut/qshortcut.pro
to ensure unique target names for CMake

Changed tst_QComboBox::currentIndex to not test the
currentIndexChanged(QString), as that one does not exist in Qt 6
anymore.

Change-Id: I9a85705484855ae1dc874a81f49d27a50b0dcff7
2020-04-08 20:11:39 +02:00
Simon Hausmann
549712830b QProperty: Add support for member function change handlers
When a class has multiple QProperty members to implement functionality,
it is common to have functions in the class that react to changes. For
example to emit a compatibility signal, in case of Qt Quick to mark the
scene graph as dirty, etc. etc.

To faciliate this use-case, this patch adds an internal
QPropertyMemberChangeHandler template that allows connecting a QProperty
field to a member function callback.

At the moment that callback is still 3 * sizeof(pointer). This could in
theory be reduced to 2 by eliminating the back-pointer (prev) as the
observer lives as long as the property. That however belongs into maybe
a future patch.

In order to get a pointer back to the surrounding object that holds the
QProperty as well as provides the callback function, the property system
was changed to pass through the address of the QProperty member at
run-time, and at compile time the delta from the QProperty member to the
beginning of the surrounding class is calculated. Through subtraction we
obtain the pointer to the owning object.

Change-Id: Ia2976357053f474ff44d0d6f60527c3b8e1f613a
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-04-06 14:25:12 +02:00
Kari Oikarinen
9ead0b0431 tst_QScopeGuard: Fix build by giving template parameters explicitly
std::function does not have deduction guides in older libc++ (presumably older
than version 10). Omitting the template parameter isn't essential for the test,
so just give it.

Change-Id: Ia9bb91f961b0928203737ec976913effd06433e0
Reviewed-by: Jüri Valdmann <juri.valdmann@qt.io>
2020-04-06 09:27:01 +02:00
Giuseppe D'Angelo
9121829916 QRegularExpression: rename AnchoredMatchOption to AnchorAtOffsetMatchOption
The name of the option may cause confusion due to the fact
that it's not _fully_ anchoring the match, only anchoring it
at the offset passed to match() -- in other words, it's a
"left" anchoring. Deprecate the old name and introduce
a new one that should explain the situation better.

[ChangeLog][QtCore][QRegularExpression] The AnchoredMatchOption
match option has been deprecated in favor of
AnchorAtOffsetMatchOption, which should better describe
that the match is only anchored at the offset.

Change-Id: Ib751e5e488f2d0309a2da6496378247dfa4648de
Reviewed-by: Samuel Gaist <samuel.gaist@idiap.ch>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
2020-04-03 21:49:57 +02:00
Edward Welbourne
0c2d6c163f Fix deprecation warning in tst_QLocale()'s use of QProcess::start()
Change-Id: I6f5dfa2d40984f86670288bdee4d1b7b060850ac
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-04-03 15:13:23 +02:00
Edward Welbourne
89bd12b9ad Change QLocale to use CLDR's accounting formats for currencies
In particular, this changed the US currency formats for negative
amounts to be parenthesised versions of the positive amount forms,
rather than having a minus sign after the $ sign. Test updated.

[ChangeLog][QtCore][QLocale] Currency formats are now based on CLDR's
accounting formats, where they were previously mostly based (more or
less by accident) on standard formats. In particular, this now means
negative currency formats are specified, where available, where they
(mostly) were not previously.

Task-number: QTBUG-79902
Change-Id: Ie0c07515ece8bd518a74a6956bf97ca85e9894eb
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
2020-04-02 20:43:34 +02:00
Sona Kurazyan
0f78e85421 Add support of failure handler callbacks to QFuture
Added QFuture::onFailed() method, which allows attaching handlers for
exceptions that may occur in QFuture continuation chains.

Task-number: QTBUG-81588
Change-Id: Iadeee99e3a7573207f6ca9f650ff9f7b6faa2cf7
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-04-01 21:51:13 +02:00
Sona Kurazyan
495f958b9a Store QFuture exceptions as std::exception_ptr
Replaced the internal ExceptionHolder for storing QException* by
std::exception_ptr. This will allow to report and store exceptions
of types that are not derived from QException.

Task-number: QTBUG-81588
Change-Id: I96be919d8289448b3e608310e51a16cebc586301
Reviewed-by: Vitaly Fanaskov <vitaly.fanaskov@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2020-04-01 21:51:06 +02:00
Fabian Kosmale
a97703d33a Enable qmetatype test with CMake
Change-Id: I34dcc0ae9187092ae1e277c2b3676d551a76991a
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2020-04-01 10:29:33 +02:00
Lars Knoll
66f06a930d Make QLocale(QString) explicit
We should not implicitly convert a QString to a QLocale object. It can
easily create unwanted side effects.

Change-Id: I7bd9b4a4e4512c0e60176ee4d241d172f00fdc32
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2020-04-01 09:29:26 +01:00
Timur Pocheptsov
44ceb56455 QFuture - add ability to move results from QFuture
QFuture's original design pre-dates C++11 and its
introduction of move semantics. QFuture is documented
as requiring copy-constructible classes and uses copy
operations for results (which in Qt's universe in general
is relatively cheap, due to the use of COW/data sharing).
QFuture::result(), QFuture::results(), QFuture::resultAt()
return copies. Now that the year is 2020, it makes some
sense to add support for move semantics and, in particular,
move-only types, like std::unique_ptr (that cannot be
obtained from QFuture using result etc.). Taking a result
or results from a QFuture renders it invalid.  This patch
adds QFuture<T>::takeResults(), takeResult() and isValid().
'Taking' functions are 'enabled_if' for non-void types only
to improve the compiler's diagnostic (which would otherwise
spit some semi-articulate diagnostic).
As a bonus a bug was found in the pre-existing code (after
initially copy and pasted into the new function) - the one
where we incorrectly report ready results in (rather obscure)
filter mode.

Fixes: QTBUG-81941
Fixes: QTBUG-83182
Change-Id: I8ccdfc50aa310a3a79eef2cdc55f5ea210f889c3
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-03-31 15:28:23 +02:00