Commit Graph

37100 Commits

Author SHA1 Message Date
Laszlo Agocs
43d379797a vkmemalloc: Silence clang warning about unused member var
Change-Id: Id968fd2302e3ff7b4d1a20cd8dd1f4d789588511
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2021-01-19 13:17:55 +00:00
Laszlo Agocs
c6d6029909 Update QVulkan(Device)Functions to Vulkan 1.2
This also needs improvements to qvkgen. What we get with this patch
are the Vulkan 1.1 and 1.2 core API's additional 11 instance-level
and 30 device-level commands present in QVulkanFunctions and
QVulkanDeviceFunctions.

All of these are attempted to be resolved upon construction. When the
implementation does not return a valid function pointer for some of them
(e.g. because it is a Vulkan 1.0 instance or physical device), calling
the corresponding wrapper functions will lead to unspecified behavior.
This is in line with how QOpenGLExtraFunctions works. The simple
autotest added to exercise some Vulkan 1.1 APIs demonstrates this in
action.

The member functions in the generated qvulkan(device)functions header
and source files are ifdefed by VK_VERSION_1_{0,1,2}. This is essential
because otherwise a Qt build made on a system with Vulkan 1.2
headers would cause compilation breaks in application build environments
with Vulkan 1.0/1.1 headers when including qvulkanfunctions.h (due to
missing the 1.1/1.2 types and constants, some of which are used in the
function prototypes). In practice this should be alright - the only
caveat to keep in mind is that the Qt builds meant to be distributed
to a wide variety of systems need to be made with a sufficiently new
version of the Vulkan headers installed, just to ensure that the
1.1 and 1.2 wrapper functions are compiled into the Qt libraries.

Task-number: QTBUG-90219
Change-Id: I48360a8a2e915d2709fe82993f65e99b2ccd5d53
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2021-01-19 14:17:55 +01:00
Christian Ehrlicher
12d8bb0709 ItemViews: Don't remove items on internal move
When an itemview only allows internal moving of items it can happen that
the target accepts the drag'n'drop operation since it's out of the
control of Qt (e.g. Recycle Bin or an other application). Due to the
nature of a move, the original item is deleted. Therefore check if the
internal move target is the same as the source and don't delete it
otherwse.

Fixes: QTBUG-86020
Pick-to: 6.0
Change-Id: I69de4b8d76d1b0f57338b402aee87580226cd6cb
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-01-18 19:51:07 +01:00
Edward Welbourne
6ee13db700 Correct string comparison in Android's IANA ID matching code
It used QString.compare() and assumed it was returning a bool true on
equality, when it actually returns an int that compares to 0 as the
given strings compare. So it should use compare() == 0.

This fixes several of QTimeZone's blacklisted tests on Android and a
crasher, which we dodged with a QSKIP. Added an id-comparison to a
test. Gave two local variables more informative names, made an early
return into a QSKIP so it explains itself.

Fixes: QTBUG-89905
Fixes: QTBUG-69122
Fixes: QTBUG-69132
Fixes: QTBUG-87435
Pick-to: 6.0 5.15
Change-Id: Icf18ed5a810143d6e65d36e34a70e82faac10b8e
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2021-01-18 15:55:15 +01:00
Edward Welbourne
50c63446f5 Fix problems with offset-derived ids for QTimeZone
When creating a time-zone from a UTC+offset name that isn't known to
the system, QTimeZone (since the fix to QTBUG-77738 in 5.15.0) falls
back to constructing a suitable UTC-offset backend; however, the id of
this is not guaranteed to match the id passed in to the constructor.
In all other cases, the id of a QTimeZone does match the id passed to
its constructor.

Some utcOffsetId testcases had different id() than the id passed to
the constructor, due to mismatches where a zone was constructed using
the fall-back but the generated id included its minutes (as :00) or
omitted its seconds. The omission of seconds is clearly a bug, but we
also don't want to include :00 for seconds when it's not needed. So
change QTimeZonePrivate::isoOffsetFormat() to accept a
QTimeZone::NameType to configure how much we include in an id. Its
callers other than the relevant constructor (from offset) still get
minutes, even when :00, but will also get seconds added if that isn't
zero; and the constructor from offset now gets the short form obtained
by omitting all trailing zeros.

Since all valid whole-hour offset names that do include :00 for the
minutes field are in fact known standard offset names, the elision of
minutes will only affect zones created by ID in the case of a
whole-hour offset given without :00 minutes specifier, so these shall
necessarily in fact get the ID passed to the constructor. Creating by
UTC-offset with a name that specifies zero seconds will result in a
QTimeZone instance whose id() differs from what was passed to its
constructor (eliding the :00 seconds and potentially also minutes, if
also zero) but this should be the only case where a QTimeZone's id
doesn't match the one passed to the constructor, when constructed by
id.

Fixed inconsistency between the offset-constructor's declaration
(taking offset as int) and definition (taking qint32) in the process.
Added an id check to the utcOffsetId() testcase. Amended two tests of
offset-derived time-zones' IDs, added comments to make clear how one
of those differs from a matching standard name test and converted two
uses of QCOMPARE(, true) to QVERIFY().

[ChangeLog][QtCore][QTimeZone] QTimeZone instances created by offset
from UTC (in seconds) shall now only include minutes in their ID when
the offset is not a whole number of hours. They shall also include the
seconds in their ID when the offset is not a whole number of minutes.

Pick-to: 6.0 5.15
Task-number: QTBUG-87435
Change-Id: I610e0a78e2aca51e12bfe003497434a998e93dc7
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-01-18 15:55:05 +01:00
Andrei Golubev
6f520abdab Add new special QObjectPrivate::{connect, disconnect} for QML
Original QML-specific connection mechanism ignores the receiver argument
and uses sender as receiver. This causes uncontrollable memory growth
in certain cases as connections on receiver persist even after receiver
is destroyed

