summaryrefslogtreecommitdiffstats
path: root/src/corelib
Commit message (Collapse)AuthorAgeFilesLines
* Fix documentation warningsVolker Hilsheimer2020-10-243-37/+25
| | | | | | | | | Declare hidden friends like qdoc expects them, and other signature fixes Document function parameters Remove documentation for removed APIs. Change-Id: I44c1caeed0d40be04612129d074acc30b75f5259 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Make QSharedPointer comparisons hidden friendsAllan Sandfeld Jensen2020-10-232-122/+70
| | | | | | | | Doesn't touch qsharedpointer.h which already seems outdated and needs a general overhaul. Change-Id: I051cdeb1fe03a7ef16e333a483bb68e2fada3c25 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QList/QVLA: fixup the docsGiuseppe D'Angelo2020-10-232-8/+8
| | | | | | | | | I'm not 100% sure that qdoc needs this, but in case it does, here's the commit. Change-Id: Ia3e17a56fd5df766c250f4875ba5e19e12b98d11 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* QList/QVLA: default the parameter for indexOf/contains/remove/etc.Giuseppe D'Angelo2020-10-232-8/+8
| | | | | | | | This allows to use list-initialization when calling these functions, for instance list.removeAll({}). Change-Id: I2828d900a44bd0bc5aea5fba4777304b09190bc9 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QList: make (last)IndexOf and contains function templatesGiuseppe D'Angelo2020-10-235-93/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There's no reason why they shouldn't be; one might want to do a lookup passing an object which is comparable with the list's value type (e.g. search with a QByteArrayView needle into a QByteArrayList haystack). Insofar we've had to add overloads to QListSpecialMethods for all these cases, which clearly doesn't scale and creates top-tier and low-tier lists. There is one downside, namely, calling QList<A>::indexOf(B) for a B for which there isn't an operator==(A, B) but only a conversion towards A. Before, B was converted only once (at call site), now it's converted at every call of operator==. In general: such types are broken and should be fixed on their own. However let's avoid a possible regression in client code, so I've left the QString overloads in QStringList in. To get there: centralize the implementation of those methods in a empty base class, which gets then inherited by QListSpecialMethods, which is inherited by QList. This is there are still special methods that may want to overload contains, e.g. QStringList which also passes a case sensitivity). The only breakages comes from code that was already broken, for instance mixing signed and unsigned types, and the beauty of this is that now we *detect* that instead of silently ignoring. QVLA and other QList methods will be tackled in future commits. [ChangeLog][QtCore][QList] The indexOf, lastIndexOf and contains methods now take an object of any datatype -- and not just the list's own value type. This allows for heterogenous lookup in QLists. Change-Id: Ib34812217eb2b0f926fad1fc195b33758196941c Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Remove usage of deprecated QStandardPaths::DataLocationKarsten Heimrich2020-10-233-25/+12
| | | | | | | | | * Rearrange the documention to match the enumeration order. Fixes: QTBUG-87037 Change-Id: Iad001351e0f309e694b8bbd503813017e6586a21 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* Doc: Add porting Guide for QRegExpKarsten Heimrich2020-10-231-0/+251
| | | | | | Fixes: QTBUG-87101 Change-Id: I370c79e295489f4eaf8418bbd53b326f0a8e5123 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* Make Q(Multi)Map equality operators documentation-friendlyVolker Hilsheimer2020-10-232-3/+16
| | | | | Change-Id: I1a84c437bb19dd3c667596c59e1404bbbf39978e Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Fix documentation for QVariantRef and QVariantPointerVolker Hilsheimer2020-10-231-10/+10
| | | | | Change-Id: I86b749ec14876df98d5d873cf2274facea49f0c5 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Doc: Fix documentation warnings for QProperty and related classesTopi Reinio2020-10-231-128/+43
| | | | | | Task-number: QTBUG-86295 Change-Id: I547f4cf34d9721f56ba1cd665218f66597ffbb5c Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Deprecate QVariant::TypeLars Knoll2020-10-2314-135/+162
| | | | | | | | | It's been obsolete for a long time already. Make sure the compiler now warns about it and remove all remaining uses in qtbase. Change-Id: I0ff80311184dba52d2ba5f4e2fabe0d47fdc59d7 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Do not store non relocatable types in QVariants internal storageLars Knoll2020-10-232-4/+7
| | | | | | | | | | | This mostly reverts change 76e8e8e9c8093f093cb9f37d61d273f43398fefb. The reason is that storing non relocatable types inline in QVariants storage would implicitly make QVariant non relocatable. Fixes: QTBUG-87686 Change-Id: I2a09b1dcdd907d60085dccf17f987086dcba878c Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Make some QMetaType members constexpr and inlineLars Knoll2020-10-232-35/+35
| | | | | | | | | Since QMetaType::fromType() is constexpr, it makes sense to also make some of it's members constexpr. Change-Id: Ia2d63a904abb680ed63c1f88cb68f1d0309d029c Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Rename the QMetaType::MovableType flag to RelocatableTypeLars Knoll2020-10-232-3/+7
| | | | | | | Keep this in sync with the changes we have done in QTypeInfo. Change-Id: Iaacb0f3cc5c46d3486084a1f6eca480a233d5e1a Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Support Java style iterators for QMultiHashLars Knoll2020-10-232-134/+65
| | | | | | | | | Take the opportunity to clean up the implementation for QHash and use the standard macro there instead of an inlined copy. Fixes: QTBUG-86986 Change-Id: Iea846ca97bd8b9be5d6534b31d4c7707fd1a53e1 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Make QPointer comparisons hidden friendsAllan Sandfeld Jensen2020-10-231-40/+22
| | | | | | | Reduces ADL noise. Change-Id: Id0aa4b32b7bb6d70ed9106b949452d895d9060a9 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QRectF/QPointF/QSizeF: document that operator== and != are fuzzyGiuseppe D'Angelo2020-10-233-8/+37
| | | | | | | | | | This has been the case for a _very_ long time, and I can't believe this hasn't been documented anywhere. Change-Id: Ib157edf14e87a6f546c155496f70a760ab218cca Pick-to: 5.15 5.12 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* qWaitFor: check predicate before sleepingMorten Johan Sørvig2020-10-221-4/+3
| | | | | | | | | | | | | | | | Return immediately if processing events caused the predicate to become true. This gives us a nice speedup on tests with call qWaitForWindowExposed() or qWaitForWindowActive(), for example tst_QGraphicsView::itemsInRect_cosmeticAdjust: cocoa 1164ms -> 825ms ~30% decrease offscreen 296ms -> 15ms ~95% decrease Change-Id: Ifbab0ca662c082e7dfb609d0cb4bc1161709067b Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Fix documentation for QIterable and related classesVolker Hilsheimer2020-10-231-81/+80
| | | | | | | | Correctly specify template parameters, fix typos, add \fn where missing, explicitly specify scope in see-also references. Change-Id: I8b04a2b76033b206098e816d1d07d105b838c260 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Fix documentation for hidden friend operatorsVolker Hilsheimer2020-10-2311-177/+80
| | | | | | | | At least for qdoc, hidden friends are class members. Change-Id: I6eaa21565937cd49c0905ee47b8b82b0c1765bc1 Reviewed-by: Topi Reiniö <topi.reinio@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Use parameter_type in QList methodsAndrei Golubev2020-10-222-24/+24
| | | | | | | | | QList::parameter_type is defined and used to give better performance e.g. for arithmetic types. Let's use it consistently in QList API instead of const T & Change-Id: I2e12bd83f55679b55a14fbb23ab6172a9cf7bbcc Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Use American "canceled" in QPromise docsAndrei Golubev2020-10-221-5/+5
| | | | | Change-Id: I4c416f52c7102750a77c3f91274dd0a235569d6e Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Make QLatin1Char and QChar comparisons hidden friendsAllan Sandfeld Jensen2020-10-221-38/+44
| | | | | | | Reduces the ADL noise on missing comparisons errors. Change-Id: I16a17d73504917feb25a94053bb54db0b083118b Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Make QEvent::setAccepted() virtual; set QEventPoints state the sameShawn Rutledge2020-10-222-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | In Qt Quick, when we deliver an item-specific QTouchEvent that contains only the subset of eventpoints that are inside the Item's bounds, traditionally the Item can accept the event to tell the delivery logic that the event is handled and doesn't need to be delivered further. But an Item cannot be expected to have total scene awareness; so now, the delivery is "done" only when all eventpoints in the original event are accepted. This behavior has been working well enough already due to logic in QQuickWindow that iterates the points and accepts them if the event is accepted; but it seems appropriate to move this enforcement into QPointerEvent itself. Making setAccepted() virtual gives us a useful degree of freedom. Event-handling code should alternatively use QEventPoint:setAccepted() or QPointerEvent::setExclusiveGrabber() to take resonsibility for only a subset of the touchpoints. Another way to put it is that we treat QPointerEvent::setAccepted() as a convenience method: accepting the QEventPoints is what counts (at least in Qt Quick). Change-Id: Icec42dc980f407bb5116f5c0852c051a4521105a Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QList docs: fix signature of removeAllGiuseppe D'Angelo2020-10-221-1/+1
| | | | | Change-Id: Ic52b6d9ab4b250dc931c650c6def35c18803ba43 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* name our glib event sources to ease debuggingAndreas Buhr2020-10-221-9/+13
| | | | | | | | | | | glib event sources can have a name, but it is not required. Internal to glib, it is common to give them a name, see for example https://git.io/JTZ8g . This patch gives a name to each glib event source created in qtbase. Task-number: QTBUG-84291 Change-Id: I4f04526dcec082242312e3a66da2adf37a22e626 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* Whitespace cleanup in corelib/globalAllan Sandfeld Jensen2020-10-2116-106/+142
| | | | | Change-Id: I087d7d949cfd43e48e8a008621a4eeaa9d104ceb Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix locale look-up when language is unspecifiedEdward Welbourne2020-10-211-6/+15
| | | | | | | | | | | Looking up a locale with unspecified language got the C locale, due to taking a short-cut that would make sense if no locale were found for a specified language. Stop assuming the language was specified. Task-number: QTBUG-74287 Pick-to: 5.15 5.12 Change-Id: I8b3c232da584fb187ebb6c190729c377d0083808 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Fix compilation when using -no-mimetype-databaseHelio Chissini de Castro2020-10-211-0/+4
| | | | | | Change-Id: I4f706a26d73f61e4a6022338e0fc0be48627e4a1 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: David Faure <david.faure@kdab.com>
* Make QPoint*, QSize*, and QRect* binary operators hidden friendsAllan Sandfeld Jensen2020-10-214-243/+102
| | | | | | | | | | | | Moves them to class scope, which will avoid them showing up as possibilities in error messages for missing operators. Also consolidates how they are compared, so QRectF and QSizeF act similar to QPointF. Change-Id: I1e12cb7e5a5c65e85c32281878da03c6136c17de Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Whitespace cleanup in corelib/ mimetypes, plugin and threadAllan Sandfeld Jensen2020-10-2128-83/+78
| | | | | | | Done with selective application of clang-format Change-Id: Iee6bf2426de81356b6d480629ba972f980b6d93d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Whitespace cleanup in corelib/toolsAllan Sandfeld Jensen2020-10-2125-220/+349
| | | | | Change-Id: Ibe796c398a8e5488b7203abb07aa54740744f1ab Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QEvent copy constructor: copy the type flags tooShawn Rutledge2020-10-211-6/+3
| | | | | | | | | | | | | Failure to copy m_inputEvent and m_pointerEvent actually left them uninitialized, and resulted in random behavior in Qt Quick when Flickable clones a pointer event for later replay. Remove the comment about copying events being a "bad idea" in Qt 4, while we're at it. Copying became more common in Qt 5, and we probably won't be able to stop doing it now. Change-Id: I40b6ba5ad696e7aaafbeefbca86eca00cab40616 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QRandomGenerator: add 64-bit bounded() versionsThiago Macieira2020-10-202-2/+152
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Unlike the 32-bit version, we can't go to a bigger integer type to do the multiplication with. So instead accept looping. Both libstdc++ and libc++ implement std::uniform_int_distribution this way anyway, but in a far more complex way. There is no looping if the "highest" is a power of two. The worst-case scenario is when "highest" is one past a power of two (like 65). In that case, we'll loop until the number is in range. Since all bits have equal probability of being zero or one, there's a 50-50 chance that the most significant useful bit will be set[*], in which case we'll need to loop and we again get the same probability. So on average, we only need two iterations to get an acceptable result. [*] There's also a possibility that the other bits are such that the number is still in range. For 65, we'd need the other 5 bits to be zero (64 is a valid result), but the probability of that is only 1/2^5 = 3.125%. The bigger "highest" is, the closer we get to zero, so approximate by saying that never happens and instead calculate that the most significant useful bit is the controlling one. [ChangeLog][QtCore][QRandomGenerator] Added 64-bit versions of the bounded() functions. They are useful in conjunction with Qt 6's 64-bit container sizes, so code that used to call bounded(list.size()) in Qt 5 will continue to compile and work in Qt 6. Fixes: QTBUG-86318 Change-Id: I3eb349b832c14610895efffd16356927fe78fd02 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Fix compiler warning from uninitialized membersVolker Hilsheimer2020-10-211-1/+1
| | | | | | | | | | | | When building tst_qmetatype.cpp, clang generates the warning that class 'AlignmentDummy' does not declare any constructor to initialize its non-modifiable members Turn the class into a struct, which doesn't generate such warnings. Change-Id: I61013a10418238a11824b18ff1e927bbafa46ec2 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix qdoc warnings from QMutex and QMutexLockerVolker Hilsheimer2020-10-211-20/+7
| | | | | Change-Id: I25faab16ad2df3682e6c6b55d4aaff1c20402995 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Whitespace cleanup in corelib/iov6.0.0-beta2Allan Sandfeld Jensen2020-10-2018-224/+224
| | | | | | | | | Selective application of clang-format to follow our coding style where it is significantly off. Change-Id: I0ff4ed146fe53922691d5473d0c236f31d478a04 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Convert QList alias definitions to 'using'Andrei Golubev2020-10-202-35/+37
| | | | | | | | | | | | Modern syntax for type aliases looks much nicer and is easier to read. Additionally, QDoc is able to generate better documentation for 'using' based aliases. Also, aliases are simplified for QDoc Task-number: QTBUG-86553 Change-Id: I44932fbd94f32c1463eafedd1b48c1e840b697e3 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix QDoc warnings for QList/QVectorAndrei Golubev2020-10-203-19/+40
| | | | | | Task-number: QTBUG-86553 Change-Id: Iac944c78640bfcfb6ee137c0ef3dd89387700b4c Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Use qmetaobject_p.h's MetaObjectFlag in QMetaObjectBuilderEdward Welbourne2020-10-203-13/+7
| | | | | | | | This saves duplicating them with its own flags. Task-number: QTBUG-85700 Change-Id: I9e938322fd787282cfd9f941f83af8c0d76aaa9d Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Drop constexpr from QAtomicTraits::isLockFree()Edward Welbourne2020-10-201-19/+17
| | | | | | | | | As requested by a ### Qt 6 comment. This then implied a few other functions weren't constexpr, which broke some tests. Task-number: QTBUG-85700 Change-Id: I6522a9b2d7a74e117442121400a1d7198d323967 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QList::removeOne: make it generic as wellGiuseppe D'Angelo2020-10-202-2/+3
| | | | | | Change-Id: I0c50b2ae76f9d0f053b3d5b1ab98d12e0524e419 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QList::removeAll: make it genericGiuseppe D'Angelo2020-10-201-3/+11
| | | | | | | | | | | | | | | | | | | | This is a bit more tricky than expected because we support passing references to objects that are into the list itself (for instance, list.removeAll(list.front())). For those objects we have to take copies. This is fine, but the moment we make the function generic, that's going to fail when passing arguments of types that cannot be copied, such as arrays (e.g. stringList.removeAll("hello")). For those, keep a reference, as they cannot be aliases into the list anyhow. [ChangeLog][QtCore][QList] The removeAll and removeOne methods now take an object of any datatype -- and not just the list's own value type. This allows for heterogenous removal inside QLists. Change-Id: I0c447770bbc7ff0ff4bb4c0e35081414c5ff963e Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QFileSystemWatcher: use nullptr, instead of 0Giuseppe D'Angelo2020-10-201-1/+1
| | | | | | | | | I'm not sure why this hasn't been flagged so far, probably we don't have this warning enabled on MSVC. Task-number: QTBUG-87713 Change-Id: I97c65079c8f8e439645ff7fe75eede9b01b26166 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QThread::create: mark as [[nodiscard]]Giuseppe D'Angelo2020-10-201-2/+2
| | | | | | | Also mark the helper function. Change-Id: I1469abf22cd132dbb1afe680121b6c928ffbe41e Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QAssociativeIterable: Unwrap variants on value()Ulf Hermann2020-10-191-2/+12
| | | | | | Fixes: QTBUG-87688 Change-Id: I66515eaa1217c34f003648af6423b318b54977c4 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QAssociativeIterable: Add methods to add/remove keys and valuesUlf Hermann2020-10-192-0/+60
| | | | | | | | This way we can actually modify the container. Previously the interface was rather useless. Change-Id: I278aae46999862ada115c9066a010d7de5cde4ff Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QMetaContainer: Consistently coerce typesUlf Hermann2020-10-1911-99/+88
| | | | | | | | | | | | | | | The high-level iterable interfaces should coerce the types of most QVariants passed to the expected ones. To do this, move the type coercion code into qvariant.{h|cpp} so that it is available to the QVariantRef specializations. The exception are variants passed to the find() functions of associative iterables. Here, we should not coerce values we cannot convert to the default-constructed keys. Instead we return end() in such cases. Fixes: QTBUG-87687 Change-Id: I0bd4e5c4e4e270dd3bf36cb3fb115794828077f2 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QLocale: do the inlining in the class body to save repetitionEdward Welbourne2020-10-191-36/+17
| | | | | | | | It also makes it easier to find the definition when looking at the declaration. Change-Id: Idae18d3881f3cf8ba6c6c7e48201ec925815013e Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Refine QLocale constructor documentationEdward Welbourne2020-10-191-1/+2
| | | | | | | | Clarify that the "minus sign" is a plain ASCII U+002D dash, not U+2212 minus sign; and, for symmetry, that the underscore is U+005F. Change-Id: I7250959d36e56f960dac24a739a1a8826a6bc578 Reviewed-by: Paul Wicking <paul.wicking@qt.io>