Commit Graph

60536 Commits

Author SHA1 Message Date
Marc Mutz
54a4d4bf76 QCryptographicHash: implement non-OpenSSL3 part of supportsAlgorithm()
Unconditionally returning true is incorrect, not only just since
NumAlgorithms was added in 0411d98192.
The values may have gaps, we might be compiling with SHA1_ONLY, and,
on a language-lawyer level, enums can legally contain values other
than those explicitly enumerated, so give the right answer in all of
these cases.

Pick-to: 6.5
Change-Id: I705d4f759b2572b8b3d1cee18b7939939eedbbac
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-26 07:51:13 +01:00
Thiago Macieira
ec2c27d596 QDeadlineTimer: add a few missing default template parameters
I don't think any of these make a difference because the Duration is an
implied parameter because of the time_point arguments, but this makes
the code match QDeadlineTimer::deadline<T>.

Pick-to: 6.5
Change-Id: Ieec322d73c1e40ad95c8fffd17468a41182944ab
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2023-02-25 18:14:11 -08:00
Thiago Macieira
81783d02e8 QElapsedTimer & QDeadlineTimer: use NSDMI for their two fields
Pick-to: 6.5
Change-Id: Ieec322d73c1e40ad95c8fffd174654d643c05097
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2023-02-25 18:14:11 -08:00
Thiago Macieira
cf059ac9ec QThread/Unix: move qt_nanosleep to qthread_unix.cpp
It's the only place that uses it.

Pick-to: 6.5
Change-Id: Ieec322d73c1e40ad95c8fffd17465370ac209c2f
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2023-02-25 18:14:11 -08:00
Ahmad Samir
caa21ffc65 tst_benchlibcallgrind: silence a compiler warning
Change-Id: I68cc530fa8eaf941a6ddb7e6987ff37ec270bc4d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-26 03:14:46 +02:00
Samuel Gaist
283cdb0e70 examples: port widget examples to new connection style
Task-number: QTBUG-106893
Change-Id: Ib10fd516fdbeda0087b1c8550ce340acd3973e6b
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2023-02-25 22:11:57 +01:00
Ahmad Samir
683ddddc6a q_core_unix: move timspec<->chrono helpers from qtools_p.h
Where it has a home with its other timespec/chrono siblings.

Luckily I only needed to change one place in the code, and that source
file already has #include's q_core_unix_p.h.

Change-Id: I783383f958ceccfd6f9210f0b76d35b0f82b7cb5
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-25 23:11:54 +02:00
Thiago Macieira
09f5bb9969 QString: make insert_helper take the insertee by const-ref
Not all callers pass a view-type object: there are several call points
passing a QVarLengthArray, which means the value ended up being copied.

Introduced in 67108ef8db. Found by
Coverity scan (CID 404702).

Change-Id: I9671dee8ceb64aa9b9cafffd1742f9cda2131752
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-02-25 12:31:17 -08:00
Thiago Macieira
938dc34f94 Revert "QLocale: update the disabling of -Wfree-nonheap-object to GCC 10 only"
This reverts commit e76bcaa203.

I managed to reproduce the warning with GCC 12. It only happens
with -flto (LTCG) builds, not in regular release builds.

Change-Id: I6747273300ee51dec05563233017ba0cdf46794a
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2023-02-25 16:45:01 +00:00
Marc Mutz
06a2101e95 QMessageAuthenticationCode: make finalizeUnchecked() properly noexcept
Replace the QVarLengthArray with HashBlock, an instantiation of
QSmallByteArray. Unlike QVLA, which may allocate memory when
capacity() exceeds Prealloc (not the case here, but could become an
issue with future hash algorithms, we're at 144 now, up from the
traditional 64), QSmallByteArray never throws, and the few Q_ASSERT()s
it contains don't matter, because we use the class' functions
in-contract here.

Requires to add an indexing operator to QSmallByteArray.