New connect() with receiver parameter uses underlying API correctly,
disconnect is provided for the symmetry (not sure it's really needed)

Task-number: QTBUG-86368
Pick-to: 5.15 6.0
Change-Id: I4580d75b617cb2c4dfb971a4dfb8e943e325572b
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-01-18 15:54:03 +01:00
Giuseppe D'Angelo
5a0e5521e4 QVectorND: make some constructors explicit
QVector2D has implicit conversions towards QVector3D/4D, and
QVector3D has an implicit conversion towards QVector4D. Although
in principle this is fine because it's not a data loss, it's still
sketchy; for instance, it allows mixed operations to compile:

  vector2d + vector3d;
  vector4d - vector3d;
  vector3d * vector4d; // !

(Random observation: the conversion from QPoint(F) to QVectorND are
actually already marked as explicit.)

This is a leftover not done for Qt 6.0. I am not making these opt-out:
having an implicit conversion here is outright *dangerous*, and any usage
that fails to compile needs to be inspected to make sure it was the
intended behavior.

[ChangeLog][Potentially Source-Incompatible Changes] The
QVector2D/3D/4D converting constructors from another QVectorND
now explicit. This was done to prevent a category of bugs resulting
from operations accidentally mixing QVectorND objects.

Fixes: QTBUG-90327
Change-Id: Ifcd873f6a0d3fc10b9e68c935fe1f69f86a2340b
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-01-18 14:53:24 +00:00
Kai Köhne
f1465c621c QLocale: Allow direct conversion to language, country, and script codes
Currently the codes are only exposed in aggregated form, i.e. through
name(), bcp47Name(). There are use cases though where you are only
interested in either language, country, or script codes. One example
is in Qt Linguist.

This patch therefore exposes the static languageToCode(),
countryToCode(), scriptToCode() methods that were so far only available
in the private API also in the public API.

[ChangeLog][QtCore][QLocale] Added static languageToCode(),
countryToCode() scriptToCode() methods that convert enum values
to the respective ISO code strings.

Fixes: QTBUG-39542
Fixes: QTBUG-64942
Change-Id: Ib1d5c3293e2f53245ba4c1fc8159275bcb290080
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-01-18 15:52:31 +01:00
Fabian Kosmale
2d8757f879 QVariant::fromValue<T>: require T to be copy constructible
In Qt 5, QVariant::fromValue<T> would not compile unless
Q_DECLARE_METATYPE(T) was used, and Q_DECLARE_METATYPE(T) would lead to
a compile error if T were not copy constructible.
In Qt 6, we do not require Q_DECLARE_METATYPE before using fromValue,
and QMetaType itself works with non-copy constructible types just fine.
However, QVariant still requires it, thus we need to now enforce this in
fromValue itself.

Change-Id: Ib6964a438d8c46033dd3a037b9d871de2b42e175
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-01-18 15:51:18 +01:00
Fabian Kosmale
ec12c30249 QUntypedBindable: Add documentation
Task-number: QTBUG-89505
Change-Id: I4428c3c0eb723e996195f6f6f5ac736757cea33e
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2021-01-18 15:51:17 +01:00
Oliver Eftevaag
3cb2b5bfe3 Fix small typo in the QMdiArea documentation
Added missing whitespace character in the documentation for QMdiArea,
in the 'detailed explanation' section.

Pick-to: 6.0
Change-Id: I6be1d664bc15e3e461c5fc3d8f82311cc6ea60ea
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2021-01-18 13:21:15 +01:00
Eskil Abrahamsen Blomfeldt
914a43d8aa macOS: Fix assert with Freetype engine
d8602ce58b removed the internal usage
of the singular fontDef.family, changing this to fontDef.families.first()
instead, which will assert if the families list is empty. To match
old behavior, we set the symbol flag to false if there is no family
name.

Change-Id: I594cf3dfa2798e60b37dc525c172fb2cd9aa7380
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
2021-01-18 13:21:15 +01:00
Joerg Bornemann
b0add5bf2f QtEntryPoint: Fix linking Release against RelWithDebInfo with MSVC
To be able to link a Release user project against a RelWithDebInfo Qt we
set several IMPORTED_*_RELEASE properties in
the *AdditionalTargetInfo.cmake file of each Qt module.

The EntryPoint module however is a bit special as it is an
INTERFACE_LIBRARY linking publicly against a static
library (EntryPointimplementation). Its *AdditionalTargetInfo.cmake file
was almost empty, because qt_internal_export_additional_targets_file was
called before EntryPointImplementation was set up. Also,
qt_internal_add_module, which calls
qt_internal_export_additional_targets_file, does not know that we want
to export the EntryPointImplementation target.

We fix this by telling qt_internal_add_module(EntryPoint) to not
generate the *AdditionalTargetInfo.cmake file and call
qt_internal_export_additional_targets_file later to take the targets
EntryPoint and EntryPointImplementation into consideration.

qt_internal_add_module learned the option NO_ADDITIONAL_TARGET_INFO to
turn off the generation of *AdditionalTargetInfo.cmake files.

Pick-to: 6.0
Fixes: QTBUG-90039
Change-Id: I68ec7125b538a57567035e7adb8dac3b213f95e6
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-01-18 13:21:15 +01:00
Laszlo Agocs
9f7088fd7f rhi: Stop hardcoding the Vulkan backend's desired instance extensions
Instead, have a static function in QRhiVulkanInitParams then Qt Quick
and anyone else who creates a QVulkanInstance that is then used in
combination with QRhi can query.

Change-Id: I046e0d84541fc00f5487a7527c97be262221527f
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2021-01-18 13:21:15 +01:00
Laszlo Agocs
036021b0d0 Add qvkgen header template to its own file
...instead of referencing the removed qtbase/header.LGPL.

Amends 9ac8b9c92e

Fixes: QTBUG-90329
Change-Id: Ic46e0adeef51f7bfcf445185c0ab5431df39bce6
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2021-01-18 13:21:15 +01:00
Laszlo Agocs
7d378bd780 vulkan: Add instance-level version getter
...as described in the Vulkan >= 1.1 spec. One can now call
supportedApiVersion() (before create(), similarly to the other
supported* functions) to determine the available Vulkan
(instance-level) version.

Fixes: QTBUG-90333
Change-Id: Ibe8482402b7f07e4abc48c88252ff0365e4e2faa
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2021-01-18 13:21:15 +01:00
Laszlo Agocs
9573441236 eglfs: Use drmClose in drm/EGLDevice backend
Pick-to: 6.0 5.15
Fixes: QTBUG-90350
Change-Id: I29a71e4abc2df7b777a895792bc5385a89223895
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2021-01-18 13:21:15 +01:00
Craig Scott
b59f77aab4 FindLibb2: Don't rely solely on pkg-config
Task-number: QTBUG-86283
Change-Id: Ie455d7cfc6e6f9ae8297f8bc0daf2816ccce91b6
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-01-18 15:42:52 +11:00
Andrei Golubev
b101f84f86 Add "Q_UNUSED" to (3rdparty) strtod.cc for a 32 bit code path
Accidentally stepped on this thing. Cannot build Qt Core on 32-bit
Ubuntu 16 without this patch.

Fixes: QTBUG-90354
Pick-to: 6.0 5.15
Change-Id: Iab5b2a317ee18b537b416eff008db29932fc043b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-01-17 22:27:46 +01:00
Giuseppe D'Angelo
d09a0e485d QMatrix4x4: mark it as Q_PRIMITIVE_TYPE
My guess: it was relocatable because before 6.0/5.15 we didn't
call constructors for Q_PRIMITIVE_TYPEs.

Change-Id: Ibc9e23e41d0c4b9718fc7036d9a647cfdcfa7d47
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-01-17 19:25:53 +01:00
Christian Ehrlicher
09696e3325 QHeaderView: fix moving sections with mouse in RTL mode
Moving sections in RTL mode did not work correctly - in contrast to LTR
mode the secion must be moved much further to the left or right to
actually move it.
Found while implementing an indicator for QTBUG-673

Task-number: QTBUG-673
Change-Id: I5a82d3cdb39415a408b2884d0ee302e0547e884f
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-01-17 13:57:50 +01:00
Allan Sandfeld Jensen
cfd935fe6c Fix XCB launch key mapping
They have been reported wrong since Qt 4, and not fixed for behavior
compatibility, fixing it for Qt 6.

[ChangeLog][X11] XF86LaunchXX keys have been remapped, so the Qt names
and X11 names match, instead of being 2 off.

Pick-to: 6.0
Fixes: QTBUG-25261
Change-Id: Ie3a8676439ae3e93a78218c9e7f4443565e84356
Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io>
2021-01-15 22:28:21 +00:00
Allan Sandfeld Jensen
2cf2f99ab1 Get rid of blend_color_rgb16
The generic functions are better optimized anyway, and it this old
method appears to have old bugs.

Fixes: QTBUG-20681
Change-Id: I60e4cc5f6cd90c851e90106ac9badfc6c249cd9f
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2021-01-15 19:45:04 +01:00
Christian Ehrlicher
c23e8cb582 QSettings: Add support for QMetaType::Float
When writing out a float value, the output string is encoded as QVariant
for no reason. Looks like an oversight when QMetaType::Float was added a
long time ago.

Fixes: QTBUG-21156
Change-Id: I7f5d31e15892d700c1b1e5e731b7733ce3a15730
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-01-15 18:51:15 +01:00
Friedemann Kleint
539553a572 QTestlib/JUnit XML: Log most messages to standard output instead of error output
Add an enumeration for system-out and alog element
for it. Redirect the messages types that are not warnings/errors
to this element. For compatibility, write it out only
if it is not empty. Rename enumerations and members accordingly.

[ChangeLog][QtTestLib] In JUnit XML, output that is
not a warning/error is now logged under <system-out>
instead of <system-err>.

Fixes: QTBUG-86540
Change-Id: I55598eafa7dafa486ac5a8221029c332ff47413b
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-01-15 18:05:40 +01:00
Friedemann Kleint
7f5d41e286 Windows: Fix dialog moving up after closing/reshowing
A resize event delivered after closing the platform window
was causing the stored frame margins to be cleared.
Bail out of QWidgetWindow::updateMargins() if the
platform window is null.

Pick-to: 5.15
Fixes: QTBUG-79147
Change-Id: Iebbc90c3cccafa209cd720baedf45affb3f3c2b8
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2021-01-15 18:05:19 +01:00
Jarek Kobus
98a89fb711 Hardcode a special case of using qOverload for slots without arguments
Pick-to: 6.0
Fixes: QTBUG-90308
Change-Id: I35cd45679ded626654dd0e7e3eea8a7bb14c1d56
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2021-01-15 17:39:46 +01:00
Morten Johan Sørvig
9cd3ff2bde macOS: Mark QFileDialog::DontConfirmOverwrite as unsupported
The native NSSavePanel does not have an option corresponding
to DontConfirmOverwrite. Qt has a workaround where
the save-file-name is temporarily given a prefix in
order do bypass the overwrite check, however this has
stopped working on recent versions of macOS. (Confirmed
on macOS 11)

Users who want to use DontConfirmOverwrite should use
Qt’s file dialog instead.

Fixes: QTBUG-39791
Pick-to: 5.15 6.0
Change-Id: Id3b9e6de72c2afc9526c96f1d9fdbce78db92aeb
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-01-15 15:19:24 +00:00
Edward Welbourne
b2a3389cfe Extend qIsInf() and friends to handle integral types sensibly
[ChangeLog][QtCore] qIsInf(), qIsNaN() and qIsFinite() now, like
std::isinf() and friends, accept integral types (returning false,
false and true, respectively) as well as floating-point ones.

Change-Id: I1e2b7f033f0e8166c0b21e31a62b3e6d37b9344a
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-01-15 16:00:40 +01:00
Sona Kurazyan
154573929a Fix setting active window as application's focus widget
When setting the application's focus widget we search for the next
child widget that can hold the focus and call its setFocus() method,
which also updates focus widgets of all its parent wigets.

In case if the focus widget is the active window itself, we only set it
as the application's focus widget, but we don't update the focus widget
of the active window itself. Because of this the focusWidget() method
always results nullptr for the active window. This prevents from setting
the focus back to active window after the focus has changed (for example
after a context menu is closed, as in the bugreport).

Transfer the focus to active window by calling the setFocus() method, as
it is done in case of transferring the focus to any other widget.

Pick-to: 6.0 5.15
Fixes: QTBUG-85846
Change-Id: I91ebf182fd5bb7d451a1186e2f3e38c8d48acc4e
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-01-15 15:22:18 +01:00
Laszlo Agocs
b5ce973b29 Document QOpenGLWidget limitations without an alpha channel
Pick-to: 6.0 5.15
Task-number: QTBUG-85869
Change-Id: I20fb70a451fc1ed93089ed699539fa12ac38fe73
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2021-01-15 15:21:28 +01:00
Laszlo Agocs
2aa7ad5e67 qvkgen: Skip command elements with alias
Otherwise we end up with generating broken qvulkanfunctions cpp and h
files.

For example, encountering the following command element should lead to
taking no action, this is not something we want to emit a corresponding
wrapper function for:
  <command name="vkResetQueryPoolEXT" alias="vkResetQueryPool"/>

This is required to be able to upgrade the bundled vk.xml to something
newer.

Fixes: QTBUG-90330
Task-number: QTBUG-90219
Change-Id: Ie6e3a8794207e30a172820eb055238bf52a0c0b9
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2021-01-15 15:21:15 +01:00
Allan Sandfeld Jensen
ade24763c7 Fix convertToRGBA64PM for Grayscale16
The input has been fetch into a set of uint32s, so no longer a
string of ushorts.

Pick-to: 6.0 5.15
Fixes: QTBUG-90246
Change-Id: Id52a6824317b0744310008cc2ce2f726539b4c8c
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2021-01-15 15:17:19 +01:00
Kai Köhne
ccce1a4e90 RHI: Use QT_BEGIN_LICENSE:LGPL header
Task-number: QTBUG-90321
Pick-to: 6.0
Change-Id: If3b0841f3e9139bb1911c6a5d03a16daf8c1b3d6
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2021-01-15 14:14:32 +00:00
Paul Wicking
efa5a69972 Doc: Clarify setLibraryPaths behavior
Fixes: QTBUG-89130
Pick-to: 6.0 5.15
Change-Id: Id8460fd00dcfdcca174d523f8d97baef1a764f6f
Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
2021-01-15 15:14:31 +01:00
Craig Scott
257edbfa53 Prevent compiler and linker flags from growing every cmake run
Functions in QtFlagHandlingHelpers.cmake try to update the CMake cache
variables for compiler and linker flags. These were using the current
value of those variables and writing the modified ones back to the
cache every time CMake ran. If a toolchain file sets or modifies any of
these variables, that updated value is used and written back into the
cache instead of the original cache variable's value. The next time
CMake executes, the toolchain file re-applies the same change and the
variable grows longer each time with flags repeated. With Ninja, this
causes a complete rebuild every time CMake is re-run. The Android NDK
toolchain file is one example where this behavior is triggered (the
fault is shared, one could argue that the NDK should only be setting
..._INIT variables, but that's out of our control).

Another related bug in the previous implementation was that the flags
used to build after the first CMake execution could be different to
those used for all builds after the second and later CMake runs. This
is because the CMake cache was being updated, but not always the
calling scope of the functions that modified them. If a toolchain file
set any of the compiler or linker flag variables as non-cache
variables, then updating the cache variable would have no effect on
the calling scope. The non-cache variable would continue to take
precedence for that scope for that run. The next time CMake executes
though, the updated cache variable would now have been used by the
toolchain file and the change *will* be part of the non-cache
variable's value.

The above are examples of why you should try to avoid updating these
cache variables from project code. We could leave the cache alone and
always update only non-cache variables, but then a developer looking
at the cache may wonder why the values they see there don't match the
values being used in builds. Or worse, they think the cache values
are being used and don't realize the builds are using something
different. Ultimately, we have to choose which downside we are happy
to live with. The changes here preserve the previous intent of
updating the cache, but it's still a bit fragile.

Fixes: QTBUG-89821
Task-number: QTBUG-85992
Task-number: QTBUG-86866
Change-Id: I8a16753e159bde338e6d2e5dd2ce91fc8ac5c39d
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-01-15 22:26:41 +11:00
Laszlo Agocs
77350b7a71 Update vkmemalloc to 2.3.0
Task-number: QTBUG-90219
Change-Id: I382f59edbc869fd4f3557411264f290e9fd5dee5
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2021-01-15 12:26:41 +01:00
Qiang Li
3f3d5e6716 Fix the tips still show when cursor move to another action
In this case, the previous action's tip is still displayed
when the cursor moves from one action with tip to another action
without tip.

Fixes: QTBUG-89082
Pick-to: 5.15
Pick-to: 6.0
Change-Id: I0a00595dc3d716725678487be9cbb363c4d3b392
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-01-15 12:26:41 +01:00
Joerg Bornemann
baff03d3d4 Doc: Document the qt_no_entrypoint target property
Fixes: QTBUG-90031
Change-Id: Ib3e7e9d966ee64f97fdd3df48b3fa5325d19cc6c
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-01-15 12:26:41 +01:00
Friedemann Kleint
f3251bcb87 QTabBar/Windows: Fix close button icons being too small on high-res screens
Add 32x32 versions. Move the icon creation to a helper function.

Fixes: QTBUG-88230
Pick-to: 6.0
Pick-to: 5.15
Change-Id: I6dda2084e0122234eacea17ac191a19f6855f466
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2021-01-15 12:26:40 +01:00
ChunLin Wang
dafd26acbe Fix QApplication::font returns the font unstable according to the object
If a default font was not registered for the widget's class, it returns the default font of its nearest registered superclass.

Fixes: QTBUG-89910
Pick-to: 5.15 6.0
Change-Id: I6e6b2c6a0044462f84db9f76a03be0c6cfaaae8e
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-01-15 14:38:35 +08:00
Ralf Habacker
ab2c61e638 If available, use a version-specific qt<major-version>.conf
To enable the current Qt version to use a qt.conf that is independent
from the previous version, a file named 'qt<major-version>.conf' is
searched for first. If this file does not exist, a file with the
name 'qt.conf' is searched for.

Task-number: QTBUG-88635
Change-Id: If75b63f72a7bdbdf1de7729ea4ecb00810b58d12
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
2021-01-14 23:30:47 +01:00
Andy Shaw
4d3d981144 Interbase: Don't error out if closing an already closed cursor
Pick-to: 6.0 5.15
Change-Id: If6964f5ae45c5ca4c0b34e417326fea1f33d7628
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
2021-01-14 19:53:16 +00:00
Ivan Solovev
00505ed2b5 Widgets: fix setTabOrder for QAbstractSpinBox-like widgets
setTabOrder was not considering the case, when a child widget has
its focus proxy set to its parent widget. This happens, for example,
for the QLineEdit that is nested inside the QAbstractSpinBox.
For such cases the lastFocusChild was calculated incorrectly, and, as
a result, such child widgets were not correctly positioned in the
focus chain. This could lead to an error while backtabbing.

Here is a brief example. Suppose we have 3 widgets arranged like this:

auto spinBoxOne = new QDoubleSpinBox;
auto spinBoxTwo = new QDoubleSpinBox;
auto button = new QPushButton;

Then the default widget focus order is:
- spinBoxOne
- lineedit (from spinBoxOne)
- spinBoxTwo
- lineedit (from spinBoxTwo)
- button

Before this commit setting the explicit tab order changed the focus
order in the following way:

QWidget::setTabOrder(spinBoxOne, spinBoxTwo);
QWidget::setTabOrder(spinBoxTwo, button);

- spinBoxOne
- spinBoxTwo
- button
- lineedit (from spinBoxOne)
- lineedit (from spinBoxTwo)

In this case, backtabbing from spinBoxOne actually leads us to
lineedit (from spinBoxTwo), which refers to spinBoxTwo.
And so we're stuck in a loop.

This commit fixes the issue by handling such special case, and
preserving correct focus order.

Note: the actual unit-test in this patch uses QLineEdit instead of
QPushButton, because one can't tab to buttons on macOS by default.
However the general idea is the same.

Pick-to: 6.0 5.15
Fixes: QTBUG-81097
Change-Id: I5d16da7733a4d63f809cab28b8ca9e116b87cffa
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-01-14 20:09:43 +01:00
Shawn Rutledge
aeeac48cbd AA_SynthesizeTouchForUnhandledMouseEvents: keep correct coordinates
QGuiApplicationPrivate::processMouseEvent() sends a
QWindowSystemInterfacePrivate::TouchEvent if the mouse event is not
accepted and AA_SynthesizeTouchForUnhandledMouseEvents is enabled.
A QPA TouchEvent always contains native touch points, which is why
it calls QWindowSystemInterfacePrivate::fromNativeTouchPoints to
translate the QMouseEvent's device-independent position back to the
raw position that it would have had if it came from a real touchscreen.
Therefore we must give that function touchpoints that are actually in
native coordinates.

It may be that some of this transformation could be avoided entirely,
but here we prove that the existing way works correctly, by adding
coordinate checking to the tst_QWindow::mouseToTouchTranslation() test.

Pick-to: 6.0
Task-number: QTBUG-86165
Change-Id: I4c9ca2b11e9eb76d79712c187db3eb9865da581a
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-01-14 19:09:28 +00:00
Christian Ehrlicher
e9ccdf4d84 QPushButton/fusion style: don't ignore QIcon::On icon
The fusion style did ignore the QIcon::On icon because it reset State_On
to avoid the visual shift of a pressed button.
But it's not needed to reset this flag - the shift does not happen
because the fusion style does return 0 as offset for
PM_ButtonShiftHorizontal/PM_ButtonShiftVertical so no shifting will
happen.

Fixes: QTBUG-86736
Fixes: QTBUG-82110
Change-Id: Ie2aaddb14bc67874f5a9a23d9f04d7a08c6d070f
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2021-01-14 19:09:13 +00:00
Allan Sandfeld Jensen
92ed274475 Add API for creating QColorSpace with multiple color-transfer tables
One table per color channel, as is possible from many inputs.

Change-Id: I9fc723c68f222a228dd2b1458207b028422913bf
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2021-01-14 11:05:22 +01:00
Alexander Volkov
cefef116ef Disable copying of QUrlResourceProvider to avoid slicing
Amends 376e3bd8ec

Change-Id: Ib7b0de900c009f3bdb3f699a218444aafbe2eabe
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-01-14 13:01:57 +03:00
Mårten Nordheim
d2e2d0d3a6 QCache: when overwriting, store the new cost instead of the delta
The delta was clearly intended to be used on the total (and still is)
but it also wound up getting stored in the cache, which wouldn't be a
big problem unless the object was removed, in which case we could
incidentally 'free up more space' than intended.

Pick-to: 6.0
Change-Id: Ib2b0f072d30da6d16a93dce60e4c5f6080c109fc
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-01-14 10:00:01 +00:00
Lu Zhen
cb4f853cb0 Add some error handling for the inotify file system watcher
In the readFromInotify() function, add a check whether
the ioctl function is successful or not. In the case of
failure, continuing to execute the following code would cause
errors in the read function because there is no data in the buffer.

Change-Id: Id53037e9e48c97c9eb75835048143875275b6370
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-01-14 09:47:07 +00:00
Andy Shaw
c2657f9762 QODBC: Preserve the whole value when using HighPrecision
Some ODBC drivers do not properly handle SQL_NO_DATA and therefore
decimal values returned with HighPrecision are cut off because the
decimal point is not taken into account.

Fixes: QTBUG-73286
Pick-to: 6.0 5.15 5.12
Change-Id: I905c947b4d0266a3245d5735300300ca00f77480
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
2021-01-14 07:02:43 +00:00
Christian Ehrlicher
1bcfada9f0 QStyle: add name() to return the name of the style
Currently there is no way to get the name of the current style to e.g.
create a QProxyStyle for a specific widget only.
Therefore add QStyle::name() so QProxyStyle(const QString &) can be
called without hard-coding the style name.
Remove an unused doc snippet as drive-by.

Fixes: QTBUG-8004
Change-Id: I466c5e870a5392b238365bdc930f6a2ecee50cdb
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2021-01-14 05:43:14 +00:00
Allan Sandfeld Jensen
47c6b5b91e Fix VNC format conversion
Pass the right from depth to the conversion function, and
set the right format before creating the compositor image
for RGB16 support.

Pick-to: 6.0 5.15
Fixes: QTBUG-85621
Change-Id: I76f46a3c2d8f1d2b040b790035dbdb0a960ff1a7
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2021-01-13 22:22:29 +01:00
Jan Arve Sæther
583668005d a11y: Do not cache classes that don't have a factory plugin
For Qt Widgets we thought it was a good idea to also store in the cache
if a class didn't have a factory plugin. This worked fine there, since
the number of QWidget classnames is quite limited (so the factory plugin
cache will soon reach a limit)

In QML however, classes are often suffixed with e.g. Button_QMLTYPE_123,
Button_QMLTYPE_124 etc.
This number suffix is just increased continuously. This could lead to that
the factory plugin cache will grow ad infinitum, which will cause
"memory leaks" in addition to a performance penalty.

Pick-to: 6.0
Pick-to: 5.15
Fixes: QTBUG-75106
Change-Id: I9ba189f989f0b90ab62a2c54a2e9230236a998d8
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-01-13 19:33:08 +00:00
Christophe Giboudeaux
2d4a40f93f CMake: Fix build with GCC and ltcg
The porting script could not handle this special case.
To achieve the same thing, we'll use an intermediate 'OBJECT' library
which will get the '-fno-lto' build flag if the conditions are met.

Fixes: QTBUG-89426
Pick-to: 6.0
Change-Id: Ied62502ce9c7f7fd6b89fab166f7bccfcd6e7433
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-01-13 18:04:16 +01:00
Christian Ehrlicher
b3b28faf26 QComboBox: fix select all columns in the view
When the QComboBox gets a custom view with multiple columns, only the
first one is selected even the selection mode of the view is SelectRows.
The selection changes afterwards properly honor the mode though.
Therefore check for the selection mode and call setCurrentIndex() with
the appropriate flags.

Fixes: QTBUG-86776
Pick-to: 6.0
Pick-to: 5.15
Change-Id: Ieba7b9e009358e7b6e802b7847640161ec776c64
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-01-13 16:44:26 +00:00
Eirik Aavitsland
2054f451b1 Fix read-only pseudo-state in QTextEdit/Browser stylesheet
Was implemented for QLineEdit but not QTextEdit.

Fixes: QTBUG-83056
Pick-to: 6.0 5.15
Change-Id: I1e67ad0f1c230a062a1e12e8bc0b209c5289dc32
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-01-13 17:22:34 +01:00
Volker Hilsheimer
ee409a536e macOS: Add more padding to width of non-editable comboboxes
The width of the combobox took the space for the checkmark and the contents
into account, but didn't provide any padding on the right side, resulting
in the text hitting the right side of the combobox popup.

Add another 12 pixels padding to the sizeFromContents implementation,
which results in a symmetrical padding on both sides of the text.

Fixes: QTBUG-88715
Pick-to: 6.0 5.15
Change-Id: I811da73d11ce935c1fb83efabbe799f9a882e1d7
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2021-01-13 16:16:50 +01:00
Christian Kandeler
b88f692d7d QTestLib: Show the values of unregistered enums
... on a failed QCOMPARE.

Change-Id: I653894927e49fad92c21409d03ed70880ca510f6
Reviewed-by: Jason McDonald <macadder1@gmail.com>
2021-01-13 16:15:06 +01:00
Friedemann Kleint
29b2387587 Windows font engine: Silence warnings about not being able to enumate font families
Turn the warning into a qCDebug() statement and add explanatory comment.

Fixes: QTBUG-85683
Pick-to: 5.15 6.0
Change-Id: I2a6a7a089a660294f3e9c3096299c75635b3b215
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2021-01-13 11:59:18 +00:00
Laszlo Agocs
c262a69851 rhi: gl: Add some enablers for supporting GL_TEXTURE_EXTERNAL_OES
From QRhi's perspective this consists of two things:

- A shader with samplerExternalOES in it cannot go through the standard
  pipeline. Rather, a QShader with suitable GLSL code in it has to be
  constructed manually. As this is something useful as an autotest
  anyway, add a test case to the qshader autotest that demonstrates
  this.

- When it comes to correctly calling glBindTexture, add a QRhiTexture
  flag. The expectation is that an OpenGL-only client sets this in
  combination with QRhiTexture::createFrom(), thus wrapping an existing
  texture that then gets bound to the GL_TEXTURE_EXTERNAL_OES target
  instead of our usual GL_TEXTURE_2D.

For completeness we also add a SamplerExternalOES variable type to
QShaderDescription, but the sampler type is not actually used by the
QRhi OpenGL backend, as it is the QRhiTexture that defines the
texture target.

Change-Id: I36b52325deb3703b59186ee3d726d0c3015bfc4b
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2021-01-13 10:08:23 +01:00
Laszlo Agocs
042cd97884 rhi: Expose device name, type, and IDs
...to the extent it is sensible. We have to make compromises still,
meaning some fields will only be applicable with certain APIs.

Most of this is already shown upon QRhi::create() as info debug
prints, when enabled. Now expose it all through the QRhi API as
well.

This is useful for printing in qtdiag, and, while it should be
avoided as much as possible, to make decisions about disabling
3D rendering features depending on the driver and GPU in use.

Change-Id: Iebe1e192965c928b82a094d1c7c50ddf4b38b9a2
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2021-01-13 10:08:23 +01:00
Joerg Bornemann
04f11f9935 Remove .prev_CMakeLists.txt files
Those serve no purpose anymore, now that the .pro files are gone.

Task-number: QTBUG-88742
Change-Id: I39943327b8c9871785b58e9973e4e7602371793e
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
2021-01-12 20:59:13 +01:00
Andy Shaw
bb00b63dee Set the PlaceholderText color in the palette from the stylesheet as well
The color should be used across the board, so the PlaceholderText color
should also be respecting the one passed for Text and so on.

Fixes: QTBUG-89815
Pick-to: 6.0 5.15
Change-Id: I2accb3db35488f95a1c8ebacf2316a08ee416fac
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-01-12 20:24:28 +01:00
Paul Wicking
8c395a20ed Doc: Add details to QFont::toString
Add details that explain the return value.

Pick-to: 6.0 5.15
Fixes: QTBUG-81467
Change-Id: Ifad407a27259711fc9abe1bacc7ba9db105bdcc0
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2021-01-12 13:50:26 +01:00
Tor Arne Vestbø
163d9c7cc4 macOS: Don't try to close already-closed/closing file dialog
Doing so results in a warning about "modalSession has been exited
prematurely - check for a reentrant call to endModalSession:", and
on Big Sur will also result in the file failing to save because the
return code from runModal will no longer be NSModalResponseOK.

This would happen when the completion handler for beginSheetModalForWindow
would call QNSOpenSavePanelDelegate_panelClosed, resulting in calls to
QDialog::done(), which in turn tries to hide the dialog, via
QCocoaFileDialogHelper::hideCocoaFilePanel().

Pick-to: 6.0 5.15
Fixes: QTBUG-89959
Change-Id: I048afe3dcc7fe62e0d0273f12b4b2c0237abb052
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2021-01-12 12:44:35 +00:00
Alexander Volkov
376e3bd8ec Introduce QUrlResourceProvider to load resources for HTML
QTextDocument and the text editor classes suggest to override
their loadResource() methods to provide data associated with
a text document. This approach has the following drawbacks:
- it requires subclassing
- there is no way to set a global resource provider
- QLabel is missing virtual loadResource() method and
  it can't be added without breaking ABI

QUrlResourceProvider is designed to solve these issues.
One should create a derived class that implements
QUrlResourceProvider::resource(). The objects of the derived
class then can be set for any text document.
The default resource provider can be set with
QUrlResourceProvider::setDefaultProvider().
This change also adds QLabel::setResourceProvider(),
which doesn't break ABI.

[ChangeLog][QtGui][Text] Introduced QUrlResourceProvider that allows to
load resources for HTML. It is intended to replace the use of
QTextDocument::loadResource().

Change-Id: Iaf19b229f522a73508f20715257450fe58f68daf
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-01-12 15:33:10 +03:00
David Skoland
9e09677c1d Remove QtDBus includes
Per the discussion of QTBUG-88831, we determined that module-wide
imports are unfortunate, especially for compile times. Following this,
all QtDBus includes have been replaced with the headers for the classes
actually used in each file. Additionally, some cleanup of header file
order and format has been performed in the changed files.

Pick-to: 6.0
Change-Id: I62c1b75682a48422f0ba1168dd5d7bd0952808ac
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-01-12 09:19:27 +01:00
Eskil Abrahamsen Blomfeldt
6a3f8cbc3a Use design metrics when adding text to QPainterPath
When we add text to QPainterPath, we will add the design metrics
(unhinted glyphs) and scale these down to match the target font size.
But the glyph positions we pass in are based on the hinted metrics,
samples at the target font size. Thus, on fonts/systems with hinting,
these do not match the scaled design metrics outlines.

To fix this issue, we make sure the text layout uses design metrics
when determining the glyph positions.

[ChangeLog][QtGui][Text] Fixed an issue where QPainterPath::addText()
would get inconsistent kerning for smaller font sizes when hinting is
enabled.

Fixes: QTBUG-20900
Pick-to: 5.15
Pick-to: 6.0
Change-Id: I651997d1a6a86e6271557438afa2cdad078a83ca
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-01-12 09:10:35 +01:00
Friedemann Kleint
7b7dda654a Windows QPA: Fix crashes when using screen reader with Q(Plain)TextEdit
Make sure the search start with valid values.

Pick-to: 6.0 5.15
Task-number: QTBUG-89354
Change-Id: I5b5100db89c62f23748b5c88e9188cfe3811e6e8
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2021-01-12 07:55:04 +01:00
Christian Ehrlicher
f8f629cc13 QSql/QSqlite: return extended error codes by default
SQlite allows to return fine-granulated error codes but this behavior is
not enabled by default (due to backwards compatibility concerns).
Enable them for the SQLite driver by default but provide an option to
disable them when needed.

[ChangeLog][QtSql][QSQLITE] The plugin now returns the extended error
codes by default.

Change-Id: I59cec9aea46eb03f1e7ca02903d769c003a1ae30
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
2021-01-11 19:55:43 +01:00
Robert Loehning
ce90248882 QSslCertificate: Guard against accessing empty QByteArray
Fixes oss-fuzz issue 29276.

Pick-to: 5.12 5.15 6.0
Change-Id: I57b0c26e5377bd6b82d9f044ae1d1d13acec996a
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2021-01-11 19:14:21 +01:00
Andreas Buhr
a75bdfda3d Clarify variable names in QPropertyObserverPointer::notify
In QPropertyObserverPointer::notify and its calling sites,
variable names "alreadyKnownToHaveChanged",
"knownIfPropertyChanged", "propertyChanged", and at its calling site
"knownIfChanged" are used. This is confusing. This patch
changes those four to "knownToHaveChanged". For the logic
implemented it is not necessary to track whether we
have knowledge about having changed and whether it has
actually changed (if we have knowledge) separately.

Change-Id: I90b86b276ab67b2ed70dba4e456cd90220588870
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-01-11 16:14:23 +01:00
Fabian Kosmale
240505457b QBindable: Improve read-only support
If we create a QBindable from a const property, we should obtain a
read-only interface. Besides implementing this feature, this patch adds
a isReadOnly method to Q(Untyped)Bindable which can be used to check
whether one can modify the property via the bindable interface.

Task-number: QTBUG-89505
Task-number: QTBUG-89469
Change-Id: Ic36949a5b84c5119e0060ed0a1cf4ac94a66f341
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2021-01-11 15:57:26 +01:00
Morten Johan Sørvig
9f894788dd Revert "Windows QPA: Call QWSI::flushWindowSystemEvents() from WM_PAINT for full update only"
This reverts commit a81dfb32d6.

Paint immediately on WM_PAINT in all cases in order to
avoid flicker on resize.

The cases mentioned in commit a81dfb should no longer
apply:
  - QTBUG-38327: QGLWidget is not supported in Qt 6.
  - QTBUG-39842: Fixed by using ExcludeUserInputEvents.

Fixes: QTBUG-89688
Change-Id: If82cf7703d6663982769048e86a7060223730ce7
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2021-01-11 14:42:50 +00:00
Paul Wicking
9a12f7e083 Bump version
CMake edition.
Also update default compiled version.

Task-number: QTQAINFRA-4126
Change-Id: Ia6f535f553e73bd6b00e2e20752f4961af21ede5
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
2021-01-11 13:58:55 +01:00
Paul Wicking
149ad1e615 Doc: Explain how boundingRect handles null QRectF
Fixes: QTBUG-87107
Pick-to: 6.0 5.15
Change-Id: Ib7f9bd58b0f3454167dc61f95e0d8e6dec52a5ed
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
2021-01-11 13:28:17 +01:00
Kai Köhne
1f53189c29 Doc: Generalize timer docs
The snippets do not talk about Qt Widgets specifically.

Pick-to: 6.0 5.15
Change-Id: Icc4f243c93189f08124074e4918d535aa37e6560
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
2021-01-11 09:52:56 +01:00
Paul Wicking
713829b718 Doc: Link to correct location
Reflow text to fit style while at it, to satisfy git clang-format.

Pick-to: 6.0 5.15
Fixes: QTBUG-89709
Change-Id: Iab2bf09399adf2cb0f0219ab40978bb238825ae8
Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
2021-01-11 07:35:21 +01:00
Craig Scott
0be2ecee37 Doc: Add partial documentation for CMake API (tech preview)
There are still other parts of the CMake API that are not yet
documented. This change only addresses qt_add_executable() and the
Android-related commands it uses.

Fixes: QTBUG-88839
Task-number: QTBUG-84482
Pick-to: 6.0
Change-Id: I761b5ce908d1f62284baabe2d414cd37a0efe83d
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2021-01-11 16:58:28 +11:00
Giuseppe D'Angelo
c34c6af374 Replace some more erase/remove patterns with removeIf
Change-Id: I6c6f33450fbfd798e5ef71a8ba18f590581dc3a2
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-01-10 15:02:47 +01:00
Christian Ehrlicher
b211148e4b Sql ODBC driver: add direct support for float and short datatype
This patch adds native support for SQL_REAL (float) and SQL_SMALLINT
(short). Previously those datatypes were mapped to double and integer.

[ChangeLog][QtSql] The ODBC driver now properly maps QMetaType::Float to
real sql datatype and QMetaType::Short to smallint

Fixes: QTBUG-8963
Fixes: QTBUG-57279
Change-Id: Ifec4c609734dbe6165c1ebdadb461c2aae47ba78
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
2021-01-10 13:02:14 +01:00
Alex Trotsenko
161e8f4d5d QProcess/Win: clean up death notifier teardown
To avoid the mostly hypothetical possibility of failure, delete the
processFinishedNotifier before closing the handle on which it operates.
Previously, because of this, we explicitly disabled the notifier in the
processFinished() function, which made the code unclear. Now, we can
remove that safely, because cleanup() works correctly, and doing it
before calling findExitCode() was not necessary to start with.

Change-Id: Ia7095ded2c7eba8f4d738c6b87c7be41aa3cbbc8
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
2021-01-09 20:56:11 +00:00
Alex Trotsenko
4ff41e6ff8 Remove useless call in QProcessPrivate::waitForFinished() on Windows
if pid == nullptr, the child process has already exited and the pipe
readers have been stopped. So the call to drainOutputPipes() is
unnecessary here.

Change-Id: I0bed90d08ac879bb0ae178a1cdc37afb9d825314
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
2021-01-09 15:16:42 +02:00
Alex Trotsenko
db5c901594 QProcess/Unix: do not activate read notifiers until process has started
Otherwise, the user may receive the readyRead() signal just before
started().

Change-Id: I8d6fd18fdfcef0580a3e609100198b03b18b1175
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
2021-01-09 15:16:34 +02:00
Alex Trotsenko
6a6d12ea4b Split QProcessPrivate::_q_processDied()
The completion of the child process can take place asynchronously or in
one of the waitFor...() functions. In both cases, we used the same
handler (_q_processDied()), which caused several problems:

  a. technically, waitForReadyRead() should have taken into account the
     result of the calls to _q_canRead...() slots inside the
     _q_processDied() function:

       - the user calls waitForReadyRead();
       - forkfd descriptor becomes signaled, while a grandchild
         process is still alive;
       - as readyRead() signal has not been emitted, _q_processDied()
         is called;
       - the grandchild process writes to stdout pipe;
       - now data arrives, and _q_processDied() will collect it, but
         won't report it.

  b. we had a bug with recursions on Unix:

       - death notification comes asynchronously;
       - waitForDeadChild() closes forkfd;
       - _q_canRead...() emits readyRead();
       - a slot connected to readyRead() calls waitForFinished();
       - waitForFinished() hangs (forkfd == -1).

   c. for blocking functions, drainOutputPipes() was called twice on
      Windows.

By introducing a new processFinished() function, we leave the read
operations in the _q_processDied() slot, while the process completion
code is guaranteed to run only once.

Change-Id: I5f9d09bc68a058169de4d9e490b48fc0b35e94cd
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
2021-01-09 13:15:54 +00:00
Christian Ehrlicher
05706bd2b0 QPdfWriter: fix embedding fonts in pdf files
The container size change from int32_t to int64_t created a subtle error
during font serialization. The size of a QByteArray was serialized
without a proper cast and therefore now 8 bytes instead 4 bytes were
written to the stream.

Fixes: QTBUG-89727
Pick-to: 6.0
Change-Id: If9255a5a3124038356bc5053810f98c7c88f8a01
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2021-01-09 09:04:29 +00:00
Andreas Buhr
d26da5fc09 Remove outdated comment and unnecessary initialization call
In construction of QPropertyBindingPrivate was an initialization
of inlineDependencyObservers with a comment that this is necessary
because of a union. But inlineDependencyObservers is not inside a
union. The comment is outdated and the explicit initialization
superfluous. This patch removes it.

Change-Id: I06544a816533c41af8fc5da3ef44ddd7c18ca86e
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-01-09 10:03:21 +01:00
Ahmad Samir
138fa9f2f4 QDir/QFileInfo: add doc notes about paths starting with ':'
This is an addendum to commit 0da5726a43b; making the note about paths
starting with ':' being treated as absolute paths by the underlying
QFileSystemEngine, more visible, so that users of the class don't hit
that pitfall.

Add similar docs to QFileInfo.

Pick-to: 5.15 6.0
Change-Id: Ib34d066d31bb673d340ec41422ed4daf911765b8
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2021-01-08 18:13:42 +02:00
Allan Sandfeld Jensen
d5a980df97 Send Qt::Key_MediaTogglePlayPause for VK_MEDIA_PLAY_PAUSE
Speculative fix to get the right keys in WebEngine

Pick-to: 6.0 5.15
Fixes: QTBUG-89915
Change-Id: I79519b715a1415dccfc4601aae5025b3222a79ae
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2021-01-08 16:56:27 +01:00
Friedemann Kleint
867b11596b Windows QPA: Fix missing QScreen change updates
Remove the logic compressing WM_DISPLAYCHANGE signals by the
WParam/LParam since it also triggers when the geometry is changed
by rearranging screens.

Fixes: QTBUG-79442
Change-Id: I00042c9e687bdb67fc17d6c507818b79a7aee0a2
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2021-01-08 13:43:47 +01:00
Alex Trotsenko
423e6c3635 QProcess/Unix: consolidate process state tracking socket notifiers
There is no reason to have the startup notifier and the death notifier
be active at the same time, as the former will detect death as well.

Previously, these notifiers were racing, but _q_processDied() ordered
signals by calling _q_startupNotification() manually. Thus, the
started()/finished() sequence was always emitted if the child process
was killed anywhere. Now this ordering is simply not necessary anymore.

This makes it possible to reuse the startup notifier for death
notification.

Change-Id: I5ebed9b5f28b19fe56c80498977a3b21be9288fd
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
2021-01-08 14:29:43 +02:00
Edward Welbourne
7fea8a079f Assert that wchar_t's size matches one of the unicode character types
This is assumed in various places, so best checked explicitly.

Change-Id: I475dcf5cbb60c0272dec560acd2893cff73872ce
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-01-08 12:41:28 +01:00
Edward Welbourne
4724d017ef Minor tidy-up: two sizetype fixes, two \nullptr uses
Change-Id: I6c4a1296350ecaf9a661dba22670fbb2ad23bd77
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-01-08 12:41:06 +01:00
Edward Welbourne
c9c598d4d7 Mark places where we missed conversion to unicode character types
We should use char32_t for the toUcs4() methods of QString and
QStringView and use char16_t for QString::utf16(), thereby matching
QStringView. These naturally imply knock-on changes in various places.
Unfortunately, we didn't make those changes in Qt 6, so they'll have
to wait for Qt 7.

Change-Id: I18451d4b31b76658092e19d3fcbc8bc0fe5ce307
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-01-08 12:40:53 +01:00
Andreas Buhr
618dd6b5a7 QProperty docs: update macro name
Use Q_OBJECT_BINDABLE_PROPERTY instead of non-existing ones.
Follow-up to 50e1976437.

Task-number: QTBUG-85520
Pick-to: 6.0
Change-Id: I138f0775d9804029f2ecd6bd3594ab47b247392e
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2021-01-08 10:01:23 +01:00
Nico Vertriest
1b636b72e5 Doc: Fix \sa statement link error
Change-Id: I19f131a7bcbbed5ec39a7ad79a9d7a46d1320529
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2021-01-07 18:36:33 +01:00
Frederik Gladhorn
a62fa9b7cc Revert "Fix invalid text layout data when a full layout run is interrupted"
This reverts commit 09ee4282e5.
The commit made the layouting time go from linear to quadratic, which is
problematic when rendering big documents impractical.

I wrote an alternative fix for QTBUG-20354 which will come as separate
change since it approaches the problem in a different way.

Fixes: QTBUG-89599
Task-number: QTBUG-20354
Pick-to: 5.15
Pick-to: 6.0
Change-Id: Ie450332f06ee40e60c8e4c6c7d10834bff1acf74
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2021-01-07 14:48:34 +00:00
Joerg Bornemann
ad2da2d27a Remove the qmake project files
Remove the qmake project files for most of Qt.

Leave the qmake project files for examples, because we still test those
in the CI to ensure qmake does not regress.

Also leave the qmake project files for utils and other minor parts that
lack CMake project files.

Task-number: QTBUG-88742
Change-Id: I6cdf059e6204816f617f9624f3ea9822703f73cc
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
2021-01-07 15:32:28 +01:00
Friedemann Kleint
fca3ea040c QTestlib: Fix custom toString() implementations for QList comparison
d25589e052 mistakenly changed the code
to use toString() from the QTest namespace. Call toString()
unqualified and move the compareSequence() helper out of the
internal namespace.

Fixes: QTBUG-89737
Pick-to: 6.0
Change-Id: I8452a0aead7771ad13a5b95438b54e202ccce76b
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-01-07 15:13:44 +01:00
Allan Sandfeld Jensen
4c6c094895 Windows QPA: Lookup DISPLAYCONFIG data for monitors
Gives more accurate orientation and refresh-rate.

Change-Id: I90b0b7563efc35c9bace07ccb3996350a957e8e5
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2021-01-07 12:00:47 +01:00
Camille Viot
8fa91c75ad Clean up code that handle clipboard image conversion on Windows
This commit remove old legacy code that try to deal with clipboard
image conversion in the qwindowsmime class. It now uses
qbmphandler under the hood which is much more complete.
It also add a small fix for the conversion
of BI_RGB clipboard image with an explicit alpha layer (which Firefox
use on Windows).

Change-Id: Iae026378831799dc676e1aba7d5bd6a0d1c01e7f
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2021-01-06 21:53:44 +01:00
Tor Arne Vestbø
e7370d0583 Skip already closing widgets when checking whether application can quit
QApplication tries to close all windows on quit using closeAllWindows,
but closeAllWindows skips windows that are already closing. This can
happen when calling quit() from a close event for example.

QApplication then tries to verify that all windows have been closed,
and that logic should skip the same kind of windows as closeAllWindows
does.

The fact that these two logics diverge was identified earlier in
5af73cd9db, but aligning them required further work. As that
commit notes, the right fix to align them is building on top of
tryCloseAllWidgetWindows(), which already returns true/false based on
whether it could close all windows or not. But, unlike the existing
logic in QApplication::event(), it doesn't skip Popups or Dialogs,
so that discrepancy needs further research.

Pick-to: 6.0
Fixes: QTBUG-89580
Change-Id: I87bff56f2eb8a539f1c859c957f5f239dc1eb93d
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-01-06 16:59:11 +00:00
Ulf Hermann
c9a1102269 Make QString and QByteArray sequentially iterable
As lists of QStrings and QByteArrays are sequentially iterable the base
types should really also be.

The only problem is that they don't have methods to remove items from
the back or the front, but that is well within what we can support with
QSequentialIterable.

Change-Id: I2ab551e7b11a092aba363fb4012d131bbc4b11b4
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-01-06 17:15:03 +01:00
Kai Köhne
05146a77fc Doc: Improve QMap, QMultiMap description
Make it clear that the fast lookup is by key, not by value.
See also discussion in

https://forum.qt.io/topic/121907/misleading-documentation-of-qhash-qmap/

Pick-to: 5.15 6.0
Change-Id: I396297e0e4674e0a1f889f4138ab52ff224c0ee2
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: Samuel Gaist <samuel.gaist@idiap.ch>
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2021-01-06 17:00:42 +01:00
Laszlo Agocs
3ce5128d80 Fix missing repaints with QOpenGLWidget in a QDockWidget
When AA_ShareOpenGLContexts is not set, docking or undocking
will lead to changing the associated top-level window. This
leads to changing the OpenGL context, and tearing down and
then recreating all OpenGL resources (assuming a well written
application). The problem is, there are no paint events after
the Show, meaning the user code's paintGL is often not invoked,
which leads to showing an empty QOpenGLWidget until something
else triggers a paint event. To remedy this, send a paint event
upon Show, which should be harmless enough, while fixing the
case of docking/undocking.

Pick-to: 6.0 5.15
Fixes: QTBUG-89812
Change-Id: I3c4560f8f069d86645a6314bf7ad1b4ee8e2c716
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2021-01-06 16:18:25 +01:00
Laszlo Agocs
f0d1a50333 rhi: vk: Prevent WAW hazard reported from sync validation with offscreen rt
...when a QVkRenderBuffer is used as depth-stencil (i.e. a "throwaway"
depth-stencil buffer that is a lazily allocated / transient VkImage
under the hood). Such a resource is not tracked by the
QRhiPassResourceTracker, so do an explicit barrier in beginPass
instead of having it generated by the tracker.

Fixes: QTBUG-89764
Change-Id: Ice794f44342175f712ea56f450270cbb8929f516
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2021-01-06 16:18:20 +01:00
Laszlo Agocs
5f8efb2597 rhi: gl: Reset tracked state upon a buffer update or readback
...encountered in the command list.

Move all, previously local, tracking variables into a struct. This
allows creating helper functions to reduce error-prone repetition in the
executeCommandBuffer() function body.

The only real change in the patch is in the handling of
Command::BufferSubData and Command::GetBufferSubData: here, instead of
calling glBindBuffer directly, use a helper function that also resets
the relevant state tracking variables. A subsequent
Command::BindVertexBuffer or BindIndexBuffer will therefore correctly
rebind the appropriate buffers.

This is particularly relevant with certain command stream patterns
exercised by some Qt Quick 3D scenes:

- A View3D renders a mesh,
- another View3D has some 2D Qt Quick content, as well as a model with
  the same mesh.

When both View3Ds use the default Offscreen render mode, the resulting
command list consists of segments along the lines of:

1. prepare resources for first View3D

2. render content for first View3D - this binds the vertex and index
   buffers for the mesh (state is tracked; all 1-4 steps are within
   the same command list, processed by a single call to
   executeCommandBuffer())

3. prepare the content for the "inline" 2D Qt Quick scene - this may
   update vertex and index buffers, that may lead to adding
   BufferSubData commands to the list (tracked state (last
   vertex/index buffer) may need invalidation/updating - and that's
   where our problem lies)

4. the second View3Ds 3D content is rendered: a model with the same
   mesh as the last (Quick)3D draw call, so same vertex and index
   buffers. If #3 did not invalidate and/or update the tracked state,
   the glBindBuffer calls are (incorrectly) skipped.

Fixes: QTBUG-89780
Pick-to: 6.0
Change-Id: Icc933252f3993b8727d192e7ba4aa0f842bab51e
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2021-01-06 16:18:15 +01:00
Andreas Buhr
6a664d0660 Fix segmentation fault in QObject::dumpObjectInfo
There was a check "if (cd && cd->signalVectorCount())" in the code
which was faulty because "signalVectorCount()" could return -1 to
indicate that no signalVector is available. This patch fixes
the problem.

Fixes: QTBUG-89846
Pick-to: 5.15
Change-Id: I12c512ff8d889ba2bd298789ab6081930f739089
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-01-06 16:17:47 +01:00
Kai Köhne
05ec5a47ab QLocale: Remove dead code
The code using it got removed in qttools commit 01da5d9a

Change-Id: I14d36ac939f2647139fcc42591a044a03e707553
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-01-06 16:17:47 +01:00
Joerg Bornemann
36b1e03ecd Remove superfluous OpenGL_GL_PREFERENCE assignment
We did set this variable, however after src/gui/configure.cmake
was loaded (it is early-loaded in src/CMakeLists.txt), meaning the
assignment had no effect.

Also, what this assignment tried to achieve is covered by our global
CMake policies now.

Pick-to: 6.0
Task-number: QTBUG-89754
Change-Id: Ie7aeee1505d112d799455b2915acbfa7e9a12a64
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2021-01-06 09:30:31 +01:00
Paul Wicking
32a46a1dcf Doc: Use correct include for QtFuture namespace
Pick-to: 6.0
Fixes: QTBUG-89766
Change-Id: I20c5d3c12490a5eed7bb4e267b2edb5d45dbaadf
Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
2021-01-06 08:02:06 +01:00
Craig Scott
ae91e3365b android: Generate deployment settings file with correct qml-import-paths
The qt6_android_generate_deployment_settings() command had been
creating deployment settings files with the wrong key name for qml
import paths. This resulted in the QT_QML_IMPORT_PATH target property
having no effect.

The QT_QML_IMPORT_PATH property can also potentially hold a list, not
just a single value. This change now handles the list case as well,
previously qt6_android_generate_deployment_settings() was assuming it
always held a single path if it was set.

Fixes: QTBUG-89628
Pick-to: 6.0
Change-Id: Ibdd74ec8d130f160433a60a14a0a9f496f496a1b
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-01-06 13:11:57 +11:00
Zhang Yu
22416ecaaf Fix QMultiHash::equal_range crashes
QMultiHash::equal_range crashes when called in a const member function.
The Data `d` is a NULL pointer when calling equal_range()
before inserting data into an empty QMultiHash.
Then calling`d->find` crashes.

Fixes: QTBUG-89687
Pick-to: 6.0
Change-Id: I10c3d196cbc72aed8c8c922ef16534bba51037b7
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-01-06 09:07:10 +08:00
Alex Trotsenko
13f9e2857b Remove superfluous call in QProcessPrivate::_q_startupNotification
There is no need to disable startupSocketNotifier because the call to
QProcessPrivate::processStarted() will do that.

Change-Id: I20b816533d9a5c4b9bf57135d26166c961a07d07
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
2021-01-05 21:15:37 +02:00
Andy Shaw
9d36ee1904 TableView: Trigger the resizing of editors resizing a row/column
If there is an editor in the table then this needs to be updated as
the resize happens, otherwise it will not adapt to the new size
correctly and can appear drawn over other cells.

Fixes: QTBUG-85484
Pick-to: 5.15 6.0
Change-Id: I918c37f1ee1b0614c03c6b38f95f0f8b35a571f2
Reviewed-by: Samuel Gaist <samuel.gaist@idiap.ch>
2021-01-05 18:31:54 +00:00
David Faure
0cbbba2aa5 Update shared-mime-info to the 2.1 release, adjust implementation
The spec hasn't changed, but I made the same mistake in xdgmime
(the reference implementation) and in Qt: when multiple globs match,
and the result from magic sniffing is unrelated to any of those globs,
then I used the magic result, but that's wrong, globs have priority
and one of them should be picked up.

This is now fixed in xdgmime
(https://gitlab.freedesktop.org/xdg/xdgmime/-/merge_requests/3)
and in the expected results in shared-mime-info
(https://gitlab.freedesktop.org/xdg/shared-mime-info/-/merge_requests/99)
which this commit is also tested against.

This change also optimizes QMimeBinaryProvider::addFileNameMatches
to have the same logic as xdgmime for glob matching:
literals > extensions > other globs
As soon as one category matches, we can stop there.
This makes no difference in the overall results, in practice.

The user bug report (against the Qt implementation, actually)
is https://gitlab.freedesktop.org/xdg/shared-mime-info/-/issues/138
as well as https://bugs.kde.org/show_bug.cgi?id=411718

Pick-to: 6.0 5.15
Change-Id: Ia0a34080427daff43c732609443ee6df8f41447c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-01-05 18:31:54 +00:00
Liang Qi
e688b99995 QInputControl: accept surrogate category character
See also https://unicodebook.readthedocs.io/unicode_encodings.html#utf-16-surrogate-pairs .

Fixes: QTBUG-89184
Pick-to: 6.0 5.15
Change-Id: I04eff7f42f0030346603a7b31e4ac854a477030c
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-01-05 16:24:29 +01:00
Edward Welbourne
6974737695 Change QLineF::setLength() to work whenever length() is non-zero
Previously it only worked when isNull() was false, which is true for
very short lines, even though length() may be non-zero.

[ChangeLog][QtCore][QLineF] QLineF::setLength() will now set the
length if the line's length() is non-zero. Previously, it was
documented to only set the length if isNull() was false; this is a
fuzzy check, so isNull() could be true for a line with non-zero
length().

Fixes: QTBUG-89569
Pick-to: 6.0 5.15
Change-Id: I803e622ad09c85815dde25df8dd3ba6dfcba0714
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-01-05 12:43:09 +01:00
Timur Pocheptsov
f319974488 QSslCertificate(OpenSSL) - harden protection against nullpointers
An invalid (as input data) certificate may have non-zero number of invalid (nullptr)
extensions (if OpenSSL failed to parse them, for example).

Fixes: QTBUG-89547
Pick-to: 6.0 5.15 5.12
Change-Id: I4b93ac9f482f850f02d01b0aea10560dc11b688d
Reviewed-by: Lars Schmertmann <lars.schmertmann@governikus.de>
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2021-01-05 07:49:59 +01:00
Christian Ehrlicher
3977357120 QTreeWidgetItem: fix documentation error for childIndicatorPolicy()
The default value is 'DontShowIndicatorWhenChildless' and not
'ShowForChildren'.

Fixes: QTBUG-83648
Pick-to: 6.0
Pick-to: 5.15
Change-Id: I5d4dd9f3f58bcac09ed38d8ae451e3b771695ce7
Reviewed-by: Samuel Gaist <samuel.gaist@idiap.ch>
2021-01-05 07:49:50 +01:00
Christian Ehrlicher
672d2ea8f4 QAbstractItemView: fix selectionCommand() with no event
QAbstractItemView::selectionCommand() returned the wrong SelectionFlags
when no event is given since c4366ff018.
Therefore re-add the call to QGuiApplication::keyboardModifiers() when
no event is given and add a unittest for them so it's not removed again.

Fixes: QTBUG-89711
Change-Id: I107357df08c4ff1b1a14d49523401c5e7b428f56
Pick-to: 6.0
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-01-05 07:49:21 +01:00
Laszlo Agocs
587fed817a Add a platform capability indicating support for QRhi-based rendering
This attempts to reconcile a minor difference between Qt 5 and Qt 6:

Running Qt Quick applications with a platform plugin such as vnc,
led to an automatic fallback to the 'software' backend based on
the OpenGL capability reported from the platform plugin. In Qt 6.0
this logic is gone from Qt Quick, because we do not have, and wish
not to have, individual flags for each and every 3D API on this
level.

Therefore in Qt 6.0 a Qt Quick application running with the vnc
(or linuxfb, or minimal) platform needs an explicit selection of
the software backend via QT_QUICK_BACKEND or
QQuickWindow::setGraphicsApi().

To keep migration for users of such platform plugins easier, we
can still reintroduce a Qt 5-like logic: by having a high level
Is-QRhi-Supported type of flag, we can make Qt Quick query that,
and trigger the fallback to the software backend when it is
reported as false by the platform plugin. As this is the minority
case and a conscious choice by platform plugins, the flag can be
opt-out (i.e. true by the default hasCapability implementation).

When it comes to the existing OpenGL flag, that needs to stay for
compatibility reasons, but it is worth noting that the new flag
semantically falls in the exact same category: it does not indicate
things will really work at run time, but rather serves as an opt-out,
"do not even try" type of declaration the platform plugin can make,
which then allows modules like Qt Quick to make early, upfront
decisions about which rendering paths/backends to take.

Change-Id: I8d6fddeb82ca6eece7b7abc1a5b64ebe6d8af29d
Task-number: QTBUG-89561
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2021-01-04 17:30:43 +01:00
Laszlo Agocs
f6cb24f4c0 Handle maxImageCount 0 in QVulkanWindow
Take the logic we use in QRhi's Vulkan backend.

Pick-to: 6.0 5.15
Fixes: QTBUG-85791
Change-Id: Ifdc2b3d351af71fbc86e20abcede902303e41fc4
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2021-01-04 17:30:30 +01:00
Giuseppe D'Angelo
d896f78999 qt_qFindChild(ren)_helper: remove pointless checks
The only callers are QObject::findChild(ren), and they always
pass valid pointers, so there's no point of checking them.

Change-Id: I789abc3a53db523acf06c1a8a340094a71c79e41
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-01-04 15:06:30 +01:00
Laszlo Agocs
f6b64c3c62 State in docs that the BufferQueueingOpenGL cap is deprecated
There are no queries for this (somewhat dubious) flag in practice.
Its usage in Qt Quick is gone since 2014 after
0129887195c7255f41515f72ceb213a38b98f72d.

Change-Id: I4fd9cef2705ce13b79ff1dc40a6eda7ce2035e30
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2021-01-04 11:49:54 +01:00
Laszlo Agocs
8bd58a97d7 rhi: vk: Fix DS WAW hazard reported from sync validation
Running with synchronization validation (SDK 1.2.154) we get:

Hazard WRITE_AFTER_WRITE vs. layout transition in subpass 0 for attachment 1
aspect depth during load with loadOp VK_ATTACHMENT_LOAD_OP_CLEAR

Attempt to fix this with an appropriate subpass dependency.

Fixes: QTBUG-89760
Pick-to: 6.0
Change-Id: I67e15a09aab564f63aab646761ccdb1f8b82111d
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2021-01-04 11:42:21 +01:00
Laszlo Agocs
97da4519ba Add a dedicated QWindow surface type for D3D
Even though there is no D3D-specific logic in the windows platform
plugin, meaning a QWindow with either OpenGLSurface or VulkanSurface
(or anything really) is DXGI/D3D-compatible, it now looks like it is
beneficial, and more future proof, if there is a dedicated surface
type.

As the linked report shows, there are OpenGL-specific workarounds
accumulated in the platform plugin, while not being clear if these
are relevant to non-OpenGL content, or if they are relevant at all
still. (and some of these can be difficult/impossible to retest and
verify in practice)

When D3D-based windows use the same surface type, all these are
active for those windows as well, while Vulkan-based windows have
their own type and so some of these old workarounds are not active
for those. To reduce confusion, having a dedicated surface type for
D3D as well allows the logic to skip the old OpenGL workarounds,
giving us (and users) a more clear overall behavior when it comes
to OpenGL vs. Vulkan vs. D3D.

The change is compatible with any existing code in other modules
because any code that uses OpenGLSurface for D3D will continue to
work, using the new type can be introduced incrementally.

Task-number: QTBUG-89715
Change-Id: Ieba86a580bf5a3636730952184dc3a3ab7669b26
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-01-04 10:37:11 +00:00
Li Xinwei
173f163ad2 CMake: Fix error and print summary for standalone building sqldrivers
qt_plugins target is needed by qt_internal_add_plugin function, but when
standalone building sqldrivers, this target does not exist, which causes
configure error. So we need to add this target manually.

Fixes: QTBUG-89714
Pick-to: 6.0
Change-Id: Ia7d613faabb82399c2f3e5771aab24302b3c8f56
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-01-04 17:58:54 +08:00
Tor Arne Vestbø
c30d05e794 macOS: Simplify and fix issues with QMenuPrivate::moveWidgetToPlatformItem
View embedding when QWidget is involved is a bit finicky. This change
breaks down the steps needed to embed it into an NSMenu item, and
simplifies the process by not relying on a container widget.

The main issue is that QCocoaWindow::recreateWindowIfNeeded() will
potentially create an NSWindow for the embedded view, resulting in
a stray view. To prevent this we set the Qt::SubWindow flag on the
window, but QWidget tends to reset this flag when the widget doesn't
have a parent, so we need to be careful about which order we do the
setup.

Pick-to: 6.0 5.15
Change-Id: I505f7c0a2d8e4350511fdb01a5e9b9c623a40a41
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2021-01-04 10:47:45 +01:00
Tor Arne Vestbø
74559dccc8 Update QPalette() documentation to not mention the application palette
It's an implementation detail that the default constructed palette
happens to use the d-pointer of the application palette, and as a
result has the same colors as the application palette if requested.

The palette has an empty resolve mask, and hence all the colors in
the palette are undefined. Users should not rely on QPalette() to
represent the application palette when for example overriding a
parent palette.

Task-number: QTBUG-85226
Pick-to: 6.0 5.15
Change-Id: Ia6747887eef6e9a5f21b2002066608c433260de2
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-01-04 10:46:26 +01:00
Friedemann Kleint
179696fcb8 uic: Do not generate QComboBox::AdjustToMinimumContentsLength into code
The enumeration value was removed in Qt 6 by
1a342b2db1. Ignore it.

Add a check to helper function checkProperty() and move
the code from a5e2f2ddad there
as well.

Pick-to: 6.0
Task-number: QTBUG-89093
Fixes: QTBUG-89700
Change-Id: I0890be8fff155d7342e2386b7f6b0783a5f3a192
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2021-01-04 10:25:41 +01:00
Giuseppe D'Angelo
1dc4e5d3eb XmlStringRef: remove operator<=>
It's defined in terms of operator<=> on QStringView, which does
not exist, causing a compile error.

Change-Id: I64fc60da4e52c7e53be7849d9b42952be139a816
Fixes: QTBUG-89729
Pick-to: 6.0
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-01-04 10:02:44 +01:00
Giuseppe D'Angelo
1f4434a8e2 Upgrade md4c to 0.4.7
Change-Id: I9400c2df13c30fb0bc14728a0c44851c2d1e9079
Pick-to: 6.0 5.15
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2021-01-04 10:02:31 +01:00
Craig Scott
1b4d70676c CMake: Prefer canonical CMAKE_ANDROID_NDK var when writing deploy file
CMAKE_ANDROID_NDK is an official variable provided by CMake. The
ANDROID_NDK variable will be set by the NDK toolchain file, but we
don't need to rely on that (the user could theoretically not be using
the NDK's toolchain file). Using the CMake-provided variable means
we don't have to explain the source of the variable in documentation
for the qt6_android_generate_deployment_settings() command. We should
prefer to use things provided by CMake already where it makes sense
and this seems to be one such case.

Task-number: QTBUG-89651
Task-number: QTBUG-88839
Pick-to: 6.0
Change-Id: Ieda54de8f5c65c36da6bb55c87a8b8fdd1d5cd7b
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-01-04 14:08:40 +11:00
Alex Trotsenko
ef968963c0 QProcess/Win: do not duplicate handles for pipelined processes
Instead, make them inheritable at creation time.

Change-Id: I1aabc203851b2873acc772ba20258238cbe01d59
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
2021-01-03 21:45:47 +02:00
Gatis Paeglis
2dc15e1f25 xcb: document QXcbEventQueue::PeekOption enum
And renamed PeekRemove* to PeekConsumed to document
better that nodes are not removed when peeking.

Change-Id: I7349f57fcfc3287d1a1309a31ee7f481f8d18755
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-01-01 17:58:20 +01:00
Christian Ehrlicher
f0818f6ed8 QAbstractButton: don't access nullptr in queryButtonList()
When a button has no parent, QAbstractButtonPrivate::queryButtonList()
unconditionally accessed parent which results in a nullptr access. Did
not crash because qt_qFindChildren_helper checks for nullptr and
therefore could only be found with a sanitizer.

Fixes: QTBUG-83865
Change-Id: I591e546e96acba50770935b9c3baaf08b09b833d
Pick-to: 6.0
Reviewed-by: Samuel Gaist <samuel.gaist@idiap.ch>
2021-01-01 16:44:09 +01:00
Alex Trotsenko
e334d6f9a7 QProcess: allow pipelining for detached processes
[ChangeLog][QtCore][QProcess] Added support for
setStandardOutputProcess() with startDetached().

Change-Id: I61278cdb7084127f583c8c017688da392017b44c
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
2020-12-31 12:16:46 +00:00
Alex Trotsenko
04c34eb799 QProcess: allow merged channels forwarding for detached processes
[ChangeLog][QtCore][QProcess] Added support for QProcess::MergedChannels
mode with startDetached().

Change-Id: I953ad2063322015332269522a297f8e2842e438c
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
2020-12-31 12:16:38 +00:00
Alex Trotsenko
1fb9c5348e QProcess: consolidate channel management
We have the same channel forwarding, redirecting, and merging rules for
all platforms. This makes it possible to introduce the openChannels()
function, which consolidates the logic and performs high-level general
processing of the channels configuration properties.

Change-Id: Id3574fc42a56829328369b6a1a6ec9c95fce8eca
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
2020-12-31 09:34:54 +02:00
Alex Trotsenko
8be9fb66f7 QProcess/Win: do not needlessly duplicate std handles in startProcess()
The idea was to create descriptors with HANDLE_FLAG_INHERIT. However,
this can be assumed to be already the case for std descriptors, and if
it isn't, the user messed up, and we shouldn't try to work around it.

This is consistent with what we already do in startDetached().

Change-Id: I8135c5e612c361e77a0442541f2d50cfbb5b4601
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
2020-12-30 23:40:53 +02:00
Alex Trotsenko
efb3d87700 QProcess/Win: handle more errors in openChannel()
In theory, low-level functions like CreateNamedPipe() or
DuplicateHandle() could suddenly fail. Thus, in order to ensure the
correct configuration of the channels, we must check for these
errors.

Pick-to: 6.0 5.15
Change-Id: I3d6291043e5e394ec5c5a7d85dfb7b09bfdcd172
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-12-30 21:43:16 +02:00
Matthias Möller
6e9125608f fix potential mem leak on connection lost
The PostgreSQL driver can change it's connection status
after the first established connection.
In this case, the function "isOpen()" returns false
and the "close()" function would not free all resources.
With this fix, the "close()" function
always frees any allocated resource
independent of the connection status.

Fixes: QTBUG-88984
Pick-to: 6.0 5.15 5.12
Change-Id: I7c9add6a183bf46a8573952ab39f8cb1f728c00c
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
2020-12-30 16:04:55 +01:00
Jonas Karlsson
a0aafefd00 Add QRhiTextureSubresourceUploadDescription QByteArray constructor
Change-Id: I1be4ef1a15c4049f19d0401d6a1a62b3117180a0
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2020-12-29 09:59:09 +01:00
Jonas Karlsson
162a859045 Add getDataView() method to QTextureFileData
This method will return a QByteArrayView of the data range corresponding
to the level. This avoids a leaky abstraction by moving the needed data
pointer arithmetic from the caller to the method. It will also make it
easier adding cubemap support in the future.

Change-Id: I2415bd88365d8d69ba14aefc77f5f1117f9e0033
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2020-12-29 09:59:06 +01:00
Lars Schmertmann
89b2b60e63 Add version() to QOperatingSystemVersion
Change-Id: I6c7f0616d52b0d118ffd8c031f3f51212b8ed821
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-12-28 17:33:20 +00:00
Laszlo Agocs
d2b0856f59 eglfs: Enable building the fbdev-based Mali backend
The configure tests are all in place for CMake as well, and this one
has no special library depdendencies. Generate the CMakeLists and
remove the special case.

Change-Id: I55817045f9e259515fb3aad33d1446d9413111d9
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-12-28 16:46:23 +01:00
Ahmad Samir
824c726340 QRegularExpression: mention raw string literal in the docs
Raw string literals (since C++11 according to [1]), make writing/reading
regex patterns easier, since one can just use e.g. "\w\d" without having
to escape those backslashes e.g. "\\w\\d"; this is especially useful with
longer/more complex regex patterns.

[1] https://en.cppreference.com/w/cpp/language/string_literal

Pick-to: 5.15 6.0
Change-Id: I119f9566d27222b915af931ee7e13e064baede61
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: André Hartmann <aha_1980@gmx.de>
2020-12-28 14:35:39 +00:00
Paul Olav Tvete
24cf218b39 Handle XCB_INPUT_DEVICE_TYPE_MASTER_POINTER properly
Make sure we use the new QXcbScrollingDevice class for the "core
pointer" as well.

Change-Id: I97575e8125cbb2aa280662aa675e61021c21ea59
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-12-25 09:07:18 +01:00
Lu Zhen
9a237257c4 Adjust the format of code blocks in handleScreenChange function
Change-Id: I5da777e2196c005d6d5402c254a9452c3a888036
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2020-12-25 10:40:29 +08:00
Andreas Buhr
741862875c Add test creating QDateTime in double-DST gap in 1947 Germany
In 1947, Germany had not only a summer time but also a
"Hochsommerzeit", a high summer time. This patch adds a test
creating a QDateTime in the time gap at the beginning of this
Hochsommerzeit on May 11, 1947.

Pick-to: 6.0
Change-Id: Ib81a23914965f092c3e3195e4c7258e5a4e0b30e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-12-24 19:41:48 +01:00
Christian Ehrlicher
41e665a452 QStylesheetStyle: fix push button label alignment
Due to a copy'n'paste error in 01ec11507d
the valign was not properly determined for text-align bottom.

Fixes: QTBUG-89366
Change-Id: I081e1b24bba0edd9dd3754599a111c1658b18746
Pick-to: 6.0
Reviewed-by: Liang Qi <liang.qi@qt.io>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2020-12-24 12:48:28 +01:00
Sona Kurazyan
f1f4fd16fd Document that QtConcurrent::run doesn't support overloaded functions
After improving QtConcurrent::run() to use parameter packs for the
arguments (see c977e74afd), calling
overloaded functions is ambiguous. Updated the porting guide and the
documentation to mention this and describe possible workarounds.

Task-number: QTBUG-89648
Pick-to: 6.0
Change-Id: I4c1f996ae67bce8c13cc1f99f54240295db6ae1d
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2020-12-23 18:34:21 +01:00
Christian Ehrlicher
f3747c21d3 QStyleOption: avoid code duplication
Use delegate constructors to avoid code duplication

Change-Id: I5c7d3764966ec07d1e3d175ccb075c64408d2338
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2020-12-23 17:08:05 +01:00
Paul Olav Tvete
c80d6473fb Fix out-of-bounds write
Change ac210c73e4 introduced the requirement that all input devices with
Scroll capability must have a QXcbScrollingDevicePrivate as their d_ptr.
However, this was not enforced, and would fail for the "Virtual core
pointer".

To fix this, always use qobject_cast to verify that the device is of the
correct type.

Change-Id: I4a6b1d4d79308eb04e9f52dda00294fffe377bdf
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-12-23 15:25:02 +01:00
Nico Vertriest
776e1f92c2 Doc: Fix broken link in stylesheet examples
Task-number: QTBUG-89211
Change-Id: Idde01e22dd57c37c78d8c86305d047562e5c1f64
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2020-12-23 07:32:04 +01:00
Christian Ehrlicher
6fbcfd9164 QListView: don't crash when an empty container is passed to itemsRect()
QIconModeViewBase::itemsRect() is crashing with Qt6 when an empty
container is passed.

Fixes: QTBUG-89434
Change-Id: I324f1a34b62e67c7bbd3fe33227f4174df7d3d37
Pick-to: 6.0
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2020-12-22 18:57:15 +01:00
Christian Ehrlicher
f8a175afba QPicture: Improve the documentation of Picture::play()
QPicture::play() does not save/restore the painting state when called
directly but this was not correctly stated in the documentation.
Therefore add a small note about this.

Fixes: QTBUG-83198
Change-Id: Ia820d32ccb4689d1e696fecffa9d6b5522e246b3
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2020-12-22 17:43:56 +01:00
David Skoland
27d96b4789 Replace QtTest headers with QTest
Complete search and replace of QtTest and QtTest/QtTest with QTest, as
QtTest includes the whole module. Replace all such instances with
correct header includes. See Jira task for more discussion.

Fixes: QTBUG-88831
Change-Id: I981cfae18a1cabcabcabee376016b086d9d01f44
Pick-to: 6.0
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-12-22 15:20:30 +01:00
Morten Johan Sørvig
093e0d452f macos: Document that Drawer is obsolete
This feature is not much used on modern macOS, and
Qt 5 has never supported it.

Pick-to: 5.15 6.0
Change-Id: I9de195aaf7df954b63f0f816e93c91e870ef5852
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2020-12-21 22:48:44 +00:00
Morten Johan Sørvig
b3b95670b2 Call QEventDispatcher::startingUp() on thread start
...instead of during createEventDispatcher().

This way, startingUp() will be called [on the thread
being started] also for custom event dispatchers installed
with QThread::setEventDispatcher().

This prevents crashes when installing event dispatches which
expects that startingUp() will be called.

Crash reproducible with test case from QTBUG-51961.

Change-Id: I71bd696539689d928a61ff9b47d05297cf803b2f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-12-21 22:48:29 +00:00
Morten Johan Sørvig
cd6d805d93 offscreen: always create a valid QPlatformIntegration
Commit f4a66e5c accidentally made it so that the offscreen
plugin would produce a null QPlatformIntegration on
X11 if QT_QPA_OFFSCREEN_NO_GLX is set.

Restore previous logic where the generic QOffscreenIntegration
is created if the X11 code path did not create an object.

Change-Id: Ic71fb04bbd824f4121480dbaf8fa0571ebb39f42
Pick-to: 5.15
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2020-12-21 23:48:06 +01:00
Morten Johan Sørvig
79cb003020 Doc: Don’t use \note when documenting enum values
qdoc does not render these nicely when outputting html:
the enum value table table is split in two around the
\note.

Pick-to: 5.15
Change-Id: Ic2b8c5a247d1100a766e4ae10161aa6ee7644514
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2020-12-21 22:47:53 +00:00
Friedemann Kleint
4a6a45ac38 sqlite: Replace NULL by nullptr
Change-Id: I8e845ae093a68d2d7ecf0e358a2316a54d0f2144
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-12-21 16:21:18 +01:00
Friedemann Kleint
7f02071503 sqlite: Fix MSVC integer conversion warnings
Change-Id: I58ab6a8d7787abce5b0f73562eb53f40e39c8186
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-12-21 16:21:14 +01:00
Volker Hilsheimer
2b9a9cfddd Fix qdoc warning, reference parameter correctly
Change-Id: Icb3d0aa005752f291f81a47a15f7157009fd09f2
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2020-12-21 15:40:50 +01:00
Alexey Edelev
56bdef9437 CMake: Use host variables instead of hardcoded directories
'QT_HOST_PATH' indicates that we use crosscompilation toolchain
to build project. In this case 'Qt6Config.cmake' loads
'Qt6HostInfoConfig.cmake' from host QT_HOST_PATH, that defines
correct paths to host tools.

Replace hardcoded paths for host tools by paths recorded
in Qt6HostInfoConfig.cmake.

Correct conditions for QT_HOST_PATH, evaluate it explicitly as
string, but not as boolean expression.

Fixes: QTBUG-86557
Pick-to: 6.0
Change-Id: Ib52bbd32478051d019a932dcb1f735e2d4aacfbf
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-12-21 13:41:13 +01:00
Craig Scott
50f939bfe8 CMake: Don't rely on versionless commands or targets existing
Commands like qt6_finalize_executable() should not rely on versionless
commands or targets being available, since they can be disabled by a
build option.

Pick-to: 6.0
Change-Id: I6a9ab6a9b6a6b731590e5b8c43f73b518ed38e81
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-12-21 23:23:16 +11:00
Joerg Bornemann
ed432b070a CMake: Do not link "prefixed" openssl libs on Android
This reverts e52239f525, because we do not
have multi-ABI builds currently, and we must link against what the
WrapOpenSSL package provides.

Fixes: QTBUG-89473
Change-Id: I4f38a2c41e90ec8b602e28f8ca77f0ebd009639c
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-12-21 13:22:55 +01:00
Doris Verria
c6379e3499 Make QPushButton on macOS use QFocusFrame to fix alignment problems
Alignment problems occur for pushbuttons because they appear smaller then their
actual widget geometry, which is used for their alignment in layouts. To fix,
shift the pushbutton's rect to the left, adjust SE_PushButtonLayoutItem
accordingly and use QFocusFrame to render the focus frame ring outside
the widget's paintable area.

Fixes: QTBUG-89133
Fixes: QTBUG-81452
Pick-to: 5.15 6.0
Change-Id: Iee885a4fb3674d966e5ff3b5c04a0845521b2d72
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-12-21 12:33:15 +01:00
Michal Klocek
b770b7517d Fix crash on reallocateAndGrow
After 6be398 few tests fail/crash with qtcharts.
Fix issue on reallocateAndGraw and avoid accessing
flags on invalid header.

Data::allocate can return invalid header and dataptr,
which takes place if capacity is 0. In code before 6be398
clone method checks if header is not null before resetting
flags. However after b76fbb4 resetting flags is no longer
needed since it is done in allocateGrow.

Task-number: QTBUG-89092
Pick-to: 6.0
Change-Id: I2fde781dad7a0694a5f17ab716f647c2e35f4ff0
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2020-12-21 10:35:16 +00:00
Andreas Buhr
855a0433a5 Add some comments to clarify meaning of observers in property system
It took me quite a while to figure out that two objects with
a similar type and a similar name which occur side by side have
a quite different meaning. Add a comment for the next one.

Change-Id: Idf4d63d8ed09ead2c3d82a798e6d7476024209bf
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-12-21 10:21:10 +01:00
Piotr Mikolajczyk
096b4590d5 Android: KEYCODE_MEDIA_PLAY_PAUSE translated right
KEYCODE_MEDIA_PLAY_PAUSE was incorrectly translated to Qt.Key_MediaPlay.
This patch changes it to Qt.Key_MediaTogglePlayPause.

Fixes: QTBUG-66448
Pick-to: 5.15 5.12 6.0
Change-Id: Icd2747857bc479228bfdffcd8ab8fdef7b79e918
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
2020-12-21 10:21:10 +01:00
Alex Trotsenko
c773fd297a QProcess/Unix: speed up initialization of write notifier
By using new QSocketNotifier API, we can avoid unnecessarily enabling
the notifier right before turning it off again.

Change-Id: Ie0dea00251e9885653677c495dfc5abaaa4db1c7
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
2020-12-18 17:06:38 +02:00
Igor Kushnir
f2d22d5a51 xcb: fix thread synchronization in QXcbEventQueue::waitForNewEvents() again
This patch amends a41701904e

If peeking into the event queue looking for a clipboard event fails,
QXcbClipboard::waitForClipboardEvent() calls queue->peek for the second
time to "process other clipboard events, since someone is probably
requesting data from us". QXcbEventQueue::peek() in turn calls
QXcbEventQueue::flushBufferedEvents(). This second flushing can acquire
a waited-for clipboard event. The issue was that the code in
waitForNewEvents() ignored this possibility and assumed that there were
no clipboard events before or at its current m_flushedTail. If there
were no more events on the X11 connection after tailBeforeFlush,
the waitForNewEvents() in waitForClipboardEvent() blocked execution
for 5 seconds and eventually timed out.

The fix is to remember QXcbEventQueue::m_flushedTail just after looking
for and not finding a clipboard event in the queue. And then wait for
more events via QWaitCondition in waitForNewEvents() only if there were
no more events after the remembered m_flushedTail.

Fixes: QTBUG-75319
Pick-to: 5.15
Pick-to: 5.12
Change-Id: I4919c5b9b9227b3a8a29a11e7094f97960b3a121
Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io>
2020-12-18 16:06:38 +01:00
Fabian Kosmale
c88905f0a9 Disallow construction of QPropertyBinding from a property
This would steal an existing binding from a property, which is most
likely not the intended action.
Alternatively, we could make it equivalent to
Qt::makePropertyBinding(foo), but that conflates properties with
bindings to it. On the other hand, this would avoid a potentially
source-breaking change.

[ChangeLog][Potentially Source Breaking Change] It was possible to
create a QPropertyBinding from a property; this would steal any set
binding from the property or create an invalid binding if none was set.
Use makePropertyBinding if you want to to create a binding which depends
on the property's value, or takeBinding if you want to repurpose the
property's binding.

Fixes: QTBUG-89507
Pick-to: 6.0
Change-Id: Icd2d3b9261b60f36948f2cea9c33ddbea36efbc1
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-12-18 13:10:46 +01:00
Fabian Kosmale
10bf3ae90c QProperty add markdirty
This adds functionality for marking properties (QProperty and related
classes) manually as dirty. This facilliates the integration of bindable
properties with non-binable properties and makes it possible for
bindable properties to change due to external events.

Fixes: QTBUG-89167
Change-Id: I256cf154d914149dacb6cadaba92b13c88c9d027
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2020-12-18 13:10:46 +01:00
Piotr Mikolajczyk
fe51137f85 Android: Fix for accessibility potential crash
When accessibility was not active it was possible to force its
update, causing a null pointer exception in java.

Pick-to: 6.0 5.15
Change-Id: I60f65612d6e9f712ba3c591ffcc6803f06f09efb
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2020-12-18 07:51:40 +01:00
Alex Trotsenko
7a4e686240 QSocketNotifier: hone setSocket() API
Remove a second argument to the setSocket(qintptr, bool) function as
it makes the API harder to understand.

Change-Id: Ib1852a4e9d96adde35bfbf0fe03b386d9ded395a
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
2020-12-17 21:33:17 +02:00
Tor Arne Vestbø
1649137b93 Clarify QWindowPrivate::maybeQuitOnLastWindowClosed
We only need to check QGuiApplication::quitOnLastWindowClosed() at
the point where we've actually concluded that the last window was
closed.

Checking for !q->parent() was redundant, as we were already
exiting early when !q->isTopLevel().

Pick-to: 6.0 5.15
Change-Id: I934e186d707361b31d19692c04d2e17b7ba0f49e
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2020-12-17 20:03:01 +01:00
Alex Trotsenko
9dbee41272 QProcess/Unix: do not create pipes for forwarded channels
The child process inherits a standard handle of the main process in
such cases:

  stdin  - inputChannelMode == QProcess::ForwardedInputChannel,
  stdout - processChannelMode == QProcess::ForwardedChannels ||
           processChannelMode == QProcess::ForwardedOutputChannel,
  stderr - processChannelMode == QProcess::ForwardedChannels ||
           processChannelMode == QProcess::ForwardedErrorChannel ||
           processChannelMode == QProcess::MergedChannels

For these combinations we should not create pipes and notifiers as
they would not be used.

Change-Id: I8e3836e4d840a40b338c85c54645539ebcaab3f6
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
2020-12-17 20:48:22 +02:00
Fabian Kosmale
1461df2ce4 Q_OBJECT_BINDABLE_PROPERTY: Silence warnings properly
For some reason, clang (and thus Qt Creator's code model) did still warn
about the offsetof usage. Moving the warning pragmas one layer higher
appears to fix the issue.

Change-Id: I1ee1cfd690fdcce9105c65e508203a722fe63151
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2020-12-17 16:38:38 +01:00
Joerg Bornemann
1ec4a7eddc CMake: Fix 'static' conditions
The pro2cmake script doesn't handle static scopes correctly, and the
generated "CONDITION static" must read "CONDITION NOT
QT_BUILD_SHARED_LIBS".

Change-Id: Ic5a5763e9fd5f5d04fb4c12227cbe85fac17b826
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-12-17 14:17:35 +01:00
Bartlomiej Moskal
2eb77139a2 Android: Pass pending state to ResumePauseListener
It can happen that updateApplicationState() is called before
m_androidPlatformIntegration is set. In such case, new applicationState
will be remembered and propagated later.

Before this change, pending application state was passed only to
QWindowSystemInterface.

ResumePauseListeners that are subscribed for changes to
ApplicationActive/ApplicationInactive state also should be informed
about new application state.

Fixes: QTBUG-84737
Pick-to: 6.0 5.15
Change-Id: I67e79860b340ee5de2d13d148a222e9f1c942b93
Reviewed-by: Rami Potinkara <rami.potinkara@qt.io>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2020-12-17 12:47:46 +00:00
Timur Pocheptsov
3bc398f766 QSslCertificate::operator == - cleanup error queue
Another case when an OpenSSL's call can dump some errors into the shared
error queue discovered. An invalid certificate with non-null X509 * may
result in several errors appended to the queue.

Pick-to: 6.0 5.15
Change-Id: I1278b371bd1edf2d656760c371bfb6da5dcab6ec
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-12-17 13:05:20 +01:00
Ivan Solovev
f0668433c4 Bindable property with initialization
Implement Q_OBJECT_BINDABLE_PROPERTY_WITH_ARGS and
Q_OBJECT_COMPAT_PROPERTY_WITH_ARGS macros.
They allow to directly initialize the property member.

Task-number: QTBUG-85520
Change-Id: I76541d6785bbbf27976b9f0b865fb45be1e9beee
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-12-17 12:41:13 +01:00
Ole-Morten Duesund
8183086513 Add sections about std containers and algorithms
Add section comparing Qt containers and std containers.

Add snippets showing use of std algorithms with Qt containers.

Task-number: QTBUG-86584
Pick-to: 6.0
Change-Id: I1133a5214a5acd086c37658ca11ab205a19a489b
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2020-12-17 09:57:53 +01:00
Laszlo Agocs
796de4f066 Prevent copy in texture upload with invalid input
Skip the memcpy when src is null.

Also silences a Codechecker warning.

Pick-to: 6.0
Change-Id: I5042d725000cb6dff6864408fa9ed9e0ca35145a
Reviewed-by: Christian Strømme <christian.stromme@qt.io>
2020-12-16 18:18:19 +01:00
Laszlo Agocs
494da40f29 Fix typo in QtOpenGL module docs
Fixes: QTBUG-89493
Pick-to: 6.0
Change-Id: I92255da2f68ec8dc0503654787e7861abe431504
Reviewed-by: Christian Strømme <christian.stromme@qt.io>
2020-12-16 18:18:19 +01:00
Mårten Nordheim
3eb35d3241 QSslSocket_schannel: Don't compare against undefined value
Something defined is always greater than undefined

Pick-to: 6.0
Fixes: QTBUG-89530
Change-Id: I7633dd4233f7b13c3c5be17352841ec873531ef9
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2020-12-16 14:54:17 +01:00
Mårten Nordheim
0ca4635832 QCache: fix updating entries breaking the internal chain
After f08492c6fd was
merged this bug would manifest as an entry appearing twice
in the chain when a updating an existing entry (insert with
an existing key). This could sometimes result in crashes later
as the list filled up and the list was used in trim() to remove
various entries.

Fixes: QTBUG-89176
Pick-to: 6.0
Change-Id: Ide80160fb4317dc0aefe79eec5dce7ec6813e790
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-12-16 14:54:17 +01:00
Shawn Rutledge
ac210c73e4 xcb: report wheel events from the correct device instance
Until now, all wheel events came from one "core pointer".  It's useful
in Qt Quick to tell the devices apart, because some support smooth scrolling
and some don't.

Also remove the QHash storing legacy ScrollingDevice structs, and use
a subclass of QPointingDevicePrivate instead.

Task-number: QTBUG-46412
Task-number: QTBUG-72167
Task-number: QTBUG-69433
Change-Id: Ie6a3d8dd494f981e8706b9a66a1021dfb51baec4
Reviewed-by: Liang Qi <liang.qi@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-12-15 19:03:24 +01:00
Ivan Solovev
50e1976437 QProperty docs: update macro name
Use Q_OBJECT_BINDABLE_PROPERTY instead of non-existing ones

Task-number: QTBUG-85520
Pick-to: 6.0
Change-Id: I47e3ff150f54176b42a478fd3ff639754d90e70a
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-12-15 15:54:46 +01:00
Ivan Solovev
13e2161b72 QString: update documentation
The QString documentation is aligned with QList regarding common
wording and ideas:
- Extend general class description
- Revise description of several methods
- Fix examples to use qsizetype instead of int
- Wrap descriptions at 80 characters

Pick-to: 6.0
Task-number: QTBUG-87962
Change-Id: I7d5a7e829ce8b98a0a1a7fae6b7ae0dec4effbae
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2020-12-15 15:54:46 +01:00
Li Xinwei
21e4e85a57 CMake: Fix compile warnings when MSVC and -DFEATURE_static_runtime=ON
When using MSVC compiler and -DFEATURE_static_runtime=ON, qrc_foo.cpp
and qtentrypoint_win.cpp are still compiled with '-MD' or '-MDd' flag,
which will cause following warnings and other possible problems:
warning LNK4098: defaultlib "MSVCRT" conflicts with use of other libs;
use /NODEFAULTLIB:library

Pick-to: 6.0
Change-Id: I6794930a64e9cff4dc1c9632fc3fc64227848af0
Reviewed-by: Yuhang Zhao <2546789017@qq.com>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-12-15 22:54:46 +08:00
Paul Wicking
0a7f9297a8 Bump version
Change-Id: I33ea33c0ecfe42cd25cb9f3a37b7aad72717edd2
Reviewed-by: Jani Heikkinen <jani.heikkinen@qt.io>
2020-12-15 15:54:46 +01:00
Paul Wicking
98292b369e Doc: Clean up changes to Qt XML docs
* Remove heading that causes QDoc's autolinker to link incorrectly.
* Clean up language a bit while at it.
* Drop a double space.

Fixes: QTBUG-89283
Pick-to: 6.0
Change-Id: Ice778d66deab384b66eb50b790670c9e3c8b0e84
Reviewed-by: Andreas Buhr <andreas.buhr@qt.io>
Reviewed-by: Nico Vertriest <nico.vertriest@qt.io>
2020-12-15 15:54:46 +01:00
Allan Sandfeld Jensen
30811f6428 Fix qt_alphaVersion and qt_opaqueVersion in the trivial case
The case no conversion was needed wasn't handled, but was assumed to be
handled by some call sites.

This can speed up QPixmaps on devices with non-standard screen formats.

[ChangeLog][QPixmap] Opaque pixmaps on devices with a non-standard
opaque format will now correctly match format for faster blitting.
Same with semitransparent pixmaps on devices with a non-standard
semitransparent format.

Pick-to: 6.0 5.15
Change-Id: Ia05ff518fea36b7e3ed5c089fa9e8681a02fc574
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-12-15 15:54:46 +01:00
Alex Trotsenko
9e1433dfdd QProcess: remove unused member
Change-Id: I448a32b8ba11426c70d49f7f492b73e7799cc257
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-12-15 16:54:46 +02:00
Andreas Buhr
3d785249ba Restore previous QDateTime behavior in DST gap
Historic QDateTime behavior when being asked to create a
QDateTime in the DST gap was to interpret the given date
as if it was in the time before that gap, mapping it to a point
in time after the gap. This has changed with
a04411119e .
Since then, the given date is interpreted as if it was in the
time after the gap, thus being mapped to a point in time
before the gap.
This patch restores the historic behavior.
This was not caught by Coin because machines ran in timezone
"Atlantic/Reykjavik" which does not have DST since 1967.
This patch changes tests to always run in "Europe/Oslo".
Driveby: Test function "findSpring" did some operations in
local time, even though being asked to work in a specific
time zone. Fixed that.

Fixes: QTBUG-86960
Fixes: QTBUG-89208
Pick-to: 6.0 5.15
Change-Id: Iecce5898bf9711a10e7dfc0a25e4bbeaed1c8ade
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-12-15 15:54:46 +01:00
Fabian Kosmale
2c8d7411ac Move QObjectBindableProperty documentation into snippet file
The \Q_OBJECT macro has been removed but using Q_OBJECT in the file
would erroneously trigger automoc. Avoid the issue by moving
the snippet into its own file.

Task-number: QTBUG-89505
Pick-to: 6.0
Change-Id: I6630ff4bfcbf33eae348ac3d92aae1878dc573ea
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2020-12-15 15:54:45 +01:00
Alexander Volkov
df28d75721 xcb: Fix available geometry after rotation
QXcbVirtualDesktop::m_workArea is not updated after screen rotation
if _NET_WORKAREA is not updated, e.g. when a window manager is not
running.

Use width of -1 for m_workArea to indicate that _NET_WORKAREA is
not set and thus there is no need to find its intersection with
screens' geometries.

Pick-to: 5.15 6.0
Change-Id: Ic1f3ec23576ed8407a76cc2b9f84a145c67b1d4b
Reviewed-by: Liang Qi <liang.qi@qt.io>
2020-12-13 20:33:39 +00:00
Andy Shaw
7b391c0d2c OCI: Fix the compilation of the plugin
Pick-to: 6.0
Change-Id: I9637bab6cc217d4fd9692f6745b4f14db6ffb259
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
2020-12-13 12:10:28 +01:00
Thiago Macieira
37917b9461 QUrl: improve parseIp6's use of QStringView
Change-Id: I55083c2909f64a1f8868fffd164f20a2fb8ff7f6
Reviewed-by: David Faure <david.faure@kdab.com>
2020-12-12 12:17:20 -08:00
Thiago Macieira
08f1d6f3df QUrl: update parseIp6 to use QStringView, as the comment requested
Change-Id: I55083c2909f64a1f8868fffd164f2058f226fa61
Reviewed-by: David Faure <david.faure@kdab.com>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-12-12 12:17:19 -08:00
Thiago Macieira
4974091699 QStringView: add constBegin and constEnd
Change-Id: I55083c2909f64a1f8868fffd164f21118a9d3ec5
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-12-12 12:17:18 -08:00
Alex Trotsenko
6dac45b246 QSocketNotifier: extend API to provide more flexible startup
Technically, having a single constructor limits the use-cases for this
class. We should take into account that:

  - an opened socket descriptor must be available at the moment of
    construction;
  - the constructor unconditionally enables the notifier (the possible
    solution

        notifier = new QSocketNotifier(...);
        notifier->setEnabled(false);

    is suboptimal due to heavy operations inside the event dispatcher);
  - for these reasons, QSocketNotifier most often cannot be a member of
    another class (we have an extra allocation and indirect access).

This patch addresses this shortcoming by making it possible to set the
socket descriptor at a later point:

[ChangeLog][QtCore][QSocketNotifier] Added setSocket() and an additional
constructor which requires no socket.

Change-Id: I2eb2edf33ddafe99e528aac7d3774ade40795e7a
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
2020-12-11 18:08:31 +02:00
Edward Welbourne
7715b186c7 Assert validity in QStringIterator's unchecked methods
These methods should never be used on strings not known to be valid UTF-16.
Their optimizations will produce undefined behavior otherwise.

Change-Id: I03a95140dcbdd1f7189eea1be69289ce227331a5
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-12-11 16:08:01 +01:00
Ivan Solovev
91c67b0416 QList docs: lexicographical -> lexical
Lexicographical is not the right word for the comparison description.
Other classes use the term "lexical", so QList is updated
in that way too.
The link to cppreference is left, because QList actually uses
std::lexicographical_compare, so it's completely valid here.

Pick-to: 6.0
Task-number: QTBUG-87962
Change-Id: I37bd3a92c5a3f857266e9c483d14e64eb90ce2c7
Reviewed-by: Andreas Buhr <andreas.buhr@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2020-12-11 14:35:49 +01:00
Doris Verria
903087d361 Remove already-set option style feature for QCommandLinkButton
The QStyleOptionButton::CommandLinkButton feature is already set in the
QComnandLinkButton's initStyleOption() so remove its setting in the
paintEvent.

Change-Id: Ic1d723c0671d6d478825d7ba2173db72a8b39c36
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-12-11 14:32:53 +01:00
Alex Trotsenko
0e8b626401 Fix event() chaining in QSocketNotifier
We should return the result of the call of the base implementation for
all events that we did not handle. Also, QObject::event() does not
actually activate any filters, so the comment was inaccurate as well.

Change-Id: Iff6644b7b1621229f8351c83569ee72594e47197
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
2020-12-11 14:48:45 +02:00
Doris Verria
f8f955151a Don't show focus rect for QCommandLinkButton
Since QPushButton sets WA_MacShowFocusRect attribute upon init, this
will be set for QCommandLinkButton too. However, we do not want to draw
the Mac focus frame for QCommandLink buttons so remove this attribute
for them.

Pick-to: 5.15 6.0
Change-Id: Ida7a437a54be078caaebc2c0744243d50e14a87f
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-12-11 11:02:05 +01:00
Doris Verria
d3ee976aca Override initStyleOption() for QCommandLinkButton
In QPushButton::initStyleOption() there is no style option feature set
to distinguish QCommandLinkButtons. The QStyleOptionButton::CommandLink
Button feature is only set during the paintEvent, but in some cases we
need to check for this feature before painting.
To fix, override initStyleOption for QCommandLinkButton and set the fea
ture there.

Pick-to: 5.15 6.0
Change-Id: I8831a6be7da642dcf8830812d99681213e7515dc
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-12-11 11:01:27 +01:00
Sona Kurazyan
335acffe1d Add support of invoking QFuture continuations in a given context
Added overloads of .then()/.onFailed()/.onCanceled() which take a
pointer of a context object, and invoke the continuations in the
object's thread.

Task-number: QTBUG-86794
Change-Id: I0f3cbb0500695673fc4087af5d4b96b416e3e1ce
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
2020-12-11 09:36:45 +01:00
Tor Arne Vestbø
188768072f macOS: Remove setObjectName call from moveWidgetToPlatformItem
It wasn't strictly necessary, and was causing a warning due to
the use of a character literal.

Change-Id: I3552ab06189b3a3f1a635b75bd6c4d8a5bce03f8
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-12-10 21:08:08 +01:00
Christian Ehrlicher
0e4cc2aca7 QTableView: honor spans when calculating height/width hint
QTableViewPrivate::heightHintForIndex()/widthHintForIndex() did not
honor spans and therefore returned too big values.

Fixes: QTBUG-89116
Change-Id: I52948902b7eaaa27c092ed39da68950c3840e8e4
Pick-to: 5.15
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2020-12-10 19:41:26 +01:00
Christian Ehrlicher
6fa1038a85 QHeaderView: respect the font role while calculating the elided text
Amends 4d94384612:

 - The macOS style must now elide the text by it's own since it is
   no longer done by QHeaderView
 - Add documentation of QStyleOptionHeader::textElideMode
 - Remove unused variables from QHeaderView::initStyleOptionForIndex()

Task-number: QTBUG-86426
Change-Id: I98fc6771c0cd56d6002390125ffbab1269f6dd39
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2020-12-10 19:40:57 +01:00
Edward Welbourne
ac1008c16f Check date validity in calendar methods taking a QDate
Previously neglected, in dateFromParts() and dayOfWeek(), which only
make sense for valid dates.

Pick-to: 6.0 5.15
Change-Id: I44879bb441dbf51b96c8fd4d45e8f07423e63047
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-12-10 18:28:39 +01:00
Tor Arne Vestbø
6198ba217f macOS: Disable WA_QuitOnClose on menu item widget container
Otherwise it will prevent quitting of the application when the last
window is closed, on account of (seemingly) being a top level window.

Pick-to: 5.15 6.0
Change-Id: Ib79615dd1e9394c96d39c8f9851005b4c073c165
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-12-10 16:45:23 +01:00
Eirik Aavitsland
36ccbee34e Avoid overflowing QFixed in text layout
Pick-to: 6.0 5.15 5.12
Fixes: QTBUG-89172
Change-Id: Icb78c8eeb1dbe4c5d4c6476beebafc0115a91e8c
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2020-12-10 13:29:45 +01:00
Alexandru Croitor
2304acab5f CMake: Regenerate projects using pro2cmake one last time
And fix up some wrong qmake project files

Pick-to: 6.0
Change-Id: I66cb82aeb9c1419a74df1a650fa78a511ade7443
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-12-10 11:52:30 +01:00
Craig Scott
b94b7687b0 CMake: Support deferred finalization for qt6_add_executable()
Some parts of qt6_add_executable() need to take into account certain
target properties, but the target is created within the function.
The caller doesn't get the opportunity to modify those properties
before they are used. This change provides a way to defer those
property-using steps until either the project explicitly calls a
function to finalize the target or the end of the current directory
scope is reached.

Automatic deferral to end of scope is only supported for CMake 3.19+.
With CMake 3.18 or earlier, deferring the finalization step has to be
explicitly requested with the new MANUAL_FINALIZATION keyword. The
caller is then responsible for also calling qt6_finalize_executable()
later. When the keyword is given, automatic finalization is disabled
even when using CMake 3.19+.

Note that while this could be implemented without CMake 3.19 features,
other work relating to qt6_import_qml_plugins() will require it so we
may as well use this method now.

Fixes: QTBUG-88840
Task-number: QTBUG-86669
Pick-to: 6.0
Change-Id: Ic3854672ba18cff5af2ffd7f63596aa3ac492f33
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-12-10 21:32:18 +11:00
Allan Sandfeld Jensen
48346e8d2d Add colorspace transfer functions based on tables of inputs
This is the most basic way to represent custom transfer functions.

Change-Id: I529fb647ece82c03e85ef77b056d9daf13fe5a61
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2020-12-10 11:03:12 +01:00
Kai Koehne
667e5b1210 Clean up qtconcurrent.qdocconf file
Remove unused parent directory for exampledirs. Also fix content
of excludedirs.

Change-Id: Iac15ec3eb12121c0384e36c31299034624257db4
Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
2020-12-10 12:02:06 +02:00
Fabian Kosmale
376959250c Workaround bogus compiler warning
gcc 9.x (but not 10.x) issues a bogus warning when strlen is used on a
string literal; disable the warning for those versions.
Upstream bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91490

Change-Id: I7a2a4d0f6ddafcafcd9fcc62fc41ad5d78e61627
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-12-10 11:02:06 +01:00
Giuseppe D'Angelo
ce0b767310 QStringView: add some QRegularExpression-related overloads
[ChangeLog][QtCore][QStringView] Added the indexOf(), contains(),
lastIndexOf() and count() methods taking a QRegularExpression.

Fixes: QTBUG-89050
Change-Id: Ic726754f67e06b3764302d2fad252e0378a77afc
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-12-10 02:15:18 +01:00
Giuseppe D'Angelo
be83ff65c4 QString::lastIndexOf: fix off-by-one for zero length matches
Otherwise, it would report that lastIndexOf of an empty pattern
in an empty string doesn't exist. Next commit adds extensive autotests;
for now, disable a broken autotest (which already features a comment
about why it's broken).

Change-Id: I9a0e5c0142007f81f5cf93e356c8bd82f00066f7
Pick-to: 5.15 6.0
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-12-10 02:15:18 +01:00
Joerg Bornemann
88fe9d3d97 CMake: Fix FEATURE_static_runtime build
We must call qt_set_common_target_properties on Bootstrap too, because
that's were FEATURE_static_runtime is handled.

Change-Id: Ie54f7d599d0c3a54b761e6c679983b475e77c17d
Pick-to: 6.0
Fixes: QTBUG-89201
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Eric Lemanissier <eric.lemanissier@gmail.com>
2020-12-09 22:12:17 +01:00
Thiago Macieira
4a1091f489 QUrl: fix parsing of empty IPv6 addresses
There's an assertion. Found by Google fuzz scan of CBOR data.

Pick-to: 6.0 5.15
Change-Id: I55083c2909f64a1f8868fffd164f1ff3af71605b
Reviewed-by: David Faure <david.faure@kdab.com>
2020-12-09 12:40:31 -08:00
Thiago Macieira
2bed336599 QCborStreamReader: move helper function to the only place it's used
Simplifies the code a little bit

Pick-to: 5.15 6.0
Change-Id: I7b9b97ae9b32412abdc6fffd164545632be4590a
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2020-12-09 20:20:08 +00:00
Assam Boudjelthia
fa0dc83135 Revert "Android: print tailored warning if qml dependency path is a dir"
This reverts commit c730a29260.

Reason for revert: The original change was wrong and caused
androiddeployqt to skip valid QML resource paths. 

Additionally, change log output from "file" to "path" when skipping
an import path.

Pick-to: 6.0 5.15
Fixes: QTBUG-89281
Change-Id: Ic338d147a04a03bb1d7acbede11b647ff036922a
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
2020-12-09 20:01:13 +00:00
Thiago Macieira
b359fd6c2a QStringConverter: add comments marking the BOM checks and emissions
Because obscure cultural references never go out of style.
https://twitter.com/steveklabnik/status/1327745325688365056?s=21

Change-Id: Idbe0d2174d4943d1865cfffd1647dd3a18af1801
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-12-09 12:00:03 -08:00
Thiago Macieira
af520c8ef3 Use QDeadlineTimer in qlogging.cpp
No change, just shorter code.

Change-Id: I25d85d86649448d5b2b3fffd1450f95b0ec66927
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-12-09 12:55:21 -07:00
Thiago Macieira
c000143ee4 QDeadlineTimer: optimize when std::chrono::steady_clock is the same
Change-Id: Ib57b52598e2f452985e9fffd14583173716343b0
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-12-09 12:54:59 -07:00
Thiago Macieira
8c8cbd1508 Simplify the detection for the monotonic clock in qelapsedtimer_unix.cpp
Unlike the previous code, we now entrust the compiler to properly
implement thread-safe statics for this code. That was the main reason
why the old code was confusing, trying to determine if the clock IDs
were positive or negative.

Instead, simply make a call to clock_getres(CLOCK_MONOTONIC) and that
will tell us if the monotonic clock is supported.

Change-Id: I0031aa609e714ae983c3fffd1469522a68fa3b66
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-12-09 21:54:15 +02:00
Giuseppe D'Angelo
7c3208c97d QString: fix count(QRegularExpression)
There is an off by one in the implementation of count(): a match
must be attempted even at the very end of the string, because
a 0-length match can happen there. While at it, improve
the documentation on the counter-intuitive behavior of count(),
which doesn't merely count how many times a regexp matches
into a string using ordinary global matching.

[ChangeLog][QtCore][QString] Fixed a corner case when using
QString::count(QRegularExpression), causing an empty in the
last position not to be accounted for in the returned result.

Change-Id: I064497839a96979abfbac2d0a96546ce160bbc46
Pick-to: 5.15 6.0
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-12-09 20:41:18 +01:00
Tor Arne Vestbø
7886fa8474 macOS: Fix crash when showing parent-less platform menus
Pick-to: 6.0
Pick-to: 5.15
Change-Id: I80f02da1621e4088eb040bb16a4db3867b6ad4d7
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-12-09 20:30:05 +01:00
Tor Arne Vestbø
b58d6831de macOS: Remove warning about KVO observers on QNSWindow/QNSPanel
NSTitleBarView in Big Sur will observe the window it is in, but makes
sure to remove these observers in viewWillMoveToWindow, as it should.
To avoid spamming user logs with this warning we remove it.

It was dubious what cases it would have caught anyways, as anyone
trying to KVO observe properties Z of a child object Y of X.Y would
need to track whether X changes its Y between adding and removing
the observer. There are no guarantees that Y is stable, and this
applies to an NSView's window property as well.

Pick-to: 6.0
Pick-to: 5.15
Pick-to: 5.12
Change-Id: I27a0d04625f96c4c5d382c39ac068721ce1e8f9d
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-12-09 20:30:04 +01:00
Christian Ehrlicher
ff8d757e22 QWidget: mark obsolete function isTopLevel() as deprecated
QWidget::isTopLevel() is deprecated and can be replaced 1:1 with
isWindow(). Sadly it's was not marked with Q_DECL_DEPRECATED in 5.15

Change-Id: I4508fbde41927f3b82e47a75011179548325029d
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2020-12-09 20:30:04 +01:00
Alex Trotsenko
5e72976237 QProcess: remove outdated references to QProcessManager
No such thing exists since Qt 5.5.

Change-Id: Ib3f83dbb1087db1880ef37438669430e0f076301
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
2020-12-09 19:30:04 +00:00
Volker Hilsheimer
4aa174ed86 Don't refer to "this" in QToolTip documentation
All APIs are static, so there is no "this" pointer.

Pick-to: 6.0
Task-number: QTBUG-89082
Change-Id: I4bfe6c14304d311b903878acd5b4c8169f4065c7
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2020-12-09 15:54:45 +01:00
Fabian Kosmale
894c2ec918 QMetaObjectBuilder: use constexpr if
Change-Id: I23319c263447714b280e9ba9da72162e19fe4e1b
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-12-09 15:54:18 +01:00
Alex Trotsenko
dccc2aff6c QProcess/Unix: unify waiting in 'Starting' state
It makes no sense to poll the I/O pipes if we didn't get a start-up
notification yet. And in fact, all waitFor...() functions except
waitForReadyRead() did already explicitly wait for process startup
completion. So fix that one up, and remove the handling of 'Starting'
state from the I/O loops.

Change-Id: Ibb7eb7c768bef3f9b6c54009c73b91775570102c
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
2020-12-09 11:48:36 +00:00
Fabian Kosmale
ddc585b7c7 QProperty: Handle eager binding calling setBinding
When an eager binding  triggers a setBinding call, we end up with a
special kind of binding loop:
setBinding() -> evaluate -> notifyObserver
      ^                           |
      |                           /
      ----------------------------
We now catch set condition, and set the binding status to BindingLoop
(with a distinct description).

Task-number: QTBUG-87153
Task-number: QTBUG-87733
Pick-to: 6.0
Change-Id: I9f9915797d82eab820fc279baceaf89d7e5a3f4a
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2020-12-09 12:48:36 +01:00
Alex Trotsenko
55245c769b QProcess: migrate to QDeadlineTimer
Replacing QElapsedTimer with QDeadlineTimer simplifies the code in
waiting functions, which also improves readability.

Change-Id: I56aedd356b547b6735ed0985dc81be706e292437
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-12-09 10:42:19 +02:00
Giuseppe D'Angelo
6f2dc8d7f2 QString: improve lastIndexOf(QRegularExpression) docs
Due to how regex matching works, lastIndexOf has to be implemented
by matching from the string's beginning until the from position
is reached. This might not be obvious for users, so document that.

Task-number: QTBUG-89050
Pick-to: 5.15 6.0
Change-Id: I4b69ea753e7d417d980031926f1e01d77e58720d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-12-09 03:02:05 +01:00
Allan Sandfeld Jensen
35d62b6852 Get rid of QPenPrivate::defaultWidth
It is no longer used.

Change-Id: I834e0cbd6ef4fefb52d0864053e95e7dea19b389
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2020-12-08 22:59:08 +01:00
Weng Xuetian
5f43d665d8 Remove the deprecated m_logicalDpi declaration
Change-Id: I8d9d59f010874e5a45084afcf55640078d5eba24
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2020-12-08 10:01:24 -08:00
Morten Johan Sørvig
fdc687913d QSplashScreen: draw pixmap with SmoothTransfrom
Use high-quality scaling to improve rendering in cases
where the pixmap has to be scaled down, such as when
drawing a @2x pixmap at 150%.

Change-Id: I216b03b61dfa2cc2cc8c573e24a576424f6f5d17
Fixes: QTBUG-88982
Pick-to: 6.0 5.15
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2020-12-08 19:00:42 +01:00
Morten Johan Sørvig
c2c163a7d8 macOS: Add missing QT_MANGLE_NAMESPACE
KeyValueObserver and RunLoopModeTracker were causing
“Class is implemented in both...” messages when loading
multiple namespaced Qt versions into the same process.

Change-Id: Idbd2229c61cde6fba2c12b35d045390a371dee68
Fixes: QTBUG-89059
Pick-to: 6.0 5.15
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2020-12-08 19:00:12 +01:00
Ivan Solovev
088c391386 QList: update docs
Update some wording to align with QString
and QByteArray documentation

Pick-to: 6.0
Task-number: QTBUG-87962
Change-Id: I8162769c1a5fc94fc8920ad0d4d91e95fe74825f
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2020-12-08 16:27:25 +01:00
Volker Hilsheimer
cd32e5d746 Fix qdoc warning from incorrectly named method parameter
Amends 2eb7d6073d.

Pick-to: 6.0
Task-number: QTBUG-87962
Change-Id: I55c9e8cf7db9e1e1644a76f29a9dc61b161ae551
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Andreas Buhr <andreas.buhr@qt.io>
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2020-12-08 16:00:54 +01:00
Edward Welbourne
d75dc06f6a Restore pass-by-ref to QRect QCalendarWidget::paintCell()
Accidentally changed to pass-by-value while doing that to QDate,
in commit af837734b2

Task-number: QTBUG-86400
Change-Id: I8d2db532f537e5f82a5f3b36e72fcf7fefdd2ee5
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
(cherry picked from commit 8db0d701e8b1fe00cdd5d71c18afff84de606013)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2020-12-08 14:49:05 +00:00
Andreas Buhr
cd66112298 Fix links to OpenGL documentation
Some links were broken. Some stated to be pointing to OpenGL ES 2.0
documentation but pointed to OpenGL ES 3.2 documentation.

Task-number: QTBUG-88533
Pick-to: 6.0
Change-Id: Iad25d8f709b8fa9421039d5cb51cee21093e3191
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2020-12-08 15:15:58 +01:00
Kai Koehne
189bc8dd15 Fix MSVC warning C4267 in qstring.cpp
Fix warnings

  qstring.cpp(9650): warning C4267: 'argument': conversion from 'size_t' to 'uint', possible loss of data
  qstring.cpp(9654): warning C4267: 'argument': conversion from 'size_t' to 'uint', possible loss of data

QDataStream::writeBytes expects an uint as second parameter, not size_t.

This reverts parts of 744e55b85a, where the explicit cast to size_t
was introduced.

Pick-to: 6.0
Change-Id: I2750a6f48fc09730aa9fa21dcc31f82e33b48b8b
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-12-08 15:15:58 +01:00
Kai Koehne
9198d7f044 Remove qlalr documentation stub
The documentation is only a stub, and hasn't been built since Qt 4 times.
qlalr is also first and foremost an internal tool nowadays, so it's very
unlikely we will fully document it.

Change-Id: I68821bf1f9ca3811ec8adda583f0c7326421c6b6
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2020-12-08 15:15:58 +01:00
Christian Ehrlicher
4d94384612 QHeaderView: respect the font role while calculating the elided text
The font role in the header view was not taken into account when the
text for an item should be elided. This leads to a wrongly elided text
esp. visible when the font size is different to the font of QHeaderView.
Fix it by passing the elide mode to the style since only the style knows
the used font (e.g. bold or not bold) and available rect. This is now in
sync with CE_ItemViewItem where the eliding is also done by the style
and not by the item view.

[ChangeLog][QtWidgets][QHeaderView] QStyleOptionHeader got a new member
textElideMode.

Fixes: QTBUG-86426
Change-Id: If6914fe5aaa5d285e6da55d2129f9249d90da3d7
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2020-12-08 15:15:58 +01:00
Tuomas Vaarala
1051e23ce9 QSystemSemaphorePrivate: Fix a call to tr() to translate()
Calling QCoreApplication::tr() without #if QT_CONFIG(translation)
can cause the build to fail if configured without translation.
Changing the call to QCoreApplication::translate() fixes that.

Pick-to: 5.15 6.0
Change-Id: I48f0e1be14fc81360b8268620afc2f6c8f255819
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
2020-12-08 14:15:58 +00:00
Allan Sandfeld Jensen
cc81aae4b3 Shortcut QImage::convertTo when no conversion is necessary
Avoids a detach when converting to existing format.

Pick-to: 6.0
Change-Id: I9a4801878ddec295a02f2c88f4a40ec13d513a94
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2020-12-08 15:15:57 +01:00
Piotr Mikolajczyk
fd20bc2277 Android: Qml accessibility fixes
- Accessibility focus can follow the position of the widget
  (for example when swiping on a scrollview)

- controls are clickable directly after appearing on the screen after
  scroll (previously you had to click somewhere else on the screen,
  and after that you could focus the newly appeared control)

- checkbox and switch react correctly on click action

- fixed combobox behavior with accessibility enabled

Task-number: QTBUG-79611
Pick-to: 6.0 5.15
Change-Id: If36914ab0165f33593e68fd7ecf168693f8538a7
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2020-12-08 10:02:34 +01:00
Alexandru Croitor
b3576164f0 CMake: Disable static plugin imports for non-executable targets
There is no point in generating cpp files containing Q_IMPORT_PLUGIN()
macro calls for non-executable targets like modules, plugins and object
libraries in a static Qt build.
It causes unnecessary compiling of 10+ files for each of those targets.
In a static Qt build, plugin imports should only be done for executables,
tools and applications.

Pick-to: 6.0
Change-Id: Ied90ef2f6d77a61a093d393cfdf94c400284c4f0
Reviewed-by: Craig Scott <craig.scott@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-12-08 09:13:03 +01:00
Fabian Kosmale
c7443d2e11 QPropertyBindingPrivate: Enable QML engine error handling
The QPropertyBindingSourceLocation is only useful for C++ bindings; for
QML bindings we store the binding location in the V4 function. As the
QML binding needs to store some additional information for error
handling, we allow that memory to be reused by putting it into a union
with an array of byte.

Moreover, we use some of the space to store a callback pointer, which
gets called when an error occurs during binding evaluation. That
callback is only called when we know that the binding actually was set
up from the QML engine, in which case a bitflag is set.

Task-number: QTBUG-87733
Change-Id: I4387a4bd59d4d1ccfe75756ce81f4608319e0490
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2020-12-08 08:47:48 +01:00
Avindra Goolcharan
1ee2558b23 wasm/js: fix invalid restartCount reference
The `restartCount` variable on line 245 is mutating
global scope. The PR makes it consistent with the
rest ob the code (`self.restartCount`).

It was observed when importing the qtloader in a
typical Webpack/Babel build environment.

Change-Id: I338285f4f6bcb80df0c16d80cc3ebfec944a8be7
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2020-12-08 01:56:22 -05:00
Shawn Rutledge
9d51fb579b Fix highdpi conversion of QTabletEvent coordinates on xcb
Amends 1535fc9fb9 : when high-dpi scaling
is enabled, there was an offset from the cursor position to the event
position, because QWindow::mapFromGlobal() works in device-independent
pixels, but we are using actual screen pixels here.

Pick-to: 6.0
Pick-to: 5.15
Pick-to: 5.12
Task-number: QTBUG-77826
Change-Id: Ic8743b9e5c4041065f530ed1d9d6c49337b0207a
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2020-12-08 07:03:12 +01:00
Tor Arne Vestbø
ae3594436b macOS: Always allow interacting with popup windows during modal session
f4889e63c7 changed the worksWhenModal logic for QNSWindow to
be based on the transient parent relationship of the child window
to the modal session window, to fix many issues where windows that
should be blocked were not.

Unfortunately, some window types do not maintain a transient parent
relationship (e.g. QCompleter, which is itself just a QObject), or
are not common for users to create with a QWidget parent (such as
a context QMenu).

This change restores part of the special-casing that was removed in
f4889e, so that all popup windows are always allowed to be interacted
with during modal sessions. This includes popup windows that were
opened as part of a parent modal session, which would normally be
fully blocked, but we assume that popup windows are intermittent
enough that this will not be a problem.

For now we leave out the other two special casings from f4889e,
namely tool windows and dialogs. The former should in most cases
be created with a parent window, while the latter definitely should.

Fixes: QTBUG-88188
Fixes: QTBUG-88985
Fixes: QTBUG-87849
Fixes: QTBUG-86845
Pick-to: 6.0
Pick-to: 5.15
Change-Id: I005a402b21e8dc16c3b18bcd7e67d12b94a66f44
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-12-08 03:27:06 +01:00
Thiago Macieira
58bea7f3a2 QCborStreamReader::next: don't allocate too much memory in a QBA
Because CBOR strings are encoded in UTF-8, it's possible that the string
that won't fit a QString in UTF-16 would still fit QByteArray in UTF-8
(e.g., anything US-ASCII and most Latin text).

The previous solution was an improvement because we used to read into a
QByteArray then convert the QByteArray to QString, thus using 3x the
amount of memory (1x in QByteArray, 2x in QString). The previous commit
skipped the middle allocation and made the regular readString() function
do the decoding either directly on source memory or by reading in small
chunks (16 kB).

Future improvement for Qt 6.1: add readStringChunk(char16_t *, qsizetype)
so we can do the validation / skipping at O(1) memory.

Pick-to: 5.15 6.0
Change-Id: I7b9b97ae9b32412abdc6fffd1645458c655cc566
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2020-12-07 22:54:39 +00:00
Thiago Macieira
bab2cd1125 QCborStreamReader: move the UTF-8 decoding into readStringChunk
This allows us to decode long UTF-8 strings in chunks, instead of
allocating a big block of the size of the UTF-8 source and then another
for the full UTF-16 content.

Pick-to: 5.15 6.0
Task-number: QTBUG-88253
Change-Id: I7b9b97ae9b32412abdc6fffd16452a47b1036ef3
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2020-12-07 22:54:38 +00:00
Mårten Nordheim
b4d7908d5a Http2: set the reply's error code and string on error
If the error occurs during the call to
QHttpNetworkConnectionPrivate::queueRequest coming from the http thread
delegate then we will not yet have connected to the signal! But the http
thread delegate checks if the error code is not NoError, and handles
those situations. To let that work we must update the replies.

Pick-to: 6.0 5.15
Change-Id: I47188e9439920694aaad1765ab28add1e86ccdff
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2020-12-07 22:34:49 +00:00
Edward Welbourne
0e742c9add Inline QCollator's QString methods via QStringView
Can't be done before Qt 7 unless we do it now, as it'd be BiC.

Task-number: QTBUG-86400
Change-Id: Ib7b2e7b20b4a80b53dfc6535efe90d1674f38e81
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
(cherry picked from commit 53a1e015fdb4082900f306b5e2cca7bd5df77d03)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2020-12-07 22:10:25 +00:00
Allan Sandfeld Jensen
37bd7b5733 Add SameSite API to QNetworkCookie
Change-Id: I3f8b25418154f74bb55fa978b03465f75771d015
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-12-07 22:38:37 +01:00
Timur Pocheptsov
c0a17ecfaf TLS utils - remove useless static_assert
Compiler (gcc) keeps nagging and complaining about an address of function
to be never nullptr in any particular instantiation, when argument is an
address of a function.

Change-Id: If67e80f2ff4d408608429d53814083777cc8441c
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-12-07 19:27:16 +01:00
Allan Sandfeld Jensen
32f0053e5b Add uninitialized constructor to qfloat16
Change-Id: Ifc1fa97168927dac96e749b5dcb2a0a38b158b12
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-12-07 17:58:40 +01:00
Friedemann Kleint
3fb039ca23 rcc: Remove support for Python2
Qt for Python only supports Python3.

Change-Id: I7b13b1f9482579b1e1128d15ee5734d063a7c4b8
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
2020-12-07 17:09:07 +01:00
Andreas Buhr
0e96e1fb75 Fix QPropertyAlias example, which did not compile
The QPropertyAlias example did not compile and comments were out of
sync with code. This patch fixes both.

Pick-to: 6.0
Change-Id: I5717f8df99f4936d0bcbae8df7d2d17e8086951d
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-12-07 15:44:03 +01:00
Andreas Buhr
3fbf922cc5 Fix QProperty example so that comments match implementation
The comments in the QProperty examples slightly mismatched the
implementation. This patch fixes it.

Pick-to: 6.0
Change-Id: I03cfb35c024fad8ea4eaa5d5db220e1907f06bc3
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-12-07 15:43:59 +01:00
Wang Chuan
04fed9f77e QStyleAnimation: make sure the last frame of animation is rendered
Amend to 8738f09b9f.
The last frame of animation might be lacked if [_skip < fps].

Fixes: QTBUG-89118
Pick-to: 6.0 5.15
Change-Id: Ia0345e2aff7579afe2d60c4e7495bfaa1f36198c
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2020-12-07 14:43:47 +00:00
Ulf Hermann
2b8674a2fc Make the overflow math functions public
As the standard library does not provide equivalent functionality, those
functions are really useful to everyone, not only to Qt itself.

[ChangeLog][QtCore] The overflow-safe math functions qAddOverflow(),
qSubOverflow(), qMulOverflow() were added.

Change-Id: I5a0a4742dae9b6f0caa65d0e93edcf3658bee9f8
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-12-07 15:37:25 +01:00
Giuseppe D'Angelo
509c257521 PCRE: update to 10.36
Dropped the RTEMS patch (upstream now uses posix_madvise).
Drop support for the TILE architecture (dropped by upstream).

[ChangeLog][Third-Party Code] PCRE2 has been updated to version
10.36.

Pick-to: 6.0 5.15
Change-Id: Idb4467bef0ff520605b8b5d9188b9d67d8e4d0f2
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-12-07 15:22:43 +01:00
Lars Knoll
cb39ea0581 Make the signal argument in Q_OBJECT_BINDABLE_PROPERTY optional
The intention was always that you can define properties that do
not require a changed signal. But having to explicitly pass
a nullptr as signal parameter into the macro is ugly, so
use the cool QT_OVERLOADED_MACRO to make it optional.

Pick-to: 6.0
Change-Id: I0ce366d043850f983c968d73c544d89933c48df9
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-12-07 15:18:44 +01:00
Friedemann Kleint
cb064dee3a uic/rcc: Use QT_VERSION_MAJOR for major version
Amends 539a16a69fa1ef302cf4eb97ff5a7f8afb606d15.

Task-number: QTBUG-89124
Change-Id: I68c9ab2179d464d83c3fd9eefc5609b7a5a58e27
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
2020-12-07 11:37:35 +01:00
Alex Trotsenko
ec02de374d QProcess: simplify the logic around _q_processDied()
Both on Unix and Windows, _q_processDied() unconditionally releases all
resources associated with the terminated child process, resets QProcess
to the initial state, and emits finished() signal. Thus, we can omit
reporting success, which also eliminates the related checks from
callers.

Change-Id: I40e32d1a9ccc8d488be6badba934355d734a8abd
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
2020-12-06 22:28:31 +02:00
Thiago Macieira
895940a425 QCborStreamReader: remove the lambdas from decodeStringFromCbor()
One was only called once. For the other, one of the calls wasn't
necessary.

Pick-to: 5.15 6.0
Change-Id: I7b9b97ae9b32412abdc6fffd16454eec59d72b8a
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2020-12-06 07:51:33 +00:00
Thiago Macieira
638171eb10 QCborValue: avoid allocating result if data is insufficient
Similar to the previous commit which applied to QCborStreamReader, don't
allocate too much data before checking that the stream actually has that
much.

Pick-to: 5.15 6.0
Fixes: QTBUG-88256
Change-Id: I7b9b97ae9b32412abdc6fffd16454b7568a063ba
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2020-12-06 07:51:19 +00:00
Thiago Macieira
9a55f40937 QCborStreamReader: avoid allocating result if data is insufficient
By calling the internal readStringChunk() function with a QByteArray
pointer, QCborStreamReader::readByteArray() can now avoid allocating the
resulting buffer until the internals have confirmed that there is
sufficient data in the incoming buffer. As a result, we first detect the
EOF condition before we conclude the payload would have been too big for
QByteArray (validation()) test. Meanwhile, the hugeDeviceValidation()
test ends up with a few conditions where it would have copied 1 GB of
data, so limit that too.

We make a choice of reporting OOM vs DataTooLarge only if QByteArray
fails to allocate in the first place (QByteArray::resize() ->
Q_CHECK_PTR -> qBadAlloc, QtCore is always built with exceptions on).

The QCborValue unit test needed a temporary work around until we apply
the same allocation fix (see next commit).

Pick-to: 5.15 6.0
Fixes: QTBUG-88253
Change-Id: I7b9b97ae9b32412abdc6fffd164523eeae49cdfe
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2020-12-06 07:50:57 +00:00
Thiago Macieira
c16ad16bd0 QCborStreamReader: move the readStringChunk code to the Private
And add a currently-unused QByteArray pointer parameter. This function
will resize the array as necessary as data comes in.

Pick-to: 5.15
Change-Id: I7b9b97ae9b32412abdc6fffd16451f5c6b280f3b
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2020-12-05 01:26:51 -08:00
Ivan Solovev
2eb7d6073d QByteArray: update documentation
The QByteArray documentation is extended to align with QList and
QString regarding common wording and ideas:
- Extend general class description
- Revise description of several methods
- Wrap descriptions at 80 characters

Pick-to: 6.0
Task-number: QTBUG-87962
Change-Id: Ie9e8ef47a85d0867c2fa63889a60cafbe76ee47a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-12-05 05:06:28 +01:00
Thiago Macieira
aab5c8e548 QString/QByteArray: add missing Q_CHECK_PTR
So these two classes throw when trying to allocate silly sizes or in OOM
conditions.

We probably want to move these Q_CHECK_POINTER into QTypedArrayData but
I didn't want to do that in this commit.

Task-number: QTBUG-88256
Task-number: QTBUG-88253
Change-Id: Ifc61bb80b9bf48a386abfffd1648176111770174
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-12-04 20:04:14 -08:00
Aleix Pol
302254f90f Improve the documentation for QElapsedTimer::restart, include units
Specify that QElapsedTimer::restart returns milliseconds

Change-Id: I47d9ffde7b0f73c30b14d2ce8467ec0a553b58f8
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2020-12-05 04:14:44 +01:00
Marc Mutz
105a66e654 Use (new) erase()/erase_if() algorithms
Change-Id: I45c18fd45c20b226e44d16315e3ebb6c305d4ab0
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-12-05 00:47:44 +01:00
Allan Sandfeld Jensen
2b9a8b8d69 Add generic rb swap for RGB64 formats
Will also be needed by half-float formats.

Change-Id: Ia735b29b65287c63da5f1b5ec25428562d743800
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-12-04 19:21:38 +01:00
Giuseppe D'Angelo
a3e5efa8a2 Sequential containers: make removeIf/erase_if not detach unless needed
Employ the same kind of optimization existing for removeAll/erase.

Change-Id: I0781cc02d4430ceab60e6e50a5ffe6fde87be9ce
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-12-04 18:52:29 +01:00
Giuseppe D'Angelo
9ae0e21131 QList: make an indirect inclusion direct
Change-Id: Ief36ac375f5c26b4a5de6bc18ee3f2f777051024
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-12-04 18:52:16 +01:00
Andreas Buhr
987ee22690 Fix broken link to Zstandard library
The old link zstd.net is not working any more. Zstandard is now at
http://facebook.github.io/zstd/. To ease maintenance in the future,
those links now point to "Zstandard Site" which is maintained in
external-resources.qdoc.

Task-number: QTBUG-88533
Pick-to: 6.0
Change-Id: Ic8f067fd5d7ce1a088d0272797fca98fd506a26e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-12-04 18:47:13 +01:00
Tor Arne Vestbø
ecb61c17f5 doc: Remove dpiawareness command line argument
We don't want to (officially) expose customizations like this
to the user, now that high-DPI is always enabled and should
work.

Change-Id: I2f0bd7c625b565896b0766586f191ff5001eb60a
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2020-12-04 17:45:20 +01:00
Mårten Nordheim
f8badeda72 QSslSocket: Don't call 'transmit' in unencrypted mode
At the same time I'll add a generic protection against being called in
unprotected mode in the schannel backend (openssl already has it in a
different form).

Pick-to: 5.15 6.0
Change-Id: I97c1be6239c27e306de0af7ad568fbcfde09da71
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2020-12-04 17:00:15 +01:00
Friedemann Kleint
e4395f3f68 Fix uic/rcc generating outdated export for Qt for Python
Bump version to 6.

Fixes: QTBUG-89124
Change-Id: Ifcf60552b5b6efb86f79da34da9c34b8efae9fa4
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
(cherry picked from commit fc9cda5f08ac848e88f63dd4a07c08b2fbc6bf17)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2020-12-04 15:46:04 +00:00
Ivan Solovev
3d780c0d70 QtConcurrent: filter/map reduction without default ctor
Previously a default constructor was required for the result type
of mappedReduced() and filteredReduced(), even if a default value
was provided.

This patch fixes the problem.

The issue was in the ResultReporter type, that was calling
QList::resize() to adjust the size of expected reported results.
A default-value parameter was added to the class, so that
a corresponding overload of QList::resize could be invoked.

Task-number: QTBUG-88452
Change-Id: I51113753e314d76aa74d201b5a7e327a6ca75f47
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2020-12-04 15:36:50 +01:00
Allan Sandfeld Jensen
0c19e3f703 Fix QImage::setPixelColor on RGBA64_Premultiplied
QColors were not premultiplied before being set.

Pick-to: 6.0 5.15 5.12
Change-Id: Id3765b6932a72374ddfd788fae4bb628a4edf0b7
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-12-04 15:09:47 +01:00
Edward Welbourne
0a01396e60 Purge double-spaces in qvectornd.cpp sentence-ends
Change-Id: I4b5692334a12374b8a6b4910d411d0eab240ce4b
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2020-12-04 15:09:47 +01:00
Edward Welbourne
c3ec3edb81 Indicate the limited locale selection in the POSIX backend
Change-Id: I82798de7ff313121144798969eed85c23e852d10
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2020-12-04 15:09:47 +01:00
Edward Welbourne
2b7c74d5ff Enable testing for whether a calendar registered its primary name
In registerAlias(), return true if this instance is already registered
with the given name.

Previously there was no way for a QCalendarBackend to tell whether its
primary name registration had succeeded, during instantiation (other
than by devious hackery using a QCalendar instance with the name and
some form of back-channel in the instance).

Use this in backendFromEnum() to catch cases in which (e.g. due to a
race condition) a new instance isn't the one that got registered.

Pick-to: 6.0 5.15
Change-Id: I468ac364a68bf3574cd7f8b8b1e672d8fd969111
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-12-04 15:09:46 +01:00
Andy Shaw
94c3c7a491 macOS: Make sure that the reserved characters are not escaped
The URL for the PAC proxy that is passed needs to be preserved for the
main URL part and not entirely percent encoded, only the query part
typically needs to be encoded. So use toEncoded instead for a URL to
ensure they are not percent encoded. This amends
c163ec1dbf

Pick-to: 6.0 5.15
Change-Id: Ie41ab55f71be8e25c18775e61ce7b4d110c2ddbf
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2020-12-04 15:09:46 +01:00
Giuseppe D'Angelo
a1a55d5b93 QTestLib: add a abort-on-fail environment variable
When debugging a spurious failure it's extremely useful to
run the test repeadtly into a debugger until a failure appears.
When that happens, one wants to immediately start debugging.

In so far, this has only been possible by placing breakpoints
inside Qt itself (when a failure is logged). Add another way:
an env variable, similar to QT_FATAL_WARNINGS, that makes
any failure fatal (terminate() gets called. Bonus: you can
control the termination handler!)

[ChangeLog][QtTestLib][QtTest] When the QTEST_FATAL_FAIL
environment variable is set to a non-zero value, a test
immediately aborts its execution. This is useful to debug
intermittent failures.

Change-Id: If2395f964ea482c30b8c8feab98db7fdee701cd3
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Jason McDonald <macadder1@gmail.com>
2020-12-04 14:09:46 +00:00
Fabian Kosmale
bc093cd294 QInputDevice: Parent default keyboard to core app singleton
With this we can avoid leaking the QInputDevice which is created when
the platform plugin does not provide any. The onwership is solved in a
similar way as in the plugins, except that here we have no parent which
really fits, so we use QCoreApplication::instance instead.

Pick-to: 6.0
Change-Id: I77a212fb592ba3d5a42b2ecd486763e3b4d3410e
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2020-12-04 15:09:46 +01:00
Shawn Rutledge
94dfb18865 Make qDebug output for QTabletEvent similar to that for QMouseEvent
Reuse operator<<(QPointingDevice*) and move the button state right after
the event type.  Now it's easier to follow when a QTabletEvent is not
accepted and a mouse event is synthesized:

qt.quick.pointer QQuickWindowPrivate::deliverPointerEvent - delivering
  QTabletEvent(TabletPress LeftButton pos=100,100 z=3 xTilt=25 yTilt=35 pressure=0.5
     dev=QPointingDevice("Wacom Intuos3 6x8 Pen stylus" Stylus id=13 seat=30002 ptrType=Pen
       caps=Position|Pressure|MouseEmulation|Hover|XTilt|YTilt uniqueId=499602d2))
qt.quick.pointer QQuickWindowPrivate::deliverPointerEvent - delivering
  QMouseEvent(MouseButtonPress LeftButton pos=100,100 scn=100,100 gbl=3739,1029
    dev=QPointingDevice("Wacom Intuos3 6x8 Pen stylus" Stylus id=13 seat=30002 ptrType=Pen
      caps=Position|Pressure|MouseEmulation|Hover|XTilt|YTilt uniqueId=499602d2))

Change-Id: If22f1c07d32f595d0444513b49635218c08a300d
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-12-04 11:22:38 +01:00
Mårten Nordheim
710886fbdd QSocks5SocketEngine: fix reference to dangling data
Following a41c61fb2d QIODevice may try to
copy the QByteArray itself (rather than the data it points to). This can
lead referencing dangling data when the QByteArray is initialized with
raw data.

Pick-to: 6.0
Change-Id: I481695b33f251f750ef482d72b81636f0d4bf462
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-12-04 11:22:38 +01:00
Allan Sandfeld Jensen
47923f7d47 Improve documented function argument names
Make them less \a fun.

Pick-to: 5.15 6.0
Change-Id: Ief9a572dcbeb029b18b352c89551963bade90198
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2020-12-04 11:22:37 +01:00
Fabian Kosmale
e236faa75f QBindable: Disallow mutation if read-only
If a QBindable is created from a computed property, it is not possible
to actually set a value or a binding. If we try to do it anyway, we'd
get a crash. Thus we now check whether the function pointer is null
before invoking it.

Pick-to: 6.0
Task-number: QTBUG-87153
Change-Id: I5bedb9080ccf79d9b8166b80d5733d095ed76f8d
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-12-04 11:22:37 +01:00
Piotr Mikolajczyk
e1440dd7bc Android: Kill calls to deprecated func in API 29
Since API 29 functions:
 - getExternalStoragePublicDirectory
 - getExternalStorageDirectory
are deprecated and no longer return directly accessible path.

This patch replaces calls to those with suggested call to
Context.getExternalFilesDir(String)

Task-number: QTBUG-87803
Pick-to: 5.15 5.12 6.0
Change-Id: I36bc5d5b72a80017996445af0d577aacf5e112d3
Reviewed-by: Rami Potinkara <rami.potinkara@qt.io>
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
2020-12-04 06:29:07 +00:00
Christian Ehrlicher
6efe11dd75 Remove unneeded qatomic_msvc.h
Since Q_COMPILER_ATOMICS is defined for every supportied MSVC compiler
in qcompilerdetection.h, qatomic_msvc.h is not included anymore in
qbasicatomic.h and can be removed.

Change-Id: I6505da5d5e9f1c3f9a060ad30cabb4b652634aa3
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-12-04 07:04:11 +01:00
Lars Knoll
57e9d9e38e Dont' return a const ref to QModelIndex
The conversion operator from QPMI to QModelIndex should return by
value, to hide implementation details and so that we don't have to
rely on a static empty QModelIndex.

Change-Id: I92b3f8451422f2b69bf31f28b387a124fd24ec46
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
(cherry picked from commit 0cd2935ed9d772f0eb06d03201baabd60764ec80)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2020-12-04 06:00:50 +00:00
Lars Knoll
6012285e7d Fix hashing of QPersistentModelIndex
The hash and equality operators used need to be consistent with
each other. Unfortunately, QPMI::operator==() is not suitable to do
this. So specialize qHashEquals() for QPMI.

Fixes: QTBUG-88966
Change-Id: If5f19a722ae9fc4e78e93537e7ea15726f148768
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 83e95956ed58e88b11e2cc3cb61c5beacb7985db)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2020-12-04 06:00:38 +00:00
Lars Knoll
793dbd8ee6 Add a qHashEquals() method and use it to compare keys in QHash
In some cases, the default equality operator for a class is not suitable
for using in hashing (for example because it uses fuzzy comparisons).

Add a qHashEquals() method that by default uses the equality operator, but
allows to tailor the operations that should be used when using the class
as a key in QHash.

Task-number: QTBUG-88966
Change-Id: I346cf0e6e923277a8b42a79e50342a1c2511fd80
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 5d8b586e73e37070b0303bee24372550854637eb)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2020-12-04 06:00:21 +00:00
Li Xinwei
013abe3206 CMake: Avoid MSVC C4996 warnings
The qmake build system defines _CRT_SECURE_NO_WARNINGS in
mkspecs/features/qt_module.prf, the cmake build system should do the
same thing in qt_internal_add_module().

Adding this definition can avoid warnings like:
warning C4996: 'strncpy': This function or variable may be unsafe.

As a special case, Bootstrap uses add_library() instead of
qt_internal_add_module(), so _CRT_SECURE_NO_WARNINGS should also be
defined in src/tools/bootstrap/CMakeLists.txt.

Pick-to: 6.0
Change-Id: Ic82193d177f82785fd84948efa78c49ca8d8db46
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-12-04 13:54:49 +08:00
Giuseppe D'Angelo
89def082c6 QTestLib: allow for non-zero values in env variables
The usual behavior for env variables is that any nonzero
value means "enable", so do the same for a couple of QTestLib
env vars. While at it: document them.

Change-Id: I854285df5d7af5be771f9d6532ddec5d8a6f8987
Pick-to: 6.0
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2020-12-04 00:17:46 +01:00
Alexey Edelev
af0a9375f3 CMake: Improve long paths handling for static builds
Use number-based naming of object libraries produced for generated
resources. This reduces path length of subdirectories for object
library targets.

Amends 08eb485a006dc2baca42eb280ae60e9f0fc00dff

Pick-to: 6.0
Change-Id: I1a449290e8a9b969601a1cc1abc6fdcfc0cd9454
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-12-03 20:21:35 +01:00
Andreas Buhr
604a8c7acc Fix documentation of QStringTokenizer
Documentation of QStringTokenizer was broken, mainly because most
parts of the interface were defined in base classes. This patch
gets those members into QStringTokenizer itself in order to document
them.

Task-number: QTBUG-88533
Pick-to: 6.0
Change-Id: Id00a79db4b293958a9c5ed53a518a97721d228c0
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-12-03 20:21:35 +01:00
Andreas Buhr
d7828a5ed3 Remove non-existent function QApplication::desktop() from docs
The method QApplication::desktop() was removed. This patch removes
a line mentioning it in the documentation.

Task-number: QTBUG-88533
Pick-to: 6.0
Change-Id: I123e41c342d64da347b9bd59378e52a8e0301c1a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-12-03 20:21:35 +01:00
Andreas Buhr
15cd7d7741 Fix documentation warnings about QCollator property
The documentation of ignorePunctuation in QCollator did not strictly
follow conventions, leading to warnings in building the documentation.
This patch fixes this.

Task-number: QTBUG-88533
Pick-to: 6.0
Change-Id: Ia1273ec8e440099afe729b54423760ad5ac26290
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-12-03 20:21:34 +01:00
Friedemann Kleint
a5e2f2ddad uic: Do not generate QDockWidget::AllDockWidgetFeatures into code
The enumeration value was deprecated by
qtbase/f15aa1fd84e46dfc4d9a78b3a7ba482e42abd9c1 and removed in Qt 6.

Pick-to: 6.0
Task-number: QTBUG-89093
Change-Id: Iaf46adc1e1bd79e4aaab066c9fa4bf84a8ee34d0
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-12-03 17:17:03 +01:00
Fabian Kosmale
df8fbcf382 Avoid signed overflow in moc
moc's preprocessor needs to implement certain math operation to
correctly handle #if conditions. Unfortunately, its implementation is
not overflow safe. However, those are rare enough in practice that we
in general do not need to care about them.
This patch adds a workaround for one case where UBSAN run into an
overflow related issue.
A complete fix would require to make moc spec compliant (do math with
std::max_(u)int_t operands; always wrap on overflow) in all operations.

Pick-to: 6.0 5.15
Fixes: QTBUG-88825
Change-Id: Ic4d2cb097db2fa2f9d4681bbaab3068eaa2745aa
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-12-03 13:51:32 +01:00
Alex Trotsenko
9a161b6700 Fix event() chaining in QWinEventNotifier
We should return the result of the call of the base implementation for
all events that we did not handle. Also, QObject::event() does not
actually activate any filters, so the comment was inaccurate as well.

Change-Id: I9eb2f9a93a6b53a1afd035433615bcc0ee8cbf2c
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
2020-12-03 08:35:34 +00:00
Shawn Rutledge
6f694b7fe1 Remove QGuiApplicationPrivate::m_fakeTouchDevice
It is no longer in use.

Change-Id: I810a79c81fe49d855b31e992bf000166247791a5
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-12-03 09:22:12 +01:00
Karsten Heimrich
8df2bf0491 Fix QTranslator::load() search order not following uiLanguages order
Merge the exact and and fuzzy search loop. This way we prioritize
translations which match a more preferred language loosely over ones
which match a less preferred language exactly. This is likely what
most users want.

Pick-to: 5.15 6.0
Fixes: QTBUG-86179
Change-Id: Id1610c82a2e77edf9a5d4417968dcc4c307810d5
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
2020-12-03 07:50:20 +01:00
Giuseppe D'Angelo
bf92f0fee5 QHash: default the argument for the hash calculator helper
Just to be consistent with everything else.

Change-Id: I48ceb4bbc1cbf65b03caee77b7405cb585793248
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-12-03 06:52:28 +01:00
Giuseppe D'Angelo
06957af471 QDuplicateTracker: allow usage of qHash
The codepath using unordered_set forced the usage of std::hash,
which isn't provided by many Qt types. Instead, use the
brand new helpers in QHash that dispatch to qHash with a fallback
on std::hash.

Change-Id: I9185fe9c52de05c470afe7466007591977e65bb1
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-12-03 06:52:06 +01:00
Giuseppe D'Angelo
427da06414 QRE: discourage users from assuming that QRE stores the subject
When matching over a QString we store a (shallow) copy of it.
That has always been an implementation detail and people should've
never relied on it, but Hyrum's law, we don't want to actually
exploit this by NOT taking the copy.

Converesely, matching over QStringView already requires that
the string data is kept alive as long as QRE(Match) objects
are alive.

Add a doc note to give us the freedom to do the change in Qt 7.

[ChangeLog][QtCore][QRegularExpression] QRegularExpression takes
a shallow copy of a QString subject when matching over it. This
means that users can destroy or modify the string data while
still having match results over it. This behavior is deprecated;
in a future version of Qt, QRegularExpression will no longer
take a copy. Note that behavior has always been undocumented and
users were never supposed to modify a subject string while
match objects were alive on it. In practice, it's very unlikely
that your code is relying on the existing behavior.

Change-Id: Ibc5f900c09a007139fb12fc4d7f11e4a8f31bf38
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-12-03 06:51:14 +01:00
Giuseppe D'Angelo
1ebccf3426 QString::fromUtf8: remove a stray cast to int
Change-Id: I0dba7ba130c3fa96eda63a0fa1a39c5f0bb863b7
Pick-to: 6.0
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-12-03 06:50:54 +01:00
Giuseppe D'Angelo
53b7cb1bd7 QRegularExpression: plaster some [[nodiscard]]
On some of the "most important" API.

Change-Id: I800b53bb7b9a95d0184f813e7ba501a7ebd485c0
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-12-03 06:50:46 +01:00
Giuseppe D'Angelo
553d4ec464 QString: plaster more and more [[nodiscard]]
The situation was quite inconsistent. Use the attribute more.

Change-Id: If21817b4c2ea1148ad4ad80e7a50fab721a58b65
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-12-03 06:50:37 +01:00
Yuya Nishihara
d9a6517076 Dialog: Fall back to transient parent to make dialog window get centered
Unlike QWidget-based application, a dialog displayed in QML app doesn't
have QWidget parent, so it would be centered in the current screen.
Let's fall back to transient parent window if widgetParent() is missing.

It's tempting to rewrite adjustPosition() to not depend on QWidget at all,
but that seems not easy. Lookup path of window() and transientParentWindow()
is slightly different for example, and QWidget::pos() is used instead of
mapToGlobal({0, 0}) if the widget is embedded into a native window.

Fixes: QTBUG-63406
Change-Id: If72d90aee8d972240243184de4d3c09d77f704ff
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2020-12-03 14:43:42 +09:00
Qiang Li
d6dcf508a6 Adjust the format of code blocks in function mouseReleaseEvent
Pick-to: 6.0
Change-Id: I8441b1c4f22ec04e34e8c2c5e9ccc69d34c67e01
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-12-03 02:19:15 +00:00
David Skoland
3ca921293a Add test for qRound
Add test for qRound that covers some edge cases for rounding. Note that
as of right now, this test fails and the docs have been updated to warn
that it should not be depended on for strict correctness.

Change-Id: I1a61bca47abd77855fe7c13ded44e913cc7e8722
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-12-02 21:24:19 +01:00
Andreas Buhr
c3ffa6036b Fix QSet::insert documentation
Documentation for QSet::insert was wrong, leading the warning
qset.qdoc:510: (qdoc) warning: clang couldn't find function when parsing
\fn iterator QSet::insert(const_iterator it, const T &value)
This patch fixes it.

Task-number: QTBUG-88533
Change-Id: I587cbae5674b9f38e37753a20c3c3f0d770980d6
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-12-02 17:08:50 +00:00
Andreas Buhr
3c0614b779 Document QMultiHash::clear function
When QMultiHash derived from QHash, it inherited the clear function
and no separate documentation was necessary. Now, QMultiHash::clear
needs its own documentation. This patch adds it.

Task-number: 88533
Pick-to: 6.0
Change-Id: I93c59b66aa3d8ccf1888b6e24a4cc47004318e37
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-12-02 18:08:38 +01:00
Giuseppe D'Angelo
e12e2b43b7 Associative containers: add erase_if
Use a trick similar to the one we use for their ranged
constructors: support predicates that either take a
container's iterator, or that take a std::pair (for STL
compatibility).

[ChangeLog][QtCore][QMap] Added removeIf() and erase_if().

[ChangeLog][QtCore][QMultiMap] Added removeIf() and erase_if().

[ChangeLog][QtCore][QHash] Added removeIf() and erase_if().

[ChangeLog][QtCore][QMultiHash] Added removeIf() and erase_if().

Change-Id: Ie40aadf6217d7a4126a626c390d530812ebcf020
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-12-02 10:35:14 +01:00
Wang Yu
9341f2e3d0 Reduce the scope of variable in focusInEvent()
The scope of the variable 'frm' can be reduced if the variable
'd->formatExplicitlySet' is true. So declare the variable when
the variable 'd->formatExplicitlySet' is false.

Change-Id: I27cea412af827d30ad9188106b7f14025e5ddb68
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-12-02 17:26:37 +08:00
Mårten Nordheim
c19695ab95 QDuplicateTracker: remove the appendTo && overload
As a requirement for unordered_set (and QSet) both "iterator" and
"const_iterator" are const, so we cannot reassign or move the key.
That means this overload is no different to the const & overload, so
we can just remove it.

Pick-to: 6.0
Change-Id: Ia14dccf7f610967649bab38161ce6d963509316b
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2020-12-02 09:17:14 +00:00
Mårten Nordheim
def1b97849 Http2: don't call ensureConnection when there's no request available
Previously we only checked if there was something in the h2 queue or
if we had not yet switched to http2. These means in some cases that
following an error it would enter this branch and, because it had not
yet switched to http2, it would call 'ensureConnection' which would try
start a reconnection. This could make the proxy socket engines try to
emit 'auth required' with no replies, meaning nothing happens.

Fixes: QTBUG-88417
Pick-to: 5.15 6.0
Change-Id: If37b8c71ac36597adc305fb1b1ea4fa7b48b0d28
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2020-12-02 10:17:13 +01:00
Mårten Nordheim
65bcac95a7 Http2: Remove errored-out requests from queue
The requests will remove themselves once they get deleted
but since the deletion is done through a _queued_ invokeMethod
to 'deleteLater' we will call
QHttpNetworkConnection::_q_startNextRequest first which may
end up starting a reconnect of the TCP socket which we had the error on.

In this specific instance it manifested as a race condition where we
either don't get a proxyAuthorizationRequired signal at all (it was
emitted while we didn't have any valid replies), or we get the signal
emitted too late and it gets emitted on whatever the next reply was.

Task-number: QTBUG-88417
Pick-to: 5.15 6.0
Change-Id: If3f8ececc5550f1868c90124559cb8e3029646d8
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2020-12-02 10:17:12 +01:00
Mårten Nordheim
734c8aa9d9 QSet: add insert(T&&)
We already have all we need in QHash to support this, so the addition
is simple enough.

Add test checking how many copies and/or moves are needed for a single
insert.

As a drive-by: remove some unneeded static_cast

Change-Id: Iaf768657644afa45f78f5c81ffcf89ba9607be96
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-12-02 10:17:11 +01:00
Ivan Solovev
6364194456 QList docs: extend prepend() description
Current description was confronting the general description of the
class, which states that prepend() is fast.
The updated description gives more information about the method's
behavior in different conditions.

Pick-to: 6.0
Task-number: QTBUG-87962
Change-Id: I7b6dfb536d143d78c441214f83320c1bf1263e0d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-12-02 09:30:29 +01:00
Ivan Solovev
5545b0f1d3 QLatin1String: documentation updates
Some updates for QLatin1String documentation:
- Update signatures of some methods
- Update outdated description for several methods
- Add missing docs for friend operators
- Wrap descriptions at 80 characters

Pick-to: 6.0
Task-number: QTBUG-87962
Change-Id: I1c3c5ce2a6f4f57f92ab503a734c8244fe7cd7c5
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Karsten Heimrich <karsten.heimrich@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-12-02 09:30:11 +01:00
Andreas Buhr
ca5ec3d6b9 Add qt5compat as a dependency to qtxml documentation
QXmlSimpleReader was moved to qt5compat. In the qt6 migration guide, we
would like to point to it. This patch adds qt5compat to the dependencies
of QtXml documentation in order to be able to do this.

Task-number: QTBUG-88533
Pick-to: 6.0
Change-Id: Ifaad595862b80d31310ed594e21168cec56133a0
Reviewed-by: Karsten Heimrich <karsten.heimrich@qt.io>
2020-12-02 06:01:20 +01:00
Volker Hilsheimer
0cc9a99865 Fix links to Application Example
The example was renamed in 6cb36d825d.

Pick-to: 6.0
Change-Id: Ic9daac60002c9988dfeb5c7dcde74edb69388f37
Reviewed-by: Andreas Buhr <andreas.buhr@qt.io>
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Reviewed-by: Jason McDonald <macadder1@gmail.com>
2020-12-02 05:59:56 +01:00
Giuseppe D'Angelo
b2ea30dde0 QString/QByteArray: add erase/erase_if
[ChangeLog][QtCore][QString] Added erase() and erase_if()
for consistent container erasure.

[ChangeLog][QtCore][QByteArray] Added erase() and erase_if()
for consistent container erasure.

Change-Id: I23e8565d39044c1f1d756500589c1f2b65e1a88f
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-12-01 23:03:28 +01:00
Volker Hilsheimer
11bde366e8 Fix link to qHash documentation
Change-Id: Idd72530464aae24fd0e5c144d0de663609632f68
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-12-01 21:30:47 +01:00
Giuseppe D'Angelo
62dad9be9e QSet: add erase_if
[ChangeLog][QtCore][QSet] Added erase_if() for consistent
container erasure. Added removeIf() as a method.

Change-Id: I4af57b654036aa08bee3f769ab2f60be37115094
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-12-01 18:55:55 +01:00
Giuseppe D'Angelo
c176525f13 Sequential general purpose containers: add erase/erase_if
This is refactor/revisit for Qt 6 of the original commit [1]
by Marc, limited to QList and QVLA.

[1] see 11aa9a2276ba5367adbbd96d0ba13111d58145f8

[ChangeLog][QtCore][QList] Added erase() and erase_if(),
for consistent container erasure. Added removeIf() as a
method, complementing removeOne() / removeAll().

[ChangeLog][QtCore][QVarLengthArray] Added erase() and erase_if(),
for consistent container erasure. Added removeIf() as a
method, complementing removeOne() / removeAll().

Change-Id: I2499504e221431ead754dd64cc8a4d4e9f116183
Done-by: Marc Mutz
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-12-01 18:55:49 +01:00
Giuseppe D'Angelo
6025ecfaa1 QMap: code tidies
Change-Id: I3a88cb2d307a44022df6d6045d99acfc9b1a1a0e
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-12-01 17:39:29 +01:00
Alex Trotsenko
6e07edb260 QProcess/Unix: remove redundant checks in waitForReadyRead()
QProcessPrivate::tryReadFromChannel() returns 'true' only if we emitted
readyRead() signal on the current read channel. Thus, these additional
checks are unnecessary.

Change-Id: Id98620cd08ee8808f60539c009986b869e517ef0
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
2020-12-01 18:39:12 +02:00
Lars Knoll
97abbf3f1f Silence code checker warnings
Pick-to: 6.0
Change-Id: I8bd8d830ade3e194f423e00f180c50b176a8adc8
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2020-12-01 15:03:22 +00:00
Lars Knoll
60ea10e70b Add a way to check whether a metatype has datastream operators
Add QMetaType::hasRegisteredDataStreamOperators() to complement
the method to check whether a data stream operator exists.

Fixes: QTBUG-82916
Change-Id: Ib2f841131b7c401d5a3ae76d49104e41697c4eac
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-12-01 16:01:08 +01:00
Sona Kurazyan
95cea24fa2 Fix memory leaks in QFuture's continuations
There were two issues:

- Some of the continuations were allocating memory for the
continuation's context dynamically, but deleting the allocated memory
only if they were actually invoked. Since the continuations may not be
invoked at all, this could cause memory leaks. Fixed by postponing the
allocations to the point when the continuations need to be invoked.

- In other cases the parent future is captured by copy in the
continuation's lambda, which is then saved in the parent. This causes
the following problem: the data of the ref-counted parent will be
deleted as soon as its last copy gets deleted. But the saved
continuation will prevent it from being deleted, since it holds a copy
of parent. To break the circular dependency, instead of capturing the
parent inside the lambda, we can pass the parent's data directly to
continuation when calling it.

Fixes: QTBUG-87289
Change-Id: If340520b68f6e960bc80953ca18b796173d34f7b
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Karsten Heimrich <karsten.heimrich@qt.io>
(cherry picked from commit 5d26d40a5596be048be87f309df9264bac741be9)
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2020-12-01 15:59:12 +01:00
Giuseppe D'Angelo
b5b2640a65 QHeaderView: fix spurious sorting
QHeaderView sorting may be triggered when the user performs
some mouse interactions that should really not result in sorting.

Generally speaking, this happens when the user:

* presses on a non-movable section (A)
* moves on another section (B)
* releases on that section

resulting in B becoming sorted / flipping sorting.

(Non-movable is required, otherwise dragging would cause section moving,
not sorting.)

To make the matter worse, QHeaderView doesn't check that the release
happens within its geometry. This makes sense when moving sections: one
is able to drag a section horizontally/vertically even if the mouse
leaves the QHeaderView.

But when not moving sections, this means that one can

* press on section (A),
* move the mouse anywhere vertically (for a horizontal bar, mut.mut
  for a vertical) above or below another section (B), that is,
  outside QHeaderView's geometry
* release the mouse

and cause B to be sorted.

Fix it by

1) remembering which one was the section that the user originally
clicked on; that's the only one that can possibly become sorted
(if we're not moving and other conditions hold). No other variable
seemed to remember this.

2) on release, check that it happens within that section's geometry.
If so, sort.

Pick-to: 6.0 5.15
Change-Id: Icfb67662221efbde019711f933781ee1e7d9ac43
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2020-12-01 15:57:10 +01:00
Andreas Buhr
10b6a87679 Fix documentation links to High DPI documentation
The documentation on High DPI was recently rewritten, renaming
several sections. This patch fixes the links which were broken
by this change.

Task-number: QTBUG-88533
Pick-to: 6.0
Change-Id: I5e9417554270a6740986d7cec5e3433d043e5560
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2020-12-01 15:48:53 +01:00
Fabian Kosmale
b21dba98e3 QProperty: Avoid spurious dependencies by suspending binding state
Avoid spurious bindings by resetting the binding state before calling
the setter of eager properties.

Fixes: QTBUG-88999
Pick-to: 6.0
Change-Id: I1e3b5662307d906598335a21d306be9c606529d4
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-12-01 15:06:35 +01:00
Lars Knoll
5494f0af32 Add a note about where to declare the streaming operators
Streaming operators for types used together with QMetaType should
get declared in the same namespace as the type itself because
of C++s ADL rules. Add a note about that to the documentation.

Pick-to: 6.0
Fixes: QTBUG-88990
Change-Id: I5d687576c6d926823dd0f1fec0743e877ae271af
Reviewed-by: Robert Griebl <robert.griebl@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-12-01 14:53:23 +01:00
Andreas Buhr
c4d488eeb9 Fix documentation of QPartialOrdering
qdoc did not find the hidden friend comparison functions at gave
errors like
qcompare.qdoc:82: (qdoc) warning:
clang couldn't find function when parsing
\fn bool operator==(QPartialOrdering p1, QPartialOrdering p2) noexcept
This patch documents them as if they were class members to fix this.

Document the constants as \variables.

Task-number: QTBUG-88533
Pick-to: 6.0
Change-Id: Ife56f16894e454f324060aeb73f66aba2d45e530
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-12-01 14:52:46 +01:00
Alex Trotsenko
80b7ef559a QProcess/Win: improve reading in waitForBytesWritten()
On Windows, tryReadFromChannel() just publishes the data that was
already buffered by the pipe reader. Reading from the pipe was still
possible only because the pipe writer enters an alertable wait state
which can trigger an I/O callback for the read operation as well. This
made the implementation unclear and tied to APC behavior.

To avoid this, we now call the "proper" pipe reader wait function
instead, which also unifies the code with the other waitFor...()
implementations.

Change-Id: I7376d7973477a722472ff8763f95f39e6ea2fce9
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
2020-12-01 15:45:17 +02:00
Mårten Nordheim
fecacfb032 qsocks5socketengine: use qintptr when referring to socket descs
One patch from many years ago already did most of it, but the key of
the hash was still int.

Change-Id: I557fa19d2573addbef7557d1a16fdd6554a117cc
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-12-01 14:42:53 +01:00
Mårten Nordheim
ffea715605 QSocks5SocketEngine: Add missing return on error
Change-Id: I199b7156c280e02c3ce37bd72ba0dc1febf10fe9
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2020-12-01 14:42:53 +01:00
Cristian Adam
7b5fd05e8b CMake: Allow WIN32 and MACOSX_BUNDLE arguments for qt6_add_executable
qt6_add_executable will forward all arguments to add_executable, which
works fine on Windows and macOS in regards of WIN32 and MACOSX_BUNDLE
arguments.

On Android however add_library is being used, and those arguments need
to be removed otherwise they will be consided as source files.

Pick-to: 6.0
Fixes: QTBUG-88926
Change-Id: Id22fdf91d58d9053eaad2d3c080ea72060d928c0
Reviewed-by: Craig Scott <craig.scott@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-12-01 14:24:48 +01:00
Eirik Aavitsland
cfad8a352a Cosmetic stroker: avoid overflows for non-finite coordinates
int overflows are usually avoided by clipping the qreal coordinates to
the device rect. However the clip function did not handle inf or nan
coordinates, so such values would be passed on. Fix by treating any
line with such coordinates a fully clipped away, i.e. rejecting it,
since it cannot be meaningfully stroked anyway.
Fixes oss-fuzz issue 25330.

Pick-to: 6.0 5.15 5.12
Change-Id: I4646172fc7a7e0a3a5f5cf03ce10ff0fb56b0d03
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Reviewed-by: Robert Loehning <robert.loehning@qt.io>
2020-12-01 14:17:36 +01:00
Andreas Buhr
bb3a53d917 Fix documentation of QMetaType::TypeFlag
QMetaType::TypeFlag::IsQmlListType was renamed to
QMetaType::TypeFlag::IsQmlList . This change was not reflected in
the documentation. This patch adapts the documentation to this change.

Task-number: QTBUG-88533
Pick-to: 6.0
Change-Id: I70be218f5f72b42aacb15ecd46972d5c808d86de
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-12-01 14:13:10 +01:00
Assam Boudjelthia
a8f6bad131 CMake: fix indentations in Qt6AndroidMacros.cmake
Pick-to: 6.0
Change-Id: I1403101fb2ab6a25ab1a2258f9a832f706b8b547
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-12-01 15:13:10 +02:00
Assam Boudjelthia
c730a29260 Android: print tailored warning if qml dependency path is a dir
androiddeployqt might be misleading when the path is adir
and the warning says that the file does not exist.

Pick-to: 5.15
Change-Id: I1129f49af58a0637a240fcfd425a61b2ed15c840
Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
2020-12-01 15:13:10 +02:00
Assam Boudjelthia
27dbb3ee54 Android: avoid reflection with ClipData addItem
Task-number: QTBUG-81687
Pick-to: 6.0 5.15
Change-Id: If07fff6f371d2c05cb61a1a7695c96219d0260d2
Reviewed-by: Rami Potinkara <rami.potinkara@qt.io>
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
2020-12-01 13:13:10 +00:00
Assam Boudjelthia
8499718351 CMake: don't add empty QT_ANDROID_APPLICATION_ARGUMENTS to Json
Pick-to: 6.0
Change-Id: I471da3f733046aeaa8381bbdeeba3ee2775b97eb
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-12-01 15:13:09 +02:00
Andreas Buhr
20e341d495 Fix qdoc warning about unknown commands
Qdoc generated warnings like the following:
qt6-changes.qdoc:771: (qdoc) warning: Unknown command '\w'
This patch correctly escapes backslashes to fix these warnings.

Task-number: QTBUG-88533
Pick-to: 6.0
Change-Id: I7849f49fd0e950c3c366cfa88b299f827b39c05a
Reviewed-by: Karsten Heimrich <karsten.heimrich@qt.io>
2020-12-01 14:13:09 +01:00
Ole-Morten Duesund
3c3737f88b Discourage the foreach keyword
Stop endorsing the foreach keyword, suggest C++11 range-based loops
instead.

Task-number: QTBUG-86584
Pick-to: 6.0
Change-Id: Icaf537aded6557b7864d731217e967ac56a84928
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2020-12-01 08:12:09 +00:00
Sona Kurazyan
bc46c7b8ea Fix perfect forwarding of callables in QFuture's continuations
Use universal references instead of rvalue references for passing
callables in the implementations of QFuture's continuations.

Change-Id: I1288c78f78f84f30c6607e505e7f9807a9272071
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
(cherry picked from commit b002722dabef794da0e80010b115b2c6cd6dc6b8)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2020-12-01 08:12:09 +00:00
Fabian Kosmale
a9ba5fe7aa QMetaProperty: Enable constructing only Data
Constructing a QMetaProperty can be unnecessarily expensive due to the
QMetaEnum resolution. Add a private method to construct only
QMetaProperty::Data. Make us of it in indexOfProperty.

Task-number: QTBUG-82931
Change-Id: If954538106bcfaa7d088db26591f6bd6eeaf3731
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-12-01 09:12:09 +01:00
Lars Knoll
1f1a322373 Simplify the safeguarding logic in notify()
The logic in notify() was doing quite a bit more work than
it needed to. By inserting a dummy node after the current one instead of
replacing it, we can avoid half of the data shuffling that has been
happening and also don't need a back pointer when executing the
notification.

Also avoid calling a semi expensive destructor of QPropertyObserver.

Reduces the overhead of notify() by ~30%.

Change-Id: I7ce16bcf9cd9c4368c18bf875fc959223452fd4f
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
(cherry picked from commit e8ef871e3522f340b4efe32382af7e35ef908665)
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2020-11-30 23:02:31 +00:00
Lars Knoll
d555425ff8 Inline the fast path for removeBinding()
Save a function call in the common case where we don't have a binding
This makes a rather large performance difference for setters that do
not have a binding.

Change-Id: I140f29790f6fe868721a33b9fad37205e547b8e9
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit c63901c5f3195596eb81e5f5ae5483ca5a0b6d35)
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2020-11-30 23:02:30 +00:00
Lars Knoll
e095bebaf5 Smaller cleanup in QBindingStorage
Unify code paths and avoid excessive code generation.

Change-Id: I4a54234dd322bba380cc45d4f9c97d97a0c93303
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit 65759c9867321d978c1f98f5cf66bef11c8f5c15)
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2020-11-30 23:02:30 +00:00
Lars Knoll
ba0e012902 Inline the fast path of a few methods
No need to do function calls for the case where we return immediately
after checking a boolean.

