summaryrefslogtreecommitdiffstats
path: root/src/corelib/global
Commit message (Collapse)AuthorAgeFilesLines
* Fix build with GCC 11: include <limits>Thiago Macieira2021-01-192-2/+5
| | | | | | | Fixes: QTBUG-90395 Pick-to: 6.0 Change-Id: Iecc74d2000eb40dfbe7bfffd165b5dd3708b7a40 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Mark qBadAlloc as [[noreturn]]Giuseppe D'Angelo2021-01-192-1/+5
| | | | | | | | | | | | So that static analyzers don't get confused by its semantics. In builds with exceptions disabled, it's not actually called by client code (e.g. Q_CHECK_PTR will just terminate in that case), but we still need to make it not return -- add another path that callss std::terminate(), otherwise we'd have a noreturn function returning. Change-Id: Ia8c4ce3e9d971f1757e9c273051cb3dedf23c61f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Update QOperatingSystemVersion version names for AndroidAssam Boudjelthia2021-01-192-0/+40
| | | | | Change-Id: I88c7713cd75f84d11b303e0dad2093c7d5568bc4 Reviewed-by: Andy Shaw <andy.shaw@qt.io>
* Fix XCB launch key mappingAllan Sandfeld Jensen2021-01-152-19/+20
| | | | | | | | | | | | | They have been reported wrong since Qt 4, and not fixed for behavior compatibility, fixing it for Qt 6. [ChangeLog][X11] XF86LaunchXX keys have been remapped, so the Qt names and X11 names match, instead of being 2 off. Pick-to: 6.0 Fixes: QTBUG-25261 Change-Id: Ie3a8676439ae3e93a78218c9e7f4443565e84356 Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io>
* Extend qIsInf() and friends to handle integral types sensiblyEdward Welbourne2021-01-151-1/+14
| | | | | | | | | [ChangeLog][QtCore] qIsInf(), qIsNaN() and qIsFinite() now, like std::isinf() and friends, accept integral types (returning false, false and true, respectively) as well as floating-point ones. Change-Id: I1e2b7f033f0e8166c0b21e31a62b3e6d37b9344a Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* If available, use a version-specific qt<major-version>.confRalf Habacker2021-01-141-1/+4
| | | | | | | | | | | To enable the current Qt version to use a qt.conf that is independent from the previous version, a file named 'qt<major-version>.conf' is searched for first. If this file does not exist, a file with the name 'qt.conf' is searched for. Task-number: QTBUG-88635 Change-Id: If75b63f72a7bdbdf1de7729ea4ecb00810b58d12 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* Assert that wchar_t's size matches one of the unicode character typesEdward Welbourne2021-01-081-0/+2
| | | | | | | This is assumed in various places, so best checked explicitly. Change-Id: I475dcf5cbb60c0272dec560acd2893cff73872ce Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Remove the qmake project filesJoerg Bornemann2021-01-071-132/+0
| | | | | | | | | | | | | | | | Remove the qmake project files for most of Qt. Leave the qmake project files for examples, because we still test those in the CI to ensure qmake does not regress. Also leave the qmake project files for utils and other minor parts that lack CMake project files. Task-number: QTBUG-88742 Change-Id: I6cdf059e6204816f617f9624f3ea9822703f73cc Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Kai Koehne <kai.koehne@qt.io>
* Add version() to QOperatingSystemVersionLars Schmertmann2020-12-282-4/+19
| | | | | Change-Id: I6c7f0616d52b0d118ffd8c031f3f51212b8ed821 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* macos: Document that Drawer is obsoleteMorten Johan Sørvig2020-12-211-0/+2
| | | | | | | | | | This feature is not much used on modern macOS, and Qt 5 has never supported it. Pick-to: 5.15 6.0 Change-Id: I9de195aaf7df954b63f0f816e93c91e870ef5852 Reviewed-by: Andy Shaw <andy.shaw@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Use QDeadlineTimer in qlogging.cppThiago Macieira2020-12-091-3/+2
| | | | | | | No change, just shorter code. Change-Id: I25d85d86649448d5b2b3fffd1450f95b0ec66927 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Add uninitialized constructor to qfloat16Allan Sandfeld Jensen2020-12-072-0/+9
| | | | | Change-Id: Ifc1fa97168927dac96e749b5dcb2a0a38b158b12 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Make the overflow math functions publicUlf Hermann2020-12-073-235/+374
| | | | | | | | | | | | As the standard library does not provide equivalent functionality, those functions are really useful to everyone, not only to Qt itself. [ChangeLog][QtCore] The overflow-safe math functions qAddOverflow(), qSubOverflow(), qMulOverflow() were added. Change-Id: I5a0a4742dae9b6f0caa65d0e93edcf3658bee9f8 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Add test for qRoundDavid Skoland2020-12-021-0/+8
| | | | | | | | | Add test for qRound that covers some edge cases for rounding. Note that as of right now, this test fails and the docs have been updated to warn that it should not be depended on for strict correctness. Change-Id: I1a61bca47abd77855fe7c13ded44e913cc7e8722 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Fix documentation of QPartialOrderingAndreas Buhr2020-12-011-16/+6
| | | | | | | | | | | | | | | | qdoc did not find the hidden friend comparison functions at gave errors like qcompare.qdoc:82: (qdoc) warning: clang couldn't find function when parsing \fn bool operator==(QPartialOrdering p1, QPartialOrdering p2) noexcept This patch documents them as if they were class members to fix this. Document the constants as \variables. Task-number: QTBUG-88533 Pick-to: 6.0 Change-Id: Ife56f16894e454f324060aeb73f66aba2d45e530 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Extend container overview documentation, mention Q_DECLARE_TYPEINFOAndreas Buhr2020-11-301-3/+10
| | | | | | | | | | | | The container overview documentation did not mention Q_DECLARE_TYPEINFO and the related optimizations. This patch adds a short paragraph about it. Task-number: QTBUG-86584 Pick-to: 6.0 Change-Id: I5b0b8ce92a47da5f0398cc413fbf3e07b0921e59 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* Fix QVariant/QMetaType::compare APIsGiuseppe D'Angelo2020-11-303-0/+291
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | std::optional<int> is the wrong datatype to use for compare. First and foremost, it can't be used in the idiomatic form of auto r = a.compare(b); if (r < 0) ~~~ // a is less than b if (r > 0) ~~~ // a is greater than b which we *already* feature in Qt (QString, QByteArray). Also, std::optional<int> (explicitly) converts to bool, which is a trap, because the result of the comparison can be accidentally tested as a bool: if (a.compare(b)) ~~~ // oops! does NOT mean a<b Not to mention extending this to algorithms: auto lessThan = [](QVariant a, QVariant b) { return a.compare(b); }; // oops! std::ranges::sort(vectorOfVariants, lessThan); which thankfully doesn't compile as is -- std::optional has an *explicit* operator bool, and the Compare concept requires an implicit conversion. However, the error the user is going to face will be "cannot convert to bool because the operator is explicit", which is deceiving because the fix is NOT supposed to be: auto lessThan = [](QVariant a, QVariant b) { return (bool)a.compare(b); }; // big oops! Instead: backport to Qt the required subset of C++20's <compare> API, and use that. This commits just adds the necessary parts for compare() (i.e. partial ordering), the rest of <compare> (classes, functions, conversions) can be added to 6.1. Change-Id: I2b5522da47854da39f79993e1207fad033786f00 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit 3e59c97c3453926fc66479d9ceca03901df55f90) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Replace discouraged Q_MOVABLE_TYPE by Q_RELOCATABLE_TYPEAndreas Buhr2020-11-303-5/+5
| | | | | | | | | | | | | | Q_MOVABLE_TYPE was conceived before C++ had move semantics. Now, with move semantics, its name is misleading. Q_RELOCATABLE_TYPE was introduced as a synonym to Q_MOVABLE_TYPE. Usage of Q_MOVABLE_TYPE is discouraged now. This patch replaces all usages of Q_MOVABLE_TYPE by Q_RELOCATABLE_TYPE in QtBase. As the two are synonymous, this patch should have no impact on users. Pick-to: 6.0 Change-Id: Ie653984363198c1aeb1f70f8e0fa189aae38eb5c Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* Update setHighDpiScaleFactorRoundingPolicy docsTor Arne Vestbø2020-11-271-2/+1
| | | | | | | | | | | The default is now passthrough. And let's not mention the environment variable overrides, as they are meant for internal testing. Pick-to: 6.0 Pick-to: 6.0.0 Change-Id: Ie2409e5411d4bdcdf041834cb5ca9e1215aa173a Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* Re-fix the definition of primitive typesGiuseppe D'Angelo2020-11-241-1/+1
| | | | | | | | | | | The conditions are AND, not OR. Technically we don't rely on not having constructors any more, but we may reserve the right in the future to have uninitialized resizes. Change-Id: Icfae61079a544f7ac8e90a32ad605c12cfa8b4aa Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit bcd38a96149f5397375b57e948c05c7a8f172194) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Replace qt_make_unique with std::make_uniqueAllan Sandfeld Jensen2020-11-232-72/+0
| | | | | | | We can depend on C++14 now. Change-Id: Iee9796cd22dbfbb70d4bdb25f0eee1662a026d6d Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Drop a [[maybe_unused]] on a variableGiuseppe D'Angelo2020-11-231-1/+1
| | | | | | | Turn it into an inline variable. Change-Id: I491bd8fee3d25f814587db5a1047f15990081d66 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Add deprecation warnings for 6.1Giuseppe D'Angelo2020-11-201-0/+8
| | | | | Change-Id: I8e78f29f338670078488247f233b99125eabb4b6 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Centralize the wchar_t == char16_t check on WindowsGiuseppe D'Angelo2020-11-181-0/+3
| | | | | | | | Don't push it onto every TU that includes QChar (... approx. everything that uses Qt). Change-Id: I4a07ce9e38a347b45315db93b0c5b90c20bacdbc Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Get rid of Q_COMPILER_CONSTEXPR checksAllan Sandfeld Jensen2020-11-172-10/+2
| | | | | | | Is required now. Change-Id: I62e95929d1649ea1390392230b619bd56d2a0349 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Don't initialize POD types with memset(0)Lars Knoll2020-11-171-4/+2
| | | | | | | | | This is dangerous as at least pointers to member objects/data are not always zero initialized. Change-Id: I1250e101ab73cd816694315fc9130f4d486b9feb Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Adjust code format, add space after 'if'Zhang Sheng2020-11-161-1/+1
| | | | | | Change-Id: Ice081c891ff7f4b766f49dd4bd5cf18c30237acf Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io> Reviewed-by: hjk <hjk@qt.io>
* Optimize qRoundAllan Sandfeld Jensen2020-11-161-0/+24
| | | | | | | | | These variants produce the same code as if std::round was compiled with -ffast-math. Change-Id: I8e0d7601928a511b9bc8b8f969cfd94df47c3784 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QFileInfo: mark constructors as explicitGiuseppe D'Angelo2020-11-151-2/+2
| | | | | | | | | | | | | | | | | | | | | | | These look like leftovers (API flaws). Construction of QFileInfo from QString (or similar) should be not implicit, as QFileInfo construction is expensive (might hit the file system), and this may have users overlook APIs (for instance build a QFileInfo out of QDirIterator::next(), instead of using ::fileInfo(); using QDir::entryList instead of entryInfoList; etc.). Leave an opt-out mechanism to ease porting. Fix a handful of usages around qtbase, with at least a couple of them likely to be actual "sloppy" code. [ChangeLog][Potentially Source-Incompatible Changes][QFileInfo] Most QFileInfo constructors are now explicit. The QT_IMPLICIT_QFILEINFO_CONSTRUCTION macro is provided to keep old code working. Change-Id: Ic580e6316e67edbc840aa0c60d98c7aaabaf1af6 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Q_PRIMITIVE_TYPE: improve the documentationGiuseppe D'Angelo2020-11-091-2/+3
| | | | | | | | | | | | | A key piece of information missing from Q_PRIMITIVE_TYPE documentation is that for them value initialization must equal memset()ting with zeroes. A type like QPoint is primitive because `QPoint p;` is initialized to (0, 0), but a type like QSize is movable (and NOT primitive) because `QSize s;` is actually initialized to (-1, -1). Amend the docs. Change-Id: I121684810da46be5d0579c7d3de945149390a32a Pick-to: 5.15 5.12 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* qglobal: Only define QT_ENSURE_STACK_ALIGNED_FOR_SSE for i386Martin Storsjö2020-11-041-1/+1
| | | | | | | | | | This define is only supposed to be used for i386, but was set for any 32 bit mingw architecture (which also covers armv7). Change-Id: Iedc057dfc493015e8339db837dbe20a57c2b2367 Pick-to: 5.15 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Cleanup container declarations in qtypeinfo.hLars Knoll2020-11-031-20/+3
| | | | | | | | | | | Use variadic templates to avoid having to use several macros to declare movable containers. Add missing movable declaration for QCache. Change-Id: I32d6a399ef8e6c39021df04deedfbbf0c526fc84 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Rename QContainerTraits namespace to QContainerInfoLars Knoll2020-11-031-1/+1
| | | | | | | | | | | | We'll need QContainerTraits as a class for changing properties of our containers, so free up that name. This is not a problem, as the namespace is new in Qt 6 and has only been used internally so far. Change-Id: I6d6b9d9c32b92b77e66323f1fc29b3ddd8baa98f Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Code cleanupsLars Knoll2020-11-031-7/+7
| | | | | | | Mark constexpr booleans as inline. Change-Id: Ib7e0f9d96ff3894b72dcd13c07643ef3b9e6e2c5 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Do not #define dynamic_castGiuseppe D'Angelo2020-11-021-13/+0
| | | | | | | | | | | | | It's illegal. [macro.names]/2: "A translation unit shall not #define or #undef names lexically identical to keywords" If someone tries to use dynamic_cast in a no-rtti scenario, let's just have the compiler yell at them for that. Change-Id: I70a7b55a93d34c433e874d379acae8b256620f80 Pick-to: 5.15 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Resolve corelib's remaining ### Qt 6 commentsEdward Welbourne2020-11-021-1/+1
| | | | | | | | | | | | | No action taken at Qt 6, suggesting it shall never happen. Four removed, one converted to Qt 7, others converted to unversioned TODOs. Filed Jira tasks, and referenced in comments, for those retained. There remain two "once bootstrap builds are obsolete" comments and one other on which pending action may yet happen. Fixes: QTBUG-85700 Change-Id: Ib140a6a21c63370e51e4734cc591f67573a29d9a Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Warn if Q_FOREACH is used with a non-shared containerOlivier Goffart2020-11-021-0/+14
| | | | | | | | Show a deprecation warning if a non shared container is used within Q_FOREACH, because it would make an expensive copy of the container Change-Id: I70cfd789b5b8d9f5b1bd6e0a57e5e968e1c6a0ca Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* Remove Q_IS_ENUMAllan Sandfeld Jensen2020-10-302-52/+0
| | | | | | | Deprecated since 5.8 already. Change-Id: I01ea32b5f4b922cecb18c5760a1b5fa49c4e54c0 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Doc: Fix link issues for QtCoreTopi Reinio2020-10-291-2/+2
| | | | | | | | | - Fix linking to CMake manual. - Remove references to the state machine framework. Task-number: QTBUG-86295 Change-Id: I01a61088da8eb36760949f39be5e71d92de956f2 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* qfloat16: make comparison and arithmetic operators hidden friendsVolker Hilsheimer2020-10-291-82/+84
| | | | | | | | Reduce ADL noise. The operators are not documented, so nothing to adjust. Change-Id: I02a8bdad6138758106283495098c72770ea74e52 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Remove QT_NO_FLOAT16_OPERATORS macroVolker Hilsheimer2020-10-282-18/+2
| | | | | | | | | It's documented to be a workaround for VC++2017 and earlier, which are all not supported in Qt 6 anymore. VC++2019 does not show the problem. Change-Id: Ie66b303a75bb5791675fc9e62bf4a84510068d6d Reviewed-by: Keith Kyzivat <keith.kyzivat@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Expunge WA_GroupLeaderShawn Rutledge2020-10-272-4/+0
| | | | | | | | | It's been deprecated since Qt 4.1. Task-number: QTBUG-85816 Change-Id: Iafc6340716556f54fc5472c60035bb57461b842f Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Replace see-alsos in qfloat16 documentation with \overloadVolker Hilsheimer2020-10-262-23/+19
| | | | | | | | | | | Explicitly specify the float-overload, otherwise it's just ends up referring to itself, and won't generate a link. Also document qFpClassify(qfloat16) overload. The internal implementation was documented, but the public overload not. Change-Id: Ifdc364597a0e7b4d943f0ec6d149977a15c805ef Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Remove documentation for removed QFlags constructorVolker Hilsheimer2020-10-261-10/+0
| | | | | Change-Id: I407392d8d92da2ebcfc2cb8050155ab44ba1f0ff Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Fix documentation for hidden friend operatorsVolker Hilsheimer2020-10-232-6/+3
| | | | | | | | 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>
* Whitespace cleanup in corelib/globalAllan Sandfeld Jensen2020-10-2116-106/+142
| | | | | Change-Id: I087d7d949cfd43e48e8a008621a4eeaa9d104ceb 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>
* Add noexcept to d-ptr accessor functionsAllan Sandfeld Jensen2020-10-191-8/+9
| | | | | | | | | | In theory this could be source incompatible with Q_DECLARE_PRIVATE on a QSharedDataPointer, but that would both be a misuse, and all places where something like that could have been used in Qt, Q_DECLARE_PRIVATE is already manually inlined. Change-Id: I60bdde3a71646129cef84f31624d0432e7af91ab Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QRandomGenerator: optimize for the common use caseThiago Macieira2020-10-182-23/+29
| | | | | | | | | | | | | The most common uses of QRandomGenerator are getting 32- and 64-bit quantities, either through the generate() and generate64() functions or by ones that call those, like bounded() or generateDouble(). So optimize for those with the same entry point by returning one 64-bit value from the _fillRange() function. Further optimize by not requiring a buffer for those two cases, which required us to replace the (begin, end) parameters with (begin, count). Change-Id: I3eb349b832c14610895efffd16356859eecd5397 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* doc: Update and flesh out native interface docsTor Arne Vestbø2020-10-181-2/+2
| | | | | | | | | The namespace and overviews are in the qtdoc repository. Docs for individual interfaces should live with their platform. Change-Id: Iba5fd7e9ebc4f1f634ec9dc3ec125ce88a1312ba Reviewed-by: Paul Wicking <paul.wicking@qt.io>