summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib
Commit message (Collapse)AuthorAgeFilesLines
* Fix QMultiHash::count(key) crashAndrei Golubev2021-03-121-0/+15
| | | | | | | | | | | | As QMultiHash uses a pointer for the data, nullptr dereference is a thing, so check for valid d before doing anything in count() Fixes: QTBUG-91704 Change-Id: Ia20440cd7bdc03cb09c77f796fb9c5b52765eac5 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit f226854d256a382a5cc7ff08b10a0d27fbefb0fe) Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QConcatenateTablesProxyModel: skip dataChanged in hidden columnsDavid Faure2021-03-091-0/+11
| | | | | | | | | | | | | | | | | When the source models don't have the same number of columns, the proxy keeps only the smallest number of columns across all source models. Afterwards, if a source model emits dataChanged in a column past that number (a "hidden" column), the proxy needs to ignore it rather than assert. But also, if the source model emits a dataChanged signal across both visible and hidden columns, then the last column number needs to be adjusted so that the signal is correctly processed and forwarded. Task-number: QTBUG-91253 Change-Id: I939e8ec0faf41370472f86785851292e4372f72c Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> (cherry picked from commit f6efbd23b59bcf75866ce47fb762c99f2e4a128a) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QJsonObject: Fix operator<=()Ulf Hermann2021-02-181-0/+31
| | | | | | | | | | | We had a copy-paste error there. Change-Id: Ib1448197ac4f4641c6559f133f41dcf326f210f1 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit a2e23bca0f2b43a26e2e489f83cfe2e521da63b9) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Rework tst_QDateTime::toString_isoDate() to eliminate an XFAILEdward Welbourne2021-02-161-16/+17
| | | | | | | | | | | | | | | | Instead of an XFAIL, actually test what we expect will happen for the test, namely that the milliseconds will be lost. In the process, verify that milliseconds since epoch also matches what was expected, change an "expecting empty" condition to check for the "invalid" test-case to which it's actually relevant and note that this test-case shall need amended when we update our ISODate support to the 2019 update, which extends the year range. Task-number: QTBUG-56552 Change-Id: I680aa31ee0dcc8fadabb5d4cd6c083a8afd48573 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit cc93dadf772480df3b27fd031a471047a5db0038) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Fix tst_QDateTime::systemTimeZoneChange() for 32-bit systemsEdward Welbourne2021-02-151-14/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The test verified that a LocalTime's time since Epoch changes when the system time-zone changes. This works when the QDateTime object is in short form and recomputes its offset from UTC every time it is needed, but fails with a pimpled QDateTime, as this caches its offset from UTC when it is created, saving the recomputation which - in the far more usual case where the system time-zone does not change in the lifetime of a QDateTime object - would normally produce the same result. Changed the test to use a newly-created QDateTime constructed with the same parameters, which doesn't have the cached out-of-date knowledge of its zone offset. Removed the XFAIL. Made the test data-driven and added test-cases: one so close to the Epoch that it should be short even on 32-bit systems, one so far that it's pimpled even on 64-bit systems (used in reproducing the issue in order to debug it). This then revealed that Android 5 doesn't seem to support the POSIX zone IDs used by this test, so it now verifies that LocalTime has the expected offset from UTC after zone changes, QSKIP()ping if not. Documented that the behavior of LocalTime is undefined after a change to the system time-zone. Cleaned up the existing doc of Qt::TimeSpec in the process. Fixes: QTBUG-89889 Change-Id: I1058f47a1ff3ee1c326f3579ac80bd8bab242e28 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit 02ae1b522193b60e7a5c8e5eff7a15d25b0f7aae)
* Restore pre-Qt6 QList::fill() behaviorAndrei Golubev2021-02-111-7/+63
| | | | | | | | | | | | | | | | | | | Somehow QList::fill(t, newSize) introduced a regression in Qt6: when newSize < QList::size() we should resize to the newSize. This is aligned with QVector::fill() in 5.15 and std::vector::assign() While 6.0 is already out, picking it to 6.0.x could save someone who haven't migrated yet as well as fix some accidental bugs in Qt's code [ChangeLog][QtCore][QList] Fixed QList::fill() regression introduced in 6.0: calling fill() with size < current list size wouldn't truncate the list Fixes: QTBUG-91042 Change-Id: Ic166e2c5e42390b61df1030f7c705e344433f7f2 Reviewed-by: Lars Knoll <lars.knoll@qt.io> (cherry picked from commit 6512a7fc642c65455db770385c67cfa6d71c294c) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Correct string comparison in Android's IANA ID matching codeEdward Welbourne2021-02-022-31/+11
| | | | | | | | | | | | | | | | | | | | | | It used QString.compare() and assumed it was returning a bool true on equality, when it actually returns an int that compares to 0 as the given strings compare. So it should use compare() == 0. This fixes several of QTimeZone's blacklisted tests on Android and a crasher, which we dodged with a QSKIP. Added an id-comparison to a test. Gave two local variables more informative names, made an early return into a QSKIP so it explains itself. Fixes: QTBUG-89905 Fixes: QTBUG-69122 Fixes: QTBUG-69132 Fixes: QTBUG-87435 Change-Id: Icf18ed5a810143d6e65d36e34a70e82faac10b8e Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> (cherry picked from commit 6ee13db700eecd8dfed54a9ec2d1081b39511562) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Fix handling of Sunday in POSIX time-zone rulesEdward Welbourne2021-02-011-11/+18
| | | | | | | | | | | | | | | | | | | | | | Dating from the origins of our support for the zoneinfo file format, the mapping of POSIX's day-numbering (0 = Sunday through 6 = Saturday, see [*]) to Qt's (1 = Monday through 7 = Sunday) was done by mapping 0 to 1, when it should have been 7. [*] http://www.gnu.org/software/libc/manual/html_node/TZ-Variable.html Corrected a QTimeZone test that trusted the results it got without checking which day of the week those were: they were all Mondays. Verified that the corrected dates are in fact Sundays. Checked the zone abbreviations, too. Fixes: QTBUG-90553 Change-Id: I84b4b14f9892ff687918cd3c42c7c9807e45313c Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> (cherry picked from commit 38a72af4fd311219779f89b2b78cd56d879f61db) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QJsonObject::take: add missing detach() callThiago Macieira2021-01-271-0/+19
| | | | | | | | | | | We were modifying shared objects. Fixes: QTBUG-89625 Change-Id: Id6bc735b79cf4beb9454fffd165c56476a5dec04 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de> (cherry picked from commit 00b759a8d06dbec42232b1b8748c0725da7ced00) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Extend alignment of QArrayData to std::max_align_t in allocationAndrei Golubev2021-01-261-1/+29
| | | | | | | | | | | | | | | | | | | | | Make stricter alignment requirements for the allocated header This strict alignment allows reallocateUnaligned() to property account for the padding occurring in cases when alignof(QArrayData) < alignof(T) <= alignof(std::max_align_t), which happens to be the case on e.g. 32-bit platforms with specific alignment requirements. This adds 4 bytes (the difference between alignof(std::max_align_t) and sizeof(QArrayData)) of overhead for QString, QByteArray and certain QLists on 32-bit systems. Task-number: QTBUG-90359 Change-Id: I8176a4cc79f100ee772b09425e88fe8ff3ae226a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> (cherry picked from commit 37e26d2b3011acc86bbda1e1f46114d7c8441915) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* tst_socketnotifier: Fix timeout of QTcpServer::waitForNewConnection()Friedemann Kleint2021-01-211-2/+2
| | | | | | | | | The timeout defaults to 0, give it 5s. Change-Id: I975810a1ecee8bb8b3a3f143f1379a9a09589a40 Reviewed-by: Alex Trotsenko <alex1973tr@gmail.com> (cherry picked from commit ad84332f2bbe10601ba4c21fd6d4a446d16ed94c) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Add new special QObjectPrivate::{connect, disconnect} for QMLAndrei Golubev2021-01-211-0/+28
| | | | | | | | | | | | | | | | | Original QML-specific connection mechanism ignores the receiver argument and uses sender as receiver. This causes uncontrollable memory growth in certain cases as connections on receiver persist even after receiver is destroyed New connect() with receiver parameter uses underlying API correctly, disconnect is provided for the symmetry (not sure it's really needed) Task-number: QTBUG-86368 Change-Id: I4580d75b617cb2c4dfb971a4dfb8e943e325572b Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit 6f520abdab7120789800208dde837b3836f762cc) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* tst_socketnotifier/unexpectedDisconnection: Extend blacklisting to all ↵Friedemann Kleint2021-01-191-2/+2
| | | | | | | | | | | windows versions The test has been failing frequently, recently. Change-Id: I3ae00a64f67e4b6a0b5ade0c660805f4d12f8317 Reviewed-by: Oliver Wolff <oliver.wolff@qt.io> (cherry picked from commit 0b4717097ebf9614937a03407e741267a6d39a39) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Android: skip tst_QFile::moveToTrash()Assam Boudjelthia2021-01-192-3/+3
| | | | | | | | | | | Android doesn't have a trash bin, so this test is not valid for that platform. Fixes: QTBUG-89398 Change-Id: I119b25682ba18e18466b5687cae369445dc73311 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit 0392dce4f0a2093987ab45c48f0748c3dd97e7fc) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Fix problems with offset-derived ids for QTimeZoneEdward Welbourne2021-01-192-7/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When creating a time-zone from a UTC+offset name that isn't known to the system, QTimeZone (since the fix to QTBUG-77738 in 5.15.0) falls back to constructing a suitable UTC-offset backend; however, the id of this is not guaranteed to match the id passed in to the constructor. In all other cases, the id of a QTimeZone does match the id passed to its constructor. Some utcOffsetId testcases had different id() than the id passed to the constructor, due to mismatches where a zone was constructed using the fall-back but the generated id included its minutes (as :00) or omitted its seconds. The omission of seconds is clearly a bug, but we also don't want to include :00 for seconds when it's not needed. So change QTimeZonePrivate::isoOffsetFormat() to accept a QTimeZone::NameType to configure how much we include in an id. Its callers other than the relevant constructor (from offset) still get minutes, even when :00, but will also get seconds added if that isn't zero; and the constructor from offset now gets the short form obtained by omitting all trailing zeros. Since all valid whole-hour offset names that do include :00 for the minutes field are in fact known standard offset names, the elision of minutes will only affect zones created by ID in the case of a whole-hour offset given without :00 minutes specifier, so these shall necessarily in fact get the ID passed to the constructor. Creating by UTC-offset with a name that specifies zero seconds will result in a QTimeZone instance whose id() differs from what was passed to its constructor (eliding the :00 seconds and potentially also minutes, if also zero) but this should be the only case where a QTimeZone's id doesn't match the one passed to the constructor, when constructed by id. Fixed inconsistency between the offset-constructor's declaration (taking offset as int) and definition (taking qint32) in the process. Added an id check to the utcOffsetId() testcase. Amended two tests of offset-derived time-zones' IDs, added comments to make clear how one of those differs from a matching standard name test and converted two uses of QCOMPARE(, true) to QVERIFY(). [ChangeLog][QtCore][QTimeZone] QTimeZone instances created by offset from UTC (in seconds) shall now only include minutes in their ID when the offset is not a whole number of hours. They shall also include the seconds in their ID when the offset is not a whole number of minutes. Task-number: QTBUG-87435 Change-Id: I610e0a78e2aca51e12bfe003497434a998e93dc7 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit 50c63446f525a8625b6315597cb0897d89908d6b) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QCache: when overwriting, store the new cost instead of the deltaMårten Nordheim2021-01-141-0/+14
| | | | | | | | | | | | The delta was clearly intended to be used on the total (and still is) but it also wound up getting stored in the cache, which wouldn't be a big problem unless the object was removed, in which case we could incidentally 'free up more space' than intended. Change-Id: Ib2b0f072d30da6d16a93dce60e4c5f6080c109fc Reviewed-by: Lars Knoll <lars.knoll@qt.io> (cherry picked from commit d2e2d0d3a6249ccbc17ec92acb32fec9a0d71807) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Android: exclude tst_QFile::moveToTrash on AndroidAssam Boudjelthia2021-01-121-0/+3
| | | | | | | | | | | | The Android tests were marked insignificant for some days, due to an emulator issue, these tests slipped during that time. Exclude them now to bring Android tests back. Task-number: QTBUG-89398 Change-Id: Ia65a0ae8d7474fd2554dda299a60371dbbc9dddb Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit b036ca33475a45298e383aa0d42f072d21e5a9df) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Change QLineF::setLength() to work whenever length() is non-zeroEdward Welbourne2021-01-061-7/+7
| | | | | | | | | | | | | | | | | Previously it only worked when isNull() was false, which is true for very short lines, even though length() may be non-zero. [ChangeLog][QtCore][QLineF] QLineF::setLength() will now set the length if the line's length() is non-zero. Previously, it was documented to only set the length if isNull() was false; this is a fuzzy check, so isNull() could be true for a line with non-zero length(). Fixes: QTBUG-89569 Change-Id: I803e622ad09c85815dde25df8dd3ba6dfcba0714 Reviewed-by: Lars Knoll <lars.knoll@qt.io> (cherry picked from commit 6974737695eae5a41bc8a3f344a4f1f199006f21) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Fix QMultiHash::equal_range crashesZhang Yu2021-01-061-0/+7
| | | | | | | | | | | | | QMultiHash::equal_range crashes when called in a const member function. The Data `d` is a NULL pointer when calling equal_range() before inserting data into an empty QMultiHash. Then calling`d->find` crashes. Fixes: QTBUG-89687 Change-Id: I10c3d196cbc72aed8c8c922ef16534bba51037b7 Reviewed-by: Lars Knoll <lars.knoll@qt.io> (cherry picked from commit 22416ecaaf58619c716229b71cdca558fda0a861) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Update shared-mime-info to the 2.1 release, adjust implementationDavid Faure2021-01-051-11/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The spec hasn't changed, but I made the same mistake in xdgmime (the reference implementation) and in Qt: when multiple globs match, and the result from magic sniffing is unrelated to any of those globs, then I used the magic result, but that's wrong, globs have priority and one of them should be picked up. This is now fixed in xdgmime (https://gitlab.freedesktop.org/xdg/xdgmime/-/merge_requests/3) and in the expected results in shared-mime-info (https://gitlab.freedesktop.org/xdg/shared-mime-info/-/merge_requests/99) which this commit is also tested against. This change also optimizes QMimeBinaryProvider::addFileNameMatches to have the same logic as xdgmime for glob matching: literals > extensions > other globs As soon as one category matches, we can stop there. This makes no difference in the overall results, in practice. The user bug report (against the Qt implementation, actually) is https://gitlab.freedesktop.org/xdg/shared-mime-info/-/issues/138 as well as https://bugs.kde.org/show_bug.cgi?id=411718 Change-Id: Ia0a34080427daff43c732609443ee6df8f41447c Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit 0cbbba2aa5b472241d45b4be6959a792062fbc30) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Add test creating QDateTime in double-DST gap in 1947 GermanyAndreas Buhr2020-12-241-0/+9
| | | | | | | | | | | | In 1947, Germany had not only a summer time but also a "Hochsommerzeit", a high summer time. This patch adds a test creating a QDateTime in the time gap at the beginning of this Hochsommerzeit on May 11, 1947. Change-Id: Ib81a23914965f092c3e3195e4c7258e5a4e0b30e Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit 741862875c4bd72ba6d28cf53f6f88579602e4bf) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Blacklist tst_QDeadlineTimer::stdchrono on Windows/clangFriedemann Kleint2020-12-211-0/+2
| | | | | | | | | It has been failing consistently, recently. Change-Id: I71b2e8857c3d5ce86ad17864c95aac7265ed9a8a Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit ec7eb1eab157ae84992ca20653f48394bb066340) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Fix crash on reallocateAndGrowMichal Klocek2020-12-211-0/+57
| | | | | | | | | | | | | | | | | | | After 6be398 few tests fail/crash with qtcharts. Fix issue on reallocateAndGraw and avoid accessing flags on invalid header. Data::allocate can return invalid header and dataptr, which takes place if capacity is 0. In code before 6be398 clone method checks if header is not null before resetting flags. However after b76fbb4 resetting flags is no longer needed since it is done in allocateGrow. Task-number: QTBUG-89092 Change-Id: I2fde781dad7a0694a5f17ab716f647c2e35f4ff0 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> (cherry picked from commit b770b7517d30dd17d1096a0bb434677a2b3ff630) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QCache: fix updating entries breaking the internal chainMårten Nordheim2020-12-171-0/+17
| | | | | | | | | | | | | | | After f08492c6fd9818c7d80b1725355453e179b4d85b was merged this bug would manifest as an entry appearing twice in the chain when a updating an existing entry (insert with an existing key). This could sometimes result in crashes later as the list filled up and the list was used in trim() to remove various entries. Fixes: QTBUG-89176 Change-Id: Ide80160fb4317dc0aefe79eec5dce7ec6813e790 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit 0ca46358321f2244386b0b6558a915cda8c6c006) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Restore previous QDateTime behavior in DST gapAndreas Buhr2020-12-171-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | Historic QDateTime behavior when being asked to create a QDateTime in the DST gap was to interpret the given date as if it was in the time before that gap, mapping it to a point in time after the gap. This has changed with a04411119ead3d4473e4f0ac4bceedc585977b2f . Since then, the given date is interpreted as if it was in the time after the gap, thus being mapped to a point in time before the gap. This patch restores the historic behavior. This was not caught by Coin because machines ran in timezone "Atlantic/Reykjavik" which does not have DST since 1967. This patch changes tests to always run in "Europe/Oslo". Driveby: Test function "findSpring" did some operations in local time, even though being asked to work in a specific time zone. Fixed that. Fixes: QTBUG-86960 Fixes: QTBUG-89208 Change-Id: Iecce5898bf9711a10e7dfc0a25e4bbeaed1c8ade Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit 3d785249ba43cf4bd895ed679bac2791e0130dc5) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* CMake: Regenerate projects using pro2cmake one last timeAlexandru Croitor2020-12-108-12/+40
| | | | | | | | | | And fix up some wrong qmake project files Change-Id: I66cb82aeb9c1419a74df1a650fa78a511ade7443 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> (cherry picked from commit 2304acab5ff3bd3832c2e388cfdab27f2a95caa8) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QString::lastIndexOf: fix off-by-one for zero length matchesGiuseppe D'Angelo2020-12-101-1/+1
| | | | | | | | | | | | Otherwise, it would report that lastIndexOf of an empty pattern in an empty string doesn't exist. Next commit adds extensive autotests; for now, disable a broken autotest (which already features a comment about why it's broken). Change-Id: I9a0e5c0142007f81f5cf93e356c8bd82f00066f7 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit be83ff65c424cff1036e7da19d6175826d9f7ed9) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QUrl: fix parsing of empty IPv6 addressesThiago Macieira2020-12-101-0/+2
| | | | | | | | | There's an assertion. Found by Google fuzz scan of CBOR data. Change-Id: I55083c2909f64a1f8868fffd164f1ff3af71605b Reviewed-by: David Faure <david.faure@kdab.com> (cherry picked from commit 4a1091f489ac3fee9efd81b0f1ffca4275725610) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QProperty: Handle eager binding calling setBindingFabian Kosmale2020-12-091-5/+16
| | | | | | | | | | | | | | | | | | When an eager binding triggers a setBinding call, we end up with a special kind of binding loop: setBinding() -> evaluate -> notifyObserver ^ | | / ---------------------------- We now catch set condition, and set the binding status to BindingLoop (with a distinct description). Task-number: QTBUG-87153 Task-number: QTBUG-87733 Change-Id: I9f9915797d82eab820fc279baceaf89d7e5a3f4a Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> (cherry picked from commit ddc585b7c773786045f3658d7da5425ed2f2f786) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QCborValue & QCborStreamReader tests: fix warning about %llx on 32-bitThiago Macieira2020-12-081-6/+6
| | | | | | | | | | | | | | | | | cborlargedatavalidation.cpp:93:60: warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 2 has type ‘qsizetype’ {aka ‘int’} [-Wformat=] 93 | QTest::addRow("bytearray-too-big-for-qbytearray-%llx", v) | ~~~^ ~ | | | | | qsizetype {aka int} | long long unsigned int | %x The cast to size_t is required to make the 64-bit not complain due to the long vs long long difference. Change-Id: I00b01c01a66748508ea1fffd164a9add2a2650cf Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io> (cherry picked from commit 017e41bb8671ed273fffcd2899c3e963d4dd9445)
* tst_QCborValue: adjust the size of the minimum string that won't fitThiago Macieira2020-12-081-1/+3
| | | | | | | | | | I don't know which of the previous commits caused this: as far as I can tell, this test should never have passed. Change-Id: I55083c2909f64a1f8868fffd164e7e8c24eec1f8 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit 3c88728b5367f9705a8ff6f62fa66d9f46880084) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QCborStreamReader::next: don't allocate too much memory in a QBAThiago Macieira2020-12-082-12/+19
| | | | | | | | | | | | | | | | | | | | | Because CBOR strings are encoded in UTF-8, it's possible that the string that won't fit a QString in UTF-16 would still fit QByteArray in UTF-8 (e.g., anything US-ASCII and most Latin text). The previous solution was an improvement because we used to read into a QByteArray then convert the QByteArray to QString, thus using 3x the amount of memory (1x in QByteArray, 2x in QString). The previous commit skipped the middle allocation and made the regular readString() function do the decoding either directly on source memory or by reading in small chunks (16 kB). Future improvement for Qt 6.1: add readStringChunk(char16_t *, qsizetype) so we can do the validation / skipping at O(1) memory. Change-Id: I7b9b97ae9b32412abdc6fffd1645458c655cc566 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io> (cherry picked from commit 58bea7f3a2d0a88a56793c3878a7fcef74b4c646) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QCborValue: avoid allocating result if data is insufficientThiago Macieira2020-12-082-10/+11
| | | | | | | | | | | | Similar to the previous commit which applied to QCborStreamReader, don't allocate too much data before checking that the stream actually has that much. Fixes: QTBUG-88256 Change-Id: I7b9b97ae9b32412abdc6fffd16454b7568a063ba Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io> (cherry picked from commit 638171eb10cfb186a6c47ec052a3b0c5b6449386) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QCborStreamReader: avoid allocating result if data is insufficientThiago Macieira2020-12-083-8/+13
| | | | | | | | | | | | | | | | | | | | | | | | By calling the internal readStringChunk() function with a QByteArray pointer, QCborStreamReader::readByteArray() can now avoid allocating the resulting buffer until the internals have confirmed that there is sufficient data in the incoming buffer. As a result, we first detect the EOF condition before we conclude the payload would have been too big for QByteArray (validation()) test. Meanwhile, the hugeDeviceValidation() test ends up with a few conditions where it would have copied 1 GB of data, so limit that too. We make a choice of reporting OOM vs DataTooLarge only if QByteArray fails to allocate in the first place (QByteArray::resize() -> Q_CHECK_PTR -> qBadAlloc, QtCore is always built with exceptions on). The QCborValue unit test needed a temporary work around until we apply the same allocation fix (see next commit). Fixes: QTBUG-88253 Change-Id: I7b9b97ae9b32412abdc6fffd164523eeae49cdfe Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io> (cherry picked from commit 9a55f40937d037d06e00b09465d8dad0554692fc) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Make the signal argument in Q_OBJECT_BINDABLE_PROPERTY optionalLars Knoll2020-12-071-6/+2
| | | | | | | | | | | | The intention was always that you can define properties that do not require a changed signal. But having to explicitly pass a nullptr as signal parameter into the macro is ugly, so use the cool QT_OVERLOADED_MACRO to make it optional. Change-Id: I0ce366d043850f983c968d73c544d89933c48df9 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit cb39ea05810bc207100018589da658a0cce98edb) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QBindable: Disallow mutation if read-onlyFabian Kosmale2020-12-041-0/+5
| | | | | | | | | | | | | If a QBindable is created from a computed property, it is not possible to actually set a value or a binding. If we try to do it anyway, we'd get a crash. Thus we now check whether the function pointer is null before invoking it. Task-number: QTBUG-87153 Change-Id: I5bedb9080ccf79d9b8166b80d5733d095ed76f8d Reviewed-by: Lars Knoll <lars.knoll@qt.io> (cherry picked from commit e236faa75f446aa3378fb013cce6598c9e076ccb) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* tst_qstorageinfo: Test the copy ctorMårten Nordheim2020-12-041-0/+7
| | | | | | | | | | It was previously untested Task-number: QTBUG-88183 Change-Id: Icc59fc632957a75cac8c7f5e2a1aed88a1c9ff9d Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> (cherry picked from commit a7610a0cf79c576b098999822c5070a078e51326) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Replace discouraged Q_MOVABLE_TYPE by Q_RELOCATABLE_TYPEAndreas Buhr2020-12-0410-12/+12
| | | | | | | | | | | | | | | Q_MOVABLE_TYPE was conceived before C++ had move semantics. Now, with move semantics, its name is misleading. Q_RELOCATABLE_TYPE was introduced as a synonym to Q_MOVABLE_TYPE. Usage of Q_MOVABLE_TYPE is discouraged now. This patch replaces all usages of Q_MOVABLE_TYPE by Q_RELOCATABLE_TYPE in QtBase. As the two are synonymous, this patch should have no impact on users. Change-Id: Ie653984363198c1aeb1f70f8e0fa189aae38eb5c Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> (cherry picked from commit 0440614af0bb08e373d8e3e40f90b6412c043d14) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Add test for QTranslator::load() translation file lookup algorithmKarsten Heimrich2020-12-031-0/+69
| | | | | | | Change-Id: I70f4b3d7dbc46d21065eab21a5af8a38d4a60589 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> (cherry picked from commit a0e04e7d2bfc47891a85378a57ceb5dca1d4c558) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QProperty: Avoid spurious dependencies by suspending binding stateFabian Kosmale2020-12-021-1/+0
| | | | | | | | | | | Avoid spurious bindings by resetting the binding state before calling the setter of eager properties. Fixes: QTBUG-88999 Change-Id: I1e3b5662307d906598335a21d306be9c606529d4 Reviewed-by: Lars Knoll <lars.knoll@qt.io> (cherry picked from commit b21dba98e3e557eece0497aeea0f0beb70cc62da) Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QDuplicateTracker: add testsMårten Nordheim2020-12-016-0/+211
| | | | | | | | | | | It didn't initially have tests. To avoid relying on realizing breakage implicitly through other classes we'll just add tests instead. Task-number: QTBUG-88183 Change-Id: I7449dc1f9a118d4b7a8158a2c34563dbd9c43c66 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> (cherry picked from commit 1911a4d40ab63d5e314d13d083d505cd3c64f683) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QProperty: add test case for spurious dependency issueFabian Kosmale2020-12-011-0/+52
| | | | | | | | Task-number: QTBUG-88999 Change-Id: Ifcbf23fedfb795771550762dfed8fc38bce65794 Reviewed-by: Lars Knoll <lars.knoll@qt.io> (cherry picked from commit cea8b5832c56e92aba2b028afc965ddcf384d37b) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Android: exclude faulty qfilesystemwatcher testAssam Boudjelthia2020-11-263-2/+7
| | | | | | | | Task-number: QTBUG-88508 Change-Id: I11b845e74e599d3bdae4f9490a591893531bc77b Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> (cherry picked from commit c7dec2faca476c94a40bd4ac5118915b1a5d9aa8) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Fix QVariant/QMetaType::compare APIsGiuseppe D'Angelo2020-11-256-3/+160
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | std::optional<int> is the wrong datatype to use for compare. First and foremost, it can't be used in the idiomatic form of auto r = a.compare(b); if (r < 0) ~~~ // a is less than b if (r > 0) ~~~ // a is greater than b which we *already* feature in Qt (QString, QByteArray). Also, std::optional<int> (explicitly) converts to bool, which is a trap, because the result of the comparison can be accidentally tested as a bool: if (a.compare(b)) ~~~ // oops! does NOT mean a<b Not to mention extending this to algorithms: auto lessThan = [](QVariant a, QVariant b) { return a.compare(b); }; // oops! std::ranges::sort(vectorOfVariants, lessThan); which thankfully doesn't compile as is -- std::optional has an *explicit* operator bool, and the Compare concept requires an implicit conversion. However, the error the user is going to face will be "cannot convert to bool because the operator is explicit", which is deceiving because the fix is NOT supposed to be: auto lessThan = [](QVariant a, QVariant b) { return (bool)a.compare(b); }; // big oops! Instead: backport to Qt the required subset of C++20's <compare> API, and use that. This commits just adds the necessary parts for compare() (i.e. partial ordering), the rest of <compare> (classes, functions, conversions) can be added to 6.1. Change-Id: I2b5522da47854da39f79993e1207fad033786f00 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit 3e59c97c3453926fc66479d9ceca03901df55f90) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QVLA: do not include QtTestGiuseppe D'Angelo2020-11-251-1/+1
| | | | | | | | | The right include is QTest, QtTest drags in all of QtCore. Change-Id: Icc2964ccdb85fe1bfc9fe8f43351a4605a34329b Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit bfe77a21fb0988a52fb77af09fe9675eb151e8b6) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Fix tst_qlibrary after rebuildAndreas Buhr2020-11-242-2/+30
| | | | | | | | | | | | | | | | | tst_qlibrary depends on a library (targets mylib and mylib2) to be built. They create a library with the same name, in two versions. This is done in order to test versioned library loading. However, those two libraries were fighting over the creation of "libmylib.so". In a fresh build, mylib2 wins, as intended. But after a rebuild, mylib won, which led to failing unit tests. This patch changes the situation. With this change, mylib no longer tries to create "libmylib.so". Thus no fighting and no problem. Change-Id: Id89baa5503c9f078a8737ff0b8616edf09044f72 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> (cherry picked from commit 1dff26dd9539feb40767b7761c5339085ad74dbf) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Fix tst_qlibrary by telling CMake about required librariesAndreas Buhr2020-11-241-0/+1
| | | | | | | | | | | | | | tst_qlibraries needs to test libraries to be built in order to run successfully. However, these libraries were not mentioned as dependencies in CMake. This patch fixes that. Fixes: QTBUG-88445 Change-Id: Ic335e46664edd98217bd55a9bca5a58a39cffe66 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> (cherry picked from commit f9d172f5a191a4e0e13923a6a1d31e86107bc75e) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QMetaType: Track whether type is QML list typeFabian Kosmale2020-11-231-19/+23
| | | | | | | | | | This information is required in the QML engine to handle list properties (instances of QQmlListproperty<T> and list<T> types from QML). Change-Id: I1e30572f1c91f58b290cb9b4b07433af99a1db6f Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> (cherry picked from commit 5806ecf5cb24cf39ea2608d42246eafbaa817582) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Add unit test for QAnyStringView::compareAndreas Buhr2020-11-211-1/+8
| | | | | | | | | | | | Coverage tests revealed that QAnyStringView::compare(QAnyStringView, QAnyStringView, CaseSensitivity) was not tested in our unit tests. This patch adds a test for this. Change-Id: Id8e0d8af87e7e7ab192fb7554a278ddbb890fb14 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit ae2c30942086bd0387c6d5297c0cb85b505f29a0) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Android: exclude qarraydata::dataPointerAllocate() from CI testsAssam Boudjelthia2020-11-201-0/+3
| | | | | | | | | Task-number: QTBUG-88705 Task-number: QTBUG-87025 Change-Id: If2dc0e650e5104d00a097e6195dd117d6cfd64e6 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> (cherry picked from commit 4713298b98503cc7c4699a6e33e3167622da91d0) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>