Change-Id: I3e449850a10fcf82acb843cce6da6dfd98de32ad
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit e165f416a752398079590161a18255f9a0058a3e)
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2020-11-30 23:02:29 +00:00
Lars Knoll
76743374e7 Remove ExtraBit and FlagMask from QPropertyBindingData
They are not needed and removing it can simplify the code in some places
and avoid a couple of masking operations.

Change-Id: I0e4241a2784026aa89deed35f408b094e89a11a0
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit b1be6e6e6f355bfcb0c3814516f6009c91d2de89)
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2020-11-30 23:02:29 +00:00
Lars Knoll
f538ce920e Inline the QPropertyBindingPrivatePtr destructor
In many cases, it only derefs and does nothing else. Inline the fast
code path.

Change-Id: Ib605c385c1683f7833f7189c84d6cf4eb5b0e59e
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit eda4c29eb26dab32e22040bdda0b9b9109b1408b)
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2020-11-30 23:02:28 +00:00
Lars Knoll
1181286d43 Optimize code in QTaggedPointer
Don't execute instructions that will never do anything.

Directly add the tag to the pointer in the constructor to avoid
additional masking operations, and avoid a masking op that is in
practice a no-op in setTag().

Do the same optimization in QTagPreservingPointerToPointer.

Change-Id: Ia364f89cbe6ccc876ec9bda0c239fc4f57c10501
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit 2721728c9056b442c0281f20792f19eb6a491aa0)
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2020-11-30 23:02:28 +00:00
Lars Knoll
de4a73ebd6 Inline access to the QBindingStorage
And inline the fast checks inside the methods in QBindingStorage.
This allows QObjectBindableProperty and friends to inline all the
fast checks and almost completely eliminates the overhead for property
accesses when no bindings are being used.

