summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
...
* Add special thread pool for Qt GuiAllan Sandfeld Jensen2023-02-259-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) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Logging: fix crash when decoding a symbol that isn't a functionThiago Macieira2023-02-232-0/+71
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Saw this on my FreeBSD VM. The backtrace() function thought the nearest symbol to something was "_ZTSNSt3__110__function6__baseIFbPvS2_EEE", which decoded to typeinfo name for std::__1::__function::__base<bool (void*, void*)> The function pointer type inside parameter threw the decoder for a loop and caused it to crash with the failed assertion in qbytearray.h: inline char QByteArray::at(qsizetype i) const { Q_ASSERT(size_t(i) < size_t(size())); return d.data()[i]; } I noticed this - because tst_qtimer hung - because qFormatLogMessage deadlocked acquiring QMessagePattern::mutex - because the logging recursed - because qCleanupFuncinfo failed an assertion while formatting the backtrace (my QT_MESSAGE_PATTERN has %{backtrace}) - because QTimer::~QTimer -> QObject::killTimer printed a warning - because tst_QTimer::moveToThread produces warnings Change-Id: Ieec322d73c1e40ad95c8fffd17464f86e9725991 Reviewed-by: Kai Köhne <kai.koehne@qt.io> (cherry picked from commit 644c06b48f45aeabcd594df4dcf25a44ea02f132) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QMessageAuthenticationCode: fix result() non-re-entrancyMarc Mutz2023-02-231-0/+8
| | | | | | | | | | | | | | | | | | | | | | While QMessageAuthenticationCode is not copyable, result() is nevertheless const, so a user could prepare a QMessageAuthenticationCode object with setKey() and addData(), pass it by const reference to two threads, which each just call result() on it. This should be safe, but because result() performed lazy evaluation without being internally synchronized, this would cause data races. Fix in the same was as b904de43a5acfc4067fc9e4146babd45c6ac1138 did for QCryptographicHash. See there for a detailed discussion of the solution. Fixes: QTBUG-111347 Change-Id: I1feb380973c480ad6268349a0a46ac471b9ca0f7 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: David Faure <david.faure@kdab.com> (cherry picked from commit 2449af142fa3d8ccb114262e994f308043ef6d70) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Fix crash with removed menusJoni Poikelin2023-02-231-6/+12
| | | | | | | | Fixes: QTBUG-111388 Change-Id: I9c9f0ad5cc02293197d7e77eeeec3ffa9d72a4af Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> (cherry picked from commit 8dfca2ee717289b334b7ec7a5a9cc9a3d8e9654a) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* CMake: Fix position independent code linker flags not being setJoerg Bornemann2023-02-231-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>
* SQL/OCI: Fix QSQLDriver::record() when tablename is a synonymChristian Ehrlicher2023-02-221-3/+2
| | | | | | | | | | | | Fix the statement when the tablename is a synonym by not appending the where clause for the table name to the initial statement used for tables and synonyms later on. Fixes: QTBUG-111339 Change-Id: Ie18a858427d124e80462048b1a9c5e2afa327546 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit 78f7a8c418bc887ebb5bd75f63e35a2b8108f107) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* qstrncpy: NUL-terminate even when src is nullptrMarc Mutz2023-02-222-7/+12
| | | | | | | | | | | | | | | | | | | | | | The goal of this function is to ensure that dst is _always_ NUL-terminated. The only exception is if there's no space to write even one NUL byte, of course, but not when src is nullptr but dst would have space. Update the docs to the new behavior and make them more precise. Fix a test that assumed qstrncpy() would not write to dst for (dst, nullptr, 10). [ChangeLog][QtCore][qstrncpy()] Now NUL-terminates the target buffer even when the source pointer is nullptr, provided the target buffer has space for at least one byte. Change-Id: I7806d8c71e260f8f02b79af7b6ce94f23599dd69 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit 05f913d57d6557d1c540894651cc83a5b1ec7cf7) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QMessagePattern: don't use strncpy()Marc Mutz2023-02-221-5/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | When Qt is configured to return nullptr from isNull() QStrings (QT5_NULL_STRINGS != 1), then we'd be feeding a nullptr src into strncpy(), which is UB. I couldn't rule the case of a null QString lexeme out with local reasoning, seeing as the code is in the else branch of an if (lexeme.startsWith(~~~) && lexeme.endsWith(~~~)), so it might be null. Instead of porting to qstrncpy(), which can deal with a nullptr src (albeit up to recently, badly), note that the strncpy + the char[] allocation is a qstrdup(), so use that instead. This also does away with the queasiness of taking the size() of a UTF-16 string to limit strncpy() for the L1-recoded version (which, in this instance is safe, as toLatin1().constData() is NUL-terminated, but in some other instances was not). As a drive-by, make sure we don't leak the strdup()'ed string if the emplace_back() fails. Amends be98fa32c7d56ea91359b647a329356fa44eca04. Qt 5 is not affected, as constData() never returns nullptr there. Change-Id: I178d356e560d2749cd6ce0b9364c710a2d117304 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit 4a9e918d4ebdd9f7ea641e2b0f12a48c5f619acb) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* qt_inIsoNametoLCID: protect against a nullptr nameMarc Mutz2023-02-221-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | The only user of the function, QCollatorPrivate::init(), passes QLocalePrivate::bcp47Name().constData(). bcp47Name() may return a default-constructed QByteArray (e.g. for QLocale::AnyLanguage), so constData() may be nullptr (QT5_NULL_STRINGS != 1). Passing nullptr to strncmp() or strncpy() is UB, though. Instead of using the nullptr-hardened q... versions of these functions, check name for nullptr once, at the top of the function, and avoid all the lookup code that follows and is known to fail (because windows_to_iso_list does not contain empty entries). This way, we take advantage of the std functions' UB for performance reasons (fewer repeated nullptr checks), instead of being taken advantage of. Qt 5 is not affected, as constData() never returns nullptr there. Change-Id: I980dace2bca1e983ac526e89fadeb92239ab5f11 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit 9f5a687ffebbc93ce5f8f25c544aa9129c6366c3) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QMessageAuthenticationCode: Extract Methods finalize{,Unchecked}() from result()Marc Mutz2023-02-221-9/+20
| | | | | | | | | | | | | This brings the code in line with its sibling code in QCryptographicHash and prepares for a static hash() optimization and the fixing of the result() re-entrancy issue (QTBUG-111347). Task-number: QTBUG-111347 Change-Id: I3d0c0cd2a37c2bbeb60974307ff138e26b82bf69 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> (cherry picked from commit ac9d25340aec5c165db5e58a3d8b869967c5ff97) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QThreadPool: Protect the access to internal data with mutexJarek Kobus2023-02-221-0/+7
| | | | | | | | | | | | | The class claims to be thread safe, however, when e.g. one thread is calling setMaxThreadCount() and the second is calling maxThreadCount() at the same time for the same thread pool instance, the latter may receive rubbish data. Protect all public setters/getters with a mutex. Change-Id: Ief29d017d4f80443fa1ae06f6b20872f07588768 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> (cherry picked from commit 0627ab17277ad5fa83fe6fcab5af5cd2748162a3) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Text: fix Soft hyphen rendering in QTextLayout::glyphRuns()Vladimir Belyavsky2023-02-221-8/+14
| | | | | | | | | | | | | | | | | | | | | | | When calculating the position offset of QGlyphRuns, either when fetching substrings or when applying fallback fonts, we would include the advances of non-printable glyphs, such as the soft hyphen. This was an oversight, and the other code which calculates the advance (like in QFontEngine::getGlyphPositions()) does this correctly. We apply the same logic as there and only include the advance if the dontPrint flag is unset. [ChangeLog][QtGui][Text] Fixed an issue where spaces would sometimes be shown in soft hyphen positions in a string. Fixes: QTBUG-46990 Fixes: QTBUG-62620 Fixes: QTBUG-67038 Fixes: QTBUG-102483 Change-Id: I4e583fb74f7a51424f14917d7cc0894beefec48b Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> (cherry picked from commit 0fe6f818d23495f07100f82c12e4232b8e56daf4) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* 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>
* savegame ex.: use NSDMI, =default the default ctorMarc Mutz2023-02-082-6/+4
| | | | | | | | | | Modernizes the code. Task-number: QTBUG-108857 Change-Id: I6ddf1de3699506ffc0fc4b1034ab48defafcf174 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> (cherry picked from commit 35b94f8b4349581c548b7aac2e858750072efa19) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>