summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools
Commit message (Collapse)AuthorAgeFilesLines
* QStringMatcher: add QStringView supportAnton Kudryavtsev2019-03-142-10/+41
| | | | | | | While touching the code, deduplicate some methods. Change-Id: I28f469f0e9ae000a34466b0ecc604b5f3bd09e63 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Avoid copying QByteArray created via fromRawData in toDoubleVolker Hilsheimer2019-03-091-2/+1
| | | | | | | | | | | qt_asciiToDouble accepts a length parameter, so we can just pass that through. No need for explicitly null-terminating, which is where the copy of the data would be made. Change-Id: I4e7921541f03295a2fae6171b35157084ff3ed8c Fixes: QTBUG-65748 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Clean up the QCollator code and commentsEdward Welbourne2019-03-084-51/+69
| | | | | | | | Broke over-long lines. Reflowed documentation, refined a phrasing, corrected some out of date details and typos. Change-Id: Ic3835bb198bd062f85b3c466b56dc9636d4d3fe4 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Report status codes in warnings about API failuresEdward Welbourne2019-03-081-10/+6
| | | | | | | | Also reuse the status variable, since the value saved in the one previously declared int was an OSStatus, too. Change-Id: I8e8fe308ae71df51e8057d89bc76cab0c6bbedb2 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Extend QCollator to support QStringViewEdward Welbourne2019-03-086-76/+59
| | | | | | | | | | This enables some simplification of the existing implementations. Refined wording of the documentation in the process. [ChangeLog][QtCore][QCollator] Added support for QStringView. Change-Id: Idffaae8d109173d47c7be076828f4b58dc334957 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Add QStringView::toWCharArray() to match QStringEdward Welbourne2019-03-084-7/+35
| | | | | | | | | | QCollator needs it to add support for QStringView. In any case, it extends the mirror of QString's API. Naturally, we can reimplement QString's version using it. Change-Id: I5a23a3f2a98c7d59597b5e935542a93764b5e350 Reviewed-by: Paul Wicking <paul.wicking@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QLineF: mark angle(const QLineF&) as deprecatedChristian Ehrlicher2019-03-052-0/+5
| | | | | | | | QLineF::angle(const QLineF&) was deprecated during Qt4 times but not decorated with QT_DEPRECATED_X. Add this so it can be removed with Qt6 Change-Id: I8950b646cc5fa8206e47bdd16647d17d615f6c6a Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Simplify toStdWStringGiuseppe D'Angelo2019-03-051-7/+5
| | | | | | | | | | | | In C++17: just use std::basic_string::data(). In C++11: dereferencing begin() on an empty string is undefined behavior on all compilers, not just MSVC, so remove that workaround. Instead of the reference-dereference combo, use std::basic_string::front(). Change-Id: I3229597e000311ce71e4083dca6667bb56d8f8e3 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QString: mark obsolete functions as deprecatedChristian Ehrlicher2019-03-042-0/+8
| | | | | | | | | | Mark obsolete functions in QString as deprecated so they can be removed with Qt6: - QString::sprintf() - QString::vsprintf() Change-Id: I9b7748db95291c34b95ff3ad3e3aabc8215aeaae Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@qt.io>
* Merge remote-tracking branch 'origin/5.12' into 5.13Qt Forward Merge Bot2019-02-261-0/+2
|\ | | | | | | Change-Id: Id511850002d9274d17891c063376ac4b3ff939dd
| * Fix build for size with gccKirill Burtsev2019-02-231-0/+2
| | | | | | | | | | | | | | | | Fixes the error: variable 'isDifferent' set but not used Change-Id: Ibd60b17126057da64a41d325b7ef548316f27c4b Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Fix can not -> cannotRobert Loehning2019-02-252-2/+2
| | | | | | | | | | Change-Id: Ie9992f67ca59aff662a4be046ace08640e7c2714 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* | Add conversion to and from long and ulongVolker Hilsheimer2019-02-233-0/+162
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This implements conversion parity with QString, which can convert to and from long and unsigned long. The implementation simply forwards to existing long long overloads or uses the existing helpers, so just as for the conversion to/from int or short, no additional test cases were added. Change-Id: I37ef06d9ce4d80d98bd72720353996bac723e09c Fixes: QTBUG-782 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit 783953f09dcfe9c58dc991394535ba07dabe2560) Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* | QtCore: replace null and nullptr with \nullptr in documentationChristian Ehrlicher2019-02-186-86/+86
| | | | | | | | | | | | | | Replace null and '\c nullptr' with \nullptr in the documentation. Change-Id: Ib9e0cfc2eb2830b213e6523773603d56180b0998 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* | Remove bogus assertLars Knoll2019-02-131-1/+0
| | | | | | | | | | | | | | | | | | | | The code was actually completely fine, but the assert was bogus. detach() can call realloc(d->alloc). Fixes: QTBUG-73756 Change-Id: I3485bc926dba3f2537e14c0c05d30ff982e6e714 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Merge "Merge remote-tracking branch 'origin/5.12' into 5.13" into ↵Liang Qi2019-02-121-5/+6
|\ \ | | | | | | | | | refs/staging/5.13
| * | Merge remote-tracking branch 'origin/5.12' into 5.13Qt Forward Merge Bot2019-02-121-5/+6
| |\| | | | | | | | | | Change-Id: Iad53d4f21263718b8ecf15fd2d1170d24c7b675d
| | * Avoid read-outside-array error by QStringRef over-reachEdward Welbourne2019-02-081-5/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Constructing a QStringRef directly from the string, offset and a length is UB if the offset + length exceeds the string's length. Thanks to Robert Loehning and libFuzzer for finding this. QString::midRef (as correctly used in both changed uses of QStringRef, since 432d3b69629) takes care of that for us. Changed one UB case and a matching but correct case, for consistency. In the process, deduplicate a QStringList look-up. Added tests to exercise the code (but the one that exercises the formerly UB case doesn't crash before the fix, so isn't very useful; the invalid read is only outside the array it's scanning, not outside allocated memory). Change-Id: I7051bbbc0267dd7ec0a8f75eee2034d0b7eb75a2 Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | | Add missing \since to QList<T>::swapItemsAt()Friedemann Kleint2019-02-121-0/+1
|/ / | | | | | | | | | | | | Amends 7f4d0405b409b1d3aa9d91e31972669576ec698c. Change-Id: I4de38428ea4a0e448e2930d19d94821884f7331e Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | Merge remote-tracking branch 'origin/5.12' into 5.13Liang Qi2019-02-083-14/+36
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/android/templates/AndroidManifest.xml src/network/ssl/qsslsocket_mac.cpp src/widgets/styles/qstylesheetstyle.cpp tests/auto/corelib/kernel/qtimer/BLACKLIST tests/auto/testlib/selftests/blacklisted/tst_blacklisted.cpp tests/auto/testlib/selftests/expected_blacklisted.lightxml tests/auto/testlib/selftests/expected_blacklisted.tap tests/auto/testlib/selftests/expected_blacklisted.teamcity tests/auto/testlib/selftests/expected_blacklisted.txt tests/auto/testlib/selftests/expected_blacklisted.xml tests/auto/testlib/selftests/expected_blacklisted.xunitxml tests/auto/testlib/selftests/expected_float.tap tests/auto/testlib/selftests/expected_float.teamcity tests/auto/testlib/selftests/expected_float.txt tests/auto/testlib/selftests/expected_float.xunitxml Done-With: Christian Ehrlicher <ch.ehrlicher@gmx.de> Done-With: Edward Welbourne <edward.welbourne@qt.io> Done-With: Timur Pocheptsov <timur.pocheptsov@qt.io> Change-Id: If93cc432a56ae3ac1b6533d0028e4dc497415a52
| * Fix race condition in getting the system locale dataThiago Macieira2019-02-011-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | QSharedDataPointer obeys the regular Qt container thread-safety rules: it's thread-safe in const methods but not in mutating ones. QSDP::data() is mutating, which causes a data race. For example, if the contained QLocalePrivate has a refcount of 2 and two threads see that, both threads will try to detach and then replace the pointer, but that pointer replacement is not atomic. Using QExplicitSharedDataPointer makes the race go away, since data() is now non-mutating. QESDP is used only to destroy the QLocalePrivate on program shutdown. Note that there are still race conditions relating to *updating* the locale private. Fixes: QTBUG-73403 Change-Id: Id98140e1c2f0426cabbefffd157ed6ec30a3e08f Reviewed-by: Thomas Sondergaard <thomas@sondergaard.cc> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
| * Q(Date|Time)+::toString: correct account of format specifiersEdward Welbourne2019-01-311-12/+30
| | | | | | | | | | | | | | | | | | | | | | Where non-format characters appear in the format string, they are not "ignored" as claimed; they are passed through verbatim. Formats without separators between fields are in fact supported, although results may be ambiguous. Cleaned up phrasing in the process. Fixes: QTBUG-51208 Change-Id: I7284a36c48aa0be29deaa16945ca0212e9e6f72c Reviewed-by: Paul Wicking <paul.wicking@qt.io>
| * Fix unused parametersJesus Fernandez2019-01-291-0/+4
| | | | | | | | | | | | | | Change-Id: Iafad6313fcf74e42c11628ce9ee0f797abfcb6ca Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* | QtCore: replace 0 with \nullptr in documentationChristian Ehrlicher2019-01-281-3/+3
| | | | | | | | | | | | | | | | | | | | | | Replace 0 with \nullptr in the documentation. As a drive-by also replace some 0 with nullptr in the corresponding code. Change-Id: I101a61f5fad71cadb73bba9a8fd5dce6cc0836d0 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* | Merge remote-tracking branch 'origin/5.12' into devLiang Qi2019-01-261-1/+1
|\| | | | | | | | | | | | | | | Conflicts: src/android/templates/AndroidManifest.xml tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp Change-Id: I4c9679e3a8ebba118fbf4772301ff8fde60455b9
| * qsimd: Fix compilation with trunk clang for mingwMartin Storsjö2019-01-221-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Current tip-of-tree clang (after Clang 8 was branched) added an intrinsic function __builtin_ia32_xgetbv, and added the following define that provides _xgetbv: #define _xgetbv(A) __builtin_ia32_xgetbv((long long)(A)) This fallback declaration of the _xgetbv function only is used in case the Q_OS_WIN branch of the #if/#elif below is used, if the #if (defined(Q_CC_GNU) && !defined(Q_CC_EMSCRIPTEN)) || defined(Q_CC_GHS) wasn't taken. I left out the !defined(Q_CC_EMSCRIPTEN) part as I believe Q_OS_WIN and Q_CC_EMSCRIPTEN are mutually exclusive. Change-Id: I257fc4283ff9f0845df51ab764cf58acdf285c66 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Add QStringList::indexOf/lastIndexOf for QStringView and QLatin1StringAlbert Astals Cid2019-01-223-12/+117
| | | | | | | | | | Change-Id: I42eac69c1f7ab88441d464b9d325139defe32b03 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Merge remote-tracking branch 'origin/5.12' into devQt Forward Merge Bot2019-01-211-0/+2
|\| | | | | | | | | | | | | Conflicts: .qmake.conf Change-Id: Ibfcb30053f3aacb8ec2ec480e146538c9bf440ea
| * QLocale: fix crash when using qDebug() in a global destructorDavid Faure2019-01-131-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | `kdevelop -s doesnotexist` led to ASSERT failure in Q_GLOBAL_STATIC: "The global static was used after being destroyed because of a qDebug() statement in some "unregister" method called by a global object's destructor. This is normally fine, but with %{time} in QT_MESSAGE_PATTERN, qDebug() ends up using QLocale after its global objects (systemLocalePrivate and defaultLocalePrivate) were destroyed. Change-Id: I8d8b34e0197ad1eda8283fcf36d2c250385bb1a3 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Merge remote-tracking branch 'origin/5.12' into devLiang Qi2019-01-046-56/+176
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Also blacklist tst_QRawFont::unsupportedWritingSystem() and tst_QGlyphRun::mixedScripts() on windows for now. Conflicts: qmake/generators/makefile.cpp src/corelib/itemmodels/qstringlistmodel.cpp src/platformsupport/fontdatabases/windows/qwindowsfontengine_p.h tests/auto/corelib/itemmodels/qstringlistmodel/tst_qstringlistmodel.cpp tests/auto/gui/text/qglyphrun/BLACKLIST tests/auto/gui/text/qrawfont/BLACKLIST Task-number: QTBUG-72836 Change-Id: I10fea1493f0ae1a5708e1e48d0a4d7d6b76258b9
| * Doc: Remove pre-Windows 7 from QCollator documentationKai Koehne2018-12-221-5/+0
| | | | | | | | | | | | | | | | The code path that this refers to was removed already for Qt 5.11 in commit 53fb2c48ef472ee74a2. Change-Id: I4a7ae1b89b24c0ab7ceaa43f763c7ef422ca4900 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
| * Doc: Consistently mark QT_XYZ_CAST_FROM_ASCII with \cKai Koehne2018-12-223-9/+91
| | | | | | | | | | | | | | | | | | | | | | Otherwise it gets linkified, which looks inconsistent. Instead, use \sa for functions where QT_NO_CAST_FROM_ASCII or QT_RESTRICTED_CAST_FROM_ASCII is referenced. Change-Id: Ic3933d8c4c81c963215de7f3aac4d0a11e61cbc2 Reviewed-by: Paul Wicking <paul.wicking@qt.io> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Reviewed-by: Martin Smith <martin.smith@qt.io>
| * QtCore: Unify license headersKai Koehne2018-12-221-1/+1
| | | | | | | | | | Change-Id: Iff4f6da9f0bbf7a0627101f455dd8467681b2783 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
| * Add an AVX2 code path to qustrchrThiago Macieira2018-12-181-0/+23
| | | | | | | | | | | | | | The new loop does 32 bytes (16 code units) at a time Change-Id: I8f261579aad648fdb4f0fffd155412a4d77428e9 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
| * Merge some code to simplify maintenanceThiago Macieira2018-12-181-40/+49
| | | | | | | | | | | | Change-Id: I8f261579aad648fdb4f0fffd15541369e3625461 Reviewed-by: Samuel Gaist <samuel.gaist@idiap.ch> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
| * Fix QRegularExpressionMatch capture-related documentationSamuel Gaist2018-12-151-1/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | The documentation is not explicit enough about the content of the returned list of capturedList nor the element 0 when calling captured or its friends. The first element (aka element 0) is the whole string captured when one or more groups are used. Change-Id: I3c59ebfc9f6d762dd4d8aaf8f5c0de24359f53d7 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Sze Howe Koh <szehowe.koh@gmail.com>
| * QRegularExpression: anchor wildcard patternSamuel Gaist2018-12-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The current implementation of wildcardToRegularExpression doesn't anchor the pattern which makes it not narrow enough for globbing patterns. This patch fixes that by applying anchoredPattern before returning the wildcard pattern. [ChangeLog][QtCore][QRegularExpression] The wildcardToRegularExpression method now returns a properly anchored pattern. Change-Id: I7bee73389d408cf42499652e4fb854517a8125b5 Fixes: QTBUG-72539 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Fix build with C++20Thiago Macieira2018-12-211-2/+0
| | | | | | | | | | | | Fixes: QTBUG-72614 Change-Id: I548dbfddb69b4fd6a0a3fffd1572614a383366a5 Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
* | QCommandLineParser: show application name in error messagesDavid Faure2018-12-201-1/+1
| | | | | | | | | | | | Change-Id: I2c39759294ca0a11a59b9a38207bf1aef941b070 Fixes: QTBUG-58490 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Merge remote-tracking branch 'origin/5.12' into devQt Forward Merge Bot2018-12-136-19/+57
|\| | | | | | | Change-Id: I0fe623517af28e408b642c879efd59f633ab63ac
| * Handle QCollator with locale C by delegating to QStringEdward Welbourne2018-12-116-19/+57
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, the C locale was treated as English because each back-end takes the locale's bcp47Name(), which maps C to en. However, the C locale has its own rules; which QString helpfully implements; so we can delegate to it in this case. Extended this to sort keys, where possible. Clean up existing implementations in the process. Extended tst_QCollator::compare() with some cases to check this. That required wrapping the test's calls to collator.compare() in a sign canonicalizer, since it can return any -ve for < or +ve for >, not just -1 and +1 for these cases (and it'd be rash to hard-code specific negative and positive values, as they may vary between backends). [ChangeLog][QtCore][QCollator] Added support for collation in the C locale, albeit this is only well-defined for ASCII. Collation sort keys remain unsupported on Darwin. Fixes: QTBUG-58621 Change-Id: I327010d90f09bd1b1816f5590cb124e3d423e61d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Use Q_DISABLE_COPY_MOVE for private classesFriedemann Kleint2018-12-122-3/+3
| | | | | | | | | | Change-Id: I3cfcfba892ff4a0ab4e31f308620b445162bb17b Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* | Merge remote-tracking branch 'origin/5.12' into devQt Forward Merge Bot2018-12-091-4/+17
|\| | | | | | | Change-Id: I10ae61ec6867b38601d85d6fc34e1f6a6ba0cc11
| * Optimize further the loading of 8 Latin 1 charactersThiago Macieira2018-12-081-4/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is important when AVX is enabled, which makes the VMOVQ load and the VPMOVZXBW instruction be combined into a single VPMOVZXBW with direct memory access. This is guaranteed to only read 8 bytes, so it's safe even close to the end of a page. Clang and ICC do combine the instructions like we want and I have filed a request for GCC to do so too[1]. AVX was first introduced in 2011, so plenty of computers today would benefit from this. [1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87317 Change-Id: I8f261579aad648fdb4f0fffd1553e08e90df3171 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* | Don't require a default constructor for storing items in a QVectorLars Knoll2018-12-061-29/+110
| | | | | | | | | | | | | | | | | | | | [ChangeLog][QtCore][QVector] QVector does not require a default constructor for its template argument anymore. Change-Id: Idd256dd756829561c21bd9e1e693f2918f1e3247 Reviewed-by: Luca Beldi <v.ronin@yahoo.it> Reviewed-by: Samuel Gaist <samuel.gaist@idiap.ch> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* | Merge "Merge remote-tracking branch 'origin/5.12' into dev" into ↵Liang Qi2018-12-046-24/+54
|\ \ | | | | | | | | | refs/staging/dev
| * | Merge remote-tracking branch 'origin/5.12' into devLiang Qi2018-12-046-24/+54
| |\| | | | | | | | | | | | | | | | | | | Conflicts: src/gui/painting/qdrawhelper.cpp Change-Id: I4916e07b635e1d3830e9b46ef7914f99bec3098e
| | * Optimize QSharedPointer::getAndRef with the three-operand testAndSetThiago Macieira2018-11-281-4/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Originally QAtomicPointer didn't have the three-operand version, resulting in code like: if (!atomic.testAndSetXxx(expected, newvalue)) expected = atomic.load(); The three-operand version gives us the current value of the atomic in case the test failed and it's free in all architectures, unlike the extra load. I have to use testAndSetOrdered here because I need the failing load to use the Acquire memory order, even though that has an extra Acquire for the successful case we don't need. QAtomicPointer does not have testAndSetReleaseAcquire. Change-Id: I1bd327aeaf73421a8ec5fffd1560fe30d3bfd9b8 Reviewed-by: Romain Pokrzywka <romain.pokrzywka@gmail.com> Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@qt.io>
| | * Merge remote-tracking branch 'origin/5.11' into 5.12Qt Forward Merge Bot2018-11-275-20/+47
| | |\ | | | | | | | | | | | | Change-Id: I12bcee17e349edd0dd4fd08da76361d1ffb1a727
| | | * Recognize E along with e as exponent character in asciiToDoubleEdward Welbourne2018-11-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixed a misguided condition in the check for bogus texts in the sscanf branch of the decoder; it checked for 'e' but neglected 'E', which is just as valid. Change-Id: I9236c76faea000c92df641930e401bce445e06c8 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>