Read and write times of QObject based properties when no bindings
are being used:
                                              Read       Write
Old style property:                           3.8ns       7.3ns
QObjectBindableProperty (no notification):    4.5ns       4.3ns
QObjectBindableProperty (with signal):        4.5ns       7.6ns
QObjectBindableProperty (inline accessors):   3.2ns       3.4ns

Numbers without this patch:

Old style property:                           3.8ns       7.9ns
QObjectBindableProperty (no notification):    7.2ns       7.7ns
QObjectBindableProperty (with signal):        7.2ns      16.0ns
QObjectBindableProperty (inline accessors):   6.3ns       6.7ns

Change-Id: Ifd1fa3a489c3be8b1468c0b88af547aac397f412
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit 98c82fb445acf45cc4c4bc86a5adda43358127bf)
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2020-11-30 23:02:27 +00:00
Joerg Bornemann
5592204b19 CMake: Fix QMAKE_LIB of WrapOpenSSLHeaders library
The correct entry for this lib is 'openssl/nolink', not
'openssl_headers'.

In configurejson2cmake's helper.py we already have
this information encoded such that the no_link_so_name field of
'openssl' points to 'openssl_headers'. Extend configurejson2cmake to
take this into account, and re-generate src/network/configure.cmake.

Pick-to: 6.0
Change-Id: I9817ea7722503a373d309b7e6fa201448d403e8d
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-11-30 23:17:50 +01:00
Joerg Bornemann
d4e9f0e633 CMake: Re-generate project files in src
Pick-to: 6.0
Change-Id: I1f5f822d68129490f1a7c495f718aead0b520ca9
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-11-30 23:17:47 +01:00
Timur Pocheptsov
abee4cdd59 QMacStyle - remove vertical adjustment for inactive tab
While it worked as expected with beta, with final release this thing
looks wrong again, especially in the dark mode.

