summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools
Commit message (Collapse)AuthorAgeFilesLines
* Merge remote-tracking branch 'origin/5.9' into devLiang Qi2017-03-287-99/+90
|\ | | | | | | | | | | | | | | | | Conflicts: examples/examples.pro tests/auto/corelib/tools/qchar/tst_qchar.cpp tests/auto/other/qaccessibility/accessiblewidgets.h Change-Id: I426696c40ab57d14dc295b8103152cede79f244c
| * Merge remote-tracking branch 'origin/5.8' into 5.9Liang Qi2017-03-271-0/+1
| |\ | | | | | | | | | Change-Id: Icdd71e9713725bda9c305e338f5c8b41a92ed8e8
| | * QVarLengthArray: fix compilation with GCC 7Marc Mutz2017-03-251-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This fixes a warning-turned-Werror in qdistancefield.cpp: In member function ‘void QVarLengthArray<T, Prealloc>::realloc(int, int) [with T = bool; int Prealloc = 256]’, inlined from ‘void makeDistanceField(QDistanceFieldData*, const QPainterPath&, int, int)’ at ../../include/QtCore/../../../../qt5/qtbase/src/corelib/tools/qvarlengtharray.h:275:10: ../../include/QtCore/../../../../qt5/qtbase/src/corelib/tools/qvarlengtharray.h:390:19: error: ‘void* memcpy(void*, const void*, size_t)’: specified size between 18446744071562067968 and 18446744073709551615 exceeds maximum object size 9223372036854775807 [-Werror=stringop-overflow=] memcpy(ptr, oldPtr, copySize * sizeof(T)); ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Apparently GCC cannot rule out that copySize may be negative in the call to memcpy. Put GCC on the right track by adding a Q_ASSUME. Change-Id: I63e3801e52ebe2a7f77e3a97ef03ec3869319c8c Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com> Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
| * | Merge remote-tracking branch 'origin/5.8' into 5.9Liang Qi2017-03-213-98/+86
| |\| | | | | | | | | | | | | | | | | | | Conflicts: src/plugins/platforms/eglfs/eglfs-plugin.pro Change-Id: Id76cdbb41b7758572a3b8ea4dcb40d49bac968db
| | * QChar: fix ambiguous comparisons with 0, '\0', ... for goodMarc Mutz2017-03-171-11/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit e0ea0f6178c9dbee2a8c888fde84ad1cd9670c6b optimized QChar <-> QString(Ref) comparisons by adding more overloads to avoid creating QStrings from QChars just to compare them. But these new overloads made existing comparisons to QChar ambiguous. This was known at the time for QChar/int comparisons. It has since turned out that also comparing to '\0' is ambiguous, ie. not comparing to int or char per se is ambiguous, but comparing to nullptr constants is, because QString(const char*) is just as good a candidate as QChar(char)/QChar(int). Since we allow QString/QChar comparisons, it seems logical to solve the problem by adding QChar<->nullptr overloads. [ChangeLog][QtCore][QChar] Disambiguated comparisons with nullptr constants such as '\0', which 5.8.0 broke. As a consequence, QChar<->int comparisons are no longer deprecated, as this was a failed attempt at fixing the ambiguity. Change-Id: I680dd509c2286e96894e13078899dbe3b2dd83bc Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
| | * QChar: fix docs of (uchar) ctorMarc Mutz2017-03-161-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | The constructor is not only disabled under QT_NO_CAST_FROM_ASCII, but also under QT_RESTRICTED_CAST_FROM_ASCII. Change-Id: I7bbaf2891913d5256dff7f80c49075ea3326155a Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
| | * Bugfix in QDateTimeParser's findTextEntry()Edward Welbourne2017-03-091-4/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If a later month-or-day were to have a name that's a prefix of an earlier one's name, the code would have selected the longer name as best match when the text matched is the shorter name, simply because it found that one first. (Found, on Turkish Cuma(rtesi)? in Thiago's recent new test, by reversing the loop that iterated the list.) Make an exact match win and a match of a full name beat any prefix match of the same length. Change-Id: I8d954b83ccc25e4f47af2e558036d714685cef5e Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
| | * Simplify QDateTimeParser's shiny new findTextEntry()Edward Welbourne2017-03-091-13/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | Decouple from the callers' offset into a larger list; just search for an entry in a list, let the caller deal with the offset. Also, defer a .tolower() to save the need to allocate a copy of each list entry. Change-Id: I748d5214c2cc6dc592fe2bd41e3f8150f71c335b Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
| | * QDateTimeParser: Merge the code to parse names of months and weekdaysThiago Macieira2017-03-081-85/+51
| | | | | | | | | | | | | | | | | | | | | | | | Simplifies everything and avoids bugfixes in one not propagating to the other. Change-Id: I95c9e502ccc74af3bcf0fffd14a69f0cde60cc8c Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
| * | QHash: unexport the hash seed variableThiago Macieira2017-03-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The only allowed way to access the variable is now via the public qGlobalQHashSeed and qSetGlobalQHashSeed functions. The variable was private API, so we're allowed to remove it. Task-number: QTBUG-47566 Change-Id: I4a7dc1fe14154695b968fffd14abd331e5810482 Reviewed-by: Jake Petroules <jake.petroules@qt.io> Reviewed-by: David Faure <david.faure@kdab.com>
| * | QMap, QHash: make key_iterator satisfy the DefaultConstructible conceptAnton Kudryavtsev2017-03-202-0/+2
| | | | | | | | | | | | | | | Change-Id: Ifc3f481ddb902b26c217516412c93a4a39a32b1c Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* | | Make QLocalePrivate::codeTo*() take QStringViewsMarc Mutz2017-03-263-13/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ... and remove now-superfluous overloads. Adapt the sole user of the (QChar*, int) overload to construct a QStringView first, which removes the ugly cast at the call site. Change-Id: Ie5249d4b1b82d471896548e8a7d83c130ae28130 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* | | Port QLocalePrivate::*ToCode() to QLatin1StringMarc Mutz2017-03-263-32/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The returned data is in US-ASCII (or else Latin-1), and resides in consecutive memory. We can therefore return it in a QLatin1String, which, however, will in general not be NUL-terminated. Many users use the return value as part of a QStringBuilder expression, and those which are not are not pessimized further by this change. The caller in qtimezoneprivate_icu looks as if it could simply zero -terminate the return value and use it as-is, as opposed to converting to UTF-8, but I left the code equivalent to the original just the same. Change-Id: I0e628af8c1320fcff8d0aacf160e859681d2b85a Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | | Long live QStringView!Marc Mutz2017-03-244-0/+771
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | QStringView is a simple container for (const QChar*, int) and (const char16_t*, size_t). It acts as a replacement interface type for const QString and const QStringRef, and enables passing all kinds of string-like types to functions otherwise expecting const QString& - without the need to convert to QString first. The use of this new class is guarded by a macro that enables three levels of QStringView support: 1. offer QStringView, overload some functions taking QString with QStringView 2. like 1, but remove all overloads of functions taking QStringRef, leaving only the function taking QStringView. Do this only where QStringRef overloads tradionally existed. 3. like 2, but replace functions taking QString, too. This is done in order to measure the impact of QStringView on code size and execution speed, and to help guide the decision of which level to choose for Qt 6. This first patch adds QStringView with most of its planned constructors, but not much more than iterators and isNull()/isEmpty(). Further patches will add support for QStringView to QStringBuilder, add QStringView overloads of functions taking QString, and add the complete API of const QString to QStringView. [ChangeLog][QtCore][QStringView] New class, superseding const QString and QStringRef as function parameters, accepting a wide variety of UTF-16 string data sources, e.g. u"string", std::u16string{,_view}, and, on Windows, L"string", std::wstring{,_view} without converting to QString first. Change-Id: Iac273e46b2c61ec2c31b3dacebb29500599d6898 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* | | Remove unused QPodList classMarc Mutz2017-03-223-114/+0
| | | | | | | | | | | | | | | | | | | | | | | | It's private API, the last in-tree user was removed in acbd7999, but failed to remove the class. Do it now. Change-Id: I26294b535d80b419a2f545a4783014b493a5dc93 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* | | Use fromUtf8() instead of fromLatin1() for QT_RESTRICTED_CAST_FROM_ASCIIhjk2017-03-211-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The change does not change legally observable behavior as the result of using QT_RESTRICTED_CAST_FROM_ASCII is only defined for (a part of) the 7-bit range where Latin1 and UTF-8 are the same. This change does not intend to lift the 7-bit restriction on string literals for which the use of QT_RESTRICTED_CAST_FROM_ASCII is well-defined even though in practice it works now for any UTF-8, which is the presumed encoding outside that range nowadays. Change-Id: If9a4199235396a43f8f26d7591907b21120823ef Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | | Merge "Merge remote-tracking branch 'origin/5.9' into dev" into refs/staging/devLiang Qi2017-03-2010-64/+45
|\ \ \
| * | | Merge remote-tracking branch 'origin/5.9' into devLiang Qi2017-03-2010-64/+45
| |\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/corelib/io/qfilesystemengine_win.cpp src/gui/text/qdistancefield.cpp src/plugins/platforms/xcb/qxcbconnection.h Change-Id: I1be4a6f440ccb7599991159e3cb9de60990e4b1e
| | * | QString: de-deplicate code of leftRef, rightRef, midRefAnton Kudryavtsev2017-03-181-19/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Re-use methods of QStringRef. Change-Id: I5ff719c08c54246e9cafd4f9aa0823ff6df8433b Reviewed-by: Marc Mutz <marc.mutz@kdab.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
| | * | Do not assume QStringRef(const QString*) to be implicitMarc Mutz2017-03-142-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It won't be for very much longer. Change-Id: I30e3e0cd8c8ecf0833f759557382a3ded7bdea34 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
| | * | Merge remote-tracking branch 'origin/5.8' into 5.9Liang Qi2017-03-138-42/+29
| | |\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: examples/network/network.pro mkspecs/features/mac/default_post.prf src/corelib/io/qfilesystemengine_win.cpp src/corelib/io/qprocess.cpp src/corelib/io/qprocess.h src/corelib/io/qprocess_p.h src/corelib/io/qprocess_unix.cpp src/corelib/io/qprocess_win.cpp src/corelib/thread/qmutex.cpp src/platformsupport/fontdatabases/windows/windows.pri src/plugins/platforms/eglfs/eglfsdeviceintegration.pro tests/auto/corelib/io/io.pro Change-Id: I8a27e0e141454818bba9c433200a4e84a88d147e
| | | * Add -Wfloat-equal to Qt's header clean checkThiago Macieira2017-03-071-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Task-number: QTBUG-57649 Change-Id: I15b62e0f9cec482fbb40fffd1490d802c54bf0fe Reviewed-by: Marc Mutz <marc.mutz@kdab.com> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
| | | * Use QT_CONFIG(library) instead of QT_NO_LIBRARYUlf Hermann2017-03-062-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For the windows file system engine, we add an extra macro to use library loading if configured to do so, but avoid it on WinRT, as none of the symbols would be found. We also QT_REQUIRE_CONFIG(library) in the library headers and exclude the sources from the build if library loading is disabled. This, in turn, makes it necessary to clean up some header inclusions. Change-Id: I2b152cb5b47a2658996b6f4702b038536a5704ec Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
| | | * Make QLocale consistent about special handling of the C localeEdward Welbourne2017-03-061-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | QLocale::matchingLocales() simply created each locale using the basic data, without (unless the matching conditions stipulated Language C) applying number-options hacks that it applies everywhere else, when creating the C locale. Thus the C locale in its returned list (if it wasn't the only entry) ended up with the default number options, without omiting separators in numbers. Thus QLocale::c() didn't actually appear as an entry in the list. Discovered while investigating QTBUG-58947. Added a dumb autotest that checks various ways of getting the C locale do actually give us equal locale objects. Fixed matchingLocales() to apply the same hack as is used elsewhere for the C locale. Change-Id: I263f31da623052b63171f5b5a83c65802383df21 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
| | | * QVector: Avoid implicit conversion warningsStig Bjørlykke2017-03-021-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This fixes compiling an application using QVector and -Wshorten-64-to-32 on a 64-bit system without getting this warning: ... 5.8/clang_64/lib/QtCore.framework/Headers/qvector.h:695:18: warning: implicit conversion loses integer precision: 'typename iterator_traits<QString *>::difference_type' (aka 'long') to 'int' [-Wshorten-64-to-32] int offset = std::distance(d->begin(), before); ~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ... 5.8/clang_64/lib/QtCore.framework/Headers/qvector.h:731:35: warning: implicit conversion loses integer precision: 'long' to 'const int' [-Wshorten-64-to-32] const int itemsToErase = aend - abegin; ~~~~~~~~~~~~ ~~~~~^~~~~~~~ ... 5.8/clang_64/lib/QtCore.framework/Headers/qvector.h:740:39: warning: implicit conversion loses integer precision: 'long' to 'const int' [-Wshorten-64-to-32] const int itemsUntouched = abegin - d->begin(); ~~~~~~~~~~~~~~ ~~~~~~~^~~~~~~~~~~~ Change-Id: I52d85908f4aac20c7e9ac8063ac760ce52f85541 Reviewed-by: Marc Mutz <marc.mutz@kdab.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
| | | * Fix parsing of day-of-week names that start with another nameThiago Macieira2017-02-281-32/+9
| | | | | | | | | | | | | | | | | | | | | | | | Task-number: QTBUG-59159 Change-Id: I95c9e502ccc74af3bcf0fffd14a69e0cd27ce96b Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
| | | * QList: Avoid implicit conversion warningStig Bjørlykke2017-02-281-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This fixes compiling an application using QList and -Wshorten-64-to-32 on a 64-bit system without getting this warning: ... 5.8/clang_64/lib/QtCore.framework/Headers/qlist.h:897:26: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32] int removedCount = e - n; ~~~~~~~~~~~~ ~~^~~ Change-Id: I688ed086805c431821c2ee6078fa5aeb631e7a07 Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
| | | * QDateTime: Fix clearing the ShortData flag in setMSecsSinceEpochThiago Macieira2017-02-241-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Unlike setTimeSpec, this forgot to clear the bit when detaching. So it's possible that some further use of the flags could incorrectly conclude that the data was short and then proceed to corrupt the pointer. The example from QTBUG-59061 caused this because toUTC() -> toTimeSpec() calls setMSecsSinceEpoch which left the bit set; then addDays() calls setDateTime(), which calls checkValidDateTime() and that corrupted the pointer. This problem was more visible on 32-bit systems because no QDateTime was short (except for default constructed ones), but it can happen on 64-bit with sufficiently large dates. Task-number: QTBUG-59061 Change-Id: Ibc5c715fda334a75bd2efffd14a562a375a4e69b Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
| | * | Deprecate QString::nullMarc Mutz2017-03-122-1/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It's a Qt 3 compatibility vehicle, and as such inherits the now-alien property to distinguish empty and null strings. Particularly worrisome is the following asymmetry: QString("") == QString::null // false QString("") == QString(QString::null) // true Instead of fixing this behavior, recognize that people might use it as a weird way to call isNull(), albeit one that once was idiomatic, and simply deprecate everything that deals with QString::null. [ChangeLog][QtCore][QString] QString::null is now deprecated. When used to construct a QString, use QString() instead. When used to compare to a QString, replace with QString::isNull(). Change-Id: I9f7e84a92522c75666da15f49324c500ae93af42 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru>
* | | | QStringList: add contains(QLatin1String) overloadAnton Kudryavtsev2017-03-202-6/+35
|/ / / | | | | | | | | | | | | | | | | | | | | | | | | ... to avoid the expensive conversion from QString to QL1S. [ChangeLog][QtCore][QStringList] Added contains(QLatin1String) overload. Change-Id: Ie75839ce9e46e03fe5155a02c7dcf00277b95c8d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | | QChar: add (char16_t) and (wchar_t) ctorsMarc Mutz2017-03-172-0/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ... for better std C++ integration. [ChangeLog][QtCore][QChar] Added constructors from char16_t and, on Windows, wchar_t. Change-Id: I2d18ea3a37e869b8ea9f4036d7200d9d13c7d929 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | | Make Q_ASSERT() usable in constexpr functionsMarc Mutz2017-03-161-5/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We need Q_ASSERT in (C++11) constexpr functions, and the only way to inject them in C++11 is to use the comma operator. E.g. in QLatin1String: constexpr QLatin1Char at(int i) const { return assert(1 >= 0), assert(i < size()), m_data[i]; } The main problem with our existing Q_ASSERT is that while it is a ternary expression in active mode, it was a statement in passive mode. This is easily fixed by dropping the do-while loop and leaving just its parenthesized exit condition. Add a cast to void, too, ensuring that Q_ASSERT has type void in both passive and active modes. But even in C++14 constexpr functions, which accept several statements, Q_ASSERT needs to have a path through its conditionals that is constexpr, but neither qt_assert(_x) nor qt_noop() are constexpr. Nor can they be in C++11 (no void returns in C++11 constexpr functions). I fixed this by replacing qt_noop() with static_cast<void>(0). The void cast is required so both 2nd and 3rd arguments to the ternary are void (mixing void and non-void branches in the ternary is only allowed if the void leg is a throw-expression[1]). As a drive-by, adjust to style guide, remove overparenthesization and reverse the conditional in the ternary. Apply it to QLatin1String where we had the problem that constexpr functions had a narrow constract. [1] should probably be extended to any [[noreturn]] void function, e.g. std::terminate(). [ChangeLog][QtCore][QtGlobal] Q_ASSERT() and Q_ASSERT_X() now always expand to expressions of type void that are usable in constexpr contexts. This makes them usable in both C++11 and C++14 constexpr functions. Change-Id: I09c396bc0034ac344cfaadc6f8cbeb1b7b0cbabc Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* | | Merge remote-tracking branch 'origin/5.9' into devLiang Qi2017-03-142-1/+5
|\| | | | | | | | | | | | | | | | | | | | Conflicts: src/widgets/widgets/qpushbutton.cpp Change-Id: I615de00e6e64540c50f658d4d8ab3e002d701a81
| * | QStaticByteArrayMatcher: enforce alignmentThiago Macieira2017-03-061-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | The data is 256 bytes, so might as well align it on a 16-byte boundary to facilitate copying (if that happens). We should consider similar for QByteArrayMatcher in 6.0. Change-Id: I74966ed02f674a7295f8fffd14a8c64526d734bb Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
| * | Make new QtCore code conform to the coding styleThiago Macieira2017-03-061-1/+2
| | | | | | | | | | | | | | | | | | Change-Id: I74966ed02f674a7295f8fffd14a8c6389da538c1 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
| * | QRegularExpression: build fixGiuseppe D'Angelo2017-03-021-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | Latest PCRE2 versions require a macro to be defined before including pcre2.h, so do it. Task-number: QTBUG-59226 Change-Id: I472ff557e29d1212fdcd99454778551323be4d4b Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | | ucstricmp: compare null and empty strings equalMarc Mutz2017-03-081-9/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For consistency with ucstrcmp(), which does the same. Before, the two overloads would sort null before empty strings. This behavior was removed in Qt 3.0, IIRC- This does not yet change anything, as all callers seem to work around the problem by handling null strings before calling this function (directly or indirectly). We would have seen a failure crop up if it wasn't so. As soon as we use these functions to compare QStringViews, however, the functions need to deal correctly with a nullptr lhs and/or rhs, so fix them. Change-Id: Ie4e417aade993213169b96b5e7351850c52ae733 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | | QLatin1String: add iteratorsMarc Mutz2017-03-072-0/+182
| | | | | | | | | | | | | | | | | | | | | | | | | | | [ChangeLog][QtCore][QLatin1String] Added iterators, {c,}{r,}{begin,end}(). Change-Id: I0222a3ff44f2aa827c737e2fa3cfbb8aad69b5a7 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | | QString: make ucstrncmp() work for more than 2Gi charactersMarc Mutz2017-03-061-8/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Required for implementing upcoming QStringView's member functions such as compare(), indexOf(), endsWith(), ... Most implementations of the function body just add the length to the begin pointer to obtain an end pointer and then either no longer use the length, or decrease it in lock-step with increasing the begin pointer. The only exception is MIPS DSP's qt_ucstrncmp_mips_dsp_asm(), which gets the length passed in as an uint, implicitly converted from the int parameter, proving that calling the function with negative length was always undefined behavior, and therefore using an unsigned type does not introduce incompatibilites. I don't stand a snowball's chance in hell to fix the assembler routine, but since the code is only included for MIPS32, we don't need to do anything except be paranoid, add a static_assert that uint is the same size as size_t, and keep calling the old code. Dropped Q_COMPILER_LAMBDA in some places. We require lambdas since 5.7. Also hold lambdas by value, not by reference. This stuff is supposedly completely inlined, anyway, so there's no reason to make the code more complicated with magic lifetime extension of temporaries bound to references. Change-Id: I0c7bdc47648b873992b51b2e9d47d808390320ea Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | | QString: make UnrollTailLoop work with non-int indicesMarc Mutz2017-03-061-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The extension of ucstrncmp to size_t will introduce the first user of this loop unrolling construct with size_t indices. Instead of choosing between int and size_t, make the index type a new template argument to facilitate a step-by-step transition from int to size_t users. Change-Id: I9d8fa7aaefa572130403bd19e11f52c58dff0a4d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | | Merge remote-tracking branch 'origin/5.9' into devLiang Qi2017-03-029-30/+68
|\| | | | | | | | | | | Change-Id: I84097f8e7b3b2128028bd7693c913d6968b82bfe
| * | QEasingCurve: mark as sharedGiuseppe D'Angelo2017-02-271-1/+1
| | | | | | | | | | | | | | | | | | | | | Requires no further changes. Change-Id: Ib280fa69a752aefa1c29fc5f0eb292e99b96270a Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
| * | QVarLengthArray: add rvalue overload of append/push_backMarc Mutz2017-02-252-0/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Improves performance when appending temporaries, esp. since the aliasing fix in the lvalue overload in 0f730ef made that overload correct, but a bit slower across reallocs. The unit tests already also pass rvalues, so the function is covered in the existing tests. [ChangeLog][QtCore][QVarLengthArray] Added rvalue overloads of append() and push_back(). Change-Id: If3a6970f03a160cba5b42d33d32d3d18948f6ce3 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
| * | Merge remote-tracking branch 'origin/5.8' into 5.9Liang Qi2017-02-245-18/+27
| |\| | | | | | | | | | | | | | | | | | | Conflicts: mkspecs/features/moc.prf Change-Id: Ia71c8e3b3185f7c999bf226d0675051b10b8740b
| | * Doc: Fix minor typos in QRectFAaron Linville2017-02-231-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix a couple incorrect references to the integer precision classes. Update snippet to use floating point precision classes. Task-number: QTBUG-51630 Change-Id: I9b08cfb68937a8e1179ee414d7981956ef7bc106 Reviewed-by: Martin Koller <kollix@aon.at> Reviewed-by: Michael Brüning <michael.bruning@qt.io> Reviewed-by: Marc Mutz <marc.mutz@kdab.com> Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
| | * Do not delete someone else's QSystemLocale when constructing anotherEdward Welbourne2017-02-231-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The QSystemLocale constructor remembers the most-recently-constructed instance - a dodgy enough proposition at the best of times - and shares it with much of the rest of QLocale. There is a global static instance, actually of a derived singleton class, to which it is usually set on program start-up. However, the constructor deleted the remembered instance before remembering any new instances; there was no way this could not lead to bad consequences. So let's not do that. Change-Id: Ie8f3d655c9d4f75f6ec00a5861d98d6020ecc633 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
| | * QTimeZone: do not access static functions through this->Marc Mutz2017-02-221-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | The this pointer cannot be null, so we can't do d->staticFunction while d is a null pointer. This was caught by Clang 3.8's ubsan. Change-Id: I3c0d39b88cca83d827a69ed1544a4412b18ac907 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
| | * Fix a race in QFreeListOlivier Goffart2017-02-171-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The _next variable need the acquire and release fence in next() to synchronize with the equivalent operations in release() (which already have the them) The ordering on the _v[block] is not enough as this does not synchronize the same object. Task-number: QTBUG-58917 Change-Id: I17cc39e6791433348b6227363dbea92bcf03700d Reviewed-by: David Faure <david.faure@kdab.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
| | * QVarLengthArray: fix appending an already-contained itemMarc Mutz2017-02-171-5/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Like the lvalue QVector::append() overload, when we reallocate, we need to take a copy of the function's argument because the reference will get stale upon reallocation. Add a test. [ChangeLog][QtCore][QVarLengthArray] Fixed a bug involving appending an item already in the container to the container again. Change-Id: I06eeed6cb383dd5924e47a302bb3d1666d04c8e8 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
| * | Clean up QByteArrayLiteral definitionMarc Mutz2017-02-241-10/+0
| | | | | | | | | | | | | | | | | | | | | | | | Remove the dead QByteArray(data, size) fall-back. We've been requiring lambdas since Qt 5.7. Change-Id: I4d9023ab4583f2ee80a74a828fba0d95c2fdb0df Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>