summaryrefslogtreecommitdiffstats
path: root/tests
Commit message (Collapse)AuthorAgeFilesLines
...
* QVarLengthArray: don't allow syncqt to export base classesMarc Mutz2021-12-151-1/+1
| | | | | | | | Check, in tst_qvarlengtharray, that the forwarding header still works. Pick-to: 6.3 Change-Id: Ia03cf48457f538287880bb676aea3fa44aeb255f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Use QAbstractItemModelTester in all QSortFilterProxyModel testsAndreas Buhr2021-12-141-0/+1
| | | | | | | | This patch installs a QAbstractItemModelTester in the QSortFilterProxyModel tests. Change-Id: I9bdcc21ba12f919c91c5b9514a5f4362437318c2 Reviewed-by: David Faure <david.faure@kdab.com>
* Fix qt_scrollRectInImage when scrolling outside of the imageTor Arne Vestbø2021-12-141-0/+39
| | | | | | | | | | | | | | | | | | | | | We were clipping the source rect to the image, both pre and post scrolling, but did not apply the same logic to the target position. By computing the target position based on the already clipped source rect we ensure that the target position is also correct. This was causing valgrind warnings on Linux, and crashes on Windows, when trying to test the lower level QBackingStore::scroll() function. The reason we were not seeing this in practice was that QWidget does its own sanitation and clipping of the arguments before passing them on. As a drive-by, fix the access of image to use constBits instead of a manual cast, and rename variables to better reflect their use. Pick-to: 6.3 6.2 5.15 Change-Id: Ibc190c2ef825e634956758f612a018f642f4202b Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* QHash: increase minimum buckets to a full spanLars Knoll2021-12-137-97/+97
| | | | | | | | | | | | | | Change the minimum amount of buckets to be at least 128, ie. one full Span. This will simplify some assumptions in the code. Regeneration of rcc test-data needed because the extra buckets causes the order of the keys to change. Task-number: QTBUG-91739 Task-number: QTBUG-98436 Change-Id: Ic0c7da03570cc4c4e6aacc9645e536aec3667a98 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QCache: Adapt to upcoming QHash changesMårten Nordheim2021-12-131-0/+16
| | | | | | | | | | QHash changes some of its preconditions, so we must not call findNode without verifying !isEmpty() Task-number: QTBUG-91739 Task-number: QTBUG-98436 Change-Id: I2701b9a01187530f541a7c9a12db56c92f856d87 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Tests: Use REQUIRED COMPONENTS in find_package(Qt6...)Kai Köhne2021-12-1316-28/+16
| | | | | | | | | Make sure configure fails early if a component cannot be found. Task-number: QTBUG-98867 Pick-to: 6.2 6.3 Change-Id: I4baa35a84342df58ce8932601fb602be92ed5ab9 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Rewrite Q_{GLOBAL,APPLICATION}_STATIC with C++17 goodiesThiago Macieira2021-12-121-1/+1
| | | | | | | | | | | | Especially static inline variables. This greatly reduces the amount of code that existed in macros, moving them to templates. Additionally, this removes one level of indirection from Q_APPLICATION_STATIC by removing the std::unique_ptr. We now directly manage the object's storage. Change-Id: I2cffe62afda945079b63fffd16bcc825cc04334e Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QNX: Cannot handle threads in given timePasi Petäjäjärvi2021-12-121-0/+4
| | | | | | | | Large amount of threads is unstable and do not finish in given time Pick-to: 6.2 Change-Id: I0ce4c8cd278d6611c9e9da7326048279ccc458fd Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QNX: inotify is supported, so enable testsPasi Petäjäjärvi2021-12-121-3/+3
| | | | | | | | | Also change usage of QDir::currentPath to QDir::tempPath instead as QNX tests are run on CI at qemu over NFS. Pick-to: 6.2 Change-Id: I2e1d6629299acd125117bcce90320c70eeb4a1a5 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QNX: Skip failing testPasi Petäjäjärvi2021-12-121-0/+3
| | | | | | | | | Seems to be bug in QNX itself Task-number: QTBUG-98561 Pick-to: 6.2 Change-Id: I525bd269b674e9e2b8c994bf778ab14b727df33f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QNX: Remove not supported testcasePasi Petäjäjärvi2021-12-121-1/+3
| | | | | | | | | Still not implemented Task-number: QTBUG-40785 Pick-to: 6.2 Change-Id: I9bb89ccaff30a3d906bf5665bc6ef981717aa054 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QNX: Limit maximum largefile sizePasi Petäjäjärvi2021-12-121-1/+6
| | | | | | Pick-to: 6.2 Change-Id: I4e43eaea98e893453c8c1356da63edb0c059f896 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QNX: Remove expected failPasi Petäjäjärvi2021-12-122-17/+0
| | | | | | | | Works with QCC 8.3.0 (Based GCC 8.3.0 20190222 (stable)) Pick-to: 6.2 Change-Id: I130847627a4b77ced83d196a7a1674963c5cd3e1 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QNX: Successful check depends on user running testPasi Petäjäjärvi2021-12-121-1/+1
| | | | | | | | Modify similar like is used for Windows Pick-to: 6.2 Change-Id: I133a8dde2e78cc66aa9544246cd750a6543b4883 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QtFuture::connect: exclude QPrivateSignal from the resulting future typeSona Kurazyan2021-12-111-1/+46
| | | | | | | | | | | | Filter out the last argument of type QPrivateSignal from the signal's arguments passed to QtFuture::connect(). Pick-to: 6.2 Fixes: QTBUG-92501 Change-Id: Idcd6baba1f01fcc94fa64b1c7030a629d01ed7a1 Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QVarLengthArray: deprecate prepend()Marc Mutz2021-12-112-3/+18
| | | | | | | | | | | | | | | | All Qt 6 containers have "fast" prepend these days. Except QVLA. Instead of enabling "fast" prepend for QVLA, slowing down idiomatic QVLA use, simply deprecate prepend(). There appear to be no users of this function in qtbase outside tests. [ChangeLog][QtCore][Deprecation Notices][QVarLengthArray] Deprecated prepend() because QVarLengthArray is the only Qt container without a "fast" prepend. If you require that functionality, even though it's a linear operation, then use insert(cbegin(), ~~~) instead. Change-Id: I39ff1dd7d4de7fc08d5380a5a7450dd8c8996fe2 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Fix widget gesture grabbingVolker Hilsheimer2021-12-111-0/+20
| | | | | | | | | | | | | | | | | | After 7369c31ca1f446e81eda1c93ba13767ffcd83efe, unaccepted touch points were not grabbed anymore in calls to activateImplicitTouchGrab. However, gesture recognition relies that widgets for which a gesture has been partially recognized grab also unaccepted touch points. Add a parameter to allow the implicit grabbing to take place also for unaccepted event points. Add test case that replays touch events similar to what Squish is doing, and fails without this fix. Pick-to: 6.2 Change-Id: Idb0b20301b1827be57a03013a59043d97c2ee7b6 Reviewed-by: Stefan Gehn <stefan.gehn@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* rhi: Auto-rebuild rt by tracking attachment id and generationLaszlo Agocs2021-12-101-0/+45
| | | | | | | | | | | | | | | | | | | | | | | Unlike the shader resource binding lists that automatically recognize in setShaderResources() when a referenced QRhiResource has been rebuilt in the meantime (create() was called i.e. there may be completely different native objects underneath), QRhiTextureRenderTarget has no such thing. This leads to an asymmetric API and requires also rebuilding the rt whenever an attachment is rebuilt: rt = rhi->newTextureRenderTarget({ { texture } }) rt->create() cb->beginPass(rt, ...) texture->setPixelSize(...) texture->create() rt->create() // this should not be needed cb->beginPass(rt, ...) Avoid having to do that second rt->create(). Change-Id: If14eaa7aac3530950498bbdf834324d0741a7c4d Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* QList: fix typo in QList(It, It)Marc Mutz2021-12-101-12/+0
| | | | | | | | | | | | Remove scaffolding in the test again. [ChangeLog][QtCore][QList] Fixed a regression that caused the range constructor to fail for pure input_iterator's. Pick-to: 6.2 Fixes: QTBUG-99036 Change-Id: I72d01a9c44c3862c335d96538f26a453b4c7c554 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* tst_containerapisymmetry: test ranged ctors with pure input_iterator typesMarc Mutz2021-12-091-0/+52
| | | | | | | | | | | Fails in Qt 6, succeeds in Qt 5.15, therefore needed to add the version check. Pick-to: 6.2 5.15 Task-number: QTBUG-99036 Change-Id: I9da1b2511d844b5fdcb63fdc58c8bc34d0f65736 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* TAP test logger: avoid dangling space on TODO and SKIP linesEdward Welbourne2021-12-091-1/+1
| | | | | | | | | If an incident has an empty description we produced output with a dangling space. Avoid triggering the inanity 'bot with those. Reorganise the code to save some duplication. Change-Id: I1dc29fa8ad4449a4584f11dddcf002e405cd9238 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* TAP test logger: skip XFail results as well as pass after an XFailEdward Welbourne2021-12-092-24/+0
| | | | | | | | | | The rationale for skipping pass after XFail is "to emit a single test point for" the test; emitting several XFails violates that aim. Task-number: QTBUG-96844 Change-Id: Ia8626dfc2dded234b3aa530fc2dc2324f1e28400 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Make Skip an incident in test loggingEdward Welbourne2021-12-0943-212/+315
| | | | | | | | | | | | | | | Skip ends the test (albeit inconclusively). Rearrange the enums in the abstract logger, move code to handle skip between relevant function and tidy up various things that became simpler as a result. Also reorder the message enum, and its switches, to separate testlib's internals from the usual Qt messages, and put each group in ascending order of severity. Task-number: QTBUG-96844 Change-Id: I2c7a634b9f849830d64eafa750155e66e244b729 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Match up testlib selftest's lists of generated filesEdward Welbourne2021-12-0952-1229/+421
| | | | | | | | | | | | | | | | | | | | | | | | The actual files present for expected data, the test function that selected which tests to skip and the python function to select which to not generate data for weren't in sync with one another. The test-code's reason for omitting three tests was that we lacked data files for them. So generate those and skip that exception. The generator script's code to decide which to generate didn't exclude anything like as many, so update it to match the test-code. In the process, save repeating a startswith test that was used both positively and negatively, unifying two conditions. Extend the generator script's handling of its --skip-callgrind option by auto-setting that option if valgrind isn't available, to match the driver program's similar skipping. The generated data included many files for tests we skip and, as mentioned already, lacked files for some tests we only skipped because we lacked them. Remove the unused files, add the lacking ones. Change-Id: If91696cdd95b7b0d5f3d686bff839f1bf15e121b Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Refactor QTEST*_MAIN() implementationsEdward Welbourne2021-12-099-54/+33
| | | | | | | | | | | | | | | | | | The various variants duplicated some rather complex code around varying setup in the middle. Rework in terms of a macro that defines main() and takes the setup code as a parameter. That setup code also had some common structure, so package that in a setup macro that takes the class to be used. Reworked various testlib selftests that were using QTEST_MAIN_IMPL(); change to use the new QTEST_MAIN_WRAPPER() and TEST_MAIN_SETUP(). These might be better dealt with by supporting a second form of the initMain() test-setup function in the test classes, that takes references for argc and argv, to let a test massage its command-line options. Change-Id: I7fb16b38d51c80ba2f5c9c82f3b7a37ffc636795 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Fix x86 preprocessor check in testlib selftestsEdward Welbourne2021-12-094-10/+20
| | | | | | | | | | | | | | | | | When deciding whether to run benchlibcallbrind, the code only tested _i386; it now tests __x86_64 as well, to match a recent change in the test itself. As there, reverse the test to reduce negations, flipping the stanzas it selects between. Also tidy up the code that tests for valgrind being present - and actually return true, to skip the test, when it claims to be skipping the test. Updated test results, now that the test can actually be run and produce sensible output. Added an _2.txt that matches the results presently seen in Coin on RHEL 8.4 (despite the fact that a local build on such a VM produces output matching the _1.txt results). Change-Id: Ibce09dca06a1eeb73e90fb1345834998683df9d8 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Fix argv hacking in tst_benchlibcallgrind.cppEdward Welbourne2021-12-099-85/+23
| | | | | | | | | | | | | | | | | | It unconditionally added -callgrind to its own command-line options, but the way testlib handles this argument is, in QTest::qRun(), to re-run the program under the control of valgrind --tool=callgrind, removing the -callgrind command-line option from the test and adding -callgrindchild to its command-line options. So we shouldn't re-add the -callgrind option in the resulting recursive call. The test now runs quickly, producing sensible output, where previously it took a very long time. Revised the drivers to reflect this speed-up, but continue skipping the non-.txt formats to save the need for variant-output files for many formats. To match that, removed the unused non-.txt results files. Change-Id: Iaa99c1b5964d50bccfc6076a21896791b6bbf289 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Replace a random define with a __has_include() checkEdward Welbourne2021-12-091-7/+8
| | | | | | | | | | | | | The given reason for needing to define it was that there was no way to test whether <valgrind/valgrind.h> is available to #include; but we now require C++17 hence __has_include(). However, moc doesn't seem to grok that, so move the test's #if-ery inside the test, since otherwise it gets omitted because the test's metatype doesn't know it's there. Change-Id: I75a100787b98a52fad4cfb0b047318a115c998e2 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QVarLengthArray: make reallocation strongly exception safeMarc Mutz2021-12-091-2/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The old code had several bugs: - it immediately clobbered *this with new state, before having copied over the elements from the old to the new buffer - when buffer relocation threw, it would keep the new (partially-filled) buffer and throw away the old - it unconditionally used std::move() for non-relocatable types, making it impossible to restore the original buffer when a move throws Instead of clobbering *this with new state, do all the work on the side and change *this only once the reallocation has happened successfully. Also use q_uninitialized_relocate_n() and unique_ptr in the implementation to simplify the code. The former got the necessary update to use std::move_if_noexcept() instead of an unconditional std::move() for the non-relocatable case. [ChangeLog][QtCore][QVarLengthArray] The append()-like functions are now strongly exception safe. This means reallocation will now use copies instead of moves, unless the value_type has a noexcept move constructor. Fixes: QTBUG-99039 Change-Id: I031251b8d14ac045592d01caed59d4638c3d9892 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QLocale: Extend support for language codesIevgenii Meshcheriakov2021-12-091-1/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | This commit extends functionality for QLocale::codeToLanguage() and QLocale::languageToCode() by adding an additional argument that allows selection of the ISO 639 code-set to consider for those operations. The following ISO 639 codes are supported: * Part 1 * Part 2 bibliographic * Part 2 terminological * Part 3 As a result of this change the codeToLanguage() overload without the additional argument now returns a Language value if it matches any know code. Previously a valid language was returned only if the function argument matched the first code defined for that language from the above list. [ChangeLog][QtCore][QLocale] Added overloads for codeToLanguage() and languageToCode() that support specifying which ISO 639 codes to consider. Fixes: QTBUG-98129 Change-Id: I4da8a89e2e68a673cf63a621359cded609873fa2 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Fix the benchmark for QList::removeAll()Sona Kurazyan2021-12-091-92/+25
| | | | | | | | | | | | | | | | | The benchmark was making assumptions about number of constructor/assignment operator calls, which are not valid in Qt 6, after the implementation of QList has changed. Considering that we already check number of constructions, copy constructions, etc., in tst_qlist.cpp, remove the checks from the benchmark. As a driveby, fix the following warning: "warning: parameter 'i' shadows member inherited from type 'MyBase'" Pick-to: 6.2 Fixes: QTBUG-95096 Change-Id: Ida68fa5803641c8fa84f8309c0093986ed4c0a2b Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* Add unit test for moving of opaque widgetsVolker Hilsheimer2021-12-081-35/+171
| | | | | | | | | | | | | | | Expose QWidgetRepaintManager's data structures so that we can write unit tests, and verify that they are correct after moving opaque widgets (which triggers the accelerated move code path). Improve the compareWidget logic to not rely on screen grabbing (which requires permissions), but instead use QPlatformBackingStore's toImage function, which is faster and more reliable, and also doesn't require us to show the UI we want to grab full screen in order to avoid issues with overlapping windows etc. Change-Id: Iff2ea419f03a390ab6baca26814fef6ff45f7470 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* tests: add a capability check for QWindow::requestActivate() callLiang Qi2021-12-081-0/+3
| | | | | | | | This amends b65159a5ea8db05165b2eaab8e180a12f30063e4. Pick-to: 6.2 Change-Id: I6055004375b440997ea41b3e4538854780202e10 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* QVarLengthArray: fix size update on failed append()Marc Mutz2021-12-081-0/+45
| | | | | | | | | | | | | If the in-place constructor throws, the old code had already updated the container's size(). Fix by delaying the update to after the in-place construction. [ChangeLog][QtCore][QVarLengthArray] Fixed a bug whereby a failed append() would leave the container with an inconsistent size(). Pick-to: 6.2 5.15 Change-Id: Ief1e668d945149bd8ba96c8af1398baaa7876880 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Widgets: setTransientParent() when a QMenu is a windowLiang Qi2021-12-081-0/+49
| | | | | | | | | | | | | On some platforms, such as X11 and Wayland with some compositors, QMenu could be a popup window, which should be set a transient parent to get relative position, which is requested by Wayland. Added transientParentWindow() for QMenuPrivate like QDialogPrivate. Fixes: QTBUG-68636 Pick-to: 6.2 Change-Id: I6d8880cb008ecf61a4c005898b38e3953379a13d Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* wasm: improve clipboard supportLorn Potter2021-12-0810-0/+745
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add support for Clipboard API Add clipboard manual test Also includes these fixes: - improve clipboard use for chrome browser - make QClipboard::setText work - html copy and paste - image copy/paste Chrome browser supports text, html and png To use the Clipboard API, apps need to be served from a secure context (https). There is a fallback in the case of non secure context (http) - Firefox requires dom.events.asyncClipboard.read, dom.events.asyncClipboard.clipboardItem and dom.events.asyncClipboard.dataTransfer to be set from about:config, in order to support the Clipboard API. Change-Id: Ie4cb1bbb1dfc77e9655090a30967632780d15dd9 Fixes: QTBUG-74504 Fixes: QTBUG-93619 Fixes: QTBUG-79365 Fixes: QTBUG-86169 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* Add unit test for QWidgetPrivate::overlappedRegionVolker Hilsheimer2021-12-082-31/+229
| | | | | | | | | | | Added to QWidgetRepaintManager test case, which is the only place where the function is used. Includes a helper that creates a complex scene with opaque children, which will be used in additional unit tests. Change-Id: I0e0188dd560923a552a8967d8e992dc17cc849d6 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* QVarLengthArray: add some basic checks for default-ctorMarc Mutz2021-12-071-0/+21
| | | | | | | | | There seems to have been no-one that checked a simple empty()/isEmpty()... Pick-to: 6.2 5.15 Change-Id: I7fa567f556532dfa21db759719f1303a768a9732 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QThread::create(): request interruption and join on destructionGiuseppe D'Angelo2021-12-071-0/+62
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If one destroys a running QThread, so far the behavior has been to crash (à la std::thread) -- assuming the thread hasn't already signalled that it has finished. This behavior is hostile to solutions such as using QThread::create(), which always require a wait() before destroying the thread object. We can use the opportunity to change the behavior without breaking any valid code. Instead of crashing, inside QThread's destructor we can ask the new thread to quit, and then join it (à la std::jthread). This simplifies the implementation of long-living runnables and the code that manages them. Deploying this solution for the whole QThread class may not be entirely painless. While no correct code would work differently with the proposed changes, incorrect code that deletes a running thread would no longer crash "loudly" -- instead, it might deadlock "quietly", have memory corruptions, etc. Hence I'm limiting this approach to only the threads created by QThread::create(), at least for the time being. This also side-steps perhaps the biggest problem of generalizing the approach, which is that placing such interrupt+join logic into~QThread's destructor would cause it to be run _after_ a QThread subclass' own destructor has run, destroying the subclass' data members too early. This might create an antipattern if one chooses to subclass QThread. With create(), a subclass in question exists, and it indeed has NSDMs, but it's entirely under our control (in fact, I'm placing the logic just in its dtor). [ChangeLog][QtCore][QThread] Destroying a QThread object created by QThread::create() while the thread that it manages is still running will now automatically ask that thread to quit, and will wait until the thread has finished. Before, this resulted in a program crash. See the documentation of QThread::~QThread() for more details. Change-Id: Ib268b13da422e277ee3ed6f6c7b2ecc8cea5750c Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* tst_qmetatype: factor the most expensive test into its own TUMarc Mutz2021-12-074-81/+127
| | | | | | | | | | | | | | | | The PRINT_2ARD_TEMPLATE macro expansion alone is responsible for about 50% of the compile time and RAM requirements of tst_qmetatype.cpp. By factoring it into its own TU, we reduce the maximum memory load on my machine from 4.0GiB to 2.5GiB, provided we don't parallelize the build, then we take 0.5GiB more. This is a quick-fix for the QNX build problems currently plaguing the CI. Going forward, we should probably have a better solution, whatever that may be. Task-number: QTQAINFRA-4669 Change-Id: I2732b4c25b369b15cce1c7afe222d041ecb6795a Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* tst_qmetatype: move an #ifdef to the headerMarc Mutz2021-12-072-8/+8
| | | | | | | | | ... so it can be used by multiple .cpp files. Task-number: QTQAINFRA-4669 Change-Id: I7212b9b08cd3bfa44ee741ee4789d1d0024e4708 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QMultiHash: fix erase returning the wrong iteratorMårten Nordheim2021-12-071-0/+16
| | | | | | | | | | | | When deleting the last item in a chain, without it being the last item in the chain, then we re-use the iterator which was passed in as an argument. This is wrong if we detached earlier in the function, and means we return an iterator to the previously shared data. Pick-to: 6.2 Change-Id: I7da6309e23a32073da59e7da0cbfd1d16734f1ca Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Optimize QMimeDatabase::mimeTypeForFile(f, MatchDefault)Igor Kushnir2021-12-067-0/+84
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Open the file only if matching on content is needed. Use QFileInfo::filePath() instead of QFileInfo::absoluteFilePath() in QMimeDatabase::mimeTypeForFile(). filePath() does much less work, and so is faster. Thiago Macieira helpfully explained in a review comment why the absolute path is not useful for correctness here: "Nothing needs absolute paths within the same application that would resolve the relative path to absolute. You only need an absolute path if you're communicating with another application that may be in a different directory." QMimeDatabase::mimeTypeForFile() checks fileInfo.isDir(), so the fileName.endsWith(QLatin1Char('/')) check in QMimeDatabasePrivate::mimeTypeForFileNameAndData() was redundant when called from this function. The other two callers of that function now check this condition before opening IO devices. This improves performance of the two QMimeDatabase::mimeTypeForFileNameAndData() overloads in the corner case. Refactor and optimize QMimeDatabasePrivate::findByFileName() and its usages. Previously each caller constructed a QFileInfo object and passed QFileInfo::fileName() into this function. Now the callers simply pass an absolute or relative path to a file into this function, which then uses QFileSystemEntry::fileName() to exclude the path. Constructing QFileInfo is relatively expensive, so this change slightly improves performance. Optimize QMimeDatabasePrivate::loadProviders() by calling static QFileInfo::exists() instead of constructing a QFileInfo object and calling the non-static QFileInfo::exists() overload. Note that the QFileInfo object was always created, even if QFileInfo::exists() under an `if` and an `#if` was never called. The following table contains the average results of the added benchmark tst_QMimeDatabase::benchMimeTypeForFile() on my GNU/Linux system before and at this commit. The numbers denote milliseconds per iteration. data row tag before at MatchDefault: archive 0.029 0.016 OpenDocument Text 0.029 0.015 existent archive with extension 0.039 0.025 existent C with extension 0.033 0.020 existent text file with extension 0.033 0.020 existent C w/o extension 0.076 0.074 existent patch w/o extension 0.11 0.105 existent archive w/o extension 0.069 0.066 MatchExtension: archive 0.012 0.0115 OpenDocument Text 0.0115 0.011 existent archive with extension 0.017 0.016 existent C with extension 0.011 0.011 existent text file with extension 0.011 0.011 existent C w/o extension 0.016 0.0155 existent patch w/o extension 0.013 0.012 existent archive w/o extension 0.013 0.012 MatchContent: archive 0.019 0.012 OpenDocument Text 0.019 0.012 existent archive with extension 0.053 0.051 existent C with extension 0.056 0.0545 existent text file with extension 0.058 0.056 existent C w/o extension 0.0605 0.059 existent patch w/o extension 0.10 0.099 existent archive w/o extension 0.057 0.054 Change-Id: Idb541656e073a2c4822ace3f4da412f29f2351f8 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: David Faure <david.faure@kdab.com>
* QFontDatabase (Windows): Sanitize font requests earlyMårten Nordheim2021-12-061-0/+31
| | | | | | | | | | | | | | | | | | | After the windows font engine was no longer marking everything as scalable we started limiting the font size of requests to the maximum of Courier when it was requested. This was a regression from 5.8 and not in agreement with our documentation. The problem is that we would only make the switch from Courier to Courier New after having already gone through the foundry-lookup and found a closest-available font size for Courier. With this sanitization step in the backend we can make these changes early enough that we haven't yet adjusted e.g. the font size. Pick-to: 6.2 5.15 Fixes: QTBUG-58995 Change-Id: I319e93e6b78c7c3c5539964ac5ab4e05f8902ab6 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* Fix tst_qfloat16 runtime failure for INTEGRITYTatiana Borisova2021-12-061-0/+13
| | | | | | | | | | - GHS compiler is not fully compliant with iec559. Therefore we need to update is_iec559 checking for GHS case. Pick-to: 6.2 Change-Id: Ia094509d26bf5f0109f2937547a056267019cffb Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Janne Koskinen <janne.p.koskinen@qt.io>
* tst_BenchlibCallgrind: fix x86 preprocessor checkEdward Welbourne2021-12-061-4/+4
| | | | | | | | | | | Its twoHundredMillionInstructions() test has #if-ery to limit it to gcc and x86; however, it was testing only __i386 for the x86 part, where gcc defines __x86_64 instead on modern 64-bit systems. In the process, invert the condition and the branches it controls - positive tests are easier to comprehend. Change-Id: I8e906c606c48aa5034e02e3ed5d042fbb1f2ecbc Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Remove chip.debug compiled binary leftover from debuggingDmitry Shachnev2021-12-061-0/+0
| | | | | | Pick-to: 6.2 Change-Id: I9d1ca06ffb5f9b8fc6e6042c399311dcec059521 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QStringBuilder: Add support for QByteArrayViewMårten Nordheim2021-12-041-0/+4
| | | | | | | [ChangeLog][QtCore][QStringBuilder] Added support for QByteArrayView. Change-Id: If2c23549d533dd31c320f3ee455fcd01ea5b460a Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QNAM: Reintroduce h2c with an attributeMårten Nordheim2021-12-041-1/+81
| | | | | | | | | | | [ChangeLog][QtNetwork][QNetworkRequest] Added QNetworkRequest::Http2CleartextAllowedAttribute which controls whether HTTP/2 cleartext (h2c) is allowed or not. The default is false. This replaces the QT_NETWORK_H2C_ALLOWED environment variable. Task-number: QTBUG-98642 Change-Id: I43ae1cc671788f6d2559cd316f6667b412c8e75e Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QFile: Add open() overload that accepts permissions argumentIevgenii Meshcheriakov2021-12-041-0/+52
| | | | | | | | | | | | | | | The new overload allows creation of files with non-default permissions. This is useful when files need to be created with more restrictive permissions than the default ones, and removes the time window when such files are available with less restrictive permissions. [ChangeLog][QtCore][QFile] Added QDir::open() overload that accepts permissions argument. Fixes: QTBUG-79750 Change-Id: Iddfced3c324e03f2c53f421c9b31c76dee82df58 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>