Pick-to: 5.15
Pick-to: 5.12
Change-Id: I6857344de897e0f39d9d8e66431635dbe2f4d077
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2020-11-30 23:11:05 +01:00
Timur Pocheptsov
1158ff67b4 QSslSocket::verify: do not alter the default configuration
QSslCertificate::verify() has an undocumented and not very desirable property -
on some platorms it updates the default configuration, which can be surprising.
For example, we deprecated QSslSocket::setDefaultCaCertificates() and recommend
using QSslConfiguration::defaultConfiguration(), QSslConfiguration::setDefaultConfiguration(),
and QSslConfiguration::setCaCertificates(). If an application does this to select
CA roots it trusts explicitly, and then for some reason is calling verify, the
application can have its QSslSockets successfully connecting to a host, whose
root was not trusted by the application. Also, on Windows, defaultCaCertificates()
include system roots already, no need to have them twice.

[ChangeLog][QtCore][QtNetwork] QSslSocket::verify - do not change the default configuration

Pick-to: 5.15
Pick-to: 6.0
Pick-to: 6.0.0
Fixes: QTBUG-88639
Change-Id: I1cd40b259d0a6dcd15c78d1e7c027ff10859595c
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-11-30 23:11:05 +01:00
Sheng Mao
dbd1c8b047 Let QXcbConnection::getTimestamp properly exit when X server quits
QXcbConnection::getTimestamp uses dummy events to get timestamp from
X server. However, in some cases, X server shuts down while client tries
to get timestamp. In this case, QXcbConnection::getTimestamp keeps
getting null event and thus falls into indefinite loop.

