summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib
Commit message (Collapse)AuthorAgeFilesLines
* Make POSIX transition rule parser more robustEdward Welbourne2021-04-161-0/+16
| | | | | | | | | | | | | | | | | | | | | | | | | The POSIX rule parser used by QTzTimeZonePrivate recklessly assumed that, if splitting the rule on a dot produced more than one part, it necessarily produced at least three. That's true for well-formed POSIX rules, but we should catch the case of malformed rules. Likewise, when calculating the dates of transitions, splitting the date rule on dots might produce too few fragments; and the fragments might not parse as valid numbers, or might be out of range for their respective fields in a date. Check all these cases, too. Added a test that crashed previously. Changed QTimeZone::offsetFromUtc() so that its "return zero on invalid" applies also to the case where the backend returns invalid, in support of this. Fixes: QTBUG-92808 Change-Id: Ica383a7a987465483341bdef8dcfd42edb6b43d6 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Robert Löhning <robert.loehning@qt.io> (cherry picked from commit 964f91fd25a59654905c5a68d3cbccedab9ebb5a) Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Fix removing columns when QSortFilterProxyModel has not been sorted yetJoni Poikelin2021-04-111-0/+14
| | | | | | | | Fixes: QTBUG-91788 Change-Id: Iddcafd3171f0f3703b94893a32b4ccaaeea9e713 Reviewed-by: David Faure <david.faure@kdab.com> (cherry picked from commit e287582cba74ddcfc67f83647e72c0b23bd99c36) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QEventDispatcher(Win): Always honor interrupted status to avoid racesMårten Nordheim2021-03-121-0/+27
| | | | | | | | | | | | | | | | | | | | | | | | | There may be a race where e.g. thread 'B' is woken up by a queued invoke. At the same time thread 'A' asks 'B' to quit, which will set various atomics (some important ones are 'interrupt' in the dispatcher and 'exit' in the event loop), but it does _not_ try to send another wake since there is already an unhandled wake triggered by 'B' itself. Sadly 'B' reads the 'exit' atomic before 'A' updates it. Then, slightly before, 'B' sets 'interrupt' back to 0, 'A' write 1 to it, meaning 'A's interrupt is ignored. Then, since there is no interrupt, 'B' goes back to waiting for events, leaving the thread alive and running instead of quitting. Maybe this has unforeseen consequences (one consequence is that it will return and re-enter the event dispatcher once more, possible unnecessarily) Fixes: QTBUG-91539 Change-Id: Ie6f861f42ffddf4817d5c8af2d764abe9d9103c2 Reviewed-by: Alex Trotsenko <alex1973tr@gmail.com> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit f274f91cebb0a4fd2ebe37bb3a605c47d6acd404) Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* 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>
* Fix parsing of dates with spaces in day or month namesEdward Welbourne2021-02-191-11/+12
| | | | | | | | | | | | | | | | | | | | Some locales have spaces in their names for months and days. This breaks parsing dates by splitting on spaces, as we were doing for TextDate. Reworked the TextDate parsers to take account of this possibility. Reworked and improved tst_QDate::roundtripGermanLocale(). It didn't configure the locale, so it was actually testing whatever locale you happen to run it with, not specifically German. It's a TextDate test, in any case, so should be #if-ed suitably. It merely did the round-trip, with a comment noting that it should produce no warnings. Changed it to do comparisons. This, with LANG=vi_VT, made it a reproducer for the issue. Fixes: QTBUG-88543 Change-Id: Ie0fb8c6d58f98efcdda2e046523172e66f3491b2 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* Rework tst_QDateTime::toString_isoDate() to eliminate an XFAILEdward Welbourne2021-02-191-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: Mårten Nordheim <marten.nordheim@qt.io>
* Fix tst_QDateTime::systemTimeZoneChange() for 32-bit systemsEdward Welbourne2021-02-191-15/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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)
* QJsonObject::take: add missing detach() callThiago Macieira2021-02-031-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>
* Fix problems with offset-derived ids for QTimeZoneEdward Welbourne2021-02-032-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: Edward Welbourne <edward.welbourne@qt.io>
* Correct string comparison in Android's IANA ID matching codeEdward Welbourne2021-02-032-20/+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>
* Change QLineF::setLength() to work whenever length() is non-zeroEdward Welbourne2021-02-031-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 handling of Sunday in POSIX time-zone rulesEdward Welbourne2021-02-021-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>
* Test QDateTime behavior in DST gapAndreas Buhr2021-02-021-1/+6
| | | | | | | | | | | | | | | | | | | | | | | 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 (after Qt 5.15) 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 was not caught (in dev) 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". A support function and each test-case thus need to use zone-time instead of local time. Fixes: QTBUG-86960 Fixes: QTBUG-89208 Change-Id: Iecce5898bf9711a10e7dfc0a25e4bbeaed1c8ade Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit 3d785249ba43cf4bd895ed679bac2791e0130dc5) Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Add new special QObjectPrivate::{connect, disconnect} for QMLAndrei Golubev2021-01-261-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)
* 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)
* QString: fix count(QRegularExpression)Giuseppe D'Angelo2020-12-101-0/+1
| | | | | | | | | | | | | | | | | There is an off by one in the implementation of count(): a match must be attempted even at the very end of the string, because a 0-length match can happen there. While at it, improve the documentation on the counter-intuitive behavior of count(), which doesn't merely count how many times a regexp matches into a string using ordinary global matching. [ChangeLog][QtCore][QString] Fixed a corner case when using QString::count(QRegularExpression), causing an empty in the last position not to be accounted for in the returned result. Change-Id: I064497839a96979abfbac2d0a96546ce160bbc46 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit 7c3208c97d2ad2c046908e144325c4ddb1e54876)
* 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>
* 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>
* QStandardPaths: Don't change permissions of XDG_RUNTIME_DIRAlexander Volkov2020-11-301-1/+7
| | | | | | | | | | | | | | | | | | | Conform to the XDG Base Directory Specification: "If, when attempting to write a file, the destination directory is non-existent an attempt should be made to create it with permission 0700. If the destination directory exists already the permissions should not be changed." At the same time the spec states about XDG_RUNTIME_DIR that "its Unix access mode MUST be 0700", so don't consider the directory with wrong permissions correct and use a fallback. Task-number: QTBUG-68338 Change-Id: I03c6b35b3f7d5ceb8e6326695bfc8207da92ea67 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: David Faure <david.faure@kdab.com> (cherry picked from commit 68de00e0d4f2c574162a6e033d41786e3757d25d) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QCalendar: increase coverage by testsEdward Welbourne2020-11-301-7/+101
| | | | | | | | | | | | | Added tests for aliases and various calendar properties, ensured dateToJulianDay()'s invalid date branch is exercised. Corrected assertion when constructing from system and asserted calendarSystem() is as expected. Task-number: QTBUG-88183 Change-Id: I510afcb5d9d115f68148d1f679f3224d712f92f4 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> (cherry picked from commit 4785e39156312c995c39e68c8f80f2efba71c49f) Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Fix invalid QSortFilterProxyModel::dataChanged parametersWang ChunLin2020-11-302-0/+168
| | | | | | | | | | QSortFilterModel shouldn't forward dataChanged() when the source model changes data in columns that the filter model refuses Fixes: QTBUG-86850 Change-Id: I26565d119d2aa36ea07b3de0c15f1b137bc002f8 Reviewed-by: David Faure <david.faure@kdab.com> (cherry picked from commit 66acca3316e3c333e4cc3abfc343e58e3516c8b4) 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 QSFPM not emitting dataChanged when source model is setWang ChunLin2020-11-212-0/+30
| | | | | | | | | | | | | | | QSortFilterProxyModel did not emit dataChanged when calling setSourceModel() after modifying the source model. QSortFilterProxyModel::setSourceModel and QSortFilterProxyModelPrivate::_q_sourceReset(), _q_clearMapping is called to delete the source_index_mapping. They also need to call create_mapping function to re-create it. Fixes: QTBUG-87781 Change-Id: Idbe34696c9d3a2fbf354b653c870bac61378811d Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit 8455bfee76ed3f1bd3bba8bd3688a7afa94ae0bb) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Be more consistent when converting JSON values from variantSona Kurazyan2020-11-201-0/+12
| | | | | | | | | | | | | | | | | | | When converting from numeric QVariant types to QJsonValue, we always convert to double. However, when converting from QVariantMap or QVariantList, we convert to qint64, which may result to negative number in the corner cases. Fixed to always cast to double, which matches with the pre-5.15.0 behavior. Note, that in Qt 6 QJsonValue got native support for integers, and we consistently fallback to double only if the value is outside the range of qint64, so this fix applies only to 5.15. [ChangeLog][Important Behavior Changes] Restored pre-5.15.0 behavior when converting from numeric QVariant values to QJson* types. Such values now always convert to a double QJsonValue. Fixes: QTBUG-88168 Change-Id: I584a35aa6ffade22a1c83fcda5598ed912f53919 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Fix logic error in QString::replace(ch, after, cs)Andreas Buhr2020-11-201-0/+11
| | | | | | | | | | | Coverage analysis showed that an if-branch marked "Q_LIKELY" was never taken. It turns out the code was incorrect, but behaved correctly. This patch fixes the logic and adds a unit test. Change-Id: I9b4ba76392b52f07b8e21188496e23f98dba95a9 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit ebaae45ea17efc230209ed90d94596647cf6cb48) Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* Update CLDR to v38Edward Welbourne2020-11-091-1/+1
| | | | | | | | | | | | | | Fresh on the heels of our update to v37, they've released a new version. No new languages to complicate life, fortunately. Updated license (year range) and attribution. One test also needed an update: Catalan's long time format now parenthesizes the zone. Task-number: QTBUG-87925 Change-Id: I54fb9b7f084b5cd019c983c1e3862dc03865a272 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> (cherry picked from commit 246ba8ca61a19b586de1750d66422f517149622e) Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Deprecate old aliases for two countries and several languagesEdward Welbourne2020-10-282-9/+9
| | | | | | | | | | | [ChangeLog][QtCore][QLocale] Deprecated several Language and Country aliases, ready for removal in Qt 6.0, in favor of their newer names. Task-number: QTBUG-84669 Change-Id: Iebaa0a5a77bfa12f7014de53fab4a25b5f1cc92c Reviewed-by: Lars Knoll <lars.knoll@qt.io> (cherry picked from commit 2c4874be40aa40b698315cac0ad768e5c650a740) Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Deprecate QLocale::Language entries that no locale data relates toEdward Welbourne2020-10-281-10/+12
| | | | | | | | | | | | | | | | | | These are languages for which CLDR does not even recognize the claimed language code (three-letter codes except for bh = Bihari, which might be an old name for bho = Bhojpuri, which CLDR does give, but provides no locale data using it). [ChangeLog][QtCore][QLocale::Language] Many obsolete language names are now deprecated in preparation for removal at Qt 6.0. No data has been available for any locale using these languages since CLDR v29 (at least; Qt now uses v37). Task-number: QTBUG-84669 Change-Id: I2bf2d49211ade7cc511277f35fb1a247e7048b31 Reviewed-by: Lars Knoll <lars.knoll@qt.io> (cherry picked from commit 2575a8ced39b607ed320ed230c83119eaad4b33b) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Deprecate ordering on QItemSelectionRangeEdward Welbourne2020-10-281-0/+4
| | | | | | | | | | | | | | | | Ready for removal at Qt 6, as advocated in a ### comment. It was never done consistently with operator==(), apparently, and should not be needed in any case. [ChangeLog][QtCore][QItemSelectionRange] Ordering of QItemSelectionRange is now deprecated. It was not consistent with equality and should not be needed. Task-number: QTBUG-85700 Change-Id: Ie99294bd7fc18f2a497598ae08840886b0a6d62d Reviewed-by: Lars Knoll <lars.knoll@qt.io> (cherry picked from commit 29c113d912fdf96f99503c9635bf89c4cabcc6fb) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Add QStringView::split()Lars Knoll2020-10-151-0/+5
| | | | | | | | | | The implementation has to live in qstringlist.h and qregularexpression.h, as those classes are only forward declared in qstring.h. Task-number: QTBUG-86516 Change-Id: Ia9b3ff48999d1c2e7df905191ee192764b309d08 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Deal with {und,ov}erflow issues in QLine's length handlingEdward Welbourne2020-10-091-12/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Use std::hypot() instead of sqrt() of a sum of squares. This ensures length() can't be zero when isNull() is false. Use length() in QLine::setLength() rather than duplicating that. Clarify and expand some documentation; isNull() never said what constituted validity, nor did unitVector() mention that is should not be used on a line for which isNull() is true. Make clear that lines of denormal length cannot be rescaled accurately. Given that we use fuzzy comparison to determine equality of end-points, isNull() can be false for a line with displacements less than sqrt(numeric_limits<qreal>::denorm_min()) between the coordinates of its end-points (as long as these are not much bigger); squaring these would give zero, hence a zero length, where using hypot() avoids the underflow and gives a non-zero length. Having a zero length for a line with isNull() false would lead to problems in setLength(), which uses an isNull() pre-test, protecting a call to unitVector(). (It was already possible for a null line to have non-zero length; this now arises in more cases.) Tweaked QLine::setLength() to allow for the possibility that the unit vector it computes as transient may not have length exactly one. Add tests against {ov,und}erflow and divide-by-zero problems in QLine. This fixes two oss-fuzz issues: oss-fuzz-24561 and oss-fuzz-25178. Change-Id: I7b71d66b872ccc08a64e941acd36b45b0ea15fab Reviewed-by: Sze Howe Koh <szehowe.koh@gmail.com> (cherry picked from commit 1c591fd9246ca776304a3c370dd2578bd886feac) Reviewed-by: Robert Loehning <robert.loehning@qt.io>
* QUrl::fromLocalFile: accept invalid hostnamesThiago Macieira2020-10-081-0/+15
| | | | | | | | | | | | | | | | | | | | QUrl hostnames must be compliant with STD3, but we must somehow accept file paths that begin with double slash but aren't valid hostnames. Because the file URI spec requires us to start with "file://" anyway, we can represent those with four slashes. Note that on Unix "//X/y" is a valid but local file path. If given to QUrl::fromLocalFile(), if the path at the root does parse as a hostname, we will still try to normalize (the above becomes "file://x/y"). [ChangeLog][QtCore][QUrl] Changed QUrl::fromLocalFile() to accept Windows UNC paths whose hostname component is not a valid Internet hostname. This makes QUrl able to accept extended-length paths (\\?\), device namespace (\\.\), WSL (\\wsl$), etc. Fixes: QTBUG-86277 Change-Id: I3eb349b832c14610895efffd1635759348214a3b Reviewed-by: David Faure <david.faure@kdab.com> (cherry picked from commit 97de53ee8cce3dc6347b08668f0de45e1000f01c)
* tst_QUrl/Win: test QUrl::fromLocalFile with backslashesThiago Macieira2020-10-081-6/+17
| | | | | | Change-Id: I3eb349b832c14610895efffd1635752ccc82889a Reviewed-by: David Faure <david.faure@kdab.com> (cherry picked from commit dfa35ee6c8c919ccf1ae378074cf1b5501c24d9e)
* tst_QUrl: give the to/fromLocalFile test rows proper namesThiago Macieira2020-10-081-52/+60
| | | | | | | | No change in testing, juts changed names and order. Change-Id: I3eb349b832c14610895efffd16357498454bcd52 Reviewed-by: David Faure <david.faure@kdab.com> (cherry picked from commit 4e0028895793f656488431179a4ee9c4f61f05fa)
* Fix race condition in QThreadPool::clearAllan Sandfeld Jensen2020-10-011-0/+26
| | | | | | | | | | | | Since we drop the lock while deleting threads, we need to handle the queue possibly being accessed and changed by the pool threads while clear() is running. Fixes: QTBUG-87092 Change-Id: I7611edab90520454278502a58621e299f9cd1f6e Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io> (cherry picked from commit fe36d47b371b71ad5fec30d4b5d7bf0baa0205ea) Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Properly deprecate QProcess::pidVolker Hilsheimer2020-10-012-2/+2
| | | | | | | | | | | | Address an old ### Qt 5 comment. The method has been documented as deprecated and replaced by QProcess::processId since at least Qt 5.9, so we can first properly flag it as such for 5.15.2, and remove it from Qt 6 in a follow-up commit. Change-Id: Ic4e3351740617083b16723db8eef7a341bccfbf6 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit 3fb8f9e44e8cbf5937257505d0bc2d1457a26da1) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QJsonObject: fix sorting after parsing from JSON textThiago Macieira2020-09-301-8/+43
| | | | | | | | | | | | The logic was complex and missed the UTF-8 UTF-8 case. It ended up calling the UTF-8 to Latin1, resulting in an improperly-sorted container, which in turn meant keys were not found when searched. Fixes: QTBUG-86873 Change-Id: I0d3ff441bec041728945fffd16379dec418637ca Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> (cherry picked from commit f00d322f6701580f97f38794b83b0ec13973d177) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QMimeDatabase: fix handling of glob-deleteallDavid Faure2020-09-231-2/+7
| | | | | | | | | | | | | | | | | Binary provider: It was not possible to remove the first glob in a local override, because the mainPattern handling would re-add the first glob back. XML provider: It didn't support glob-deleteall. Also, the order of the providers was wrong. We want to pick local overrides first, the internal DB has to go last in the list. Fixes: QTBUG-85436 Change-Id: I9a4523f37cd962c730df9a6ed992bd01c075bf03 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit fc8f5afc874073f91d3770273e0a9164182d7897) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QStandardPaths/Unix: improve the XDG_RUNTIME_DIR creation/detectionThiago Macieira2020-08-272-59/+203
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | First, use QT_MKDIR instead of QFileSystemEngine::createDirectory(), as the latter can't create a directory with the right permissions. That would allow an attacker to briefly obtain access to the runtime dir between the mkdir() and chmod() system calls. Second, make sure that if the target already exists that it is a directory and not a symlink (even to a directory). If it is a symlink that belongs to another user, it can be changed to point to another place, which we won't like. And as a bonus, we're printing more information to the user in case something went wrong. Sample outputs: QStandardPaths: runtime directory '/root' is not owned by UID 1000, but a directory permissions 0700 owned by UID 0 GID 0 QStandardPaths: runtime directory '/dev/null' is not a directory, but a character device, socket or FIFO permissions 0666 owned by UID 0 GID 0 QStandardPaths: runtime directory '/etc/passwd' is not a directory, but a regular file permissions 0644 owned by UID 0 GID 0 QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-tjmaciei' QStandardPaths: runtime directory '/tmp/runtime-tjmaciei' is not a directory, but a symbolic link to a directory permissions 0755 owned by UID 1000 GID 100 Change-Id: Iea47e0f8fc8b40378df7fffd16248b663794c613 Reviewed-by: David Faure <david.faure@kdab.com> (cherry picked from commit ad5a65b6a2bfca1658634e380559d14ea1e904a4) Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Synchronize QEventDispatcherWin32::processEvents() with QCoreApplicationAlex Trotsenko2020-08-261-0/+26
| | | | | | | | | | | | | | | | QCoreApplication has a special internal mechanism to control whether the event dispatcher should block after delivering the posted events. To handle queued connections in nested loops properly, we should use that functionality. Fixes: QTBUG-85981 Change-Id: I124179a23b26a995cf95ed379e97bfa62c95f42a Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit fe4b246446f721085946e399b96a42eccfcecca8) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Un-deprecate QByteArray's relational operators taking QStringSona Kurazyan2020-08-261-2/+0
| | | | | | | | | | | | QString still has the overloads of relational operators taking QByteArray. Un-deprecate QByteArray's relational operators taking QString for symmetry. See also the comments of d7ccd8cb4565c8643b158891c9de3187c1586dc9 for more details. Change-Id: If3f59376b389fe4cbc2bd649a748bb78378a530c Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit d8ee1f6385b4dfeb57cb466b6c5f6bcfd3a90dfb) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QRegularExpression: do not assume QStringViews are NUL terminatedGiuseppe D'Angelo2020-08-261-0/+31
| | | | | | | | | | | | The convenience API used to look up the index of a named capturing group expects NUL terminated strings. Therefore, we can't just use it together with QStringViews, which may be not. Use the non-convenience API instead. Change-Id: I25ca14de49b13ee1764525f8b19f2550c30c1afa Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit 049d8892eaa18d71d6edb10752418ad33305f310) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Fix CaseSensitivity handling for QRegularExpression in QSortFilterProxyModelMarcel Krems2020-08-241-0/+21
| | | | | | | | | | | | setFilterRegExp retains the caseSensitivity() while setFilterRegularExpression did not. Change setFilterRegularExpression to also retain the case sensitivity. Also fix the inverted logic in setFilterCaseSensitivity. Fixes: QTBUG-83313 Change-Id: I46f494d320aee99d50612f01f63558c693276989 Reviewed-by: Samuel Gaist <samuel.gaist@idiap.ch> Reviewed-by: David Faure <david.faure@kdab.com> (cherry picked from commit 9a921d78e87452962043721669f3027f7566eef4)
* Properly deprecate Qt::MidButton in favor of Qt::MiddleButtonEdward Welbourne2020-08-221-3/+3
| | | | | | | | | | | | | MidButton had its // ### Qt 5: remove me upgraded to Qt 6 at 5.0; but it dates back to 4.7.0 Replace the many remaining uses of MidButton with MiddleButton in the process. Change-Id: Idc1b1b1816673dfdb344d703d101febc823a76ff Reviewed-by: Lars Knoll <lars.knoll@qt.io> (cherry picked from commit 16e546e32fec393bc3b126f280114bcbfa7151ff) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Fix conversions to JSON from QVariantSona Kurazyan2020-08-141-0/+149
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | After reimplementing Qt JSON support on top of CBOR, there were unintended behavior changes when converting QVariant{, List, Map} to QJson{Value, Array, List} due to reusing the code for converting QVariant* types to CBOR types, and from CBOR types to corresponding JSON types. In particular, conversions from QVariant containing QByteArray to JSON has been affected: according to RFC 7049, when converting from CBOR to JSON, raw byte array data must be encoded in base64url when converting to a JSON string. As a result QVariant* types containing QByteArray data ended up base64url-encoded when converted to JSON, instead of converting using QString::fromUtf8() as before. There were also differences when converting QRegularExpression. Reverted the behavior changes by adding a flag to internal methods for converting CBOR to JSON, to distinguish whether the conversion is done from QVariant* or CBOR types. These methods now will fall back to the old behavior, if the conversion is done using QJson*::fromVariant*(). Additionally fixed QJsonValue::fromVariant conversion for NaN and infinities: they should always convert to QJsonValue::Null. This works correctly when converting from variant to QJsonArray/QJsonObject, but has been wrong for QJsonValue. Added more tests to verify the expected behavior. [ChangeLog][Important Behavior Changes] Restored pre-5.15.0 behavior when converting from QVariant* to QJson* types. Unforeseen consequences of changes in 5.15.0 caused QByteArray data to be base64url-encoded; the handling of QRegularExpression was also unintentionally changed. These conversions are now reverted to the prior behavior. Additionally fixed QJsonValue::fromVariant conversions for NaN and infinities: they should always convert to QJsonValue::Null. Fixes: QTBUG-84739 Change-Id: Iaee667d00e5363906eedbb67948b7b39c9d0bc78 (cherry picked from commit 1df02b5f980b01a4e42f32061f1cba696b6a22e9) Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QJsonDocument: fix comparison of valid vs defaultThiago Macieira2020-08-121-0/+61
| | | | | | | | | | | | [ChangeLog][QtCore][QJsonDocument] Fixed a bug that caused QJsonDocument's equality operator to crash if one of the operands was default-constructed and the other wasn't. Fixes: QTBUG-85969 Change-Id: I5e00996d7f4b4a10bc98fffd1629f835f570ef6b Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io> (cherry picked from commit e790af0e0a030dea597bbc9489170b5ba1cf9e46) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QSharedPointer: do allow calling deleters on null pointersThiago Macieira2020-07-311-2/+31
| | | | | | | | | | | | | | I don't know why std::shared_ptr allows this, but why not. [ChangeLog][Important Behavior Changes] QSharedPointer objects will now call custom deleters even when the pointer being tracked was null. This behavior is the same as std::shared_ptr. Fixes: QTBUG-85285 Change-Id: I24006db8360041f598c5fffd161c260df0313b55 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> (cherry picked from commit 95afe6b244dbd9623a92399d1bed0b9f52aa1e65) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Make qfloat16 helper functions consistent with float/double versionsAllan Sandfeld Jensen2020-07-281-1/+1
| | | | | | | | | | | Infinite is only when the mantissa is 0, everything else is NaN. std::isnormal returns false on zero. Change-Id: I897fc0dc3b8a9c557bb1922ea7ca8df501e91859 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit d782df48612a932f03a579c889670d34c26e9574) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* tst_QPluginLoader: Fix MachO stub testsTor Arne Vestbø2020-07-222-5/+12
| | | | | | | | | The -arch_blank argument to lipo is no longer supported. Change-Id: I47efcb3633f23b7a18d66211bc16d5c9dbc067c8 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit 15a5d1996fff52e50bb2d0f768f459990b266531) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Deprecate QTimeLine's curveShape in favor of its easingCurveEdward Welbourne2020-07-161-11/+11
| | | | | | | | | | | | | | | QEasingCurve has a richer variety of curves and curveShape was already implemented by changing the easingCurve property. [ChangeLog][QtCore][QTimeLine] Deprecated QTimeLine's curveShape property in favor of the easingCurve property. Change-Id: I7261c0f24d7e02bc94624f0b74d699df62de1a52 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: hjk <hjk@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io> (cherry picked from commit d6502614d0f04695bdb362778ecfc0dbc0b3de21) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>