Pick-to: 6.5
Change-Id: Ica3656adc190e0141e065287fadc38e0cebce0f4
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-25 16:50:04 +01:00
Marc Mutz
57a8c3173d QMessageAuthenticationCode: replace result QByteArray with QSmallByteArray
This minimizes the impedance mismatch between
QCryptographicViewPrivate and QMessageAuthenticationCodePrivate and is
the penultimate step to finally marking QMAC's finalizeUnchecked()
noexcept, too (QCH's has been for a few Qt versions now).

It also enables adding a QMAC::resultView() a la QCH::resultView(),
but that's another commit, as 6.5 is closed for new API.

Pick-to: 6.5
Change-Id: I3fe228585c560d8d32e99e12bba2be21fddaf642
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-25 16:50:04 +01:00
Marc Mutz
289a54a809 QMessageAuthenticationCode: reuse messageHash in finalizeUnchecked()
The only reason why we couldn't before was because we had a view on
messageHash's result, which would have been clobbered when resetting
messageHash for reuse.

Since QMessageAuthenticationCodePrivate now contains
QCryptographicHashPrivate, we gain access to the latter's
QSmallByteArray result, and can just take a copy before reset()ing.

Re-using a QCryptographicHash is faster than creating a new one,
esp. in OpenSSL3 mode, where construction allocates a context while
reset() no longer does.

Pick-to: 6.5
Change-Id: I3bc0454918840a104fd53909e79b6fe21326bfbf
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-25 16:50:04 +01:00
Marc Mutz
2a726582b7 QCryptographicHash: give the result container a catchy name
Repeating QSmallByteArray<maxHashLength()> when reusing the type for
QMessageAuthenticationCode isn't DRY.

Pick-to: 6.5
Change-Id: I6d5ca2c14c5ea696a4d28eeb1fb384ff5671d161
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-25 16:50:04 +01:00
Marc Mutz
81ca8aa4ab QMessageAuthenticationCode: make qt_hash_block_size() constexpr
Because we can, and as a preparation for using it to determine the size
of a fixed-size buffer for the HMAC's key material.

Pick-to: 6.5
Change-Id: I4add1115ef6d649baab25a842e1238db8a98bb7d
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-25 16:50:03 +01:00
Marc Mutz
0411d98192 QCryptographicHash: auto-calculate MaxHashLength
Add Algorithm::NumAlgorithms and use it to iterate over all
statically-available algorithms, querying their hashLengthInternal().

This avoids having to statically_assert(<= MaxHashLength) everywhere,
and auto-adjusts the buffer size in SHA1_ONLY builds.

Yes, the extra case labels for NumAlgorithms are a nuisance, but at
least the compiler will remind us when we forget, unlike a missing
static_cast(<= MaxHashLength) that might easily be forgotten.

Adjust the test (which iterates over the QMetaEnum for
QCryptographicHash::Algorithm, so finds NumAlgorithms and tries to
pass it to the hash() function which responds with a
Q_UNREACHABLE(). Only test hashLength() == 0 for that enum value.

Pick-to: 6.5
Change-Id: I70155d2460464f0b2094e136eb6bea185effc9d5
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-25 16:50:03 +01:00
Ahmad Samir
10e9687159 Use one common repeatCount() function in QLocale and QDateTimeParser
Change-Id: I4b6554966c4eb2c82f406a17d686982a38610b8c
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2023-02-25 15:25:30 +02:00
Allan Sandfeld Jensen
93047c71e8 Add special thread pool for Qt Gui
To avoid gui slowdowns due to global pool being blocked.

Fixes: QTBUG-109511
Pick-to: 6.5 6.4 6.2
Change-Id: I4e8d91e8fb0bd2e395072a082e992a3c5d3464ad
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-02-25 10:54:19 +01:00
Ahmad Samir
a861eea14f QTimerInfo: replace a goto with a lambda
More readable and now we can return earlier in an already long method.

(Patch best viewed in terminal: `git show -W --ignore-all-space` :)).

Change-Id: Ia405cdb91966b993cf7130c662bc1d189ff2c155
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-24 18:31:20 +02:00
Ahmad Samir
17d36d92fc QTimerInfo: use range-for; use STL algorithms
Change-Id: I7e1b603540a2a2b4d1b12d4dbdba7e9183ee367f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io>
2023-02-24 18:31:10 +02:00
Ahmad Samir
2f17a1b4ef QTimerInfo: don't shadow member variable name
"currentTime", which one? the member, a local var or a method arg?!

Change-Id: I7f8269ef15a8a901e47e4f83f8e16f185fe8b8f5
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io>
2023-02-24 18:30:54 +02:00
Ahmad Samir
6754795e54 QTimerInfo: use chrono for time intervals
For VeryCoarseTimer:
   - The code used to convert QTimerInfo::interval to seconds in
     registerTimer(), then convert to milliseconds when creating
     QTimerInfo in registeredTimers(); this is a bit confusing as
     "interval" was sometimes milliseconds and sometimes seconds
     depending on the type of the timer; instead "round" to the nearest
     second while always keeping "interval" in milliseconds (relying on
     chrono doing the conversion)..
   - Add roundToSecs() helper; it behaves like the original code (i.e.
     rounding each 500ms to 1 full second):
   const auto list = {300, 499, 500, 600, 1000, 1300, 1499, 1500, 1501,
                      1600, 2000, 2300, 2499, 2500, 2600};
   using namespace std::chrono;
   for (int dur : list) {
       auto i = dur;
       i /= 500; i += 1; i >>= 1; // Original code

       milliseconds msec{dur};
       seconds secs = duration_cast<seconds>(msec);
       milliseconds frac = msec - secs;
       if (frac >= 500ms)
          secs += 1s;

       assert(i == secs.count());
   }
----

- Don't mix signed and unsigned when doing arithmetic

The next "chrono-first" step would be changing
QAbstractEventDispatcher::TimerInfo::interval from int to
chrono::milliseconds, and adding a virtual
QAbstractEventDispatcher::registerTimer() overload that takes
chrono::milliseconds; neither can be done until Qt7 due to binary
compatibility constraints, c.f.:
https://community.kde.org/Policies/Binary_Compatibility_Issues_With_C++

Task-number: QTBUG-110059
Change-Id: I36f9bd8fb29565b1131afb3cdfc313452f625598
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-24 18:30:38 +02:00
Ahmad Samir
39a4cd126f q_core_unix_p.h: use std::chrono for time intervals
Also move some timespec helpers from qtimerinfo_unix.cpp to
q_core_unix_p.h, so that similar functions are grouped in one place.

Change-Id: I817733dd70607a1f4243a9745626f5c9b37ddc2a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-24 18:30:29 +02:00
Assam Boudjelthia
738c48244b Android: use FileProvider with QDesktopServices::openUrl()
Allow openUrl() to use FileProvider for opening files that are located
under app scoped paths and that use a file scheme for Android sdk 24 or
above.

[ChangeLog][Core][Android] Add FileProvider support for
QDesktopServices::openUrl().
[ChangeLog][Core][Android] Add AndroidX dependency to Gradle builds
by default since it's required by FileProvider.

Fixes: QTBUG-85238
Change-Id: Ia7403f74f2a8fd4886f74dba72e42b318ef5d079
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Reviewed-by: Nicholas Bennett <nicholas.bennett@qt.io>
Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
2023-02-24 17:45:10 +02:00
Sharaf Zaman
b8d51001f7 Android: Set TMPDIR to point to cache dir rather than a persistent dir
Otherwise the app size keeps increasing. This is consistent with
QStandardPaths::TempLocation.

Pick-to: 6.5
Fixes: QTBUG-98502
Change-Id: If4f0bd7a84443fe80a026b5f4443a38c32a7c836
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2023-02-24 17:45:09 +02:00
Mårten Nordheim
2457dd8bd0 QVLA: Optimize assign() for non-throwing copies
Change-Id: I39e2bef482fa638a6d197623759b5163fc7cc3a6
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-24 16:10:11 +01:00
Mårten Nordheim
cb15967014 QVLA: Skip one unneeded reallocate call for assign()
Change-Id: I09bc8835335df82aca10aa16d1902e7a1e79a10c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-24 16:10:11 +01:00
Antti Määttä
eb85a5eee7 Do not add trace_location meta-data by default
Instead document the meta-data and let the user set it.

Pick-to: 6.5
Change-Id: I13c9cd0129ffeef7b72635f46f53cf3dbfcf6684
Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2023-02-24 15:30:27 +02:00
Volker Hilsheimer
f97501524a Fix warning from signed/unsigned mismatch
Seen (and breaking local build) with VC++2022:

qrhid3d12_p_p.h(206): warning C4018: '<': signed/unsigned mismatch

QD3D12ObjectHandle::index is a quint32, whereas data is a QVector,
with count() returning a signed qsizetype.

Pick-to: 6.5
Change-Id: I81946459ea9222dee2cbb2ae4589fb0e4028f5dd
Reviewed-by: Kristoffer Skau <kristoffer.skau@qt.io>
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2023-02-24 13:11:34 +00:00
Edward Welbourne
cb54da2366 Support Cyrillic's equivalent of 'E' as exponent separator
Only Ukrainian is actually recorded in CLDR as using U+0415 as
exponent separator; all other Cyrillic-using locales officially use
plain ASCII 'E'. However, it seems reasonable, in all Cyrillic
locales, to recognize both (given that they look very similar).

Task-number: QTBUG-107801
Change-Id: I70a1e60a2d9fe7e254e01d32c5bad909ea4b8c76
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
2023-02-24 13:37:07 +01:00
Edward Welbourne
4931fe9b02 Fix parsing of numbers to cope with non-single-character tokens
In some locales signs and the exponent are not single character
tokens. Replace QLocaleData::numericToCLocale() with a tokenizer that
will cope with this. At the same time, cache the locale data needed in
support of that, so that we don't repeatedly recreate QString()
objects just to compare them against input tokens.

The caching class is inspired by Thiago's proposal for fixing the
performance, which also inspires the optimization of the C locale in
the tokenizer used here.

Add some testing that round-tripping numbers via strings works for the
locales with signs and exponents that use more than one character.

Task-number: QTBUG-107801
Change-Id: I9fd8409a371ed62ed969d9ebc8b09584e752f7fb
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-24 13:37:07 +01:00
Edward Welbourne
d753941817 Use isAsciiDigit() in a few more places in qlocale.cpp
Use the function now in qtools_p.h in several more places.
(A later commit rewrites the remainder away.)

Change-Id: I782f0dceffe0e6e76753643a889011a834bc3ff0
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-24 13:37:07 +01:00
Edward Welbourne
e0f9671338 Reflow some code and comments in the aftermath of a dedent
There's more space to the right now, so we may as well use it.

Change-Id: I653c52e1a2fb9eb2a0b027be90fb7bc2734a5e85
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-02-24 13:37:07 +01:00
Edward Welbourne
846e532458 Dedent some switch statement bodies to match coding style
The case labels are meant to line up with the switch statement.

Change-Id: I62a45ffca22582d2264ecb3eb5ad7fbfe2aa148b
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-02-24 13:37:06 +01:00
Edward Welbourne
e204de690b Add missing shbang line to shell script
If it's executable, it should specify how it's to be executed.

Change-Id: If5671712da3e1fbc42b15d22c1253129910091bc
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2023-02-24 13:37:06 +01:00
Ivan Solovev
2a4c64cbed Add QtConcurrent Examples page
The QtConcurrent examples were only discoverable from the
"All Qt Examples" page, which was very inconvenient.

This patch adds a separate page for all Qt Concurrent examples, and
links to it from the module's main page.

Pick-to: 6.5
Change-Id: Iecabd9e21033605c1ec74232ce4f3d68b0c78d82
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Jaishree Vyas <jaishree.vyas@qt.io>
2023-02-24 12:59:52 +01:00
Mikolaj Boc
6c12ea1d45 Skip non-qtbase tests on Coin
The previous attempt failed as target coin configuration doesn't
use superbuild. Skip the tests based on the TESTED_MODULE_COIN
environment variable

Task-number: QTBUG-109786
Change-Id: I0dbe6ff64ca4a2e81fef377865ef4e99b58c5eb2
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2023-02-24 10:10:14 +00:00
Marc Mutz
494786ce73 QMessageAuthenticationCode: make messageHash a QCryptographicHashPrivate
... avoiding one more memory allocation, and giving us access to
QCryptographicHashPrivate::result, for use in subsequent commits.

The only real adjustment to users of QMACPrivate::messageHash is that
instead of

   messageHash.result();

they now need to use

   messageHash.finalizeUnchecked();
   messageHash.resultView() // .toByteArray()

I.e. explicitly finalize.

Pick-to: 6.5
Change-Id: I80b1158b062554bbf8afa7241674a892de27f204
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-24 07:26:55 +01:00
Marc Mutz
d53f8d6bbb QCryptographicHash: move addData(QIODevice*) to Private
To be reused in QMessageAuthenticationCode.

Pick-to: 6.5
Change-Id: Ie4f003ad38ce9072cf6ee52ef2d7a63438e4d7ae
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-24 07:26:19 +01:00
Marc Mutz
d2e1c0aef1 QMessageAuthenticationCode: re-use messageHash for hashing the key
With the OpenSSL3 code allocating state on the heap instead of in
QCH::Private's inline union, reset() should be faster than even a
static hash() call. Even in the non-OpenSSL3 case, using less
QCH::Private objects to do the same thing means we increase effective
data cache size.

Pick-to: 6.5
Change-Id: I0b1347864081169a24c5d349702931afdab6c5bf
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-24 07:26:13 +01:00
Marc Mutz
8de0262ded QMessageAuthenticationCode: use SHA-256 instead of insecure SHA-1 in doc sippet
Pick-to: 6.5
Change-Id: I5b39229abbb3e21d90fd83f5f3bcbe1afe609526
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-23 22:56:59 +01:00
Marc Mutz
2a2fc4d16d QMessageAuthenticationCode: remove lazy initialization of messageHash
This just complicates the code, for the small benefit of avoiding a
messageHash seeding from an empty key that then has to be reset.

This lazy initialization is in the way of using QCH's SmallByteArray
for the key, which this author thinks is the more important
optimization, because it will allow passing keys by QByteArrayView,
removing the impedance mismatch between QMAC and QCH.

Since the QMAC API doesn't distinguish between the absence of a key,
and the presence of a null (ie. empty) key, we can't not call
initMessageHash() when the key is empty, so we should suggest to pass
the actual key to the constructor as often as possible, and use
setKey() only to change the key afterwards.

[ChangeLog][QtCore][QMessageAuthenticationCode] No longer delays
processing of the key to the first setData() or result() call. While
passing a default-constructed key to the constructor and then calling
setKey() continues to work, for optimal performance, we suggest to
pass the actual key as a constructor argument and call setKey() only
to change the key.

Pick-to: 6.5
Change-Id: If0a078f37a16f8306f77d2b2bd5dacf23ce5c3e2
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-02-23 22:56:54 +01:00
Marc Mutz
dff0d5133f QMessageAuthenticationCode: make Private::method member const
Like in QCryptographicHash, it's never re-set, so, like there, make it immutable.

Pick-to: 6.5
Change-Id: I88f3dc15febffa8950256aedc5e8d1385fc86ddd
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-02-23 22:56:50 +01:00
Marc Mutz
d235953a82 QMessageAuthenticationCode: use QCryptographicHashPrivate in finalizeUnchecked()
... basically inlining static QCH::hash(), which, however, accepts
only one piece of data, while we have two.

Avoids the memory allocation of the QCH d-pointer. The toByteArray()
is now the only memory allocation left in finalizeUnchecked(), and
will be removed in a subsequent commit.

Pick-to: 6.5
Change-Id: I7549d6e1c116a4cdc29dac74b867dfa6647022a0
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-23 21:56:47 +00:00
Marc Mutz
29050fa65b QCryptographicHash: move SmallByteArray out of Private
Rename it to QSmallByteArray, and make the maximum size a template
argument. Initialize m_size to 0, to avoid a partially-formed
default-constructed objects (default-constructed containers should
always be in the empty state).

As a drive-by, fix placement of some {'s.

Don't move it into a header of its own, yet, as it lacks a lot of
features expected of a generally-reusable class. Maybe one day.

This is in preparation of re-using the class to hold the key in
QMessageAuthenticationCode.

Pick-to: 6.5
Change-Id: Iee77e03e50afdf2ebc5889feeead344bef8ab3e8
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-23 22:56:34 +01:00
Marc Mutz
9a18ca59ff QCryptographicHash: move result.clear() to beginning of reset()
... from the end().

It was lonely down there, and prone to be overlooked when performing
early returns in the #ifdef'ery above, as witnessed by the early
returns in the OpenSSL3 code.

Amends 1fe74c3bd3, itself amending
633c136596.

Pick-to: 6.5
Change-Id: I8c941ecb5c4755d8823b2161544cf6f7fe75a239
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-23 22:56:29 +01:00
Thiago Macieira
1d167b515e QHash: fix GrowthPolicy::bucketsForCapacity
It was confusing entry capacity with the bucket capacity. The value
maxNumBuckets() returned was the maximum number of entries. This issue
was harmless: we would just fail to cap the maximum to an allocatable
size. But the array new[] in the Data constructors would have capped the
maximum anyway (by way of throwing std::bad_alloc).

So instead of trying to calculate what the maximum bucket count is so we
can cap at that, simplify the calculation of the next power of 2 while
preventing it from overflowing in our calculations. We continue to rely
on new[] throwing when we return count that is larger than the maximum
allocatable.

This commit changes the load factor for QHashes containing exactly a
number of elements that is exactly a power of two. Previously, it would
be loaded at 50%, now it's at 25%. For this reason, tst_QSet::squeeze
needed to be fixed to depend less on the implementation details.

Pick-to: 6.5
Change-Id: I9671dee8ceb64aa9b9cafffd17415f3856c358a0
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-02-23 10:36:36 -08:00
Thiago Macieira
e836c4776f tst_qmessagehandler: fix QtTest warnings about duplicate row names
Pick-to: 6.5
Change-Id: Ieec322d73c1e40ad95c8fffd17464fcb2ca96f5f
Reviewed-by: Kai Köhne <kai.koehne@qt.io>
2023-02-23 10:33:39 -08:00
Thiago Macieira
644c06b48f Logging: fix crash when decoding a symbol that isn't a function
Saw this on my FreeBSD VM. The backtrace() function thought the nearest
symbol to something was "_ZTSNSt3__110__function6__baseIFbPvS2_EEE",
which decoded to

 typeinfo name for std::__1::__function::__base<bool (void*, void*)>

The function pointer type inside parameter threw the decoder for a loop
and caused it to crash with the failed assertion in qbytearray.h:

 inline char QByteArray::at(qsizetype i) const
 { Q_ASSERT(size_t(i) < size_t(size())); return d.data()[i]; }

I noticed this
 - because tst_qtimer hung
 - because qFormatLogMessage deadlocked acquiring QMessagePattern::mutex
 - because the logging recursed
 - because qCleanupFuncinfo failed an assertion while formatting the
   backtrace (my QT_MESSAGE_PATTERN has %{backtrace})
 - because QTimer::~QTimer -> QObject::killTimer printed a warning
 - because tst_QTimer::moveToThread produces warnings

Pick-to: 5.15 6.2 6.4 6.5
Change-Id: Ieec322d73c1e40ad95c8fffd17464f86e9725991
Reviewed-by: Kai Köhne <kai.koehne@qt.io>
2023-02-23 10:33:39 -08:00
Jani Heikkinen
c827b058dd Revert "Revert "Add binary compatibility file generated against 6.4.0""
This reverts commit cebcb7991a.

Reason for revert: We need to enable BIC tests again
Pick-to: 6.5

Change-Id: I3a51cddba52ae65683f377916f65a32707c4d346
Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
2023-02-23 15:28:37 +00:00
Amir Masoud Abdol
a1782c1492 Fix a typo
Pick-to: 6.5
Change-Id: I13c344113c2e924dbe43995affe9b1aa3647f2aa
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2023-02-23 16:28:37 +01:00