summaryrefslogtreecommitdiffstats
path: root/tests
Commit message (Collapse)AuthorAgeFilesLines
* QHttpHeaderParser: Allow larger fields but restrict total sizeLars Schmertmann2022-06-284-16/+143
| | | | | | | | | | | | | | | | | | | Our limit of 8k for a single header field was too small for certain services which returned Location values or WWW-Authenticate challenges longer than 8k. Instead, taking inspiration from Chromium, we have a limit of 250k for the full header itself. And increasing our field limit to 100k, which would occupy almost half of what the total header allows. Also took the opportunity to make it adjustable from the outside so we can set more strict limits in other components. Fixes: QTBUG-104132 Change-Id: Ibbe139445e79baaef30829cfbc9a59f884e96293 Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io> (cherry picked from commit e3ea1d02e6a2cbc63e8ae6fff6ccae49258fe5a2) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* qtestlib: exit with error if a test is invoked with unknown data tagDimitrios Apostolou2022-06-281-0/+52
| | | | | | | | | | | | | | | Previously trying to execute a test function with an unknown data tag would print an error message but exit with 0. This patch stores a test failure, and continues trying to execute the rest of the command line arguments, if any. In the end the process exits with the usual exit code (number of failed tests) which is now !=0. Fixes: QTBUG-24240 Change-Id: Id4d422035f173e01e77ca88028dfd94dc0f9085c Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> (cherry picked from commit d23dcc05425dcd2ab0eb621f5f2ea793a78fcc9f) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* rhi: metal: Switch back to presentDrawableLaszlo Agocs2022-06-281-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This convenience should be, according to the Apple docs, equivalent to calling present from a scheduled handler. (which on its own makes it unclear why we switched in the first place) In practice it seems the two approaches are not identical. It looks like that once a frame is submitted earlier than the next display link callback, the throttling behavior we implement in beginFrame() (waiting on the semaphore for the completion of the appropriate command list etc.) starts exhibiting unexpected behavior, not correctly throttling the thread to the refresh rate. Changing back to presentDrawable does not exhibit this at all. The suspicion is that presentDrawable is probably doing more than what the docs suggest, and so is not fully equivalent to calling present manually from a scheduled handler. Therefore, switch to presentDrawable now, which restores the expected cross-platform behavior, but make a note of the oddity, and also prepare the hellominimalcrossgfxtriangle manual test to provide an easy, self-contained application to allow experimenting in the future, if needed. This allows Qt Quick render thread animations to advance at the expected speed (because the render thread is correctly throttled to the refresh rate), even if the render thread decides to generate a new frame right away, without waiting for the next display link update. Without this patch, attempting to get updates not via requestUpdate(), but by other means (timer etc.) leads to incorrect throttling, and so the triangle in the test app is rotating faster than expected - but only with Metal. Running with OpenGL on macOS or with any API on any other platform the behavior will be correct. Even if scheduling updates without display link is not efficient, and should be discouraged, not doing so cannot break the core contract of vsync throttling, i.e. the thread cannot run faster just because it renders a frame not in response to an UpdateRequest. Amends 98b60450f7ce6b16464392747ab8721f30add15e (effectively reverts but keeps the code and the notes because we might want to clear this up some day) Fixes: QTBUG-103415 Change-Id: Id3bd43e94785384142337564ce4b2644bf257100 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> (cherry picked from commit f814cc6a7911f6cf14ce443f41c2336bc1d213c6) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* FatalSignalHandler: print some more information from siginfo_tThiago Macieira2022-06-281-5/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The siginfo_t parameter allows us to show what process sent a signal or the crashing address. Additionally, it allows us to determine if the crashing signal was indeed sent due to a crash. The selftest tst_crashes produces now: $ QTEST_DISABLE_STACK_DUMP=1 ./crashes ********* Start testing of tst_Crashes ********* Config: Using QtTest library 6.4.0, Qt 6.4.0 (x86_64-little_endian-lp64 shared (dynamic) debug build; by GCC 11.2.1 20220420 [revision 691af15031e00227ba6d5935c1d737026cda4129]), opensuse-tumbleweed 20220428 PASS : tst_Crashes::initTestCase() Received signal 11 (SIGSEGV), code 1, for address 0x0000000000000004 Function time: 0ms, total time: 0ms [1] 201995 segmentation fault (core dumped) QTEST_DISABLE_STACK_DUMP=1 ./crashes The last line comes from the shell. The code isn't decoded, but on Linux it's a SEGV_MAPERR. macOS prints exactly the same thing. I've updated one of the expected_crashes_*.txt output that doesn't seem possible (the "Received a fatal error" message does not appear in Qt anywhere). Change-Id: I5ff8e16fcdcb4ffd9ab6fffd16ebc8391234f0e2 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit 5e67e7efaa2669252fd8c55392b7bc35b72c6079) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Fix QDBusInterface crashing with empty path on constructionMårten Nordheim2022-06-271-0/+7
| | | | | | | | | | | | | | On some machines having an empty path passed to QDBusInterface would cause a crash. This happened because the code created a QDBusMessage and manually marked it as validated when it was not. The validation would not pass for this object. Change-Id: I496dd922fa64353399655a1e84996b99990f5879 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit 4d60ba61dca7d50c8eaf9f4525cb9565b363ca81) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QNetworkReply: Fix the test compilationLaszlo Papp2022-06-251-0/+1
| | | | | | | | | | | It would not compile on my Linux box due to using QVariantMap, but not actually including QMap itself. Using gcc 9.3.1 on CentOS 7. Change-Id: I808a270c814a906030cb34b197d3a2a85ba384e1 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Jesus Fernandez <jsfdez@gmail.com> (cherry picked from commit 0a78cb7fab7b2d093f53be06839b08bca08077ea) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Add QDom internalSubset implementationYe ShanShan2022-06-251-0/+66
| | | | | | | | | | | | | QDom's internalSubset() always returned empty because nothing actually set the internal data member it returns. When parsing the DECLTYPE, extract the internal subset and save it to the doctype()'s member when present. Fixes: QTBUG-53661 Change-Id: I6e41ff8b914381168246073b3289d82205b1c255 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io> (cherry picked from commit c3b959733a739e9b2fc00b2af469fa44f3048e29) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Skip tests that terminate threads under ASANVolker Hilsheimer2022-06-251-0/+16
| | | | | | | | | | | | | | | | Thread termination might prevent stack unwinding, which then generates ASAN errors such as ERROR: AddressSanitizer: stack-buffer-underflow on address 0x7f3c1d7858b0 at pc 0x7f3c243d8918 bp 0x7f3c1d7857f0 sp 0x7f3c1d7857e8 Skip such tests so that we can enable blocking CI runs under ASAN. Fixes: QTBUG-104421 Change-Id: I169235a12190e3f72525cddfe1a44a4bee19eca1 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> (cherry picked from commit ea4d6b987ae10f1bb910081b523c3b22b11f7b64) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Add QStringDecoder::decoderForHtml()Lars Knoll2022-06-251-20/+64
| | | | | | | | | | | | | | | Now that QStringConverter can handle non UTF encodings through ICU, add a way to get a decoder for arbitrary HTML code. Opposed to QStringConverter::encodingForHtml(), this method will try to create a valid string decoder also for non unicode codecs. Change-Id: I343584da1b114396c744f482d9b433c9cedcc511 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit 9c1f3b6d4d5a5fe59396062c6f68cc1201665c62) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* tst_moc: fix build with GCC 12Thiago Macieira2022-06-251-3/+3
| | | | | | | | | | | | | | You can't mismatch the export macros. The QT_MOC_EXPORT_PLUGIN_V2 macro defines these functions as Q_DECL_EXPORT so they can be found by QPluginLoader. We must match the macro here, otherwise GCC 12 complains (tst_moc.cpp is compiled with -fvisibility=hidden): tst_moc.cpp.o: non-canonical reference to canonical protected function `qt_plugin_instance' in moc_plugin_metadata.cpp.o Change-Id: Id0fb9ab0089845ee8843fffd16f99893d5730da5 Reviewed-by: Marc Mutz <marc.mutz@qt.io> (cherry picked from commit f5697d2b2aca7f7c058e25f08fc6f68b26f0ad83) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Emit autolinks in QTextMarkdownWriterShawn Rutledge2022-06-242-2/+4
| | | | | | | | | | | | | | | | | | | | When a markdown document contains a "naked" URL, or an angle-bracketed <URL>, md4c recognizes it, and we set the AnchorHref charfmt property. There's no need to expand it into the [text](url) form if the text is the same as the url, there is no tooltip, and the url is valid. QTextMarkdownWriter now writes a CommonMark "autolink" in that case: https://spec.commonmark.org/0.30/#autolinks [ChangeLog][QtGui][Text] QTextMarkdownWriter now writes an autolink whenever a hyperlink has no custom text and no tooltip, including when the document was parsed from Markdown containing a naked URL. Fixes: QTBUG-94713 Change-Id: I432db8499c62e1e0b1e913bfd8ef2147e3c2bb2a Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io> (cherry picked from commit 846b314aaf484a3cb62d466660c08bbde00542cb) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Support markdown in QTextEditMimeData; fix pasting trailing newlinesShawn Rutledge2022-06-242-0/+105
| | | | | | | | | | | | | | | | | | | | - Since 4edcea762d9ce334c4c1a78234c90c118b81da87 the dropsite example shows markdown if available; and now it shows that when we do DnD of a selection from the richtext example, text/markdown is available. - If we artificially make html unavailable, copying and pasting between widget-based rich text editors uses markdown. In case markdown writer output contains unnecessary backticks due to monospace fonts getting used, the workaround from 1ad456c908467212bc30223a69eb7524b64b86e1 is applied. Task-number: QTBUG-76105 Task-number: QTBUG-103484 Change-Id: Ie6ca4dbb450dbc36b3d09fd0df1ae5909aaebca7 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io> (cherry picked from commit 56f0ebfe860e440dcbba8997f44836debc901119) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Network: Update expired certMårten Nordheim2022-06-242-30/+30
| | | | | | | Change-Id: I233ffee5b720c0554071c1d49d4fb861736b2e2a Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> (cherry picked from commit 6cbe8f74ce5940f749796c88db2322b1a0d3dd8b) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* moc: fix use of escape sequence of more than one characterThiago Macieira2022-06-231-20/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We had the code to calculate the length, but were improperly using it only for the offset, not the length of the string or its containing array. That resulted in the generated moc output containing: QT_MOC_LITERAL(111, 5), // "\xffz" QT_MOC_LITERAL(114, 5), // "\0012" QT_MOC_LITERAL(117, 23), // "slotWithAReallyLongName" The two strings are described as occupying 5 bytes (length 4 + null terminator), which is incorrect. The offset was correct: 114 - 111 = 3 and 117 - 114 = 3. The new output is: QT_MOC_LITERAL(111, 2), // "\xffz" QT_MOC_LITERAL(114, 2), // "\0012" QT_MOC_LITERAL(117, 23), // "slotWithAReallyLongName" The effect of the array size calculation would only be felt if moc decided it needed a second string array (for strings over 65535 bytes), which would cause the offsets in the second array to be all wrong. There was no such test until now. Drive-by fixing of the newline, indentation, and the stale comment referring to QByteArrayData (Qt 5). Change-Id: Id0fb9ab0089845ee8843fffd16f9cd01b3e0709a Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit dda9c9e2bc4fd2efe9e3fb0e451a8c3512f9a4d2) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QDom: Stop treating non-BMP characters as invalidSona Kurazyan2022-06-221-0/+22
| | | | | | | | | | | | | | According to https://www.w3.org/TR/REC-xml/#NT-Char unicode characters within the range of [#x10000-#x10FFFF] are considered to be valid, so fix the check for valid characters accordingly. This requires changing the loop over the input QString to iterate over code points (instead of code units). Fixes: QTBUG-104362 Change-Id: I7dcf5cad05265a54882807a50522d28b647e06ee Reviewed-by: Marc Mutz <marc.mutz@qt.io> (cherry picked from commit da0d7f61c851431d14430684c62345bc23dbf001) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Don't crash when removing the last visible tabVolker Hilsheimer2022-06-221-0/+34
| | | | | | | | | | | | | | | | | | | | | The code incorrectly tried to ensure that the firstVisible tab was a valid index, even though there might not be any visible tab left after removing the last visible tab. The same logic didn't exist of the lastVisible tab, so we tripped the assert in qBound, as max (being -1) ended up smaller than min (0). Fix this by removing the wrong correcting of firstVisible to be always valid. Make sure we emit currentChanged with -1 when no visible tab is left after removing the current tab. Add a test. Fixes: QTBUG-104003 Change-Id: I27e6438a02d0a0f1ac4d0e0160cee4f33b3f3766 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> (cherry picked from commit ac80cee846e270a42ce736cac80ca865321b5422) Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QJsonValue: fix incorrect to{Array,Object} when the value is emptyThiago Macieira2022-06-221-2/+16
| | | | | | | | | | | | | This is a repeat of commit de6ced66920600e659dbaa2509526a3bcb0b3360 "QCborValue: fix incorrect to{Array,Map} when the value is empty" (6.4), which fixed the same thing for QCborValue. I've just copied the exact same implementation onto the QJsonValue functions. Fixes: QTBUG-104085 Change-Id: I175efddd75f24ae59057fffd16f6b257bf7ed36d Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io> (cherry picked from commit e114fec62adf13b8c21ca890fb748cb27f391c25) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* tst_tostring: add benchmarks for QCOMPARE vs. QCOMPARE_EQMarc Mutz2022-06-221-0/+55
| | | | | | | | | | | | | | | There's currently no statistically-significant difference between the two, due to a huge pessimistion in QTestLib where every QCOMPARE* and QVERIFY writes 1KiB of data onto the stack before doing anything else, so I'm not reporting numbers in this commit message. Task-number: QTBUG-98873 Task-number: QTBUG-98874 Change-Id: I233878596f0a8fe6b96360adb839fecd72c398a2 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> (cherry picked from commit 32925d0a85b13d2a8032e580db544af5cdfecf8b) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QPromise: run continuation(s) on destructionSona Kurazyan2022-06-221-0/+20
| | | | | | | | | | | | | | | | | | | If the QFuture is canceled because the associated QPromise has been destroyed, we still need to run its continuations (i.e. onCanceled handler, if it's attached), so replaced the cleanContinuation() call inside ~QPromise() with runContinuation(), which will also take care of cleaning the continuation. [ChangeLog][QtCore][Important Behavior Changes] QFuture now runs its continuations when its associated QPromise has been destroyed. Previously, if a QFuture was canceled because the associated QPromise has been destroyed, its continuations were skipped. Fixes: QTBUG-103992 Change-Id: Ie05bc760c96c349aade8adb8d2fe5263aff8efac Reviewed-by: Marc Mutz <marc.mutz@qt.io> (cherry picked from commit bf3fc5c95cb4e6acedf242c00b7a1c3b455062bb) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* tst_bench_shared_ptr: fix build with BOOST_NO_EXCEPTIONSMarc Mutz2022-06-221-0/+13
| | | | | | | | | | | | | | | | | | If, for whatever reason, BOOST_NO_EXCEPTIONS is defined, the user of the Boost libraries is supposed to provide a definition of boost::throw_exception, which we didn't. We used to run into this only on ubsan builds, but it seems we now have the problem on a regular Ubuntu 22.04 build, too (cf. bugreport). Fix by adding the necessary definitions. Fixes: QTBUG-104083 Change-Id: I9b061a158a5b77e8d286bd7b40312e5bc63ee8de Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> (cherry picked from commit 882fc48b9e0966c8d93ce71e0843a3c50da97be8) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* function_ref test: Don't take reference of temporariesMårten Nordheim2022-06-211-5/+10
| | | | | | | | | | | | | | When assigning the lambdas directly to a function_ref their lifetime is limited to that of the expression. Store them on the stack first to avoid the UB. Fixes: QTBUG-104419 Change-Id: I3c85ac683b0bd7768b646dc9d0a1ed4dd173e6f3 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> Reviewed-by: Marc Mutz <marc.mutz@qt.io> (cherry picked from commit 3d73aa660b5e1af5758ae7207ce1c05d7a0458e1) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Use CSS classes on html list items for checkbox supportShawn Rutledge2022-06-212-14/+30
| | | | | | | | | | | | | | | | If we replace the bullet character with a UC checkbox character, it looks ok in a browser, and the HTML parser can recover the BlockMarker attribute from the css class. [ChangeLog][QtGui][Text] Checkbox list items can now be read and written in both HTML and Markdown, including conversions. Task-number: QTBUG-103714 Change-Id: Ic6b74512075cd4ac16d6f80fdf55b221447491a9 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io> (cherry picked from commit eee9d252028c4b3b743c77a406cd6939eda3962f) Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QGraphicsScene: respect that items can override selection changesVolker Hilsheimer2022-06-201-0/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | QGraphicsItems may override itemChange to prevent certain attribute changes. Overriding ItemSelectedChange this way is explicitly documented to be allowed. However QGraphicsScene::clearSelection did not test whether items were in fact deselected after the call to setSelection, and always cleared the stored set of selected items. Fix this by checking the actual selected state of the item as we iterate over them, and store those items that are still selected in a set that becomes the new selectedItems set (which will be empty if no item overrides, which is the default). Add a test that also checks that clearing the selection emits the selectionChanged signal correctly (and does not if all selected items block being deselected). Fixes: QTBUG-85474 Change-Id: I665afc132876e02e6e1061b7be37f4f6e4be418f Reviewed-by: Axel Spoerl <axel.spoerl@qt.io> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> (cherry picked from commit 2e12479e06d6869f568f0a7ee939453cda9afdbf) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* BLACKLIST tst_qfont for Ubuntu 22.04Heikki Halmet2022-06-201-0/+2
| | | | | | | | Task-number: QTBUG-84248 Change-Id: I2978cd2a6ed07bb6fc5769b174d0a897dfa3566d Reviewed-by: Tony Sarajärvi <tony.sarajarvi@qt.io> (cherry picked from commit bb674adb25698943bc0cd45821b5036e240faabc) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* BLACKLIST tst_QMenuBar::check_menuPosition for Ubuntu 22.04Heikki Halmet2022-06-201-0/+1
| | | | | | | | Task-number: QTBUG-68865 Change-Id: I1eda9789a30737104c6e97de583a9f3022ae0bf6 Reviewed-by: Tony Sarajärvi <tony.sarajarvi@qt.io> (cherry picked from commit 5aca1fe1d07c9386435fd94c4a90d6f5dabc47b6) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* BLACKLIST: tst_QGlyphRun::mixedScripts for Ubuntu 22.04Heikki Halmet2022-06-201-0/+1
| | | | | | | | Task-number: QTBUG-68860 Change-Id: I79c085c7321e0bee78e8cb31daa8c7992d3a3ec6 Reviewed-by: Tony Sarajärvi <tony.sarajarvi@qt.io> (cherry picked from commit 903bde19a416d82fc255777955237fd410acd690) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* BLACKLIST tst_QApplication::sendEventsOnProcessEvents for Ubuntu 22.04Heikki Halmet2022-06-201-0/+1
| | | | | | | | Task-number: QTBUG-87137 Change-Id: Ib09382af7504f5ee078d23cc021c1b0faf051e23 Reviewed-by: Tony Sarajärvi <tony.sarajarvi@qt.io> (cherry picked from commit a3c43394bb391ef8d4439ed4c09d5644245038e7) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Avoid misleading bindingStatusAllan Sandfeld Jensen2022-06-201-1/+37
| | | | | | | | | | | | Set it to nullptr on clear, and deal with possibly null bindingStatus. Task-number: QTBUG-101177 Task-number: QTBUG-102403 Change-Id: I66cb4d505a4f7b377dc90b45ac13834fca19d399 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> (cherry picked from commit 0bd287627508c61a7abfd6430d8c1243ea153081) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Long live the ICU-based QStringConverter interface!Fabian Kosmale2022-06-203-2/+280
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds support for additional codecs to QStringConverter when ICU is available. We store the converter in the state (d[0]), and its canonical name in d[1]. We need the name there, as in the clear function we close the UConverter, and set the pointer to null. Consequently, the actual conversion functions might need to re-open the converter again. The advantage of this approach is that clear is used in the destructor of State, and with this approach we properly clean up the state. There is however a disadvantage: The clear function was so far also used for resetting the state when QStringConverter::resetState . Discarding the whole Uconverter for that is however rather costly. For that reason we modify resetState to call a new function, State::reset. For existing converters, it behaves the same as clear; for the ICU based converter, we call the more efficient ucnv_reset. Code compiled against Qt 6.4 can benefit from this more efficient version; code compiled against older Qt versions will continue to work, as the conversion functions can just recretate the converter from the name. We can distinguish between ICU and non-ICU converters by checking if the UsesIcu flag is set. QStringConverter::name is changed to return the name stored in d[1]. The interface of the ICU converter has a dummy name, so code using the old name function from QT < 6.4 still returns something, namely a message asking the user to recompile. The function is moved out of line, as we need to check for the private ICU feature, and want to avoid having that check in the public header. As the QStringConverter ctor taking a name now can allocate memory, it can no longer be noexcept. Removing the noexceptness is safe, as it was only added after Qt 6.3. Note that we cannot extend the API consuming or returning Encoding, as we use Encoding values to index into an array of converter interfaces in inline API. Further API to support getting an ICU converter for HTML will be added in a future commit. Currently, the code depending on ICU is enabled at compile time if ICU is found. However, in the future it could be moved into a plugin to avoid a hard dependency on ICU in Core. [ChangeLog][Corelib][Text] QStringConverter and API using it now supports more text codecs if Qt is compiled with ICU support. Fixes: QTBUG-103375 Change-Id: I7afb92fc68ef994179ebc7a3aa73beebb1386204 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit 122270d6bea164e6df4357f4d4d77aacfa430470) Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QMainWindow: fix restoreState() for toolbarsIvan Solovev2022-06-171-0/+5
| | | | | | | | | | | | | | | | | | | Restoring the toolbar state of a QMainWindow could not update QWidgetPrivate::widgetItem for the QToolBar, because at that point it was still holding the pointer to the widgetItem of the previous state. Later on, when the new state was successfully applied, the previous state was deleted, and the corresponding widgetItem was reset to nullptr. This patch explicitly resets the QToolBar's widgetItem while updating the state, so that it is later correctly updated while creating a new QWidgetItemV2. Fixes: QTBUG-102395 Change-Id: I17613d62423edcc0faf85ecb0a714865a50d87e8 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit 2ed54dedf3783471716b21509db1f8279d5b5af8) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Update window state in QWindowsWindow and QXcbWindow geometry settersAxel Spoerl2022-06-171-0/+97
| | | | | | | | | | | | | | | | | | When QWidget::resize() is called on a maximized or minimized QWidget, the window state of the widget and the corresponding QWindow is not updated (i.e. remains maximized or minimized). This patch updates the window state to Qt:WindowNoState when setGeometry() is called in QWindowsWindow or QXcbWindow. A test is added in tst_QWidget. Fixes: QTBUG-104201 Change-Id: I07491fb9293d13509573fc403750da0a50f6a785 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit 99c8ffb9f259760e45618f0988bbd79237d6d291) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Accessibility: don't emit focus change when reason is window activationVolker Hilsheimer2022-06-161-0/+10
| | | | | | | | | | | | | | | | | | | | | If a window becomes active, then the accessibility system gets informed about that already. Qt puts focus on the focus child of the activated window afterwards, and if this emits another accessibility event, then accessibility clients like Windows Narrator will stop reading the activated window, and instead read about the focused widget. This makes dialogs like message boxes poorly accessible. Accessibility clients already know that a window became active, and can query Qt about the focused child within that window. Amend test case. Fixes: QTBUG-101585 Change-Id: I2d6bff7c415a6f29c4a4f7f4e4be38079fb976ca Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io> (cherry picked from commit 79a11470f3c4c61951906223f97001a77ce36500) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Implement a dedicated QAccessibleInterface for QMessageBoxVolker Hilsheimer2022-06-161-0/+104
| | | | | | | | | | | | | | | | | QMessageBox has text values that an accessible client should be able to read directly without having to navigate through the text labels. Add test coverage. Windows Narrator is inconsistent in reading the contents of a message box. It might skip them completely, even though the text property is read through the interface. Task-number: QTBUG-101585 Change-Id: I639c2210a627733c093743790c6a6b83f4bb80d0 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io> (cherry picked from commit 56d6a360206c7bd93e6503a63daf1517ff40a1d4) Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QComboBox: emit currentIndexChanged() and currentTextChanged() when the ↵Ivan Solovev2022-06-161-0/+33
| | | | | | | | | | | | | | | | | | | model is cleared QComboBox uses QPersistentModelIndex to store the current index of the underlying model. When the model is cleared, that index is automatically invalidated, so calling QComboBoxPrivate::setCurrentIndex(QModelIndex()) does not result in signals being emitted, because we do not detect the index change. This patch uses indexBeforeChange to detect such situation and emit all necessary signals. Fixes: QTBUG-103007 Change-Id: I29326830a30a17900839e8d1737a08bd940081ea Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit 662184ac68803aac553921520a1b4b7b23a0633c) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Work around lavapipe bug in tst_qvulkanLaszlo Agocs2022-06-161-7/+9
| | | | | | | | | | | | Work around https://gitlab.freedesktop.org/mesa/mesa/-/issues/5875 by treating the driver as broken when both the driver and device UUIDs are all zeroes. Fixes: QTBUG-104231 Change-Id: Ibf7973361d472ebb1cb433bc61b50b2828f75c6b Reviewed-by: Andy Nichols <andy.nichols@qt.io> (cherry picked from commit e4961afed2fc019c2a95ca582f86da2de56e351f) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QStringConverter: fix use-after-free in the stack in the testThiago Macieira2022-06-161-7/+11
| | | | | | | | | | Detected by ASan. Introduced by aef27c5aa2f43e8e34970168dfc517062cc87db8 Fixes: QTBUG-104261 Change-Id: Id0fb9ab0089845ee8843fffd16f88bdeb4f42c7c Reviewed-by: Lars Knoll <lars.knoll@qt.io> (cherry picked from commit 2a1122f46587e27f3d93e1f2af63f439116569c4) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Fix typos in docs and commentsKai Köhne2022-06-157-9/+9
| | | | | | | | | | Found by codespell Change-Id: Ie3e301a23830c773a2e9aff487c702a223d246eb Reviewed-by: Nicholas Bennett <nicholas.bennett@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> (cherry picked from commit 9d2cc4dd766ca6538e17040b6ac845ed880ab0fe) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Make two QDT benchmarks data-driven and add more rowsEdward Welbourne2022-06-151-60/+40
| | | | | | | | | | | | | | | | | | | The QDateTime benchmark's toMSecsSinceEpoch() and toMSecsSinceEpochTz() each iterated the 2010s and had 1950 and 2050 variants for two other decades. I want to also test some earlier decades and do similar for create(), so combine the existing triplets as three rows of a data-driven test for each triplet, add the new rows and apply the same to create(). In the process, turn an enum used for qint64 constants into a set of constexpr qint64 declarations. Task-number: QTBUG-104012 Change-Id: I2657346b65d96a7ef7503cd33c870b688ea5dbff Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> (cherry picked from commit 12eac545b6f5a6f963fcc1d06c3ae426260adb9b) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Add support for painting at integer DPR with downscaleMorten Sørvig2022-06-151-2/+7
| | | | | | | | | | | | | | | | | | | | Enable by setting QT_WIDGETS_HIGHDPI_DOWNSCALE=1 and QT_WIDGETS_RHI=1. This will make the backing store and painter operate at the next highest integer DPR in cases where QWindow::devicePixelRatio() returns a fractional value. The backing store image will then be downscaled to the target DPR at flush time, using the RHI flush pipeline. [ChangeLog][QWidgets] Added experimental support for always painting at an integer device pixel ratio (rounding the DPR up if necessary), followed by a downscale to the target DPR.Enable by setting QT_WIDGETS_HIGHDPI_DOWNSCALE=1 and QT_WIDGETS_RHI=1. Task-number: QTBUG-86344 Change-Id: Id5b834a0e3499818b0b656161f5e0c38a6caa340 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io> (cherry picked from commit 79bead6c3b507331614dcc3c789e18438bc10395) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Revert "qxp::function_ref: drop use of q23::invoke_r"Marc Mutz2022-06-141-0/+40
| | | | | | | | | | | | | | | | | | | | | This reverts commit b9cce12e76796962e5e5ad0d5408370af56af459, which broke function_ref<void(int)> f = [](int i) { return i; }; ie. swallowing of return types. We could maybe implement the same without invoke_r, with the same manual if-constexpr that invoke_r has, but it would be a pointless duplication across the two thunks we have, so just use invoke_r. Add tests. Task-number: QTBUG-103739 Change-Id: I6034f05d813c06a25e8058ded5b6b62f3ca858b4 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit fa4d18b86c0cb0de495ce988fd9d3714e09b05dd) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* tst_QAnyStringView: explicitly check the spaceship operatorMarc Mutz2022-06-141-0/+31
| | | | | | | | | | | | | | | | We implicitly checked it, because, in C++20 builds, the non-equality relational operators are synthesized from it by the compiler, and we test those, but we didn't check that <=> returns strong_ordering. We now do. Task-number: QTBUG-104108 Change-Id: Ieb19a2d4cb2d600d884f4e2e89e98c6187e23872 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> (cherry picked from commit 1b8b8024554f9f36bc6642c2dfe830765e932df5) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Windows: fix DeferredDelete events processing on QThread::terminate()Vladimir Belyavsky2022-06-131-0/+78
| | | | | | | | | | | | | On finishing/terminating a thread, when processing posted events, we need to consider QThread's own data instead of caller thread's data. Otherwise we can get into unexpected situations such as double destruction of an object, premature destruction, etc. Fixes: QTBUG-103922 Change-Id: Idf77221ebbaa0b150ee2d0c296b51829ae8dc30e Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit 865212057b9f4e2809ebe42ec25c2d94d818cde7) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* FatalSignalHandler: print the signal name on crashThiago Macieira2022-06-122-2/+2
| | | | | | | | | | | | | | It's easier to remember what "SIGSEGV" means instead of "11". GNU libc has offered sigabbrev_np() (non-portable) since 2.32; for older libcs, we'll be happy with a hardcoded list. Selftest updated to match... though it didn't seem to be necessary. Change-Id: I5ff8e16fcdcb4ffd9ab6fffd16ebc66ecf6e9465 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> (cherry picked from commit 17454bf9c60d9a7f836461234f48e1bb9d7d5bf9) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Update Catch2 to v2.13.9Marc Mutz2022-06-081-5/+9
| | | | | | | | | | Two patches applied to upstream release. Fixes: QTBUG-103732 Change-Id: Id64b65c4567433806047a2a34fa85ab5f260e6cc Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> (cherry picked from commit a7dcdf063d55bfb332ca47c7330a9a2e0ad83460) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* tst_qfile: skip trash bin test on webOSJanne Juntunen2022-06-081-2/+2
| | | | | | | | | | | Skipping moveToTrash() test is needed because WebOS does not implement a trash bin directory. Fixes: QTBUG-104053 Change-Id: Id1d1595eb401d8ef3a403c915d95be1cd75368d2 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> (cherry picked from commit c58e97245df207034ab6a4b066813d02ee74234f) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Support cosmetic brush patterns in the pdf and opengl paint enginesEirik Aavitsland2022-06-043-2/+85
| | | | | | | | | | | | | | | | | | This implements the recent functionality extension of painting cosmetic (untransformed) brush patterns, and the corresponding NonCosmeticBrushPatterns render hint, in the pdf and opengl paint engines. As part of the implementation it also fixes a couple of pre-existing bugs in the opengl engine, relating to updating the brush after changes in transformation or brush origin. As a driveby, it also includes a minor fix for the lance testing tool: request stencil buffer, as that is needed and not always provided by default. This echoes a recent fix done to tst_baseline_painting. Change-Id: Ia8811477e015eebeb40ed138bca96643ce1ab0dc Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* QTest::toString benchmark: do not pass a template type parameterGiuseppe D'Angelo2022-06-041-1/+1
| | | | | | | | Let it to be deduced, otherwise it may force instantiations which are ill-formed. Change-Id: I3ce674128d96a48ad6883e265734ff330645dd75 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Unify QSslServer from QtWebSockets and QtHttpServer into QtNetworkØystein Heskestad2022-06-047-0/+551
| | | | | | | | | | | | | Both QtWeSockets and QtHttpServer has a QSslServer class that is useful elsewhere. They are different though, so the new class has features from both versions. [ChangeLog][QtNetwork] Unify QSslServer from QtWebSockets and QtHttpServer into QtNetwork Task-number: QTBUG-100823 Change-Id: I523f04db39297ceb9b258f673eb12deecfc6886c Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* The new signal pendingConnectionAvailable is added to QTcpServerØystein Heskestad2022-06-041-0/+71
| | | | | | | | | | | | | | | | | | | | | | | | | | The new signal pendingConnnectionAvailable is emitted after a new connection has been added to the pending connections queue. Connect to this signal and call nextPendingConnection to handle incoming connections. The existing unchanged newConnection signal is emitted after the overridable function incomingConnection is called, regardless of whether a new connection is added to the pending connections queue in the incomingConnection function or not. If a subclass that overrides incomingConnection either decides to not add all incoming connections to the pending connections queue, or to postpone adding the connection until a handshake is successfully completed, the pendingConnectionAvailable signal should be to used, because this signal directly corresponds to insertions to the pending connections queue. [ChangeLog][QtNetwork][QTcpServer] New signal pendingConnectionAvailable is emitted when a new connection is added Task-number: QTBUG-100823 Change-Id: I00c76761389065f68271553e69e6c45c393a2fa8 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* QTestLib: rework QTest::compare_helper()Ivan Solovev2022-06-038-7/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | [ChangeLog][QTestLib] QCOMPARE now evaluates toString() on its arguments lazily, speeding up the general case where the comparison doesn't fail. This is true for the QCOMPARE functionality provided by Qt. If you specialized qCompare() for your own types, then you need to change its implementation in line with Qt's own qCompare() specializations in order to enable this feature. [ChangeLog][QTestLib] QCOMPARE calls with nullptr argument(s) will now print the actual and expected values upon failure. Previously it was not like that because of the compareHelper() overload in qtestresult.cpp that treated the presence of nullptr-arguments as a reason to ignore formatFailMessage() call. New implementation does not have this check, and correctly executes formatFailMessage() for all arguments. Note that the qCompare() overloads that call QTestResult::compare() internally were not affected by this patch, because they already defer toString() invocation until the comparison fails. Some numbers, collected against shared release developer build. I checked how this change affects the test execution. The idea was to pick some tests for types that do not have a specific QTestResult::compare overload, so I picked a couple of QByteArray tests. The comparison is done by running a test 10 times and taking the average execution duration, as reported in the log. tst_qbytearrayapisymmetry: Before: 15.6 ms After: 14.2 ms tst_qbytearray: Before: 41 ms After: 36 ms The benefit is around 9% and 12% respectively. Fixes: QTBUG-98874 Change-Id: I7d59ddc760168b15974e7720930f629fb34efa13 Reviewed-by: Marc Mutz <marc.mutz@qt.io>