This fix checks if xcb connection is still valid and use a special
xcb_timestamp_t value, CurrentTime (0L), as returned value.
CurrentTime should not be generated by X server and if getTimestamp
returns this value, it means an "exception" case is triggered.

This fix is introduced because in kwin_x11 (KDE project), X server can
exit on logout. kwin_x11 should handle disconnection from X server.
But the indefinite loop prevents kwin_x11 to process disconnection
event and therefore kwin_x11 cannot quit properly.

Fixes: QTBUG-88435
Pick-to: 5.12 5.15 6.0
Change-Id: Iaf7ef3f8a35fa8389d22a608e3c49041bf90e1b9
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Liang Qi <liang.qi@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2020-11-30 23:11:04 +01:00
Liang Qi
92a57e0b01 Revert "xcb: add xcb-util dependency for xcb-image"
This reverts commit 39b1dea2ec.

39b1dea2 is wrong, the bug is for static build of qt with static
xcb. It adds the explicit dependency of xcb-util 0.3.9, which is
not available on Debian yet.

Task-number: QTBUG-86287
Fixes: QTBUG-88688
Pick-to: 5.15 6.0
Change-Id: Iffc821f49bdfcad3f2556951d3677c35a7682266
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2020-11-30 22:11:04 +00:00
Andreas Buhr
d545fbb61b Extend container overview documentation, mention Q_DECLARE_TYPEINFO
The container overview documentation did not mention
Q_DECLARE_TYPEINFO and the related optimizations. This patch
adds a short paragraph about it.

