summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* QVarLengthArray: fix memory leak in (qsizetype) ctorv6.4.36.4.3Marc Mutz2023-03-111-15/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | Instead of duplicating the logic of resize() to avoid three stores to (ptr, a, s), and getting the memory management wrong (malloc()ed ptr leaked when a following default-construction failed), simply call the QVLA default ctor followed by std::uninitialized_default_construct_n(). After we called the QVLA default ctor, the lifetime of this object has begun, so if the following code throws, ~QVLA will be called to clean up. This was not the case when we didn't delegate the ctor: if the body of this ctor threw, ~QVLA would _not_ have been called, since the lifetime of the object had never started. Since the dtor may now run, we need to maintain the class invariants, so we can't just set the size() before we have constructed all elements. This is where std::uninitialized_default_construct_n() comes in: it's strongly exception-safe, so if a constructor throws, it will destroy all previously-constructed elements, so that either we fail and size() == 0 is true or it doesn't, then we can set size() to asize. Change-Id: I03408d8a473e8a31fa0086ef5ac551ce46a758f8 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> (cherry picked from commit 217f2ab3eb04b7489959e8e1134184e8071dbaf0)
* Fix overflow in SHA-3/KeccakMårten Nordheim2023-03-104-2/+64
| | | | | | | | | | | | | state->rate is always larger than or equal to state->bitsInQueue; when bitsInQueue == rate the queue is consumed and bitsInQueue is set to 0 again. Done-with: Marc Mutz <marc.mutz@qt.io> Change-Id: I56d268a19fb3cd542cc027edc962253f09d97a14 Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit fa4b7495b741c3e7943860c5ff15212afceda710) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* tst_QCryptographicHash: Extract Method ensureLargeData()Marc Mutz2023-03-101-1/+11
| | | | | | | | | ... to make large data usable from other test functions. Change-Id: I302070121a8bb49f373c7711bc3ab9e6418874ef Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> (cherry picked from commit f7ea9b36b7c56bb288f3ea55f587d2ccb8a9b7fa) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* qsimd_p.h: remove LZCNT feature from the ARCH_HASWELL listThiago Macieira2023-03-071-2/+2
| | | | | | | | | | | | | | | | | | And for good measure, I'm also removing BMI2. The one we really care about ensuring gets enabled instead of -mavx2 is FMA anyway. Complements commit 29d3938aa56663f09666a0ac58b33e70e00abff2 (which in turn complemented commit a98cf15ed1b57aee695de01b04a974637b2cd44a), which removed BMI1 because AMD introduced it before AVX2. Looks like they also introduced LZCNT in some earlier processor too (family 10h) or GCC 12 began emitting __LZCNT__ for that family -- IIRC the AMD feature list was bigger than just the lzcnt instruction. Fixes: QTBUG-111698 Change-Id: I7f354474adce419ca6c2fffd1748f5b24f69a692 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io> (cherry picked from commit 8413824ca00188fa36b6adf46d4a5bddb9515ec7) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Add special thread pool for Qt GuiAllan Sandfeld Jensen2023-03-029-20/+50
| | | | | | | | | To avoid gui slowdowns due to global pool being blocked. Fixes: QTBUG-109511 Change-Id: I4e8d91e8fb0bd2e395072a082e992a3c5d3464ad Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> (cherry picked from commit 93047c71e8e6dd4ac28e1e59dcb561df11c759eb)
* Update Harfbuzz to 7.0.1Eskil Abrahamsen Blomfeldt2023-03-02338-28976/+44685
| | | | | | | | | | | | | | | This is the 6.4-specific update of Harfbuzz, since Harfbuzz was currently on an older version in 6.4 compared to other branches. This also backports the change to the qtextlayout test that was done on other branches for the 6.0.0 update. Fixes: QTBUG-111535 Change-Id: Ie8217f1541a02d3800142b88cf0007be0ed0d1e2 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit 13549fa7c2d27ba588471f97a640f4dbcf86b10c) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* tst_QMutex: use constexpr variables instead of 'enum-trick'Marc Mutz2023-03-021-2/+2
| | | | | | | | | | | | C++20 doesn't like arithmetic with enums anymore. While this hasn't caused immediate pain, yet, fix it pro-actively for an imminent patch. As a drive-by, fix the missing space at start of comment. Change-Id: Id08bb227c587bc7b900c593a7b6d2655ca32eefd Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit b8966021ffb2cfddc77aee6dbe145eb74ef22f9d) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* tst_qvarlengtharray: add test for QVLA(n) ctorMarc Mutz2023-03-021-0/+44
| | | | | | | | | | | Also add one for types that are neither copy- nor move-constructible. In contrast to resize(n), the QVLA(n) ctor worked for such types, so make sure it stays that way. Change-Id: If54fbc9dd6a4808175c4bcb0ffb492b33c879746 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> (cherry picked from commit e7c792ba7179c4c81fb2e26f66031ec81234b0d7) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Update to Freetype 2.13.0Eskil Abrahamsen Blomfeldt2023-03-02514-7721/+6158
| | | | | | | | | | | | Also adds a file to patches which is a required modification to the update in order to make it compile. Fixes: QTBUG-111536 Change-Id: Iaabc1b7736cfd98217a8aff2b7f9bc65402d0451 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit 18aa3309a4e4b5a874298af1243095db9aa207d3) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Windows drag&drop: Use correct window for drag target processingOliver Wolff2023-03-021-1/+2
| | | | | | | | | | | | | | GetFocus will return the window that currently has keyboard focus. This is not what we want for drag and drop handling though. Use the window under mouse and process events for that window when doing the touch/pen input workaround. If no window is found we fall back to the focus window. Followup to 31e7790102b260344893eaa8bf8b7b1a0f95e3b7 Fixes: QTBUG-111149 Change-Id: Ib8233debc267df0cc19b21c1dc5c6881d018d84a Reviewed-by: Timothée Keller <timothee.keller@qt.io> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> (cherry picked from commit c912bde52a1b85a782db6aed8d6f9917d597f58b)
* SQLite: Update SQLite to v3.41.0Andy Shaw2023-03-013-1354/+2979
| | | | | | | | | | | [ChangeLog][QtSQL][SQLite] Updated SQLite to v3.41.0 Fixes: QTBUG-111539 Change-Id: Ia90939bf57222a290fe7bcb3741013c2576eec13 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit 8f33a0424f5799a87d6d56691f3e47a09156c720) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> Reviewed-by: Jani Heikkinen <jani.heikkinen@qt.io>
* QAbtractItemView: deselect before click opens editorVolker Hilsheimer2023-03-012-17/+14
| | | | | | | | | | | | | | | A click on the selected item should deselect all other items before editing starts. Remove the part of the test case that assumes that we can have multiple items selected in ExtendedSelection mode, and click on an item to start editing while maintaining selection. That can never happen. Fixes: QTBUG-111131 Change-Id: I0312eed4614502cfb77eca26d3f7615427493d7d Reviewed-by: Axel Spoerl <axel.spoerl@qt.io> (cherry picked from commit 3f2d02e2f4436ace5f0fbbf432878a963f5ee969) Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* CMake: Fix position independent code linker flags not being setJoerg Bornemann2023-02-271-0/+4
| | | | | | | | | | | | | | | | | | | | We set CMAKE_POSITION_INDEPENDENT_CODE to ON and require CMake 3.16. This sets CMP0083 to NEW and should pass -fPIE to linker calls as well. However, the PIE-enabling flag is not passed to the linker unless we call check_pie_supported(). This behavior is documented in CMake's CMP0083 documentation page. [ChangeLog][CMake] Qt tools are now built with position independent code even with Unix toolchains where this is not the default, for example clang. Change-Id: I1d98e0ea7063a76e3fddc94d6555c6eaf14c7885 Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> (cherry picked from commit 4183768d9bc6f80ac7b86c3dbf93e6b251369ae4) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> (cherry picked from commit 6d301449fd36ccb3ea33dc58d41b44f5ba31ca3a) Reviewed-by: Jani Heikkinen <jani.heikkinen@qt.io>
* corelib: silence `-Wcomma` with clang-12Tim Blechmann2023-02-221-1/+5
| | | | | | | | | | | | clang-12 warns with -Wcomma warning: possible misuse of comma operator here [-Wcomma] { return Q_ASSERT(i >= 0), Q_ASSERT(i < size()), QLatin1Char(m_data[i]); } Change-Id: Ice8a809c8ac9069e55aedefa71faf06385e97789 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit c24f4d2c32b475a24250ff4bed15837615f33ef0)
* QVarLengthArray: fix UBs in emplace()/insert() ([basic.life], broken class ↵Marc Mutz2023-02-211-21/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | invariant) There are two problems in emplace_impl() (the same code exists as rvalue insert() since 5.10): First, the old code updated size() at the end of the function. However, if, after constructing the new end element, one of the subsequent move-assignments fail (throws), then the class invariant that size() be the number of alive elements in the container is broken, with the immediate consequence that the QVLA dtor would not destroy this element, but surely other unpleasantness (UB) that the C++ lifetime rules decide to throw our way. Similarly, in the trivially-relocatable case, the memmove() starts the life-time of the new end object, so if the following placement new fails, we're in the same situation. The latter case is worse, though, since here we leave *b in some weird zombie state: the memmove() effectively ended its lifetime in the sense that one mustn't call the destructor on the source object after trivial relocation, but C++ doesn't agree and QVLA's dtor will happily call b->~T() as part of its cleanup. The other ugly thing is that we're using placement new into an object that C++ says is still alive. QString is trivially relocatable, but not trivially copyable, so we can't end a QString's lifetime by placement-new'ing a new QString instance into it without first having ended the old object's lifetime. The fix for both of these is, fortunately, the same: It's a rotate!™ By using emplace_back() + std::rotate(), we always place the new object in a spot that didn't contain an alive object (in the C++ sense) before, we always update the size() right after doing so, maintaining that invariant, and we then rotate() it into place, which doesn't leave zombie objects around. std::rotate() is such a fundamental algorithm that we should trust the STL implementors to have optimized it well: https://stackoverflow.com/questions/21160875/why-is-stdrotate-so-fast We know we can do better only for trivially-relocatable, but non-trivially-copyable types (ex: QString), so in order to not lose the memmove() optimization, we now fall back to std::rotate on raw memory for that case. Amends dd58ddd5d97f0663d5fafb7e81bff4fc7db13ba7. Manual conflict resolutions: - no q20::construct_at() in 6.4 Change-Id: Iacce4488ca649502861e0ed4e084c9fad38cab47 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit e24df8bc726d12e80f3f1d14834f9305586fcc98) Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QObjectBindableProperty: Avoid use-after-free in notifyObserversFabian Kosmale2023-02-202-1/+27
| | | | | | | | | | | | | | | | | | | | We so far refetched the first observer after evaluating bindings, as binding evaluating might change the list of observers. However, that approach did not take into account that the 'this' pointer might no longer be valid after binding evaluation: In case of a QObjectBindableProperty (or a QObjectCompatProperty), binding evaluation might cause a reallocation of the binding storage, and consequently the invalidation of the QPropertyBindingData. Fix this by refetching the QPropertyBindingData from the storage (if a storage has been provided, which is always the case for the affected classes). Fixes: QTBUG-111268 Change-Id: Ie7e143a0bbb18f1c3f88a81dd9b31e6af463584f Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> (cherry picked from commit b124171309b259d429bd064fe3bfdec148869ef4) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Fix QString from ASCII warning in qoperatingsystemversion_darwin.mmTor Arne Vestbø2023-02-201-1/+1
| | | | | | | | | Introduced in d05f2fb2d567. Change-Id: Ifa308be3be9c817c6304f634a53da62e631f54af Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit 9416012523e75b8b73bb9a8c02e5bbeb30aafac5) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Resolve actual macOS version despite process running in compatibility modeTor Arne Vestbø2023-02-184-34/+54
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If the application executable was built against a pre-macOS 11 SDK, macOS will report its version as 10.16 on every OS from macOS 11 and up, for compatibility reasons. From Qt 6.2 and up, we require at least Xcode 12 with the macOS 11 SDK to build Qt applications, so normally this should not be an issue, but in the case where the Qt 'app' is a plugin library hosted by a third party host application, the host application determines the behavior, and we might end up in the compatibility situation after all. However, since the Qt app was built against at least the macOS 11 SDK, we know that it can/should handle the new version number scheme, and we can resolve the real version number for QOperatingSystemVersion. We do that by launching the sysctl binary with the SYSTEM_VERSION_COMPAT environment variable set to 0, which is the supported way of disabling the compatibility mode. Now that we have the real version number we can use that for the deployment target check via qt_apple_check_os_version(), but we still need to account for possible failures in reading the plist file. We can also simplify the QOperatingSystemVersion::MacOSBigSur definition, now that we always know the app the should be able to handle major versions above 10. Task-number: QTBUG-111114 Change-Id: I2a2756381c31b195f7b8800c5008a87b37114080 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit d05f2fb2d567617730d7d4757fff39ddc3e903ce) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QScroller: use categorized loggingVolker Hilsheimer2023-02-181-71/+96
| | | | | | | | | | | | | | Replace local built-time enabled macro with a logging category. As a drive-by, move QDebug streaming operator into the anonymous namespace to prevent external linkage, break some excessively long lines, and remove dead code. Task-number: QTBUG-102010 Change-Id: I49d212ee4a66a3eabfa5567f6c8d9674ffbb8880 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io> (cherry picked from commit 5edb1bed3fc360276aec3e678f8b46cb40dd5d26) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QGesture: make sure we copy timestamp value for event clonesVolker Hilsheimer2023-02-182-42/+65
| | | | | | | | | | | | | | | Otherwise, double-click recognition will fail. Use QEvent::clone when possible, or set the timestamp explicitly when not. As a drive-by, remove some long-dead code in affected code lines. Fixes: QTBUG-102010 Change-Id: I882bf6e8090bf6f182b7a0a3c62aa3a4c8db2e14 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> (cherry picked from commit fb09c82a2c7c44d41a0a36d8fe6d6d22e792668a) Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Darwin: Ensure encrypted library is loaded before parsing plugin metadataTor Arne Vestbø2023-02-173-8/+51
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Application delivered via the macOS or iOS App Store might have their libraries encrypted, in which case we can not read any of the sections of the binary until it has been dlopened. This was causing issues for our plugin loading code, which assumed we could read the .qtmetadata section of a yet to be loaded plugin to determine its suitability, before loading it. We now detect whether a library is encrypted during the Mach-O parsing, and propagate this back to QLibraryPrivate::updatePluginState(), which can handle the case by explicitly loading the library before continuing with metadata validation. We still ensure that the library has a .qtmetadata section, so that we don't need to dlopen any random library in our path. This does mean that we will potentially load more plugins than we need, and since the Qt version validation happens as part of meta data validation, we might dlopen() incompatible plugins, but it's expected that in an App Store deployment scenario you control both the versioning and set of shipped plugins, so this should not be an issue in practice. As encrypted libraries are only produced for apps that are fully published to the App Store, and then deployed via MDM, VPP, or Apple Configurator 2, we don't have an easy way to test this, but the existing code paths should be unaffected, and hopefully this patch improves the situation for the encrypted library case. Change-Id: Iff733505f7067ce5571854ea978bc95e8376e347 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> (cherry picked from commit 667aec810f71ac378a618032846df4bb6d76c647) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* TLS[openssl]: Use optional<> for CA cert we are fetchingMårten Nordheim2023-02-172-4/+4
| | | | | | | | | | | | | | The QSslCertificate ctor is somewhat expensive, especially when we are shutting down. By using optional<> we simply reset() it and no longer need to create a new, valid, certificate. Task-number: QTBUG-102474 Change-Id: I514433b0d380dd3ceabbed3a6164f7e3efc490c7 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io> (cherry picked from commit 61bfe87a64ca322de0ebf9bf61a0a0a81ee5bf7d) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Delete references to deleted examplesMårten Nordheim2023-02-162-2/+0
| | | | | | | | | The bearer code hasn't been in Qt for some years. Change-Id: Id69ad1ce5035a0970f3507d4b6ba4a5549bf1d6c Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> (cherry picked from commit d5e98cde1a1da17df1c82e697ce786878e71511c)
* QAbstractItemView: don't start editing on Ctrl-ClickVolker Hilsheimer2023-02-162-2/+46
| | | | | | | | | | | | | | | | | | | | Amends 17c1ebf8bfd254ff75cc55e335d1c1fb01da547f, after which dragEnabled item views toggled selection on click rather than on press. If the edit trigger included SelectedClicked at the same time, then Ctrl-Clicking a selected item would start editing the item, instead of toggling selection. Fix this by ignoring clicks with modifier when evaluating whether editing should start. Extend the mouseSelection test case by including a column for the editTrigger, and cover the respective combinations. Fixes: QTBUG-111131 Change-Id: I9605f9b3d5a49e292551a34c3c4c7a5f9ecb2a89 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> (cherry picked from commit 557dcd8a87c6c6c77ccc71a85b1ec349c69eb4c4) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QVarLengthArray: protect against aliasing in resize(n, t)Marc Mutz2023-02-161-0/+4
| | | | | | | | | | Amends a00a1d8806cfbf17e04b88d1b4ff4a9cf5b6294a. Change-Id: I3fa6183466715555530d4042006049e286897343 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> (cherry picked from commit 0cfaa6e8964a0458cca20ce686b6a399293ad4cc) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Fix QStatusBar::removeWidget to hide the right widgetThorbjørn Lindeijer2023-02-162-12/+47
| | | | | | | | | | | | | | `QStatusBar::removeWidget` was hiding the wrong widget (the next one), since the `removeAt` call changed the item that the `item` variable is referencing. This fixes a regression in Qt 6.3.0 (7166a82844500238a4dad91857384479c7). Change-Id: I9977b47e6208f8d451ff1037bcb9f4e8414cb431 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Thorbjørn Lindeijer <bjorn@lindeijer.nl> (cherry picked from commit 3e7226f10702828eaaf2fa939efc2ac476e8a2b4) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Android: use test QFileInfo fileName() instead of completeBaseName()Assam Boudjelthia2023-02-161-1/+1
| | | | | | | | | | using fileName is more correct in this case. Task-number: QTBUG-98974 Change-Id: I7c547bfc1c2321d4817dc087d3e962dbc2a0b7fd Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io> (cherry picked from commit df47d7d1ff2ac45ab5c6cdade89e5e1857f12479) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QFileSystemWatcher/Win: remove the pre-QFileInfo path normalizationThiago Macieira2023-02-152-14/+20
| | | | | | | | | | | | | | | | | | It's completely unnecessary, since QFileInfo will query the file system anyway and that has a much better view of what is normalized and what isn't. More importantly, this fixes the mistake in failing to normalize properly in removePaths(), which removed the ending slash of a root directory such as "C:\\". That caused the path to become "C:", which QFileInfo interprets as "current path on drive C:". [ChangeLog][QtCore][QFileSystemWatcher] Fixed a bug that prevented removePaths() from removing the root of a drive on Windows. Fixes: QTBUG-110986 Change-Id: I9671dee8ceb64aa9b9cafffd17419b6d69670876 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> (cherry picked from commit 6d1769791348e9387e0c5f29d970131895888814) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QVarLengthArray: clear() is not resize(0)Marc Mutz2023-02-151-0/+10
| | | | | | | | | | | | | | | The latter needs the value_type to be default-constructible, which shouldn't be required to clear() a container. Use std::destroy_n() instead. [ChangeLog][QtCore][QVarLengthArray] clear() no longer requires the value_type to be default-constructible. Change-Id: I806de8f3826b50c0bd38156892c3afeb15f13ac9 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit fbfee2d7c59a7c6cd17ae7a3f63f983b9f3316f5) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Doc: Fix member name in code snippetAndreas Eliasson2023-02-151-1/+1
| | | | | | | | | | QstyleOption has no init() member, only initFrom(). Fixes: QTBUG-107770 Change-Id: I00ff0b980fbfac813f113a7052bd3df32c7912b6 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit d6bdc5e9b6bcc9324c506c194bc168cdb6ec1da7) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QFuture: fix continuation cleanupIvan Solovev2023-02-152-0/+27
| | | | | | | | | | | | | | | | | Not clearing the continuationData could lead to use-after-free when there is an attempt to cancel an already finished future, which belongs to an already-destroyed promise. This patch fixes it be explicitly resetting continuationData to nullptr in the clearContinuation() method, which is called from the QPromise destructor. Task-number: QTBUG-103514 Change-Id: I6418b3f5ad04f2fdc13a196ae208009eaa5de367 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> (cherry picked from commit b34bea5e96370986ea5dfc499fc2ec6366fda627) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QIosFileDialog - properly handle QUrl for assets-libraryTimur Pocheptsov2023-02-151-3/+7
| | | | | | | | | | | | | | | | For QT_PLATFORM_UIKIT 'PicturesLocation' manually appended by "assets-library://". When converted to QUrl, such a path becomes a valid url, having empty path and scheme "assets-library". Later in QIOSFileDialog we convert this path (options()->initialDirectory()) calling QUrl::toLocalPath, which gives us an empty string and thus we erroneusly select document picker dialog, not an image picker. So let's also check a scheme, not path only. Fixes: QTBUG-107844 Change-Id: If4dd453549b37933cba07b5d7af6e45f2504dd29 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> (cherry picked from commit 402a526b2a87cbf6b7466bacb9dd3d8b7c71d9b2) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Fix few QFileInfo and QDir callsAssam Boudjelthia2023-02-143-8/+15
| | | | | | | | | | | | | | | Return the file engine impl of QFileInfo::completeBaseName() and QDir::absolutePath() and QFileInfo::fileName() (based on QAbstractFileEngine::BaseName) if the file engine impl is valid. Amends f77668ffec48d8aaad7c74069c6f3e770a305ae1. Task-number: QTBUG-98974 Change-Id: I28a8c75a6f25e30012b0791c12dbde51bfe8f62c Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit 249d613a60aa6a1347ebc1c29902049247b93324) Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* rhi: gl: Skip the vertex-fragment interface check with more stagesLaszlo Agocs2023-02-141-1/+5
| | | | | | | | | | | | Once tessellation and geometry shader support is added, the check makes no sense when there are additional stages between the vertex and fragment stages. Change-Id: I3d3c0a5b338f5fe191c072a13a8699924f7a6a1b Reviewed-by: Kristoffer Skau <kristoffer.skau@qt.io> Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io> (cherry picked from commit 5476973325288e399f99af004e53184e41892282) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QAbstractItemView: don't access invalid indexes on copy-keyVolker Hilsheimer2023-02-131-5/+6
| | | | | | | | | | | | | | | | When pressing the copy key the view tried to access the model's data for the currentIndex() without checking whether the index is valid. This resulted in debug output to the console, and might break models that didn't check incoming indexes for validity (or asserted validity). Fix this by checking whether the currentIndex() is valid before reading the model's data for that index. Fixes: QTBUG-106569 Change-Id: Ide75fbdfdbd1451ab6d48f07b22136553c5b2468 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> (cherry picked from commit 3a0c33da3d913431391c5b7f4f0e93ea9d2221dc) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Accept full-width parentheses in removeMnemonics()Edward Welbourne2023-02-131-5/+15
| | | | | | | | | | | | | | | | | | | | QPlatformTheme::removeMnemonics() removes any match to /\s*\(&[^&]\)/ from the text it is given (a menu entry). It transpires that translators are apt to use the full-width parentheses (compatible with some far-eastern scripts) instead of the plain ASCII ones. This leads to their translated mnemonics don't match the same pattern unless we treat the full-width parentheses as a match for the ASCII ones; consequently, they don't get removed, which this function exists to do. So teach it to recognize the full-width versions, too. In the process, break out the pattern-matching (aside from the leading space) to a lambda to make it easier to read and document. Fixes: QTBUG-110829 Change-Id: I7335d0bd8dbba66e1fe58fc3eec93caaaf6ec140 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> (cherry picked from commit 86b930f073b6b75790a6af8d021f4daa00f80aae) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QMenu: guard for destruction when emitting action signalsVolker Hilsheimer2023-02-132-3/+31
| | | | | | | | | | | | | | | If a slot connected to a QMenu-action destroys the QMenu, then we must not touch data members in subsequent code, and instead return immediately. We cannot use QBoolBlocker here, as that would reset the data member of QMenuPrivate even when trying to return early. Fixes: QTBUG-106718 Change-Id: I6b5ea471b1bf1f9864e1384382100f8f6c01346f Reviewed-by: Axel Spoerl <axel.spoerl@qt.io> (cherry picked from commit 52ce4d2d29db8a44fa2fa817cab9ebe969db082e) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* ODBC/MySQL: fix compilation with MySQL < 5.7.9Christian Ehrlicher2023-02-131-0/+5
| | | | | | | | | | | | MYSQL_TYPE_JSON was introduced in MySQL 5.7.9 but our documentation states that we still support 5.6 so we have to define this value by ourself for the older versions. Fixes: QTBUG-109832 Change-Id: I935edb14495d162ed58109610946b2805d37bbc4 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit 5bc61ec5d028d57640b9c4cd515ed7dfebac945c) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Update bundled libjpeg-turbo to version 2.1.5Eirik Aavitsland2023-02-1321-87/+154
| | | | | | | | | | [ChangeLog][Third-Party Code] libjpeg-turbo was updated to version 2.1.5 Task-number: QTBUG-110336 Change-Id: Ifc08ad7f1a3c5b3e66b11e5a51d523b091288790 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io> (cherry picked from commit 94efcf9be4c5e46dff463806e278fcee90ff4d53) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* macOS: map Qt::Key_Return to NSCarriageReturnCharacter in menusVolker Hilsheimer2023-02-121-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | On macOS, key combinations with the Return key do not get delivered through NSView::keyDown, but they are seen by the QCocoaNSMenu::menuHasKeyEquivalent override. We already use that override to check whether any menu item uses a matching shortcut, and give Qt's focus object a chance to override the shortcut. The key mapper used the NSNewlineCharacter '\n' for Qt::Key_Return. However, the character we get from macOS for the return key is the NSCarriageReturnCharacter character, '\r'. This makes the lookup fail, and shortcut overrides are not delivered for shortcuts using Qt::Key_Return. To fix this, map Qt::Key_Return to NSCarriageReturnCharacter. The inverse mapping maps both NSCarriageReturnCharacter and NSNewlineCharacter to Qt::Key_Return, and there are no other users of this function in Qt. Fixes: QTBUG-107526 Change-Id: I716190adf3cd94697e2b3ad1afc25b95d8ebde25 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> (cherry picked from commit 0835537c3c3a8b7991b7a6e4a877a13f165a66e7) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QAbstractItemView: Don't unselect on click on empty area in SingleSelectSebastian Beckmann2023-02-112-1/+37
| | | | | | | | | | | | | | | | | dfb4697e4a4828acd47292a89207b3975ec6766e made a change to selection behavior that resulted in a regression where clicking on an item view but not on an item would cause the current item to get unselected. Changes the behavior to not update in this case. Added a new test that specifially checks for this scenario and ensures that the current item is still selected, even after the user clicks on empty area. Fixes: QTBUG-105870 Change-Id: I191c3878819b99897083039fba0ab43908da5429 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit f11e5435c776deddf27f7759180c1d41f64b8cce) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Fix Qt 6 performance regression when painting outside deviceEirik Aavitsland2023-02-113-17/+24
| | | | | | | | | | | | | | | | | | | | | | | | | Painting wide lines and filling would be clipped to cliprect (by default, the device rect) only if the bounding rect coordinates exceeded QT_RASTER_COORD_LIMIT. In Qt 6, that limit was raised from 2^15 to 2^23, so a lot of time could be spent on rasterizing elements that would anyway be outside the rendering area. Fix by instead clipping whenever the path to be painted overshoots the cliprect by a significant margin. At this point, the path is already flattened to straight lines, so clipping is quick and precise. Testing indicates that this solution improves performance a lot when large portions of the elements to be painted fall outside the cliprect, while not causing significant performance hits otherwise. As a side effect, it is then no longer necessary to test the bounding rect explicitly against QT_RASTER_COORD_LIMIT, since we already make sure that the clip rect we check against is within that limit. Fixes: QTBUG-110595 Change-Id: Iaf1afbb481c2d7059405f334278796ad46f5bcb6 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io> (cherry picked from commit ce7b4c734b78d24b75ecb389cf799ce85d0cc3bf) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* tst_qvarlengtharray: fix MyBase trackers for swap()Marc Mutz2023-02-101-0/+34
| | | | | | | | | | | | | | | I don't begin to understand the semantics of the trackers here, but whatever they are, they break with the fallback std::swap() 3-moves implementation and lose track of alive objects, so provide an ADL swap that does the right thing. Amends dd58ddd5d97f0663d5fafb7e81bff4fc7db13ba7 (I think). Change-Id: I1cd49c95dca2d103a26c2c7ac0a896929135a6c8 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit 49fca96d88c308bc22cd898a8d202228d185654e) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* SQL/MySQL: Fix retrieving a datetime for libmysql >= 8.0.27Christian Ehrlicher2023-02-101-9/+19
| | | | | | | | | | | | | | | Somewhere between libmysql 8.0.18 and 8.0.27, the MYSQL_TIME structure gained an additional member which increased the struct size by 4 bytes. This makes an internal check for the correct size of the structi go fail. Since it can now happen that the plugin is linked against a new libmysql and used with an old and the other way round, duplicate the old MYSQL_TIME struct to use this in our code Fixes: QTBUG-110967 Change-Id: I5bc631179a0a1be47a5966954e757f27a72f1592 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit c67cc6d5706fa732ee78e286e0142f97f5b9d61f) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* SQL/ODBC: add handling for SQL_SS_TIME2Christian Ehrlicher2023-02-101-0/+6
| | | | | | | | | | | MSSql Server sometimes returns SQL_SS_TIME2 instead SQL_TIME. Since this value is non-standard, we have to define it by ourself. Fixes: QTBUG-109206 Change-Id: I40a4b32590d877ebfdc4b2f1d9080d8cdb2ae7a5 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit 7ebac2081244bc1f075bc16da6ce59cbd5122c7d) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Use qt_winrtbase_p.h workaround in more placesYuhang Zhao2023-02-091-2/+4
| | | | | | | | | | | | | | | | | This patch addresses the following issues: (1) some places are still using the original workaround, replace them with the new qt_winrtbase_p.h workaround. (2) add more comment to let people know how to workaround other cppwinrt issues (it was a common issue for many years and may be fixed upstream recently, but let's at least document it in case the user is still using old version cppwinrt). Amends commit b2c1237b4512480a17009afe1981af02c2a9869e Change-Id: Ife676f41739bbe69d9fb23bf5758be4b1fab4855 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Oliver Wolff <oliver.wolff@qt.io> (cherry picked from commit ad7227ada177dec4e61e8bbc51dd70f00a6e3d15)
* savegame ex.: fix include order [2/2]: game.hMarc Mutz2023-02-081-3/+3
| | | | | | | | | | | | | | | Includes should be ordered from most specific to most general. This means that project-specific includes always come before Qt includes. This example didn't follow that guideline. Fix. Amends 88e8094f18e6581f2b652eb3d82f514ecf687046. Task-number: QTBUG-108857 Change-Id: Iafdae9dd8e70ff99882c4344a023a21d15fa3c54 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> (cherry picked from commit ac6e8b3b21c2ae25e7a4fe483b604ea6ddecd3ff) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* savegame ex.: make Level ctor explicitMarc Mutz2023-02-081-1/+1
| | | | | | | | | | | A QString is not a full representation of a Level, so the Level(QString) ctor should be explicit. Task-number: QTBUG-108857 Change-Id: I24b705139e61c4aaf59cb0aad3b536013e0d07df Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> (cherry picked from commit fa55d46e1f09ddf45dbe5700d4637b003363c559) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Avoid accessing deleted binding data in grouped updatesFabian Kosmale2023-02-082-16/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This fixes a use-after-free in QPropertyDelayedNotifications::notify. Before this patch, evaluateBindings or a notify from a property index might have caused the originalBindingData to become reallocated. However, at that point, we've already restored the original bindingData in evaluateBindings, so we won't track updates, and thus won't adjust originalBindingStatus, which will then point to already freed data. To remedy this, we no longer do the notification with data fetched from originalBindingData, but instead use the information we have in the proxyData. We also need to enure that referenced bindings do not get deleted; for that we keep the PendingBindingObserverList alive for the whole duration of the endPropertyUpdateGroup. As we now have the PendingBindingObserverList, we use it for the notification logic, and only notify change handlers in QPropertyDelayedNotifications::notify. That will allow a follow-up cleanup of QPropertyObserverPointer::notify, and aligns the logic for grouped updates with the logic for "nornal", non-grouped updates. Amends f1b1773d0ae636fa9afa36224ba17566484af3cc. Task-number: QTBUG-110899 Change-Id: Iae826e620d9614b7df39d86d8a28c48c8a5c4881 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> (cherry picked from commit 7a415a051a464ee3145c11b4ff44dbb16010323e) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* savegame ex.: use ranged instead of indexed loopsMarc Mutz2023-02-082-4/+4
| | | | | | | | | | Modernizes the code, and fixes qsizetype/int mismatch. Task-number: QTBUG-108857 Change-Id: Id4262ee0bcb673d62135a81c30976903eef3e5e2 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> (cherry picked from commit 44933343937d7a6d9f6afe1f8e0b0f93a387b100) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>