summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools
Commit message (Collapse)AuthorAgeFilesLines
* Remove non-Qt6 compile time switches from QtCoreAllan Sandfeld Jensen2020-07-241-5/+1
| | | | | | | | We already manage to compile without this code, and none of it are full classes or separate functions suitable for qt5compat. Change-Id: I47facac7ec621cfc4b0b26214b7de37897443519 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Temporarily add a private QESDPv2Giuseppe D'Angelo2020-07-222-0/+168
| | | | | | | | | To unlock work while waiting for QISP. QESDP is lacking a few crucial APIs (isDetached() / isShared() / reset(ptr) / deep const), so we can't go there right away. Change-Id: I647eb0db4ea800488a323f3b64661e848998168d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QCommandLineOption: purge deprecated APIEdward Welbourne2020-07-202-38/+2
| | | | | | | | Since 5.8: setHidden(), isHidden() Part of the QCommandLineParser test also used setHidden(). Change-Id: I05a1c63ff3beb1167ed75632c1b71d7fff17f09e Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Deprecate QTimeLine's curveShape in favor of its easingCurveEdward Welbourne2020-07-163-28/+43
| | | | | | | | | | | | | | 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. Pick-to: 5.15 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>
* Work around compiler problems on MSVC 16.6.XLars Knoll2020-07-151-1/+2
| | | | | | | | | | | The compiler apparently doesn't resolve the emplace overload correctly to the rvalue version, leading to infinite recursion in the overload that takes a const Key & as argument. Take a copy to make it explicit. Change-Id: I22039d6ca1e2176c81e51b181c72f511dab662f7 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Doc: Mark API in Q[Mutable]HashIterator as deprecatedKai Koehne2020-07-141-31/+222
| | | | | | | | | | The reverse iteration API got deprecated in code already in commit dbb54805f63f9e . Now also fix the documentation. Fixes: QTBUG-85482 Pick-to: 5.15 Change-Id: I3b575f60dabfe1005b9744d17c257da3e22817c5 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QCryptographicHash: explicitly activate the used union memberGiuseppe D'Angelo2020-07-121-7/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | A union member lifetime does not start automatically if one takes a pointer to a union member and writes into the member. Only the subscript syntax in an assignment features such automatic lifetime start [class.union§6]. In the other cases, one is allowed to get a pointer to the storage ([basic.life§6]) but has to start lifetime explicitly via placement new. Hence, do so, or we end up in UB land. We're left with the problem of reset() which may be called multiple times. I think we can actually just create a new object in the same storage without destroying the pre-existing object by exploiting [basic.life§5]: reusing the storage causes lifetime end for the old object. Moreover, since the union is over trivial datatypes (C structs), there's no side effects in the destructor of the old object, so there is no need to call it. Drive by fix, apply some DRY for SHA3. Change-Id: Idc351568635e59d45421311f043956ab3aabf389 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Linus Jahn <lnj@kaidan.im>
* QVLA: use std::aligned_storageGiuseppe D'Angelo2020-07-121-5/+1
| | | | | | | Remove the hand-rolled union used only to achieve alignment. Change-Id: I8e635fa0d09042f30fd67d589db9bc384c0ec8ef Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Remove the setting of GrowsBackwards from QListAndrei Golubev2020-07-101-4/+0
| | | | | | | | | | | | | | | The flag is practically unused, there is no logic that relies on its existence. From experience of prototyping prepend optimization (where the flag actually makes sense), it is better to temporarily remove it: QList is, in fact, unaware of how to correctly use it at the moment Once GrowsBackwards-using code is implemented at the lower levels, the usage of the flag will be reintroduced to QList along with the changes that ensure correct behavior Task-number: QTBUG-84320 Change-Id: I618adfcd69b15c76ddafd78cca5e9aa0073e4c91 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QArrayDataPointer: use move and swap in move assignmentGiuseppe D'Angelo2020-07-101-1/+2
| | | | | | | | | Not plain swap; QADP does not hold just memory but arbitrary state (depending on T). Change-Id: I3560577e4109607a51b2c72b67e22e38813977b3 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Constrain the comparison operators for our container classesLars Knoll2020-07-086-54/+62
| | | | | | | | | | | | This had already been in very few places, where we ran into issues with this before. More generic constraints here will significantly reduce the amount of error messages a user has to parse in case he tries to instantiate an operator by accident (or with a lacking comparison operator for one of it's template arguments). Change-Id: I1521d19c55d99732d9742402bd534c390a8e4242 Reviewed-by: Paul Wicking <paul.wicking@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Add type traits to safely determine the existence of comparison operatorsLars Knoll2020-07-082-1/+5
| | | | | | | | | | | | | | | | | | Containers often define an operator==() or operator<() which is very useful for generic code. But those operators can usually not be instantiated if the template argument doesn't implement the operator. This sometimes leads to the compiler trying all possible template expansions and implicit conversions for the type, giving extremely long error messages. The traits support can be used to safely constrain those operators. Being able to safely detect this will also allow us to fold the comparison support that is currently a large cludge for user types directly into QMetaType. Change-Id: Ib84afb5348c3eb0be5161d6ba9d5fe237709c65f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Introduce QByteArrayViewSona Kurazyan2020-07-082-0/+13
| | | | | | | | | | | | | | | | | | | | Created a QByteArrayView in symmetry with QStringView. Added the basic tests symmetrical to QStringView tests. Moved the implementations of non-modifying methods of QByteArray to namespace QtPrivate, to be reused inline from both QByteArray and QByteArrayView. Changed QByteArray's counterparts of those methods to take QByteArrayView as argument instead of QByteArray. Removed QByteArray's operator QNoImplicitBoolCast(), because it was causing ambiguity when calling those methods with QByteArray argument (it was there to perevnt if(!ba)/if(ba) from compiling, but currently that would be ambiguous and won't compile anyway). [ChangeLog][QtCore][QByteArrayView] New class. Task-number: QTBUG-84321 Change-Id: I05f92e654cf65c95f2bb31b9c9018746ac110426 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Small fixes to the QList documentationLars Knoll2020-07-061-3/+3
| | | | | Change-Id: Ic839f7859912eb48bb192755d6f10536a0a73f8e Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
* Add support for first(n), last(n) and sliced() to QListLars Knoll2020-07-062-0/+72
| | | | | | | | | This keeps the API symmetric with what we have in our string classes. Change-Id: I94c5b39b718ca2472f9ca645e7a42e4314636f67 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Use qsizetype in QListLars Knoll2020-07-061-62/+62
| | | | | | | | | | | | | | | | | | | | The change creates a slight source incompatibility. The main things to take care of are * code using printf statements on list.size(). Using qsizetype in printf statements will always require a cast to work on both 32 and 64 bit. * A few places where overloads now get ambiguous. One example is QRandomGenerator::bounded() that has overloads for int, uint and double, but not int64. * Streaming list.size() to a QDataStream will change the format depending on the architecture. [ChangeLog][QtCore][QList] QList now uses qsizetype to index into elements. Change-Id: Iaff562a4d072b97f458417b670f95971bd47cbc6 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Allow allocating more than 2G items in a vectorLars Knoll2020-07-063-67/+59
| | | | | | | | | | | Also adjust qCalculateBlockSize() to be able to handle large allocations. QVector::length() is currently still limited to 2G items, that will get changed in a later commit. Change-Id: I3a92fbfd7f281d30844c5fafa3b9a474bc347c19 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Implement a proper iterator for QTypedArrayDataLars Knoll2020-07-061-2/+66
| | | | | | | | | | | This avoids ambiguities in our API when someone e.g. writes vector.insert(0, ...). It requires a slight workaround in qlalr, where std::search() for libc++ doesn't like that our difference_type is qsizetype. Change-Id: I40aa1040781ffbdd12d04410078207969b3bde53 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Make QArrayDataPointer::size a qsizetypeLars Knoll2020-07-062-8/+8
| | | | | | | | This is a next step towards making QList, QString and QByteArray able to deal with large sizes. Change-Id: Icad49b33f503401ac4912678b2f88584c6f91a63 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Add a couple of noexceptLars Knoll2020-07-062-15/+15
| | | | | Change-Id: I993da2094482092540388ee72be3262bac94fad7 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Get rid of QArrayData::sharedNull()Lars Knoll2020-07-063-42/+4
| | | | | | | | Remove the last places where those got used and avoid allocations when we resize to 0. Change-Id: Ib553f4e7ce7cc24c31da15a55a86d18bdf1cc5c3 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Get rid of QArrayData::isMutable()Lars Knoll2020-07-061-11/+2
| | | | | Change-Id: Ifb6368b83cd12ec3897c6b6b846d71bffa1f74b9 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Get rid of unused flags in QArrayDataLars Knoll2020-07-062-24/+8
| | | | | Change-Id: I3ea754b44fb33e33baba0781d9ae15b7f3b3d8eb Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Simplify Q_ARRAY_LITERALLars Knoll2020-07-063-50/+17
| | | | | | | And clean up some unused pieces of code. Change-Id: I285b6862dc67b7130af66d3e08f652b1a56b990e Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Get rid of shared null for QByteArray, QString and QVectorLars Knoll2020-07-065-110/+45
| | | | | | | | | | | | | | As a side effect, data() can now return a nullptr. This has the potential to cause crashes in existig code. To work around this, return an empty string from QString::data() and QByteArray::data() for now. For Qt 6 (and once all our internal issues are fixed), data() will by default return a nullptr for a null QString, but we'll offer a #define to enable backwards compatible behavior. Change-Id: I4f66d97ff1dce3eb99a239f1eab9106fa9b1741a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QList: improve the range constructorsGiuseppe D'Angelo2020-07-061-4/+4
| | | | | | | | | | In case of forward iterators, call std::distance just once and not twice. In case of non-forward iterators, don't call reserveIfForwardIterator -- as the name says, it doesn't make sense on non-forward iterators. Change-Id: I7e6a603205286c05f7bc7c47fd1f1e0d92705b20 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QList: go for the rule of zeroGiuseppe D'Angelo2020-07-061-9/+2
| | | | | | | | | The hand-written special member functions did exactly what the compiler generated ones would do anyhow. Change-Id: I66439178460d30957135aac44680dd3109ada62a Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Remove unnecessary ; after function implementationsLars Schmertmann2020-07-061-1/+1
| | | | | | Task-number: QTBUG-82978 Change-Id: Iea3bcaec1ef9f4bd0f73e5dccca33354650f5bf4 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Only use one macro per lineLars Schmertmann2020-07-031-1/+2
| | | | | | | | | Also add a ; where it is missing. Task-number: QTBUG-82978 Change-Id: Ic5d2a07363c25ab641d234baca89bc62238458cb Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Remove method declaration that's not used or implementedLars Knoll2020-07-021-2/+0
| | | | | | Change-Id: If8c03c08b7bfc162908510cac278ce9267b61cdf Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Move the reallocate() method from QArrayDataPointer to the Ops classLars Knoll2020-07-022-6/+10
| | | | | | | | | And only implement it for QPodArrayOps, as that's the only case where we should be using it. Change-Id: If48f3e4b142c322d3451309d6d1cf68aee569ea2 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Small cleanupLars Knoll2020-07-021-9/+2
| | | | | | Change-Id: Ic8ed50a05a9723ed252f0762d86e41fe719fc3ef Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Use std::memmoveSamuli Piippo2020-06-301-3/+4
| | | | | | | | ... and add include for it. Amends ffb73175e6c5b35e6367c88479cc0bf160482016 Change-Id: I709a5aed13f6f62017b9e4116a03a4dfaae4bb13 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* Use QList instead of QVector in corelib docsJarek Kobus2020-06-293-307/+136
| | | | | | | Task-number: QTBUG-84469 Task-number: QTBUG-85221 Change-Id: Ieb0ba7d82409e3c053a5788a01e92ea495505643 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Use QList instead of QVector in corelib implementationJarek Kobus2020-06-298-33/+33
| | | | | | | | Omitting state machine and docs for now. Task-number: QTBUG-84469 Change-Id: Ibfa5e7035515773461f6cdbff35299315ef65737 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* QList: use =default for its default constructorGiuseppe D'Angelo2020-06-261-1/+1
| | | | | Change-Id: Id5270eac2464bf2d3810de18579d4dc295e98b38 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Improve deprecation message for QLine::angle(QLine)Eirik Aavitsland2020-06-261-1/+1
| | | | | | | | | | | | | | angleTo() always gives an answer measured ccw, so between 0 and 360 degrees. The deprecated angle() would give either cw or ccw, depending on which is smaller, so between 0 and 180 degrees. Help users porting by showing a simple way to achieve the angle() behavior in the deprecation message. Change-Id: I66f77d2b4e688562e443428209737aa3332a448f Pick-to: 5.15 Fixes: QTBUG-85087 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Use QList instead of QVector in corelibJarek Kobus2020-06-257-63/+44
| | | | | | | | | | Applied to headers only. Source file to be changed separately. Omitted statemachine for now to avoid conflicts. Omitted qmetatype.h for now - to be handled later. Task-number: QTBUG-84469 Change-Id: I317376037a62467c313467d92955ad0b7473aa97 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* Improve castingAllan Sandfeld Jensen2020-06-252-2/+2
| | | | | | | Make a handful of narrowing casts explicit Change-Id: I318e9778840f2437963377b6b97f269d569909dc Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* QVarLengthArray: add missing move special member functionsMarc Mutz2020-06-223-0/+73
| | | | | | | | | | | | | | | | A QVLA is copyable, so it should be movable, too. Added a helper function a la P1144's uninitialized_relocate_n to deal with the QTypeInfoQuery stuff. This way, the code is re-usable everywhere it's needed. The same cannot be said for QArrayDataOps, which only a parent can love... [ChangeLog][QtCore][QVarLengthArray] Added missing move constructor and move-assignment operator. Task-number: QTBUG-39111 Change-Id: If0dc2aa78eb29062d73dcd3dc4647ba345ae39e6 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Move implementation of QVector/List back to qlist.hLars Knoll2020-06-205-1017/+1015
| | | | | | | | | | | | | And name the main class QList. That's also the one we document. This gives less porting pain for our users, and a lot less churn in our API, as we use QList in Qt 5 in 95% of our API. In addition, it gives more consistent naming with QStringList and QByteArrayList and disambiguates QList vs QVector(2|3|4)D. Fixes: QTBUG-84468 Change-Id: I3cba9d1d3179969d8bf9320b31be2230d021d1a9 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QRect(F): remove deprecated functionsChristian Ehrlicher2020-06-202-38/+0
| | | | | | | They were deprecated since Qt5.0 so it's time to go away. Change-Id: Ib0192f9048ff15c9d47fb1a23046ccfe0ee7d807 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Port Q_STATIC_ASSERT(_X) to static_assertGiuseppe D'Angelo2020-06-194-11/+11
| | | | | | | | | | | | | | | | | There is no reason for keep using our macro now that we have C++17. The macro itself is left in for the moment being, as well as its detection logic, because it's needed for C code (not everything supports C11 yet). A few more cleanups will arrive in the next few patches. Note that this is a mere search/replace; some places were using double braces to work around the presence of commas in a macro, no attempt has been done to fix those. tst_qglobal had just some minor changes to keep testing the macro. Change-Id: I1c1c397d9f3e63db3338842bf350c9069ea57639 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Cleanup float-equal warningsLars Knoll2020-06-172-6/+2
| | | | | | | | Consistently use the macro from qcompilerdetection.h instead of manually disabling the warning for three different compilers. Change-Id: Id59d30047c8a504e1082d7e47c02f4746fddf9d6 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Port remaining usages of QStringRef in QtCore to QStringViewLars Knoll2020-06-123-16/+6
| | | | | | Task-number: QTBUG-84319 Change-Id: If77bc94c18e8d522b4577050091cd7d7aa941311 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Long live std::pair!Giuseppe D'Angelo2020-06-104-353/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Make QPair an alias for std::pair, and qMakePair just a forwarder towards std::make_pair. Why? Fundamentally to ditch a bunch of NIH code; gain for free structured bindings, std::tuple and std::reference_wrapper compatibility, and so on. Breakages: * Some that code manually forward declares QPair. We don't care about it (<QContainerFwd> is the proper way). * Some code that overloads on std::pair and QPair. Luckily it's mostly centralized: debug, metatypes, testing macros. Just remove the QPair overload. * Usages of qMakePair forcing the template type parameters. There are a handful of these in qtbase, but only one was actually broken. * std::pair is NOT (and will never likely be) trivially copiable. This is agreed to be a mistake done by practically all implementations in C++11, can can't be fixed without breaking ABI. Some code using QPair assuming it's trivially copiable may break; exactly one occurrence was in qtbase. * QMetaType logic extracts the type names in two different ways, one by looking at the source code string (e.g. extracted by moc) and one via some ad-hoc reflection in C++. We need to make "QPair" (as spelled in the source code) be the same as "std::pair" (gathered via reflection, which will see through the alias) when compared. The way it's already done e.g. for QList is by actually replacing the moc-extracted name with the name of the actual type used in C++; do the same here. On libc++, std::pair is actually in an inline namespace -- i.e. std::__1::pair; the reflection will extract and store "std::__1::pair" so we need an ad-hoc fix to QMetaType. [ChangeLog][QtCore][QPair] QPair is now an alias to std::pair, and does not exist as a class in Qt any more. This may break code such as functions overloaded for both QPair and std::pair. Usually, the overload taking a QPair can be safely discarded, leaving only the one taking a std::pair. QPair API has not changed, and qMakePair is still available for compatibility (although new code is encouraged to use std::pair and std::make_pair directly instead). Change-Id: I7725c751bf23946cde577b1406e86a336c0a3dcf Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Q(E)SDP: add get()Giuseppe D'Angelo2020-06-102-0/+21
| | | | | | | | | | [ChangeLog][QtCore][QSharedDataPointer] Added get() for STL compatibility. [ChangeLog][QtCore][QExplicitlySharedDataPointer] Added get() for STL compatibility. Change-Id: I1acb3b4f4bd70842ed53f6437be10404b67d9909 Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* Ensure left/right/mid behave in a compatible wayLars Knoll2020-06-093-33/+36
| | | | | | | | | | | | | | | | | | | | QString and QStringRef did bounds checking for left/right/mid, whereas QStringView was asserting on out of bounds. Relax the behavior for QStringView and do bounds checking on pos/n as well. This removes a source of potentially hidden errors when porting from QStringRef (or QString) to QStringView. Unfortunately, one difference remains, where QByteArray::left/right() behaves differently (and somewhat more sane) than QString and QStringRef. We're keeping the difference here, as it has been around for many years. Mark left/right/mid as obsolete and to be replaced with the new first/last/slice methods. Change-Id: I18c203799ba78c928a4610a6038089f27696c22e Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QArrayData: stop using std::is_literal_typeGiuseppe D'Angelo2020-06-091-10/+2
| | | | | | | | The trait is deprecated in C++17 and removed in C++20. Enforce the same meaning by using a constexpr variable instead. Change-Id: Ief13afc3f889af09094391e626037778d879c4f5 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QSsl: port a local QStringList to QDuplicateTrackerMarc Mutz2020-06-081-0/+14
| | | | | | | | | | | | Apart from a more fitting, minimal, API, QDuplicateTracker also transparently uses C++17 pmr::monotonic_buffer_resource to avoid, or at least reduce, memory allocations. The code is the first user of the collected data, so make that available by adding QDuplicateTracker::appendTo(Container&) methods. Change-Id: Ibd8810c0070db7e6b3ead6d6a569facdab88b646 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>