summaryrefslogtreecommitdiffstats
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
* doc: Update details about QSystemTrayIconShawn Rutledge2022-01-041-5/+5
| | | | | | | | | | | | - StatusNotifierItem is now more widely implemented (but I'm sure the list could be even longer); but Unity is obsolete - XEmbed is nearly obsolete, so list it after StatusNotifierItem - fix the links: it was meant to have friendly anchor text rather than showing the whole URL inline Pick-to: 6.2 6.3 Change-Id: Id81059f9484a8144b6402e74a500edf81d845b65 Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io>
* rhi: Drop the profiler for nowLaszlo Agocs2022-01-0417-1175/+153
| | | | | | | | | | | | | | | | | | | | | | | | | | | The system we inherited from the original Qt 5.14 introduction of QRhi is a text stream based solution where resource creation and frame timings are sent in a comma-separated format to a QIODevice. This, while useful to get insights about the number of resources at a given time, is not actively helpful. The frameworks built on top (Qt Quick, Qt Quick 3D) are expected to provide solutions for logging timings in a different way (e.g. via the QML Profiler). Similarly, tracking active resources and generating statistics from that is better handled on a higher level. The unique bits, such as the Vulkan memory allocator statistics and the GPU frame timestamps, are converted into APIs in QRhi. This way a user of QRhi can query it at any time and do whatever it sees fit with the data. When it comes to the GPU timestamps, that has a somewhat limited value due to the heavy asynchronousness, hence the callback based API. Nonetheless, this is still useful since it is the only means of reporting some frame timing data (an approx. elapsed milliseconds for a frame) from the GPU side. Change-Id: I67cd58b81aaa7e343c11731f9aa5b4804c2a1823 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* Pass QT_BUILD_STANDALONE_TESTS to Android external project if definedAlexey Edelev2022-01-041-0/+8
| | | | | | | | | | | | | | If we configure qtbase standalone tests for multiple Android ABIs, external project also needs the QT_BUILD_STANDALONE_TESTS flag enabled to avoid configuring the whole qtbase but not only tests. TODO: Need to forward all cache variables that are defined by user to the external project since otherwise the configuration of the external project will differ. Created QTBUG-99537 to track this. Pick-to: 6.3 Change-Id: I3aec1391c850fb37696dc50416e0ff2a2646e759 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* Fix build of multiple apks in a single project treeAlexey Edelev2022-01-041-1/+1
| | | | | | | | | | | | | | | | | | ExternalProject_Add_Step adds the step timestamp file as the dependency to a '-complete' file generated by add_custom_command that is run inside the ExternalProject_Add function. Since the '-complete' file path is computed using CMAKE_CURRENT_BINARY_DIR we run into the issue if ExternalProject_Add and ExternalProject_Add_Step are run from the different source directories and have the different default binary directories as well. This change suppresses the behavior by adding the 'EXCLUDE_FROM_MAIN TRUE' flag. We may do this since the target related to the step is added to the dependency chain of executable target and the chain of external project is not used for now. Pick-to: 6.3 Change-Id: I7203261b61cfa56bcd9e49ac3e8d7ecb217a5a6c Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* Update internal function signaturesAlexey Edelev2022-01-041-20/+20
| | | | | | | | | | | Update _qt_internal_add_android_deployment_multi_value_property and _qt_internal_add_android_deployment_property signatures to match the _qt_internal_add_android_deployment_list_property signature. Pick-to: 6.3 Change-Id: Ie4fb2ebe96c783222fc4b56c3186e22b96cbbb95 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Collect the apk dependencies regardless of targetAlexey Edelev2022-01-042-32/+71
| | | | | | | | | | | | | | | | | | | | _qt_internal_collect_target_apk_dependencies function is common for all targets, but its signature was telling that it's target-specific. This also causes an issue when we had more than one target in tree that produce apk, since only first target got the property after respective finalizer was executed. This change generalize the function and uses _qt_internal_apk_dependencies target to store the extra library directories from the build tree. _qt_internal_add_android_deployment_list_property signature is also changed to support reading values from multiple lists of multiple targets. Amends d20f4ae706559fb7de8db9dd4845f7ce3936061a Pick-to: 6.3 Change-Id: I5b40fa96a0eb73348c0029e2b13c63a9465cb520 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* Update copyright year to 2022Kai Köhne2022-01-043-3/+3
| | | | | | | Pick-to: 5.15 6.2 6.3 Change-Id: If6f1d6f9f82a601f8e2b6d36650d6e737518aa60 Reviewed-by: Paul Wicking <paul.wicking@qt.io> Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* rhi: Enable exposing separate image and sampler objects from the shaderLaszlo Agocs2022-01-036-13/+210
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Adds the following in a QShader/QShaderDescription: - a list of separate images - a list of separate samplers - a list of "combined_sampler_uniform_name" -> [ separate_texture_binding, separate_sampler_binding ] mappings (relevant for GLSL only) On the QShader (and qsb/QShaderBaker) level not having separate image (texture) and sampler objects exposed in the reflection info is not entirely future proof. Right now we benefit strongly from the fact that Vulkan/SPIR-V supports both combined and separate images/samplers, while for HLSL and MSL SPIRV-Cross translates combined image samplers to separate texture and sampler objects, but it is not given that relying on combined image samplers will always be possible in the long run; it is mostly a legacy OpenGL thing that just happens to be supported in Vulkan/SPIR-V due to some benefits with certain implementations/hw, but is not something present in any newer APIs. In addition, before this patch, attempting to run a shader with separate textures and samplers through qsb will just fail for GLSL, even though SPIRV-Cross does have the ability to generate a "fake" combined sampler for each separate texture+sampler combination. Take this into use. This also involves generating and exposing a combined_name->[separate_texture_binding,separate_sampler_binding] mapping table for GLSL, not unlike we have the native binding map for HLSL and MSL. A user (such as, the GL backend of QRhi) would then use this table to recognize what user-provided texture+sampler binding point numbers correspond to which auto-generated sampler2Ds in the GL program. Take the following example: layout(binding = 1) uniform texture2D sepTex; layout(binding = 2) uniform sampler sepSampler; layout(binding = 3) uniform sampler sepSampler2; Inn the reflection info (QShaderDescription) this (assuming a corresponding qtshadertools patch in place) now gives one entry in separateImages() and two in separateSamplers(). Assuming sepTex is used both with sepSampler and sepSampler2, the GLSL output and mapping table from QShaderBaker will have two auto-generated sampler2Ds (and no 'texture2D' or 'sampler'). One immediate benefit is that it is now possible to create a shader that relies only on separate images and samplers, feed it into qsb, generate all the possible targets, and then also feed the SPIR-V binary into a tool or library such as Tint (e.g. to generate WGSL) that canot deal with combined image samplers. Change-Id: I9b19847ea5854837b45d3a23edc788c48502aa15 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* [doc] QCoreApplication::installTranslator() doesn't take ownershipMarc Mutz2022-01-031-0/+2
| | | | | | | | Document it. Pick-to: 6.3 6.2 5.15 Change-Id: I25d305945bf29348d6ea5756fbf80c418f812d0f Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* rhi: Add the basics for HDR swapchainsLaszlo Agocs2022-01-0313-47/+328
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ...backed by support in the backends for D3D11 and Vulkan. Expose only what works in practice: scRGB with RGBA16F and HDR10 with RGB10A2 (or A2BGRA10 etc.). For general use, e.g. to render 2D/3D content, scRGB (i.e. extended sRGB linear) should be chosen because that is a linear space. On Windows with a HDR10 display (and an NVIDIA card) both of these are known to work, as long as Use HDR is enabled in the Settings for the display on which the window is created. When requesting a HDR format and it is not supported, we will fall back to the default SDR RGBA8/BGRA8 format. However, the behavior seems to be a bit weird with Vulkan and NVIDIA at least when there is a HDR display but Use HDR is set to Off: this seems to enable HDR mode for the lifetime of the window (with the usual set of black screens while switching over the entire display). Not sure why the driver does this. With D3D/DXGI, with fewer abstractions in the way, we can check upfront properly, so that will nicely fall back to the defaults regardless of why HDR is not available. Support can also be checked in advance via QRhiSwapChain::isFormatSupported() as long as the QWindow is available. (though with Vulkan, as said above, this also seems to ignore the Use HDR setting of Windows) Complications, such as moving a window from one screen to another, are currently not known how they behave. To be seen how this is handled by the Windows compositor. (from 1903 and up it is said to be able to automatically downconvert scRGB to SDR so perhaps moving from a HDR to a non-HDR screen would work - remains to be seen if this needs something more involved) When it comes to other platforms and potential future support: - based on its docs Android 8+ may support scRGB with Vulkan as-is on a suitable device/display, as long as the application declares android:colorMode="wideColorGamut" in the manifest. - for Metal the layer can be made EDR enabled and then e.g. MTLPixelFormatRGBA16Float/kCGColorSpaceExtendedLinearSRGB should work. However, this won't be added unless we can test it. - Linux is unknown. If one needs access to display specific values such as the min/max luminance when implementing tonemapping or a transfer function, that needs platform/API specific approaches, and sadly the kind of data exposed seems to vary, potentially making it difficult to maintain a single cross-platform logic. With D3D one can get the DXGI_OUTPUT_DESC1 from the IDXGIOutput6. This has the min/max luminances in nits and a bunch of other things. For convenience the output object is now exposed from the swapchain's nativeHandles() whenever the D3D backend is used at run time. For Metal one would presumably access maximumExtendedDynamicRangeColorComponentValue and co. in the NSScreen. Elsewhere one needs to rely on platform/winsys specific approaches, if there are any. Remains to be seen longer term if/how this needs/can be better supported. Change-Id: I2e61a0e062282d4bfdfba39655941c0f9a795112 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* Replace ANDROID_ABI argument with the QT_ANDROID_ABI target propertyAlexey Edelev2022-01-032-104/+112
| | | | | | | | | | | | | | | | | | | | | | This change tries to make the API more user friendly and prevent wrong use of multi-abi API. ANDROID_ABI argument of qt6_add_executable was position-depend and needed to be placed after the executable 'sources'. Using the target property we solve this problem and provide more consistent and common way to enable multi-abi build for the single target. This meanwhile also requires to execute multi-abi build configuration in the finalizer, since the property might be set at any point. Also the priority of the QT_ANDROID_ABI target property now is higher than the priority of the QT_ANDROID_BUILD_ALL_ABIS variable. So target will only build packages with the ABIs specified in QT_ANDROID_ABI property if both are set. Pick-to: 6.3 Task-number: QTBUG-88841 Change-Id: I3515297ed267974498913c59619433dc234ec217 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* QRingBuffer: optimize and simplify QRingChunk::toByteArray() futherMarc Mutz2022-01-031-8/+3
| | | | | | | | | | | | | | | | | | | | | | - use sliced() instead of mid(), since we know we call sliced() in-contract - replace the manual memmove() with calls to QBA::remove(), but first resize() to tailOffset, and only then remove(0, headOffset), so we only move Chunk::size() bytes, as the old code did - don't bother updating the offset members, as we're restricted to rvalues now, and we only need to leave behind a partially-formed object This code shows that we desperately need QBA::slice() and/or an rvalue overload of QBA::sliced(), cf. QTBUG-99218. Add a comment to use these functions when they become available. Change-Id: I5d8c7363d443dff69338f6f6a7b4bff9957917ec Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Alex Trotsenko <alex1973tr@gmail.com> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* QTestData: fix streaming of u8 string literals in C++20 modeMarc Mutz2022-01-031-0/+8
| | | | | | | | | | | | | | | | | | | ...fixing tst_QLocale: QDEBUG : tst_QLocale::formatDate() expected data of type 'QString', got 'char8_t [64]' for element 1 of data with tag 'unicode in format string' QFATAL : tst_QLocale::formatDate() ASSERT: false in file /home/marc/Qt/qtbase/src/testlib/qtestdata.cpp, line 105 In C++20, the type of u8 string literals changed from const char[] to const char8_t[]. [ChangeLog][QtTest][QTestData] Fixed streaming of u8 string literals in C++20 mode. Pick-to: 6.3 6.2 5.15 Task-number: QTBUG-99480 Task-number: QTBUG-99481 Change-Id: I53bd73522a4ebce307f360e225f25590f981d44a Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QThread: fix UB (invalid enum value) on Private::PriorityMarc Mutz2022-01-033-6/+6
| | | | | | | | | | | | | | | | | | | | | The Unix code stores an additional flag, ThreadPriorityResetFlag, in the Policy enum, but ubsan does not approve: qthread_unix.cpp:303:30: runtime error: load of value 2147483648, which is not a valid value for type 'Priority' qthread_unix.cpp:304:75: runtime error: load of value 2147483648, which is not a valid value for type 'Priority' Fix by making the variable of std::underlying_type_t<Priority>. The masking and unmasking code can now be simplified, too. In the Windows version, replace some switch targets with equivalent ones to keep -Wswitch-like warnings, though I hasten to note that both switches use a default case, so have anyway implicitly disabled said warning. Pick-to: 6.3 6.2 5.15 Change-Id: Ie4ea7d05e2928d2755ad12d36535197f85493191 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QByteArray: avoid detach() in a no-op replace()Marc Mutz2022-01-031-2/+3
| | | | | | | | | | | | | When the the replacement has the same size as the replacee, but that size is zero, the whole operation is a no-op, and there's no need to detach(). [ChangeLog][QtCore][QByteArray] A replace(pos, n, after) call no longer detach()es when n == after.size() == 0. Pick-to: 6.3 6.2 Change-Id: I1e8d7c7fb6383f8bfea3212e49fca8a128535564 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Avoid crash on app startup if the default font family is emptyLars Knoll2022-01-031-3/+6
| | | | | | | | Don't call first() on a potentially empty list of families. Fixes a crash on startup on QNX for me. Change-Id: I551d21dac8cfd104b774d6442bdbe1db35f8b75c Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Add PublicShare and Templates QStandardPathsBjörn Feber2022-01-017-2/+63
| | | | | | | | | | | | | | | | | These directories are common on desktop operating systems. "Public" is used for sharing files with other users and "Templates" lets you add new files to the file creation desktop menu (for example in a file manager). An example use in a Qt application would be KDE's KIO having default icons for both directories. This is where they point to: Windows: C:/Users/Public, C:/Users/<USER>/AppData/Roaming/Microsoft/Windows/Templates macOS: ~/Public, ~/Templates Unix: ~/Public, ~/Templates Task-number: QTBUG-86106 Task-number: QTBUG-78092 Change-Id: Ifca60c7d2a6dc2109ec290e8fb109ee2d5ca4d38 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Extract Header qforeach.h from qglobal.hMarc Mutz2021-12-303-84/+140
| | | | | | Task-number: QTBUG-99313 Change-Id: Ie89314ca7022e88c1fea957880c5aa4a41640744 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QThread/Unix: extract duplicate codeMarc Mutz2021-12-301-36/+27
| | | | | | | | | | | | | | Extract function terminate_on_exception() that de-duplicates the #ifdef'ery around the try/catch and the handling of the pthread cancellation pseudo-exception. Apart from de-duplicating complex code, it will also help suppressing a ubsan false positive, which is why we're picking it all the way to 5.15. Pick-to: 6.3 6.2 5.15 Change-Id: I99ad2c0618b8dc30801931df09400c6611d9f9e4 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QWindow: use std::exchange when ... exchanging valuesMarc Mutz2021-12-301-3/+1
| | | | | | | | | Replaces a three-liner with a more elegant, idiomatic one-liner. Pick-to: 6.3 Change-Id: I57fbe5d808dffa44f6fceffb97c47f0c84ccd3df Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* QWindowPrivate: fix inconsistent inline on some methodsMarc Mutz2021-12-301-2/+2
| | | | | | | | | | | Two functions' implementations were marked as inline, when their definitons weren't. This is non-sensical, bordering on dangerous, so remove the inline keyword. Pick-to: 6.3 6.2 5.15 Change-Id: Iece21f9552aede273fa1f5a7aef0c94307fa5142 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Docs: Add other Unix paths to the Linux table in QStandardPathsNicholas Bennett2021-12-301-1/+1
| | | | | | | | | | | | Added Unix to the title of the enum QStandardPaths::StandardLocation docs Linux paths table as this also aplies to Unix based OS's such as QNX. Fixes: QTBUG-63695 Pick-to: 6.2 6.3 Change-Id: I37b1bb6167984ccf7877baf2e6e764337121a947 Reviewed-by: Tommi Mänttäri <tommi.manttari@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Eradicate Q_FOREVER from header filesMarc Mutz2021-12-282-6/+6
| | | | | | | | | The qgenericatomic.h occurrences are getting in the way of splitting up qglobal.h, so inline the define. Task-number: QTBUG-99313 Change-Id: I0d6e3553c5ed4ac9e426bef2fe07d2672d73c671 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QLocale: replace use of append(QString(n, c)) with resize(size() + n, c)Marc Mutz2021-12-281-1/+1
| | | | | | | Avoids a temporary QString creation. Change-Id: Ibc87a3f1bf2979780e4a2cce7e1757f97c39a9be Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QLocale: replace a few getData() with viewData()Marc Mutz2021-12-281-5/+5
| | | | | | | | | | Both multi-arg as well as QStringBuilder support QStringView these days, so there's no need for a temporary QString, even one fromRawData(), with all its extra codegen, when QStringView can do the job just fine. Change-Id: Ie9031aef85c5f0b535e94d9e414b7bd71ad909f7 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix pattern type matchingJarek Kobus2021-12-281-4/+4
| | | | | | | | | Amends 3c747aafa44ac2d0b314a002d2672227bf6513e5 Pick-to: 6.3 6.2 5.15 Change-Id: I2753b627c269cbb50009ef5e9c2ffa274e0ccf5c Reviewed-by: David Faure <david.faure@kdab.com> Reviewed-by: Alex Richardson <arichardson.kde@gmail.com>
* Remove unused internal flag from raster painting engineEirik Aavitsland2021-12-282-27/+0
| | | | | | | | | Just a leftover from code that has been replaced long ago. Task-number: QTBUG-95237 Pick-to: 6.3 6.2 5.15 Change-Id: I8b1b0f319683ecfb2c93cc51a047616fe29770f7 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Windows: Fix handling of childGroups() when fallbacks are disabledJeremie Graulle2021-12-271-4/+10
| | | | | | | | | | When fallbacks are disabled for QSettings then it should not be falling back to any child groups or keys that might exist in a fallback set of settings. Fixes: QTBUG-85295 Change-Id: I563999293a103702035c8d3b027b59b94ca43c0e Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* wasm: hardcode idealThreadCount for some browsersLorn Potter2021-12-241-1/+5
| | | | | | | | | Browsers like Safari do not support the hardwareConcurrency property. Will hard code it to 2, as iOS only supports that amount. Pick-to: 6.3 6.2 Change-Id: Icb35d3b698b28d8191a554167dc8cc262b806fb2 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* macOS: Sanitize scroll deltas for NSEventPhaseCancelledTor Arne Vestbø2021-12-231-0/+10
| | | | | | | | | | | | | | | | On macOS 12.1 the NSEventPhaseCancelled phase can in some situations report deltas, which causes the scroll to "jump". This happens for example when initiating a momentum-scroll, and then putting two fingers on the trackpad to cancel the momentum phase, which starts a new NSEventPhaseMayBegin phase. When then lifting the two fingers again, we get an NSEventPhaseCancelled event with deltas, but the deltas seem like uninitialized data (has a x-value, after doing a purely vertical scroll e.g.). Task-number: QTBUG-97841 Pick-to: 6.3 6.2 5.15 Change-Id: I14e765b6111e53e7d3d0da219d4ac7fefe5243d0 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Doc: QSysInfo::productType: remove the "will be" note about Qt 6Thiago Macieira2021-12-231-4/+3
| | | | | | | Fixes: QTBUG-99413 Pick-to: 6.2 6.3 Change-Id: Ib42b3adc93bf4d43bd55fffd16c360797871011b Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* QString: reorganize some template functionsThiago Macieira2021-12-231-192/+185
| | | | | | | | | | | | This is going to screw up the git blame functionality (which is why they were forward-declared instead of implemented on-site) but the alternative is that Qt Creator thinks qstring.cpp had almost no functions inside. Pick-to: 6.3 6.2 Task-number: QTCREATORBUG-25594 Change-Id: Ib42b3adc93bf4d43bd55fffd16c1986f1a3c1574 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Document the State Machine Framework changes in the Core Migration GuideTamas Martinec2021-12-231-0/+6
| | | | | | | | | | | | Added section about having the State Machine Framework moved to its own module. Pick-to: 6.2 Pick-to: 6.3 Task-number: QTBUG-89285 Change-Id: I95d065230708d5b505d04309fd6ca21007d878dc Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io> Reviewed-by: Juha Vuolle <juha.vuolle@insta.fi>
* wasm: Use new event dispatcher for QtGuiMorten Johan Sørvig2021-12-235-230/+18
| | | | | | | | | | | | | The event dispatcher implementation is now in QtCore, except for the call to QWindowSystemInterface::sendWindowSystemEvents(). Implement QWasmWindow::requestUpdate() using emscripten_request_animation_frame(), instead of the previous registerRequestUpdateCallback() function which now is removed. Pick-to: 6.3 Change-Id: I7a13eb5391d48dba0f2afe4704ef3188b8daa74b Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* wasm: add virtual processWindowSystemEvents()Morten Johan Sørvig2021-12-232-0/+9
| | | | | | | | | | The QtCore event dispatcher will be used from QtGui as well. Add virtual function where window system events processing can be added. Pick-to: 6.3 Change-Id: Ia6eda9ae18b2e91189ef9f60b6621d19a83313de Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* Add QObject::isQuickItemType() for convenienceYuhang Zhao2021-12-232-1/+15
| | | | | Change-Id: Ibde4e919ba028117336974eb7a804aa11c1ee086 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QTextHtmlParser: fix prefix lookahead and html commentsOliver Eftevaag2021-12-222-4/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | The hasPrefix() function would only use the second 'lookahead' parameter to check if there was more unparsed text after the current character. When it's obvious from the codebase that it should actually look ahead of the current character being processed, and compare againt that future character. Html comments were also not handled quite right. Partially because of the broken hasPrefix() function, but also because it would advance the current index tracker by 3 instead of 2. Remember that the beginning of an html comment is <!-- meaning that there are only supposed to be 2 dashes required, not 3. The result would be that something like this <!----> would not automatically close, because the current index tracker would jump over the first 3 dashes when it begins a comment, and the remaining unprocessed string would be -> Also, because of the broken lookahead in hasPrefix(), a comment could actually be started with just <!- not requiring a second dash at all. Pick-to: 6.3 6.2 5.15 Fixes: QTBUG-99147 Change-Id: I8f4d4a1107eaf2dae16d16b7b860525d45a1c474 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Deliver context menu event with correct coordinates to widgets in popupsVolker Hilsheimer2021-12-221-1/+2
| | | | | | | | | | | | | | If a popup is open, Qt delivers events to the popup child under the mouse, so we need to correctly translate the local position of the context menu event to that child's coordate system. This is already done correctly for regular mouse events, so use the same logic here. Fixes: QTBUG-99371 Pick-to: 6.2 6.3 5.15 Change-Id: Ief24c755e76d4d1aa2304b06662ed26ae309f684 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Windows: Don't crash in mouse handling when QApplication is recreatedVolker Hilsheimer2021-12-221-1/+3
| | | | | | | | | | | | | | | | | We store the primary pointing device in a static variable to avoid the lookup for each mouse event. However, when QApplication is destroyed, then the device is destroyed, and the pointer needs to be reset so that QApplication can be created again by the same process without the first mouse event crashing the program. Use QPointer to prevent the pointer from becoming dangling. Fixes: QTBUG-99319 Pick-to: 6.2 6.3 Change-Id: Ie534c5eee48afb83e3a4adf70fc6cb4a2c310a7a Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: André de la Rocha <andre.rocha@qt.io>
* macOS: Don't read keyCode of non-key events when inserting newlinesTor Arne Vestbø2021-12-222-2/+5
| | | | | | | | | | | | | | | | | | | | | | | When the system input method decides to trigger an insertNewline message it might come from a synthetic NSEvent of type AppKitDefined, which does not respond to the keyCode message. Accessing the keyCode would result in an exception being thrown. We guard for this scenario by moving the keyCode access into the key-press and -release specific parts of the KeyEvent constructor, making the KeyEvent usable with generic NSEvents (even if that means it will only pull out the timestamp and modifiers). We also prefer to use the currently interpreted NSEvent, if one is available, when preparing the synthetic newline event. This ensures that we get a valid timestamp and modifiers, since the synthetic AppKitDefined event that the system IM generates does not provide valid values for these. Fixes: QTBUG-99186 Pick-to: 6.2 6.3 Change-Id: I050ae2aa2d8ded1be3541f746e6c052f3546e27c Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QRingBuffer: remove QByteArray::resize()-shrinks work-aroundMarc Mutz2021-12-211-1/+0
| | | | | | | | QByteArray::resize() is now documented to not shrink capacity(), so remove the extra reserve(0) work-around. Change-Id: I3d5d944b9f01f8f84b31599548773198903aad4c Reviewed-by: Alex Trotsenko <alex1973tr@gmail.com>
* QDateTime: fix UB (signed overflow) in addDays()Marc Mutz2021-12-211-3/+4
| | | | | | | | | | | | The comment indicated that the author expected any overflow to be caught by a bounds check in the subsequent function, however, signed overflow is UB, so anything can happen. Fix by using our API for safe additions instead. Pick-to: 6.3 6.2 5.15 Change-Id: I41909defffa5305b02fdfcf6d5808e0d9fd5924f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QVariantAnimation: fix UB (FP 0/0) in interpolated() arg calculationMarc Mutz2021-12-211-1/+3
| | | | | | | | | | | | | | | | | | | | | | When startProgress, endProgress, and progress were all 0 (as provoked by tst_QPropertyAnimation::startWithoutStartValue()), we'd calculate 0/0 and ubsan complained: qvariantanimation.cpp:284:60: runtime error: division by zero Fix by detecting progress - startProgress == 0 and setting localProgress = 0.0 in that case. This is a logical result, even though it might not be what IEEE754 rules would have yielded. A more comprehensive change that aims to reliably keep localProgress ∈ [0,1] and thus avoid the infinities when endProgress == startProgress, is outside the scope of this patch, which deals only with the UBSan error. Pick-to: 6.3 6.2 5.15 Change-Id: I5258b054a2060006795f49fb1cd7604aea3ed46b Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
* QMimeDatabasePrivate: deduplicate QStandardPaths usesIgor Kushnir2021-12-211-2/+7
| | | | | Change-Id: I81dc76ddcf2aaa8aa6fdca504384ed72ad27f344 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QMimeDatabasePrivate: deduplicate QStringLiteralIgor Kushnir2021-12-212-13/+23
| | | | | | | | | | | | | | | | | | | | defaultMimeType() cannot be moved out of the class and defined in qmimedatabase.cpp, because it is called from QMimeType::isDefault() in qmimetype.cpp. Return m_defaultMimeType constant by reference rather than by value from the inline helper function. This eliminates useless copying of QString when calling code needs only a reference, and so improves performance. Even though m_defaultMimeType is initialized with a QStringLiteral and its QArrayDataPointer has d == nullptr, QArrayDataPointer's ref() and deref() still have to compare d with nullptr to decide that no reference count manipulation is needed. Compilers might be unable to reorder these checks with surrounding code because they guard reference count manipulation. Branch misprediction could further harm performance. Optimizing these checks out can be difficult for compilers. Change-Id: I3ffa0fdc5ad948452301dd9688073b5323a7983b Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QStringBuilder: handle freeSpaceAtBegin() in op+=Marc Mutz2021-12-211-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Amends 9b320edb535a0fbe118933d2e983b73f90c32685. The above commit made the mistake of relying on the 30yr+ old fundamental relation size() - capacity() == freeSpaceAtEnd() which, however, Qt 6's prepend()-optimization (freeSpaceAtBegin()) broke. Because of that, while size() - capacity() may be large enough to hold the new data, if freeSpaceAtBegin() > 0, then freeSpaceAtEnd() may not. Fix by inspecting freeSpaceAtEnd() instead of capacity(). The following reserve() call is unaffected, since it internally already adds freeSpaceAtBegin() to the requested size, which is why the unconditional reserve() in 9b320edb535a0fbe118933d2e983b73f90c32685^ worked while 9b320edb535a0fbe118933d2e983b73f90c32685's capacity() check did not. Fixes: QTBUG-99330 Pick-to: 6.2 6.3 Change-Id: I520f36216011423f97a24484263acd40d8b1fa43 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Topi Reiniö <topi.reinio@qt.io> Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* QMimeDatabasePrivate: construct QString from QStringLiteralIgor Kushnir2021-12-211-16/+16
| | | | | | | | | In the changed code no QLatin1String overloads exist, so replacing QLatin1String with QStringLiteral improves performance by eliminating allocations. Change-Id: I77530fe72c309b0609f40b1dc34189bd3454c813 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QMimeDatabasePrivate: pass QLatin1String to QStringBuilderIgor Kushnir2021-12-211-2/+2
| | | | | | | | This should be more efficient than passing QStringLiteral. Change-Id: Ia96633c9db6cb287dd9c196e739047b8a46abb4d Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QMimeDatabasePrivate: remove Release-only fallbackIgor Kushnir2021-12-211-4/+3
| | | | | | | | | | When mimeTypeForFile()'s `mode` argument equals none of MatchMode enumerators, an assertion fails or the default MIME type's name is returned if assertions are disabled. Simplify and optimize this code by assuming MatchDefault in the unsupported-mode case. Change-Id: Iada36e0c96c378aefaa3a9d4a170222f764e94b6 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* wasm: prevent thread cross-talk when loggingMorten Johan Sørvig2021-12-211-0/+7
| | | | | | | | | | | Emscriptens implementation of fprintf does not provide mutal exclusion when called from multiple threads, for the emsdk versions Qt 5.15, Qt 6.2, and current dev is using. Pick-to: 5.15 6.2 Change-Id: Ied92730b735b11e4e5e85442de48fc25cbad0611 Reviewed-by: Lorn Potter <lorn.potter@gmail.com>