Task-number: QTBUG-86584
Pick-to: 6.0
Change-Id: I5b0b8ce92a47da5f0398cc413fbf3e07b0921e59
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2020-11-30 23:11:04 +01:00
Topi Reinio
99abdd180b Doc: Fix various documentation warnings
- QList iterators are now nested classes inside QList.
- Drop reference to Qt OpenGL Widgets landing page, there is no such
  page.
- Fix typos and linking issues.

Fixes: QTBUG-86295
Pick-to: 6.0
Change-Id: I964843deb81aa55ff8ddb9a1c2b004cb72e68de9
Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2020-11-30 16:16:22 +00:00
Topi Reinio
3789ca6c99 Doc: Fix QVector[2|3|4]D documentation
The \fn commands for friend functions need to include the class
scope for QDoc to find the declarations.

Pick-to: 6.0 6.0.0
Fixes: QTBUG-88932
Change-Id: Icbb45c12d7d657d95243231148483c00baf07c36
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2020-11-30 17:16:22 +01:00
Topi Reinio
af7f7732cb Doc: Document BINDABLE attribute for Q_PROPERTY macro
Pick-to: 6.0
Fixes: QTBUG-87036
Change-Id: Ia6067d887b9b697dbcb8e02bce5a560a8ac5eaf3
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-11-30 17:16:22 +01:00
Fabian Kosmale
5082b84b38 QMetaObjectPrivate: Add firstMethod
QMetaObject::indexfOfMethod returns the method corresponding to a
specific signature. In QML, we however only want any of the methods with
a given name (and do overload resolution at a later point).
For this usecase this patch introduces the internal
QMetaObject::firstMethod function.

