summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib
Commit message (Collapse)AuthorAgeFilesLines
* Merge remote-tracking branch 'origin/tqtc/lts-6.2.8' into ↵Tarja Sundqvist2024-01-2224-212/+987
|\ | | | | | | | | | | | | | | | | tqtc/lts-6.2-opensource Conflicts solved in a file: src/corelib/io/qstandardpaths_android.cpp Change-Id: Ie8cef36c1379679ca358df50c56b3c25aa15c5d6
| * Fix overflow in SHA-3/KeccakMårten Nordheim2023-03-131-0/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | state->rate is always larger than or equal to state->bitsInQueue; when bitsInQueue == rate the queue is consumed and bitsInQueue is set to 0 again. Manual conflict resolutions: - QCOMPARE_GE -> QVERIFY( >= ) - replace QByteArrayView usage Done-with: Marc Mutz <marc.mutz@qt.io> Change-Id: I56d268a19fb3cd542cc027edc962253f09d97a14 Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit fa4b7495b741c3e7943860c5ff15212afceda710)
| * tst_QCryptographicHash: Extract Method ensureLargeData()Marc Mutz2023-03-091-1/+11
| | | | | | | | | | | | | | | | | | ... to make large data usable from other test functions. Change-Id: I302070121a8bb49f373c7711bc3ab9e6418874ef Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> (cherry picked from commit f7ea9b36b7c56bb288f3ea55f587d2ccb8a9b7fa) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
| * tst_QAlgorithms: don't use random numbers in the test row namesThiago Macieira2023-03-071-17/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Just describe the row instead. We'd lose the original input in case of failure, so I added a class to print that value on destruction. Example: FAIL! : tst_QAlgorithms::countLeading64(0) Compared values are not the same Actual (qCountLeadingZeroBits(value)): 63 Expected (expected) : 64 Loc: [tests/auto/corelib/tools/qalgorithms/tst_qalgorithms.cpp(374)] QWARN : tst_QAlgorithms::countLeading64(0) Original value was 0x1 Fixes: QTBUG-109958 Change-Id: I69ecc04064514f939896fffd1738b1119cd80cf8 Reviewed-by: Dimitrios Apostolou <jimis@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> (cherry picked from commit d0408b5f13f811f73cf2485b5b31d5ec4b7f2b62)
| * tst_QAlgorithms: fix misleading indent in data tableEdward Welbourne2023-03-071-8/+11
| | | | | | | | | | | | | | | | | | | | | | A violation of coding style (requiring braces on multi-line bodies of conditionals) was accompanied by a mis-indented else block. Fix a long line while I'm about it. Change-Id: Ibe9cf15eadbe9ef58138d7876e5e2c5a14a92fd4 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Marc Mutz <marc.mutz@qt.io> (cherry picked from commit 0d915623ecef9d81f25c3891101b68384331233d)
| * Clean up tst_QAlgorithms::count{Trail,Lead}ing_data_impl()Edward Welbourne2023-03-071-12/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Pull out the arbitrary factor of three as a named constant and document its arbitrariness once. Pull out the mask and bit used in each function's loop to the outer layer of the loop, since they don't depend on the inner loop variable (or the random value generated in that loop). Use QTest::addRow() instead of constructing a string to pass to newRow(). Change-Id: Ifacbcb390e00828fd47f51b0c73d0ad5f6bc8bdb Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> (cherry picked from commit ce950bcbf7f6cf3bd5bf5113e7b70016f0d60492)
| * tst_QVariant: check fromValue() with a non-default-constructible typeMarc Mutz2023-03-041-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ... by just using fromValue() instead of the QVariant(QMetaType, void*) ctor. Code coverage isn't reduced, because fromValue() will, of course, call that exact ctor itself. Amends df0085d3a28005e84eb7688cc2575a121ba322aa. Task-number: QTBUG-105140 Task-number: QTBUG-111598 Change-Id: I02464803090fa7078947625616e6fc20e623ef31 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit fd17eaca8396288f34e89f5f66d2779c42ffc414) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
| * tst_qvarlengtharray: add test for QVLA(n) ctorMarc Mutz2023-03-021-0/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Also add one for types that are neither copy- nor move-constructible. In contrast to resize(n), the QVLA(n) ctor worked for such types, so make sure it stays that way. Manual conflict resolutions: - QCOMPARE_GE() is 6.4+, use QVERIFY( >= ) instead. Change-Id: If54fbc9dd6a4808175c4bcb0ffb492b33c879746 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> (cherry picked from commit e7c792ba7179c4c81fb2e26f66031ec81234b0d7) Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
| * tst_QMutex: use constexpr variables instead of 'enum-trick'Marc Mutz2023-03-021-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | C++20 doesn't like arithmetic with enums anymore. While this hasn't caused immediate pain, yet, fix it pro-actively for an imminent patch. As a drive-by, fix the missing space at start of comment. Change-Id: Id08bb227c587bc7b900c593a7b6d2655ca32eefd Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit b8966021ffb2cfddc77aee6dbe145eb74ef22f9d) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
| * tst_QMessageAuthenticationCode: check that setKey() reset()sMarc Mutz2023-02-281-0/+43
| | | | | | | | | | | | | | | | | | | | | | | | | | It's documented as such. Manual conflict resolutions: - QCryptographicHash::supportsAlgorithm() is 6.5+, remove the QSKIP Change-Id: I7299d289117e52dcefe3c4ab917d7ecad6dd02be Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> (cherry picked from commit a62aa1817863880fd340aab54d5b86aa4f8b1e53) Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
| * Logging: fix crash when decoding a symbol that isn't a functionThiago Macieira2023-02-231-0/+65
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 Change-Id: Ieec322d73c1e40ad95c8fffd17464f86e9725991 Reviewed-by: Kai Köhne <kai.koehne@qt.io> (cherry picked from commit 644c06b48f45aeabcd594df4dcf25a44ea02f132) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
| * qstrncpy: NUL-terminate even when src is nullptrMarc Mutz2023-02-221-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The goal of this function is to ensure that dst is _always_ NUL-terminated. The only exception is if there's no space to write even one NUL byte, of course, but not when src is nullptr but dst would have space. Update the docs to the new behavior and make them more precise. Fix a test that assumed qstrncpy() would not write to dst for (dst, nullptr, 10). [ChangeLog][QtCore][qstrncpy()] Now NUL-terminates the target buffer even when the source pointer is nullptr, provided the target buffer has space for at least one byte. Change-Id: I7806d8c71e260f8f02b79af7b6ce94f23599dd69 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit 05f913d57d6557d1c540894651cc83a5b1ec7cf7) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
| * QFuture: fix continuation cleanupIvan Solovev2023-02-171-0/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Not clearing the continuationData could lead to use-after-free when there is an attempt to cancel an already finished future, which belongs to an already-destroyed promise. This patch fixes it be explicitly resetting continuationData to nullptr in the clearContinuation() method, which is called from the QPromise destructor. Task-number: QTBUG-103514 Change-Id: I6418b3f5ad04f2fdc13a196ae208009eaa5de367 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> (cherry picked from commit b34bea5e96370986ea5dfc499fc2ec6366fda627) Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
| * QPromise: improve documentation snippetIvan Solovev2023-02-151-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The multi-thread snippet in the documentation, when copied as is, could actually crash because of the race condition between the main thread and the thread that generate results for the promise. This is fixed by explicitly calling QPromise::start(). Actually, the underlying snippet already has this call, it just was not included in the documentation. This patch modifies the documentation snippet to include calls to both QPromise::start() and QPromise::finish(). Fixes: QTBUG-109230 Change-Id: Ic25f31a6b3b16ba6bc06a0b199289c8c5d50bab6 Reviewed-by: Sona Kurazyan <kurazyan.sona@gmail.com> (cherry picked from commit a8261e327d6316d944cfcc312a1b2e71bd4e5d27) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
| * tst_qvarlengtharray: fix MyBase trackers for swap()Marc Mutz2023-02-101-0/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I don't begin to understand the semantics of the trackers here, but whatever they are, they break with the fallback std::swap() 3-moves implementation and lose track of alive objects, so provide an ADL swap that does the right thing. Amends dd58ddd5d97f0663d5fafb7e81bff4fc7db13ba7 (I think). Change-Id: I1cd49c95dca2d103a26c2c7ac0a896929135a6c8 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit 49fca96d88c308bc22cd898a8d202228d185654e) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
| * Pass short time format to GetTimeFormat from GetLocaleInfoIlya Fedin2023-02-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | TIME_NOSECONDS doesn't really switch to short time format, just removes the seconds from long time format. In picking to 6.2, rename a local variable to avoid shadowing the new format (and incidentally reduce scope for conflict on any later picks back from dev). Fixes: QTBUG-110627 Change-Id: Ie799958f3942c657f00bc8196588258661ddc1d9 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit 763884cfb7be0cadd353cfa3b9b760d521851718) Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Mate Barany <mate.barany@qt.io>
| * tst_QStringConverter: improve the char-by-char UTF-8 testingThiago Macieira2023-02-033-68/+168
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The utf8.txt file was only 21 bytes and contained exactly two non-ASCII characters. It wasn't very good. This commit brings back the UTF-8 test rows that existed before commit 18ec53156ee704fdb4977436fccfdc85333e614b deleted tst_Utf8. There's a lot of overlap with some of the other rows in this test, though. Change-Id: I77c8221eb2824c369feffffd16f094619b69faef Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io> (cherry picked from commit aef27c5aa2f43e8e34970168dfc517062cc87db8) Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
| * QUrl: restore empty-but-not-null for components that are presentThiago Macieira2023-01-271-39/+43
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This got lost during the QStringView port that happend in Qt 6.0 (commit 548dcef08976649c820054f3db1ad108c72439cd) because QString::operator+=(QStringView) does not copy the nullness of the right side, whereas QString::operator+=(const QString &) does. Fixes: QTBUG-84315 Change-Id: Ide4dbd0777a44ed0870efffd17399b772d34fd55 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> (cherry picked from commit a14a3a5487675a231b912e9a5ae575357d1c2cf8) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
| * QStringConverter: use the QUtf8 codec when Windows is using UTF-8Thiago Macieira2023-01-271-14/+50
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The QLocal8Bit implementation assumes that there's at most one continuation byte -- that is, that all codecs are either Single or Double Byte Character Sets (SBCS or DBCS). It appears to be the case for all Windows default codepages, except for CP_UTF8, which is an opt-in anyway. Instead of fixing our codec, let's just use the optimized UTF-8 implementation. [ChangeLog][Windows] Fixed support for using Qt applications with UTF-8 as the system codepage or by enabling that in the application's manifest. Discussed-on: https://lists.qt-project.org/pipermail/interest/2022-May/038241.html Change-Id: I77c8221eb2824c369feffffd16f0912550a98049 Reviewed-by: Lars Knoll <lars.knoll@qt.io> (cherry picked from commit 9bad4be21482d36bff76357a000e008755b60361) Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
| * Fix crash when cancelling a QFuture that has continuation with contextSona Kurazyan2023-01-061-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | To support cancellation of continuations attached via the parent future, we store a pointer to continuation future's data in parent. This requires preserving the lifetime of continuation future's data while the parent is still alive (see 24dedaeaa1a94bfe9ade2da2a2c9aa112241b07a). This is achieved by capturing the promise in the continuation's lambda, which is only cleaned up after the parent's data is destroyed. This is already the case for continuations without context, but was overlooked for continuations with context: they transfer the ownership of the continuation promise to lambda passed to QMetaObject::invokeMethod(), which destroys the lambda's context after it's run. As a result, the continuation's promise (and data, if there are no other copies of it) is also destroyed, leaving the parent pointing to deleted continuation data. To fix this, capture a copy of continuation future's ref-counted data in the continuation's lambda. This will guarantee that the continuation data remains alive until the parent is destroyed and the continuation is cleaned up. Fixes: QTBUG-108790 Change-Id: Ief4b37f31e652988d13b03499505ac65c7889226 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> (cherry picked from commit 9e61cc4f72a4fe86fa97f64238f1e3d940a7746b) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
| * tst_QStringApiSymmetry: fix a typo and deal with the falloutMarc Mutz2022-12-291-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | Turns out we don't support QStringView/QUtf8StringView comparison, and the only reason the corresponding test succeeded was because it contained a typo (QStringView instead of QUtf8StringView). Fix the typo and disable the now-failing test. Change-Id: I2210a247aac66743851e53578172a563ee1e96f7 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit 92e913a5414ea3a7fb002a139251bb8ae53c467c) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
| * Autoclose a FILE* if we open itVille Voutilainen2022-12-191-9/+1
| | | | | | | | | | | | | | | | Task-number: QTBUG-105736 Change-Id: I2bc10b54b77436cad914ec21fd85678c54de4305 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io> (cherry picked from commit f7559904d0e8f7966e726fd04801cb58a1bd4a2d) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
| * tst_QStringApiSymmetry: add checks for QByteArrayViewMarc Mutz2022-12-191-1/+89
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ... where checks for QByteArray existed before. The checks we can't add are - left/right/mid (legacy APIs not implemented in QBAV) - several relational operators, d/t ambiguities. Created QTBUG-108805 to track these. Manual conflict resolutions: - remove additions to tests which don't exist in 6.2, yet (overload, trimmed, toNumber{,WithBases}) - adjust to different set of local traits (is_utf8_encoded vs. is_bytearray_like) Task-number: QTBUG-108805 Change-Id: I30cc9b29a228d69d32af51234f2c28221478a75c Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> (cherry picked from commit 5812c36cd53ab7ccf472f7d041e0c61a00482d9d) Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
| * tst_qxmlstream: swap WHEN and THEN in readBack()Marc Mutz2022-12-161-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | WHEN writing an invalid character, THEN we expect the writer to report an error. The old code had it the wrong way around. It checked that WHEN the writer reports an error, THEN the character was invalid. The formulations are equivalent, but the latter is mixing up cause and effect, making it less clear what's being checked (QXmlStreamWriter, not isValidSingleTextChar()), so swap. Change-Id: I703de9ddde98d9913977a913f671472930735900 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Mate Barany <mate.barany@qt.io> (cherry picked from commit 7d0f08094a2318b753ea7d69b71c0abe0a46b3d3) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
| * tst_qmlstream: re-use QBuffer instance in readBack()Marc Mutz2022-12-161-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | This improves the runtime of this particular test function by almost 17% on my machine. Change-Id: Icd77cdda92374b92121988c99e56787d405fa2d9 Reviewed-by: Mate Barany <mate.barany@qt.io> Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> (cherry picked from commit 7fa6670fa4ff5a916477f14d5754f9337ec9f1a8) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
| * QBuffer: test and document open() behaviorMarc Mutz2022-12-141-0/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | QBuffer::open() was only documented as \reimp, so its behavior regarding WriteOnly was never actually described. Add a test and document the outcome. Change-Id: I75c49cd3f6a1961bcaece4a92a4e479bb3300d36 Reviewed-by: Mate Barany <mate.barany@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit c262a1805a062fd99abc890f58ea951da80ff0af) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
| * Android: fix Android assets handler not listing dirs with only sub dirsBartlomiej Moskal2022-12-134-0/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It looks like AAssetDir_getNextFileName is not enough. Directories that contain only other directories (no files) were not listed. On the other hand, AAssetManager_openDir() will always return a pointer to initialized object (even if the specified directory does not exists), so we can't just leave only it here. Using FolderIterator as a last resort. This approach should not be too time consuming. As part of this fix, add some unit tests to cover/ensure assets listing/iterating works as expected. Fixes: QTBUG-107627 Change-Id: Id375fe8f99f4ca3f8cad4756f783ffafe5c074df Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io> (cherry picked from commit 4ceee3911a2ef567f614fc296475bc2b2a0e3add) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
| * tst_QString: fix custom QCOMPARE for strings > 2Gi charactersMarc Mutz2022-12-071-1/+1
| | | | | | | | | | | | | | | | | | | | Same fix as in tst_qbytearray's QCOMPARE() in cb9715557c414d5b3c90165cc8fc710fbdcdba77. Change-Id: I2222d9015ae7121a2fbcf5b936b27de20e873064 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit 20d1477c14316a43b65415bae90d1e5d12fcbf44) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
| * Refactor\Extend tst_QString::prepend_data with additional test casesMate Barany2022-12-021-10/+72
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | During the implementation of QString::append(QUtf8StringView) it has become apparent that the testing is insufficient as it did not warn about an extra growth. The following tests have been added that append: - y-umlaut and greek letter small theta (2 UTF-8 code units => 1 UTF-16) - devanagri letter ssa (3 UTF-8 code units => 1 UTF-16) - chakma digit zero (4 UTF-8 code units => 2 UTF-16 code units) - some combinations of the above Task-number: QTBUG-103302 Change-Id: I981213c296bafc81663b08c0f1f339bbd8a96485 Reviewed-by: Marc Mutz <marc.mutz@qt.io> (cherry picked from commit 8c0ed7422c426046343e6d3ce81b35105cc2bc6b) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
| * Refactor\Extend tst_QString::insert_data with additional test casesMate Barany2022-12-021-10/+90
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | During the implementation of QString::append(QUtf8StringView) it has become apparent that the testing is insufficient as it did not warn about an extra growth. The following tests have been added that append: - y-umlaut and greek letter small theta (2 UTF-8 code units => 1 UTF-16) - devanagri letter ssa (3 UTF-8 code units => 1 UTF-16) - chakma digit zero (4 UTF-8 code units => 2 UTF-16 code units) - some combinations of the above Task-number: QTBUG-103302 Change-Id: I3d81cf10b7eb74433ce5bea9b92ce6bce1230dcd Reviewed-by: Marc Mutz <marc.mutz@qt.io> (cherry picked from commit bc9e1c5c2724161b97560b2957b9273bee013316) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
| * Refactor\Extend tst_QString::append_data with additional test casesMate Barany2022-12-021-14/+87
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | During the implementation of QString::append(QUtf8StringView) it has become apparent that the testing is insufficient as it did not warn about an extra growth. The following tests have been added that append: - y-umlaut and greek letter small theta (2 UTF-8 code units => 1 UTF-16) - devanagri letter ssa (3 UTF-8 code units => 1 UTF-16) - chakma digit zero (4 UTF-8 code units => 2 UTF-16 code units) - some combinations of the above Note that this also affects operator_pluseq_data, which is basically a wrapper around append_data. Task-number: QTBUG-103302 Change-Id: I09ed950e3f0e71ae9ae85a455f42e130887f1109 Reviewed-by: Marc Mutz <marc.mutz@qt.io> (cherry picked from commit 4e5f8740635d1d57371b7639d58e9998c0027a04) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
| * tst_qlocale: only restore the fp control masks we changeMårten Nordheim2022-11-281-5/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Certain masks are not supported outside 32-bit x86, and will assert on x64. Cherry-pick resolution: - Pick the modern 'portable' API instead of rewriting with x86-specific functions - Essentially means we also cherry-pick 67a563e5c55df8de595822880d92e297f580e053 Fixes: QTBUG-106000 Change-Id: Ic9f58e5a19c1db3309edeb5ec529e7a78c929665 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> (cherry picked from commit 070446d5ebf2a82531160268fbae0bb7c6730ecd) (cherry picked from commit 67a563e5c55df8de595822880d92e297f580e053) Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
| * tst_QString: check empty regex can replace in empty/null stringMarc Mutz2022-11-281-0/+3
| | | | | | | | | | | | | | | | | | | | It's not intuitive, so check lest people break it. Change-Id: I2435cd69be7b77a6ae59cdc7b5fb99658cfc42fd Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit d1a37ab0997fbe393fb9cca7158dfa59041f165d) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* | Merge remote-tracking branch 'origin/tqtc/lts-6.2.7' into ↵Tarja Sundqvist2023-10-0314-51/+406
|\| | | | | | | | | | | tqtc/lts-6.2-opensource Change-Id: Ie70d33341cccaaa69968dc8d1337ec27d7895127
| * tst_QMap: remove unused std::as_const cloneMarc Mutz2022-11-181-6/+0
| | | | | | | | | | | | | | | | | | Amends d273076b4474bb473d90e996960c4c773745761a. Change-Id: Icfff438223ed10756f15e25ea52cccdf93dd47a2 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> (cherry picked from commit 0786405857d79f009136197d8c795750a28bf0d4) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
| * Q(Multi)Map: prevent dangling key/value after detach()Giuseppe D'Angelo2022-11-171-0/+68
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Q(Multi)Map mutating functions that take reference to a key and/or a value (e.g. insert(), take(), etc.) must make sure that those references are still valid -- that is, that the referred objects are still alive -- after the detach() call done inside those functions. In fact, if the key/value are references into *this, one must take extra steps in order to preserve them across the detach(). Consider the scenario where one has two shallow copies of QMap, each accessed by a different thread, and each thread calls a mutating function on its copy, using a reference into the map (e.g. map.take(map.firstKey())). Let's call the shared payload of this QMap SP, with its refcount of 2; it's important to note that the argument (call it A) passed to the mutating function belongs to SP. Each thread may then find the reference count to be different than 1 and therefore do a detach() from inside the mutating function. Then this could happen: Thread 1: Thread 2: detach() detach() SP refcount != 1 => true SP refcount != 1 => true deep copy from SP deep copy from SP ref() the new copy ref() the new copy SP.deref() => 1 => don't dealloc SP set the new copy as payload SP.deref() => 0 => dealloc SP set the new copy as payload use A to access the new copy use A to access the new copy The order of ref()/deref() SP and the new copy in each thread doesn't really matter here. What really matters is that SP has been destroyed and that means A is a danging reference. Fix this by keeping SP alive in the mutating functions before doing a detach(). This can simply be realized by taking a local copy of the map from within such functions. remove() doesn't suffer from this because its implementation doesn't do a bare detach() but something slightly smarter. Change-Id: Iad974a1ad1bd5ee5d1e9378ae90947bef737b6bb Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> (cherry picked from commit 8c9875893bbd7b1355e36d9501d8cb1f84cb6b4d) Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
| * tests: fix build with -no-feature-concurrentJohannes Kauffmann2022-11-091-1/+1
| | | | | | | | | | | | | | Change-Id: I91602931bfb63e7d6659599a26e00e0bc4f854ab Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> (cherry picked from commit c958e5daf18b069f5f1f40c71e3e45fe68d30d03) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
| * Android: Fix incorrect fullscreen dimensionsSamuel Mira2022-11-072-0/+106
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The insets used to calculate the correct height were not the best choice. It used display cutout insets which would work correctly on most devices, but in the case of an emulator or a device without a camera, it could fail to calculate correctly. Task-number: QTBUG-107604 Task-number: QTBUG-107709 Task-number: QTBUG-107523 Change-Id: I8c4da83ae7359a0c133dbeb02dbd2cd260565f78 Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io> (cherry picked from commit d53ea82950e0662b8265642b840a12d9f9556888) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
| * Revert "Android: fix Android assets handler not listing dirs with only sub dirs"Tarja Sundqvist2022-11-024-26/+0
| | | | | | | | | | | | | | | | | | | | | | This reverts commit a9b036eb84ec2cd4aa22fe93bf1ad7ddcf23c9d7. Reason for revert: QTBUG-107879 Task-number: QTBUG-107627 Fixes: QTBUG-107879 Change-Id: I24f61cb7abc2c4966c772da5b4eca6eb8df454f6 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
| * QString::asprintf: fix handling of a present-but-empty precisionThiago Macieira2022-10-281-0/+37
| | | | | | | | | | | | | | | | | | | | | | %.f should be handled like %.0f. You probably don't want it for strings, though. Fixes: QTBUG-107991 Change-Id: I07ec23f3cb174fb197c3fffd1721a941fbcf15e1 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> (cherry picked from commit bdee2c9760109d8e483c3b0e5c99fabc48bf21f5) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
| * Port qCompress() to zstream/deflate()Marc Mutz2022-10-251-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The zlib convenience API we've been using so far has two problems: - On Windows-64, where sizeof(long) == 4, the use of ulong for sizes meant that we could not compress data compressable on other 64-bit platforms (Unix). While zstream also uses ulong, being a stream API, it allows feeding data in chunks. The total_in and total_out members are only required for gzip compression and are otherwise just informational. They're unsigned, so their overflow does not cause UB. In summary, using zstream + deflate() allows us to compress more than 4GiB of data even on Windows-64. - On all platforms, we always allocated the output buffer in such a way as to accommodate the pathological case of random, incompressible data, so the output buffer was larger than the input. Using zstream + deflate(), we can start with a smaller buffer, then let zlib pick up where it left off when it ran out of output buffer space, saving memory in the common case that compression meaningfully reduces the size. To avoid the first few rounds of reallocations, we continue to use zlib's compressBound() for input less than 256KiB. This completely fixes the compression side of QTBUG-106542 and QTBUG-104972. Fixes: QTBUG-104972 Fixes: QTBUG-106542 Change-Id: Ia7e6c38403906b35462480fd611b482f05a5c59c Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> (cherry picked from commit 2fd990b386c3555cf66cd3efff0d6a47cdc63763) Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
| * Port qUncompress() to zstream/inflate()Marc Mutz2022-10-251-0/+62
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The zlib convenience API we've been using so far has two problems: - On Windows-64, where sizeof(long) == 4, the use of ulong for sizes meant that we could not uncompress data compressed on other 64-bit platforms (Unix). While zstream also uses ulong, being a stream API, it allows feeding data in chunks. The total_in and total_out members are only required for gzip compression and are otherwise just informational. They're unsigned, so their overflow does not cause UB. In summary, using zstream + inflate() allows us to decompress more than 4GiB of data even on Windows-64. - On all platforms, if the size hint in the header was too short, we'd double the output buffer size and try again, from scratch. Using zstream + inflate(), we still need to reallocate, but we can then let zlib pick up where it left off when it ran out of output buffer space. In all but the most pathological cases, copying the already-decoded data instead of re-decoding it again should be faster, esp. if QArrayData uses realloc() instead of malloc() + free() to grow the buffer. We also now directly allocate at least as much output buffer as we have input, to cut the first few rounds of reallocations when the expectedSize was created, as qCompress still does, using modulo arithmetic mod 4GiB instead of saturation arithmethic. Factor the growing of the output buffer into a wrapper function, flate(), which can be reused when porting qCompress(). This completely fixes the uncompression side of QTBUG-106542 and QTBUG-104972. Manual conflict resolutions: - ported from q20::ssize to qsizetype(std::size()) - ported from qxp::function_ref to template arguments Task-number: QTBUG-104972 Task-number: QTBUG-106542 Change-Id: I97f55ea322c24db1ac48b31c16855bc91708e7e2 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> (cherry picked from commit bda3628402d04ed6fc244616791e1170a0cb61d0)
| * Android: fix Android assets handler not listing dirs with only sub dirsAssam Boudjelthia2022-10-214-0/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Amends edd983071e0a90ee8665d2f45916fb575fc25857. Remove redundant calls to AAssetDir_getNextFileName() in AndroidAbstractFileEngine::setFileName(). It's enough to check if AAssetManager_open() returns null and AAssetManager_openDir() is valid for the provided asset file name. As part of this fix, add some unit tests to cover/ensure assets listing/iterating works as expected. Fixes: QTBUG-107627 Change-Id: I37ae9cb64fbbc60699bb748895f77fd6a34fae1f Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> (cherry picked from commit 89f89cedc0e62f4b66de340da57d6c56dc61baf0) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
| * tst_Q{BitArray,ContiguousCache}: check not only count(), but size(), tooMarc Mutz2022-10-182-0/+3
| | | | | | | | | | | | | | | | | | Add at least a few, so size() isn't completely untested. Change-Id: I500d28f7efb30ab578808d8fefb6ea57949edc2e Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit f5205bd6a409d736942a4eed8869245cb9646d35) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
| * QTaggedPointer: disable operator= with an empty initializer listGiuseppe D'Angelo2022-10-111-0/+42
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Given a QTaggedPointer, users may write taggedPtr = {}; to mean "reset it". This is error-prone: due to overload resolution, this actually ends up calling QTaggedPointer<T>::operator=(T *), which changes the pointer but *not* the tag, and not the implicitly declared QTaggedPointer<T>:operator=(const QTaggedPointer<T> &) which would reset both pointer and tag. Given the idiomatic usage of {} is indeed to perform a full reset (cf. std::exchange(obj, {}), std::take, etc.), work around this by disabling the operator= overload for pointers in case an initializer list is passed. In other words, make `={}` fall back to the implicitly declared overload. Note, this breaks some usages, such as taggedPtr = {rawPtr}; but at least we get a compile error for these, and they don't look common at all. [ChangeLog][QtCore][QTaggedPointer] The operator assignment taking a raw pointer has been reimplemented in order to avoid subtle issues when assigning `{}` to a QTaggedPointer. This will cause code that assigns a braced-init-list to a QTaggedPointer object to stop compiling (for instance, `tagPtr = {ptr}` is now ill-formed). Change-Id: I5e572a9b0f119ddb2df17f1797934933dff2ba7b Task-number: QTBUG-106070 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit 42b66bd809f0cadf232cd8527746b55cd00d9f10) Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
| * QFuture: fix handling of cancelled continuation chainSona Kurazyan2022-09-231-0/+71
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | To support cancellation of continuations attached via the parent future, for each future returned by a continuation we store a pointer to its parent (i.e. future the continuation is attached to). Later, before executing a continuation, we go through chain of parents and check if any of them is cancelled. However, if one of the parents is destroyed while the chain is executing, the next continuations' parent pointers will become invalid. So storing the parent pointers isn't safe. This commit changes the logic of handling the cancelled continuation chain in the following way: - Instead of storing a parent pointer in the continuation future's data, we do the opposite: we store a pointer to continuation's future in the parent. - When a future is cancelled, we mark all continuation futures in the chain with a flag indicating that the chain is cancelled. - To guarantee that the pointers to continuation future's data don't become invalid, we clean the continuation (that stores a copy of its future's data and keeps it alive) only when the associated promise is destructed, instead of cleaning it after the continuation is run. Fixes: QTBUG-105182 Fixes: QTBUG-106083 Change-Id: I48afa98152672c0fc737112be4ca3b1b42f6ed30 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> (cherry picked from commit 24dedaeaa1a94bfe9ade2da2a2c9aa112241b07a)
| * QVariant: do allow non-default-constructible typesThiago Macieira2022-09-161-2/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | So long as you only ask us to copy it. Copying is mandatory, though. I'll firm up the warning in a later commit, which may not get cherry- picked as far back. Fixes: QTBUG-105140 Change-Id: I3859764fed084846bcb0fffd170432abf65dc197 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit df0085d3a28005e84eb7688cc2575a121ba322aa) Reviewed-by: Michal Klocek <michal.klocek@qt.io>
| * Remove preprocessor conditionals for chrono includeKonrad Kujawa2022-09-163-44/+3
| | | | | | | | | | | | | | | | | | | | __has_include(<chrono>) is always true, because C++11 chrono include is required since 6.0. Change-Id: I50cb92571bf4f1f86e2f3f2b5f486dd3c3f30f4a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit ec2af0a9df0ac7bf9036f59a94ac3f3ef45c6740) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* | Merge remote-tracking branch 'origin/tqtc/lts-6.2.6' into ↵Tarja Sundqvist2023-03-0114-41/+496
|\ \ | | | | | | | | | | | | | | | tqtc/lts-6.2-opensource Change-Id: I498f628eea18ec7b5fa3f14c12bb953f0d13663c
| * | QVariant: do allow non-default-constructible typesThiago Macieira2022-09-161-2/+29
| |/ | | | | | | | | | | | | | | | | | | | | | | So long as you only ask us to copy it. Copying is mandatory, though. I'll firm up the warning in a later commit, which may not get cherry- picked as far back. Fixes: QTBUG-105140 Change-Id: I3859764fed084846bcb0fffd170432abf65dc197 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit df0085d3a28005e84eb7688cc2575a121ba322aa)