summaryrefslogtreecommitdiffstats
path: root/tests
Commit message (Collapse)AuthorAgeFilesLines
* Fix QMultiHash::keys(const T&) overloadIvan Solovev2021-07-081-8/+57
| | | | | | | | | | | | The method was never tested, but it failed to compile after QMultiHash was introduced as a separate class in 6.0. This patch fixes it and adds some unit-tests to cover the case. Task-number: QTBUG-91736 Pick-to: 6.2 6.1 Change-Id: I5dd989d4775efc6a9bb13c5ed1d892e499d95dc2 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QLocalSocket/Win: reimplement skipData() functionAlex Trotsenko2021-07-081-0/+55
| | | | | | | | The base implementation discards the data by reading into a dummy buffer, which is slower than necessary. Change-Id: Iabf0c4a25746af6cac5b61d7bda66d89501c808c Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* QMultiHash::find - prevent detaching shared nullIvan Solovev2021-07-081-0/+15
| | | | | | | | | | | | | Do not detach when find(key, value) is called on an empty QMultiHash. As a drive-by: fix return value for QMultiHash::remove() in case of empty QMultiHash. Task-number: QTBUG-91736 Pick-to: 6.2 6.1 Change-Id: I1e32f359e7ee9ce8403dae79d02e0b88a20ec4a5 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Test Q_CLASSINFO("foobar", #__VA_ARGS__) in tst_mocAndrei Golubev2021-07-081-0/+18
| | | | | | | | There's a chance that this would be used in some macro, so why not test that this thing works in general (especially since it actually works) Change-Id: Ib9d91fbd17cf16675ae89a99f010dacc5d30967a Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Unify and clean up two identical tst_qfile::*_data() functionsEdward Welbourne2021-07-071-57/+41
| | | | | | | | | | Convert newRow() to addRow() to simplify formatting, use a ranged-for iteration, take out a common factor of 1024, use QByteArray instead of roundtripping ASCII via Unicode, and break some long lines. Change-Id: I052730a71fb74f40a0dbd0695dcc286bc39896fb Reviewed-by: Jason McDonald <macadder1@gmail.com> Reviewed-by: Andreas Buhr <andreas.buhr@qt.io>
* Move QSKIP()s to _data() functions in QFile benchmarkEdward Welbourne2021-07-071-24/+11
| | | | | | | | | | Skipping once in the data function is the clean way to do this. Saves setting up dummy data just so as to skip it, or setting up real data and then skippin on each row. Change-Id: I1666d134b6f206e8055fbbc5efd2e2116431a9c1 Reviewed-by: Jason McDonald <macadder1@gmail.com> Reviewed-by: Andreas Buhr <andreas.buhr@qt.io>
* tst_QCryptographicHash: simplify the creation of a large QBAMarc Mutz2021-07-071-4/+1
| | | | | | | | | Use the ctor instead of appending 1'000'000 chars. Introduce C++14 digit separators as a drive-by. Change-Id: Icdbef3173f42d12ae2226b8556f9b1519e594adc Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* QProperty: Downgrade assert in noSelfDependencies to warningFabian Kosmale2021-07-071-0/+9
| | | | | | | | | | | | | | | We call evaluateRecursive_inline in setBinding, which in turns runs the noSelfDependecies check. However, creating a binding resuting in a binding loop must not crash, but instead result in the binding entering an error state. To prevent a crash caused by the assert in debug builds of Qt, we replace the assert with a warning for now. A better approach in the future would be to ensure that we only run the check in cases where we are sure that a self-dependency is really a fatal error. Pick-to: 6.2 Change-Id: I58158864ed81fa907132a4e7d6667c9b529e7e64 Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
* Fix placement of placeholder text in QLineEdits with action iconsVolker Hilsheimer2021-07-061-0/+66
| | | | | | | | | | | | | | | | | | | | After dc794f7622bc00f7ca50fab65d6965695d6d2972, side widgets only got space if they were not fading out, but the logic was not correctly accounting for side widgets that never fade, such as buttons added via QLineEdit::addAction. Fix this to give visible widgets space, unless they are fading out. That was the intent of the original change. Rename the variable to make its purpose clearer, and reset it at the end of the fade-out animation. Add a much-needed test that relies on private APIs to verify that the effective margins are calculated correctly. Fixes: QTBUG-94824 Pick-to: 6.2 6.1 5.15 Change-Id: If2ee6be52be9e4f9be1e91f72f27681ce27def6d Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Fix memory leaks in tst_qlineeditAndreas Buhr2021-07-061-2/+2
| | | | | | | | | | | | In the unit tests, two times a validator was used without a parent, which led to memory leaks. This patch changes this: The validators are initialized with the widget they are meant for as parent. This fixes the memory leaks. Pick-to: 6.2 Change-Id: I480c0c5104cbe60159fad49df28cbb6240e7ce68 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
* QCryptographicHash: port addData() to QByteArrayViewMarc Mutz2021-07-061-7/+7
| | | | | | | | | | | | | Incl. the static hash() function. Remove the QByteArray versions from the API, but not the ABI. Adapt some callers. [ChangeLog][QtCore][QCryptographicHash] Replaced QByteArray with QByteArrayView in addData() and static hash() functions. Change-Id: Ia0e9bf726276305e05894d323d76a29e985f39eb Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QFile benchmark: always use Unbuffered for QFSFileEngine testsEdward Welbourne2021-07-061-7/+5
| | | | | | | | | | Support for buffered usage with QFSFileEngine was dropped in 5.10; trying to use it triggers an assert. Task-number: QTBUG-91713 Pick-to: 5.15 6.1 6.2 Change-Id: I5f46e9f793310538344b96bf2efbeba34098de83 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Fix QDirIterator benchmark to actually find its test dataEdward Welbourne2021-07-061-15/+13
| | | | | | | | | | | | | | | | | The benchmark had a hard-coded path on MS and needed an environment variable set otherwise; neither sounds like a good approach, when testlib defines a variable that tells us the test's source directory, a clearly superior way to find things in our source directories. In the process, replace exit()ing on failure to get a path with a QSKIP() so that the test at least fails gracefully if it ever can't find its data. (Using QFAIL() left it with no rows but still trying to run the test, leading to an assert failure.) Pick-to: 6.2 6.1 5.15 Task-number: QTBUG-91713 Change-Id: I1bd5561971239bb838bcf6c24bcdf1d07c81a657 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Clarify readLine() behavior on sequential devicesAlex Trotsenko2021-07-061-0/+102
| | | | | | | | | | QIODevice::readLine() can also return partial lines, which was not properly documented. Add an autotest for QLocalSocket to illustrate and test this behavior. Pick-to: 6.2 Change-Id: Ia2c1c438cc68d2672d34881e11fdf7837232f3b4 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* QCryptographicHash: don't present the same data over and over againMarc Mutz2021-07-061-0/+84
| | | | | | | | | | | | | | | | | | Need to decrement 'remaining' (check), but also increment data (meep). Testing is a bit complicated, as most algorithms are just too slow to fit into the 5min QTestLib timeout. Picked the fast ones and Sha512 (which completes here in < 17s, with threads), at least. Amends e12577b56396cca0df05f88f8787706a3a12c82d. [ChangeLog][QtCore][QCryptographicHash] Fixed a bug where presenting more than 4GiB in a single addData() call would calculate the wrong result(). Pick-to: 6.1 6.2 Change-Id: Ic72916ebc33ba087d58225af6d8240e46e41f434 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* tst_QCryptographicHash: make hashLength() data-drivenMarc Mutz2021-07-051-3/+12
| | | | | | | Pick-to: 6.1 6.2 Change-Id: I44bf73e15b53b8d93d116f4114bc667c4c94b7b4 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* Repolish child widgets when parent style sheet changesVolker Hilsheimer2021-07-051-0/+14
| | | | | | | | | | | | | | | | | | | If a child widget that is affected by the parent's style sheet is polished (because it's been shown explicitly, for instance by a layout), then it must be repolished when the parent's style sheet changes, even if the parent itself has not been polished yet. Since the style sheet is set on the parent widget, we must repolish the parent (which will repolish the entire widget tree), not just the individual children and grand children. Fixes: QTBUG-76945 Task-number: QTBUG-39427 Task-number: QTBUG-18958 Change-Id: I7bca9ee1badc07202fa05dc97f440f4ca6c9517d Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Andy Shaw <andy.shaw@qt.io>
* Run tst_QIODevice::skip() on random-access deviceAlex Trotsenko2021-07-031-3/+4
| | | | | | | | Due to mistake in data it was missed for testing. Pick-to: 6.2 Change-Id: I4dcd6fd90fd501e4cc941c07efcf9439ba6acf30 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* Use target_link_options to propagate object librariesAlexey Edelev2021-07-022-3/+67
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | target_link_options are placed by CMake at the beginning of a linker line. This gives us an opportunity to use the function to propagate object libraries. This change adds one more check in the root Config.cmake file. If CMP0099 policy is enabled, CMake enables propagating of the linking options when linking two static libraries using the PRIVATE linking visibility, so we can rely on the correct linking order and expect object libraries to be propagated. Note that on the platforms where cmake version is higher than 3.16 Qt uses CMP0099 NEW in functions like qt_add_executable. This means that at the moment of creating an executable target the TARGET_POLICY genex will also be NEW, so we do not take into the account the user defined CMP0099. If the CMP0099 policy is not available for a certain CMake version we skip the TARGET_POLICY check and simply disable propagation of the object libraries using target_link_options for both user and Qt libraries. This is applicable for the CMake versions 3.16 and less. Linking approaches have the following priorities(from higher to lower) after this change: - target_link_libraries - works if link order matters not or CMake version greater equal 3.21. - target_link_options - works if CMP0099 is set to NEW by user or if the CMake version is greater than or equal to 3.17 and an executable is created using Qt functions. - object library finalizer - works if CMake version is greater equal 3.19 or qt6_finalize_target is called explicitly. - target_sources - is used when all the other approaches could not be used. Amends a1fd4f51ada82854f35654158a334454e760a9f7 Amends 3329212815777e33dfb4697b748d10927d73f44c Pick-to: 6.2 Change-Id: I14f88caeb04e357191c840abeab89b03e210b796 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* tst_QDtls: Move the function declaration outside the functionMårten Nordheim2021-07-021-1/+2
| | | | | | | | | With MSVC it tries to link with the function in the scope qt::tst_QDtls::* where it is not found Pick-to: 6.2 Change-Id: If83a9f69c7b3834248569f6bdf203f5442693080 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QNetworkRequest: Rename (set)minimumArchiveBombSizeMårten Nordheim2021-07-022-4/+4
| | | | | | | | | To (set)decompressedSafetyCheckThreshold, as suggested on the API review. Task-number: QTBUG-94407 Change-Id: Iffc52691022939ae46703de8a0416355487b716f Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Fix tst_qmessagehandler::formatLogMessage() test on AndroidAssam Boudjelthia2021-07-011-0/+4
| | | | | | | | | This amends 87d8ee755bfdef8e72a122789c2e3ed382881a12. Pick-to: 6.2 Task-number: QTBUG-94708 Change-Id: Iac9b0f896ede76074504f777b65ad572dd8d6377 Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
* QTest: fix -Wformat-overflow GCC warningMarc Mutz2021-07-016-26/+26
| | | | | | | | | | | | | | | Says GCC: In function ‘char* QTest::toString(QPair<T1, T2>&) [with T1 = QWidget*; T2 = QEvent::Type]’, warning: ‘%s’ directive argument is null [-Wformat-overflow=] Fix by re-using formatString(), once introduced for std::tuple. As a side-effect, this gets rid of the funny double-quotes around the output. Change-Id: I2dd5f10fa2b3a392370bf487c1b7e98f3d190978 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QSemaphore: add <chrono> overload of tryAcquire()Marc Mutz2021-06-301-1/+35
| | | | | | | | | | | | | | | ... and C++20 std::counting_semaphore API compatibility. [ChangeLog][QtCore][QSemaphore] tryAcquire() now optionally takes a <chrono> duration as timeout, not just int milliseconds. [ChangeLog][QtCore][QSemaphore] Added try_acquire{,_for,_until}() for C++20 std::counting_semaphore compatibility. Change-Id: I34b6b4bf57a54745d4b97349903d090c4995338a Reviewed-by: David Faure <david.faure@kdab.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* tst_qglobal: fix an uninit'ed variable warningMarc Mutz2021-06-301-1/+1
| | | | | | | | | | GCC can't see through all the foreach code to determine whether the loop will execute at least once, so don't play hardballs with the compiler and initialize the variable. Change-Id: I95756a99eda497a25aa277046df9895f558758c3 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* tst_QMatrixNxN: fix type-punning warningMarc Mutz2021-06-301-32/+14
| | | | | | | | | | | | | ... by making the test class a friend of the CUT, as we do elsewhere for the same reason. This allows to remove the duplicated enum and struct in favor of using The Real Thing™, which means the test can no longer go out of sync with the CUT anymore. Change-Id: I87dc8bb4a5476ae4fc99e006c4690e96d2f530d2 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* tests: fix deprecated implicit capture of this via [=]Marc Mutz2021-06-303-3/+3
| | | | | | | | Fixes compiler warnings: warning: implicit capture of ‘this’ via ‘[=]’ is deprecated in C++20 [-Wdeprecated] Change-Id: Ia7cf50f491e92f39162c69afb2a8320afedba056 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* QList benchmark: fix annoying -Wdeprecated-copy warningMarc Mutz2021-06-301-0/+2
| | | | | | | | | | MyPrimitive has a copy ctor but lacked a copy assignment operator, leading to above-mentioned warning. Fix by supplying the missing special member function. Change-Id: Icd0c3c12554eb838b5d880ec9a649d0b5cfc81b7 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* tst_QWindow: fix -Wsuggested-overrideMarc Mutz2021-06-301-1/+1
| | | | | Change-Id: I9e6eb0a4e0a64146d3c733c8cf34530a2cca5c4b Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* tst_qstringapisymmetry: add checks for common overload setsMarc Mutz2021-06-251-0/+106
| | | | | | | | | | | | | - QString/QStringView overloads were designed to be compatible for all possible argument types, so check that it stays that way - QString/QAnyStringView overloads have several known ambiguities that we cannot and don't want to fix, because it would make QAnyStringView less versatile, but at one should at least be able to overload QString and weak-QAnyStringView. Change-Id: I5e5ae3c96060c93bfe070f6c19213328dae9c5f9 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* tst_QSslSocket: Remove empty test functionsMårten Nordheim2021-06-251-10/+0
| | | | | | | | For flush() it's not clear what they wanted to test. isEncrypted() is tested indirectly in many of the other tests. Change-Id: Id6dfecbb25b7bba8f1a99518fd9c9e06280aaa9f Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* tst_qsslsocket: detect ALPN support (on server) using supportedFeatures()Timur Pocheptsov2021-06-251-17/+4
| | | | | | | Pick-to: 6.2 Change-Id: I30409667395bbe568823b8697dded41067a8346c Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* tst_QSslSocket: Use supportedFeatures() instead of macroMårten Nordheim2021-06-241-4/+2
| | | | | | | | | It needs to be checked at runtime to know if the current backend supports it Pick-to: 6.2 Change-Id: I0998309149b109e2075a008b2b8d8115fa3688cc Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* qopenssl_symbols: Change how we mark function unusedMårten Nordheim2021-06-241-29/+16
| | | | | | | | | | | | | With MSVC the current way we mark it (potentially) unused ends up with a warning: warning C4551: function call missing argument list We require c++17 core language support so let's use [[maybe_unused]] instead. Pick-to: 6.2 Change-Id: I125986b729cb7cd540901702a47365f0491e7887 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* TLS: Mark TLS 1.0, 1.1 and DTLS 1.0 deprecatedMårten Nordheim2021-06-251-13/+102
| | | | | | | | | | | | As per the best practice laid forth in RFC-8996. TLS 1.2 was recommended from 2008 until TLS 1.3 was released in 2018. [ChangeLog][QtNetwork][QSslSocket] TLS 1.0, 1.1 and DTLS 1.0 are now deprecated, as recommended by RFC-8996. Fixes: QTBUG-92880 Change-Id: I90cebcfb07cfce623af7ac9f2b66ce9d02586b54 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* QSslSocket: Set isEncrypted to false on disconnectMårten Nordheim2021-06-251-0/+1
| | | | | | | | | Since we're no longer connected, much less encrypted. Was done in schannel backend, but not in ST or OpenSSL Pick-to: 6.2 Change-Id: Ia49387be0088f899a0c89091f7e468dba1c0eee6 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* tst_http2: use the supportedFeatures() instead of macrosTimur Pocheptsov2021-06-241-10/+14
| | | | | | | | | | | With the recent change, 'system' headers gone: not in the test code anymore, so, for example OPENSSL_VERSION_NUMBER is undefined, making the test to select a wrong code-path - 'h2c', instead of encrypted h2. Pick-to: 6.2 Pick-to: 6.1 Change-Id: I3b201e21fac56875c9045c7463e2ae69af4c6470 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Implement generating of a module cpp export headerAlexey Edelev2021-06-2411-0/+344
| | | | | | | | | | Add an option that automatically generates an export header for a Qt module. The header contains only Q_DECL_EXPORT/Q_DECL_IMPORT related content, so it's not a full replacement of 'global' header files. Task-number: QTBUG-90492 Change-Id: I250d1201b11d4096b7e78e61cbf4565945fe6517 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Consistent indentation for BINDABLE propertiesAndreas Buhr2021-06-241-3/+6
| | | | | | | | | Triggered by API review in Gerrit patch 355960. Task-number: QTBUG-94407 Pick-to: 6.2 Change-Id: I7cafc1cc9d4b929040b53c6bf92c91d73c3b39f2 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Expand a test that QVariant isn't null even when what it wraps isEdward Welbourne2021-06-241-4/+6
| | | | | | | Match the checks in the constructor test that are similar. Change-Id: Ifb62af09e31aac339f001f44bc30789330c85be6 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Fix compiler warning from unused parameterVolker Hilsheimer2021-06-231-1/+1
| | | | | Change-Id: I227b7188eddbad024dcced908c894925cee56591 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Use UTC when parsing only a date or only a time, not a date-timeEdward Welbourne2021-06-231-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | This should reduce the amount of fall-out from DST complications. Also document the assumptions of QDateTimeParser's two fromString() methods (and fix the punctuation on the QDateTime parameter). Adjusted some tests to match. Since only QDateTime-returning methods will show the difference, and it's at least somewhat odd to be using those on QDateEdit or QTimeEdit, this should have little impact on API users. [ChangeLog][QtCore][Behavior Change] QDateEdit and QTimeEdit now operate in UTC, to avoid spurious complications arising from time-zone transitions (e.g. DST) causing the implicit other half to combine with the part being edited to make an invalid result. Returns from their dateTime() and other methods returning QDateTime (max/min) shall thus be in UTC where previously they were in local time. QDateTimeEdit continues using local time. The default can be over-ridden by setTimeSpec(), as ever. Change-Id: I44fece004c12342fe536bbe3048217d236fd97b2 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix handling of day-of-week in QDateTimeParser and QDateTimeEditEdward Welbourne2021-06-231-12/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | QDTP's absoluteMax(), setDigit() and getDigit() simply treated day-of-week as synonym for day-of-month. Consequently, QDTE::stepBy() did the same. This meant that wrapping happened at the month boundary, so would jump within the week if it wrapped around, otherwise the up/down arrow would "jam" at a particular day of the week when further steps would leave the month. Instead, when wrapping, wrap round the week while still moving the day-of-month to match, jumping back or forward a week to stay within the month on hitting a month boundary; otherwise, stop backwards stepping on hitting the locale-specific day of the week, or forward stepping when the step would be to or past this first day. Fixed various bugs found in the course of testing this. [ChangeLog][QtWidgets][QDateTimeEdit] Corrected handling of weekdays. Previously, changes to the week-day were simply changes to the day of the month. Weekday fields are now handled as such: changes to them do change the day of the month, but a change that would step past the end (or start) of the month is adjusted to the relevant day of the nearest week within the month. When wrapping is disabled, the locale-specific first and last days of the week are the bounds. Formats which specify day of week but not day of month will now preserve day of week when changing month or year, selecting the nearest day of month that matches. Change-Id: I7868b000fea7a4bc17a1b5687c44bcd56d42ae90 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QString: Respect precision when reading data for %.*s format stringUlf Hermann2021-06-221-0/+30
| | | | | | | | | | | If we disregard the precision we may read a very large string that we subsequently discard. Furthermore, people use this to read non-null-terminated strings, which randomly crashes. Pick-to: 5.15 6.1 6.2 Change-Id: Ifa255dbe71c82d3d4fb46adfef7a9dc74bd40cee Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QWidgetAction: add test for defaultWidget() being deleted before actionMarc Mutz2021-06-221-0/+12
| | | | | | | | | ... even though the documentation states that the action takes ownership of the widget. Change-Id: Ie5520fbda295a5a2774ff8b82165070e9d49e310 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* BLACKLIST tst_QListView::internalDragDropMove for OpenSUSE leapHeikki Halmet2021-06-211-0/+3
| | | | | | | | Task-number: QTBUG-94250 Change-Id: I9ea92b5952e1823cf90716f027f2f8eea1b86278 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Tony Sarajärvi <tony.sarajarvi@qt.io>
* Add basic benchmarks for QFutureSona Kurazyan2021-06-193-0/+332
| | | | | | | | | | The benchmark simply calls the non-trivial methods of QFuture, mostly to make sure that fixes in the parent patches don't have any performance implications. Task-number: QTBUG-92045 Change-Id: Ib4e8c314a70b3090a1af55f1b96d9dad4bc63861 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* Move the linking logic of the object libraries to a common functionAlexey Edelev2021-06-181-1/+1
| | | | | | | | | | | | | | | | | | | The linking logic of object libraries should be reusable outside of the resource context. This introduces a __qt_internal_propagate_object_library function that prepares all the necessary genexes to link and propagate the object library to the end-point executable. Rename resource object finalizer API to make the naming more generic to object libraries of any kind. Amends 5fb99e3860eb43f4bacacec7f4a4626cb0159b14 Pick-to: 6.2 Task-number: QTBUG-93002 Task-number: QTBUG-94528 Change-Id: I69d0f34c0dadbd67232de91035aaa53af93d1fa1 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Do not alter a widget's backing window's format once createdLaszlo Agocs2021-06-181-3/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Changing anything on a QWindow's QSurfaceFormat has zero and null effects once the underlying native window has been created. Letting QWidget update the format is wrong in this case, because we always expect that the value returned from QWindow::format() reflects reality. (reality being the settings with which the underlying native resource was created, which is typically frozen after QWindow::create(), not the state of some QWidget attribute. There are certain exceptions to this, such as when preparing to recreate the underlying native window, in which case one will want to update all relevant fields of the format based on the current values of the widget attributes, which is exactly what QWidgetPrivate::create() implements, and that's good.) Such a mismatch can have fatal consequences when OpenGL and friends are involved, but this always depends heavily on the platform and windowing system. For example, claiming that the alpha buffer size is 0 when the native window was created with 8, or vice versa, can break OpenGL-related code (both in Qt itself and in applications), that tries to create a QOpengGLContext configured based on what QWindow::format() returns. If that format describes settings that are incompatible with the actual underlying native window, we end up with the classic Invalid pixel format, EGL_BAD_MATCH, and alike errors. This is exactly what is happening when a QOpenGLWidget (or QQuickWidget) is placed in a QDockWidget where one of the ancestors is forced to native (winId() was called or WA_NativeWindow was set). When undocking, various code paths in QWidget will try to update the opaque flag of the widget, which in turn calls updateIsTranslucent. Now, if this function unconditionally changes the alphaBufferSize in the QWindow's QSurfaceFormat (even though this is completely futile to do, it has no visible effect in practice), we get the problem described above: rendering breaking down due to OpenGL contexts created with a pixel format incompatible with the native window. Prevent all this by not touching the format once the QWindow has a QPlatformWindow. This is the right thing to do, regardless of the bug in question: a window's (or context's or any other native resource wrapping class's) format must describe the underlying native resource and must never deviate, unless we are preparing to create a new native resource underneath. When it comes to the autotest, this changes the test added in 555661b625c40f21a6a3e4c73e928a6e8a46db20: the autotest logic is inverted because what we should test for is that the QSurfaceFormat stays untouched once the application makes a - futile - attribute change on the widget. Fixes: QTBUG-85714 Pick-to: 6.2 6.1 Change-Id: I7bf90711867e8a0fd474895625bf9530a7821fd5 Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* QHash: Fix erase() edge-caseMårten Nordheim2021-06-181-0/+19
| | | | | | | | | | | | | | | | | | | | | When the element you want to erase is the last element AND the next element (element 0), when rehashed, would be relocated to the last element, this leads to the state below. Which is similar to a test in tst_qhash for some seeds. auto it = hash.begin + (hash.size - 1) it = hash.erase(it) it != hash.end By forcing the iterator to increment if we were erasing the last element we always end up with a pointer which is equal to hash.end Befriend the tst_qhash class so we can set the seed to a known-bad one Pick-to: 6.2 6.1 Change-Id: Ie0b175003a2acb175ef5e3ab5a984e010f65d986 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io>