Change-Id: Ie3820354edffb273c4cbe1399201a955ebe79344
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-11-30 17:16:22 +01:00
Giuseppe D'Angelo
405244fe30 Fix QVariant/QMetaType::compare APIs
std::optional<int> is the wrong datatype to use for compare.

First and foremost, it can't be used in the idiomatic form of

  auto r = a.compare(b);
  if (r < 0) ~~~ // a is less than b
  if (r > 0) ~~~ // a is greater than b

which we *already* feature in Qt (QString, QByteArray).

Also, std::optional<int> (explicitly) converts to bool, which is
a trap, because the result of the comparison can be accidentally
tested as a bool:

  if (a.compare(b)) ~~~ // oops! does NOT mean a<b

Not to mention extending this to algorithms:

  auto lessThan = [](QVariant a, QVariant b) { return a.compare(b); }; // oops!
  std::ranges::sort(vectorOfVariants, lessThan);

which thankfully doesn't compile as is -- std::optional has
an *explicit* operator bool, and the Compare concept requires an
implicit conversion. However, the error the user is going to face
will be "cannot convert to bool because the operator is explicit",
which is deceiving because the fix is NOT supposed to be:

  auto lessThan = [](QVariant a, QVariant b) { return (bool)a.compare(b); }; // big oops!

Instead: backport to Qt the required subset of C++20's <compare>
API, and use that. This commits just adds the necessary parts
for compare() (i.e. partial ordering), the rest of <compare>
(classes, functions, conversions) can be added to 6.1.

Change-Id: I2b5522da47854da39f79993e1207fad033786f00
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 3e59c97c3453926fc66479d9ceca03901df55f90)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2020-11-30 17:16:22 +01:00
Giuseppe D'Angelo
81e893fb2d QHash: support std::hash as hashing function
In addition (and as a fallback) from requiring qHash, add support
for std::hash specializations. This catches two birds with one stone:

1) users of Qt can simply specialize std::hash for their datatypes,
and use them in both QHash and stdlib unordered associative containers;

2) we get QHash support for any (stdlib) datatype that is hashable
without having to overload qHash for them.

[ChangeLog][QtCore][QHash] QHash, QMultiHash and QSet now support
for key types anything that can be hashed via std::hash, instead of
always requiring a qHash() overload.

Change-Id: Ib5ecba86e4b376d318389500bd24883ac6534c5f
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2020-11-30 17:16:22 +01:00
Giuseppe D'Angelo
5dab710b90 Seedless qHash catch-all: make it SFINAE-friendly
To support qHash overloads without a seed we have a qHash(T, size_t)
catch-all that calls qHash(T) and XORs the seed. The problem is
that this catch-all is not SFINAE friendly. For a type Foo which
does not have any qHash overload, we can't ask if qHash(Foo, size_t)
is callable because it would instantiate the catch-all and fail
to compile.

Add a suitable trait and enable_if.

Pick-to: 6.0
Change-Id: Idffd48a537eebaf77cee7030b8d91a302643ffde
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2020-11-30 17:16:21 +01:00
Giuseppe D'Angelo
d982fdfca4 QHeaderView: allow un-sorting of models
If one clicks on a QHeaderView's section, the header view will
sort the view by the respective column/row. By clicking multiple
times, one is able to toggle the sorting between ascending
and descending. Something that is NOT possible to do however is to
un-sort the view -- that is, to restore the model's original
sorting. This must be done via code, by asking the header or the
view to sort by section -1.

This commit adds new property to QHeaderView to make it possible
to unsort models. Basically, the sort indicator becomes a tri-state:
sort ascending, sort descending, unsort (sort by column -1).

[ChangeLog][QtWidgets][QHeaderView] Added the sortIndicatorClearable
property. Setting this property allows the user to clear the sort
indicator on a section, resetting the model to its default ordering.

Change-Id: Ibf4e280b2086b75ccd64d619ea4d70816dc3529f
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: David Faure <david.faure@kdab.com>
2020-11-30 18:16:21 +02:00
Andreas Buhr
0440614af0 Replace discouraged Q_MOVABLE_TYPE by Q_RELOCATABLE_TYPE
Q_MOVABLE_TYPE was conceived before C++ had move semantics. Now, with
move semantics, its name is misleading. Q_RELOCATABLE_TYPE was
introduced as a synonym to Q_MOVABLE_TYPE. Usage of Q_MOVABLE_TYPE
is discouraged now. This patch replaces all usages of Q_MOVABLE_TYPE
by Q_RELOCATABLE_TYPE in QtBase. As the two are synonymous, this
patch should have no impact on users.

Pick-to: 6.0
Change-Id: Ie653984363198c1aeb1f70f8e0fa189aae38eb5c
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2020-11-30 17:16:21 +01:00
Alexandru Croitor
908ee750ed CMake: Fix resource object file paths in prl files for prefix builds
Before this change, the prl files always assumed that resource object
files are installed into $qt_prefix/lib when doing a prefix build.
That was true for qt_internal_add_resource calls, but not for
qt6_add_qml_module and qt6_target_qml_files.

Change qt_internal_record_rcc_object_files to take a new required
INSTALL_LOCATION argument. The argument takes a path relative
to CMAKE_INSTALL_PREFIX.

Modify __qt_propagate_generated_resource to save the relative path of
the generated resource source file, which will be used in the
computation of the final resource object file location.
This is needed because the Qml resource functions place the source
files in a different directory layout, e.g. .rcc vs .qmlcache

Modify qt_generate_prl_file to prepend $$[QT_INSTALL_PREFIX]/
instead of $$[QT_INSTALL_LIBS]/ for the resource install paths.

A follow up patch is done in qtdeclarative to pass the new
INSTALL_LOCATION argument from the Qml CMake functions.

Amends f9dcade5e7

Task-number: QTBUG-87702
Task-number: QTBUG-88425
Change-Id: Id17bb517b4cb5d00911bfd10a728ba4e0d44871b
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
(cherry picked from commit 54d0ca93bca78f8fd31b6761f078e7a96283f183)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2020-11-30 16:16:21 +00:00
Alexander Volkov
68de00e0d4 QStandardPaths: Don't change permissions of XDG_RUNTIME_DIR
Conform to the XDG Base Directory Specification:
"If, when attempting to write a file, the destination directory
is non-existent an attempt should be made to create it with
permission 0700. If the destination directory exists already
the permissions should not be changed."

At the same time the spec states about XDG_RUNTIME_DIR that
"its Unix access mode MUST be 0700", so don't consider the
directory with wrong permissions correct and use a fallback.

Task-number: QTBUG-68338
Pick-to: 5.15 5.12
Change-Id: I03c6b35b3f7d5ceb8e6326695bfc8207da92ea67
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: David Faure <david.faure@kdab.com>
2020-11-30 19:16:21 +03:00