Commit Graph

39766 Commits

Author SHA1 Message Date
Morten Johan Sørvig
d62e9d3c5b Compile: Work around false positive on gcc >= 900
Change-Id: Id9d2c968322963af6a2e31f0d9e4195120d0b5ea
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-11-19 19:26:49 +01:00
Morten Johan Sørvig
0d12c9f354 wasm: remove unused variable
Change-Id: I442e3dc4534193709c3510c43a484e5d3c2eb4af
Reviewed-by: David Skoland <david.skoland@qt.io>
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
2021-11-19 19:26:48 +01:00
Joerg Bornemann
68600869cd Link printer plugins into user projects when using a static Qt
When building a user project against a static Qt on Windows or macOS the
static printer support plugins were not linked.  Move the
Q_IMPORT_PLUGIN statements to qplatformprintplugin.cpp, which is a
translation unit that is guaranteed to be linked into the user project.

Pick-to: 6.2
Fixes: QTBUG-97490
Change-Id: Ic35c6483a664a06461304c7e8a2b7b06ce651ed6
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-11-19 18:48:07 +01:00
Alexey Edelev
a41d9bcac9 Fix generating of Android deployment config in Multi-Config build
Add the config-specific suffix to the generated Android deployment
config file.

Amends d20f4ae706

Change-Id: If1755baf5548adb4d95733477d8b5af85e1fd2dd
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-11-19 18:48:07 +01:00
Joerg Bornemann
04ec14105e Change qt.conf key Qml2Imports to QmlImports
[ChangeLog][qt.conf] The key Paths/Qml2Imports has been renamed to
Paths/QmlImports. For backwards-compatibility, Paths/Qml2Imports is
still accepted and acts as default value for when Paths/QmlImports is
not present.

Fixes: QTBUG-98335
Change-Id: If7ffedd281eb8a87e8ab1a2b69a823e615c33541
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
2021-11-19 16:44:32 +01:00
Marc Mutz
a3303aceeb QLoggingRegistry: avoid double-lookup
The code used the if (!contains()) { insert() } anti-pattern,
necessitated by Qt's deviation from the STL of allowing insert() to
overwrite an existing entry, causing two lookups of the same key.

Fix by recording the size prior to the execution of the indexing
operator and taking a size increase as the cue to populate the (new)
entry. This way, we look up the key only once.

Change-Id: Ica039035fe9ea4b88c20184784c324c9fac33d49
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
2021-11-19 16:28:45 +01:00
Marc Mutz
7fe5611365 QHash: optimize value(key) and key(value) callers
... by not injecting potentially-expensive temporary objects into the
caller's stack frame.

Default arguments are a convenient way to avoid overloads, but if the
defaulted argument isn't a Trivial Type, and the common use case is
not to pass the extra argument explicitly, the construction of the
temporary can dominate the call's runtime.

Since QHash is generic code, we don't know whether T or Key are
expensive or cheap to construct, so use overloading instead of default
arguments to avoid injecting needless code into call sites.

[ChangeLog][QtCore][Potentially Source-Incompatible
Changes][QHash/QMultiHash] The value(key) and key(value) functions are
now overloaded on presence of the defaultValue (was: defaulted
argument) to avoid injecting temporary objects into the caller's stack
frame.

Task-number: QTBUG-98117
Change-Id: I80fdd5436f3de3e4bbe20242fe45916aef62ff0c
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-11-19 16:28:44 +01:00
Edward Welbourne
14b0e2fb1e Prefer QBAV over raw char * form of qt_configure_strs
Passing the QByteArrayView to QString::fromLocal8Bit() ensures we tell
it the size and saves a strlen(). Quite apart from avoiding some
misguided grumbles from compilers, this save searching for a '\0' when
we already know where it is.

Change-Id: I2e3f2edfb4d3bdf488374570567d1dd30641ebc3
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-11-19 16:28:44 +01:00
Nicholas Bennett
a4dca9936d Docs: Move manifest and androiddeployqt docs to where code lives
Removed content describing androiddeployqt from deployment-android.html
to androiddeployqt.html,the qdoc source now living in qtbase.
Docs src locations added to the qtcore.qdocconf.

Task-number: QTBUG-97842
Pick-to: 6.2
Change-Id: I94783520280098ce1ab35f335a644bea70b8131a
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2021-11-19 12:18:50 +00:00
Kai Köhne
426b2cae7c Remove unneeded int conversions in qmetatype.h
They were added in Qt 5, where QByteArray::reserve() was an int
argument, and qstrlen() was returning an int. In Qt 6, both
accept and return qsizetype/size_t.

As a side effect, this fixes various informational messages when
loading a Qt project into Visual Studio 2022:

  lnt-arithmetic-overflow: A sub-expression may overflow before being assigned to a wider type.

Pick-to: 6.2
Change-Id: Ifc9a1f7046a78bcfb97fe241d697c1bf91c6ba4f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-11-19 12:18:50 +00:00
Eirik Aavitsland
4f69a1e1d2 Clean up line clipping code in rasterizer
Replace old code with the line clipper from qcosmeticstroker.

Also avoids tripping some issue with the current clang 13 that would
cause paint errors on macOS.

Fixes: QTBUG-98403
Fixes: QTBUG-98388
Pick-to: 6.2 6.2.2
Change-Id: I257eeec6f71153ec51b4176df3be8c443938484c
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2021-11-19 12:40:10 +01:00
Mårten Nordheim
919f5bd459 QOperatingSystemVersion: Add Windows11
Change-Id: Ieb7674bbbbc78689f1e2a1e5a06dfd4d0ce25ac1
Reviewed-by: Yuhang Zhao <2546789017@qq.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-11-19 09:14:34 +01:00
Marc Mutz
b7f4041669 QAnyStringView: fix broken implicit conversion from QStringBuilder
Need to use QConcatenable<>::ConvertTo for SFINAE, the forwarded type
alias in QStringBuilder itself doesn't work.

[ChangeLog][QtCore][QAnyStringView/QStringBuilder] Implicit conversion
from QStringBuilder to QAnyStringView now works as advertised.

Pick-to: 6.2
Fixes: QTBUG-98138
Change-Id: I1c300675cf43b13017bc56398ae5d8c1c51e64fe
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-11-19 03:32:20 +01:00
André de la Rocha
8283df4d8c Windows QPA: Fix multi-touch support in some devices
Some multi-touch devices send touch information for each finger using
different WM_POINTER messages/frames, instead of a single one with
a list of touches, like most devices. This would result in the generation
of multiple touch events, which can cause unexpected behavior in
applications (the QTouchEvent documentation specifies that it should
contain all simultaneous touches). This patch adds a workaround to
ensure all simultaneous touches are included in the events, to comply
with the expected behavior.

Pick-to: 6.2 5.15
Change-Id: I12a2f84b35a6bdd49ee53d25de580c0941a9aea6
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2021-11-18 23:41:02 +01:00
Tor Arne Vestbø
3cc1a32f97 Clarify validity of image returned from QPlatformBackingStore::toImage()
The backingstore may reconfigure the internal data, so clients should
not assume that the image is valid beyond any new operations on the
backingstore.

Pick-to: 6.2
Change-Id: I137ad4f2adb45ec8bb78a989fbb5bac1e72965ce
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2021-11-18 23:41:02 +01:00
Tor Arne Vestbø
71f75bf6c5 xcb: Don't mark scrolled area as flushed when doing client side scroll
The m_pendingFlush variable is used to track what is missing in the
server side backingstore. If we're doing a client side scroll the
pending area is still the same.

If we were to always discard the scrolled area from m_pendingFlush
we would get in trouble on the next non-client side scroll, as
we think the content exists server-side.

Pick-to: 6.2
Change-Id: Ie50a99a8e5d8a83d1299c53534a1c83c6bfb47bd
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2021-11-18 23:41:02 +01:00
Tor Arne Vestbø
12af9ce6db xcb: Ensure we have pixmap GC before trying to flush to it during scroll
Pick-to: 6.2
Change-Id: Icc85b1eb830d8d9b1b2bfb8b9998470388522832
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2021-11-18 23:41:02 +01:00
Tor Arne Vestbø
709a932d7b xcb: Prepare correct area when doing client side backingstore scroll
The area we're going to fill is the one after applying the scroll delta.

Pick-to: 6.2
Change-Id: I254830a15e5f4c93ba28ed8f0a9b35c40f1d1af2
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2021-11-18 23:41:02 +01:00
Eskil Abrahamsen Blomfeldt
7102aa6b15 Fix assert in QFontComboBox when setting empty font
Don't crash if the font does not have any families set.

Pick-to: 6.2
Task-number: QTBUG-97995
Change-Id: I8dc2f2fc00309b6fff6d4a661ec6d659f30808af
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
2021-11-18 23:41:02 +01:00
Eskil Abrahamsen Blomfeldt
71faedc5b4 Fix deserializing Qt 5.x fonts through QDataStream
In Qt 5, fonts had both singular family and plural families properties,
and both were stored separately when streaming through QDataStream. The
families list was treated as an extension of family in this case, and
the primary font family was always the singular family property.

In Qt 6, it has been merged into one and family() is now just a
convenience for families().at(0).

But when reading files generated with Qt 5, we would ignore the fact
that these were previously separated. We would first read the family
entry into the families list, and then we would later overwrite this
with  an empty families list.

Instead, we detect streams created with Qt 5.15 or lower and make sure
we append the families list instead of overwriting it in this case. In
addition, we need to make sure we split up the list again when
outputting to Qt 5.x.

This adds a file generated with QDataStream in Qt 5.15 to the test to
verify.

[ChangeLog][Fonts] Fixed a problem deserializing the family of fonts
that had been serialized using QDataStream in Qt 5.

Pick-to: 6.2
Fixes: QTBUG-97995
Change-Id: Id3c6e13fc2375685643caee5f8e3009c00918ccb
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
2021-11-18 23:41:02 +01:00
Volker Hilsheimer
4bee9cdc0a macOS: Fix QSlider's knob positioning on Monterey
QMacStyle has a single NSSlider that is used to render any QSlider. For
each QStyle API operating on a slider, the style sets the slider up with
respecive properties. On macOS 12, the NSSlider maintains some states
that make QSlider instances influence each other's knob position when
rendering, resulting in uncontrollable jumping of the slider.

This can be fixed by not using startTrackingAt/stopTracking APIs, which
are however the only way we have to make the slider knob get rendered
pressed - there is no property in NSSlider(Cell), and none of the NSCell
attributes have any effect. So we need to use startTrackingAt, and work
around the side effect by reinitializing the NSSlider by calling
initWithFrame.

This fixes the positioning error, but also causes flickering of the knob
when dragging. To fix the flickering, we have to always call
startTrackingAt for a slider that is pressed, even for calls to
setupSlider that are made in QStyle APIs that are not drawing anything.

Also tried with no complete success (either positiong bug or flicker):
* call prepareForReuse on the NSView
* always call stopTracking on the NSSlider

Fixes: QTBUG-98093
Pick-to: 6.2 6.2.2
Change-Id: I3423b9f7cb125a59831c6722509ab3b74742b6ae
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2021-11-18 22:06:21 +00:00
Volker Hilsheimer
b3dc0fec2b Add operating system version for macOS 12 "Monterey"
With pre-11 SDKs, macOS reports version 10.16, which already matches
BigSur, so we only match Monterey if version 12 is reported.

Change-Id: I37fee43756310370444981212750cdfe7fad64b8
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-11-18 22:53:21 +01:00
Mike Achtelik
f7fd57075b Introduce Q_APPLICATION_STATIC
QObjects must be deleted if the QCoreApplication is being destroyed.
This was previously done by implementing custom code in qtbase and
other modules. So unify it and introduce a Q_APPLICATION_STATIC,
based on the Q_GLOBAL_STATIC, which centralises the logic.

Since we still have a few remaining living QObjects,
this comes in handy to fix those as well.

Task-number: QTBUG-84234
Change-Id: I3040a2280ff56291f2b1c39948c06a23597865c4
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-11-18 20:53:27 +01:00
Allan Sandfeld Jensen
1a8b7eb1d4 Increment reference count when restoring reference
Otherwise the count will be wrong after an out of memory failure in
reinterpretAsFormat.

Pick-to: 6.2 5.15
Fixes: QTBUG-98377
Change-Id: Ice51d47a6db9277126a5c7337e14aaf5ddee3a10
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2021-11-18 20:46:41 +01:00
Lucie Gérard
fb33e2a8e8 Add missing QT_TRID_N_NOOP definition
Amends c74bd2b93, properly following up on qttools/bc47b5190.

[ChangeLog][QtCore] Added missing QT_TRID_N_NOOP() macro. Lupdate
actually recognizes it since Qt 5.12.

Fixes: QTBUG-98277
Fixes: QTBUG-3945
Change-Id: I0ea15ceb49b2ead5c8bb40d2a55a0ae8577e8850
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
2021-11-18 18:13:21 +01:00
Edward Welbourne
4515c5e4fc Use a QVarLengthArray for FatalSignalHandler's alternate stack
The stack needs to be at least SIGSTKSZ, which isn't constexpr, so we
can't allocate it at compile time. However, we can resize(SIGSTKSZ) a
QVarLengthArray that's probably big enough anyway. At the same time,
increase the compile-time size to 32k, to match what our Catch2
harness for the self-test uses.

Change-Id: I3a34ece73901dd402672cd6fe4da66923f1932c8
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-11-18 18:13:20 +01:00
Edward Welbourne
2ad5fd36fb Rework FatalSignalHandler to use ranged-for loops over signals
Shrinks the const array by one zero-terminator and makes the code
accessing it read more gracefully.

Change-Id: I4034116a83ff3cd05ea0feb0ce8a4340c54a9faa
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-11-18 18:13:20 +01:00
Edward Welbourne
771657e55f Test the return from sigaction()
If we fail to install our own action, the contents of oldact are noise
anyway, so we can't use them to decide anything; and, in any case, we
didn't replace the prior action, so have no duty to restore it.

In the process, restructure and comment the code to make it easier to
follow what's going on and why. Package a conditional in a lambda to
make the #if-ery less problematic. This should also make it easier to
hack any other complications into the condition, should they arise.

Change-Id: I712335ee27f68a8594dc2fe6441a91f686967da2
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-11-18 18:13:20 +01:00
Edward Welbourne
f75d36fd18 Fix macOS system locale's formatting of negative years
It leaves off the minus sign.

Change-Id: Iad72349368d8849330524144033453cbd79e9e7c
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2021-11-18 18:13:20 +01:00
Edward Welbourne
8926eb86c6 Fix formatting of dates before 1601 in MS system locale
The relevant MS system calls (say they) don't support date formatting
for years < 1601 (but apparently do in fact) and the year field of the
data structure is unsigned, so can't support years < 0. As a result,
the windows back-end for QSystemLocale failed for negative years.
So replace year < 1601 with a place-holder and substitute after
formatting.

Added new tests (based loosely on one in qtdeclarative that failed) to
verify that this actually works. These reveal that macOS also fails to
handle negative years; marked as expected failure there pending a fix.

Change-Id: I9b63cefd5f0b77a39cf1238549412de3e26ca1bd
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-11-18 18:13:20 +01:00
Edward Welbourne
2bf5a60bfa Remove some spurious prefixes in declarations
The parameter-list of a method is already in its class's context, so
doesn't need it made explicit on the other class members involved.

Change-Id: I253b098ad1f2d2db80d49d8f484b7f95d14acec1
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2021-11-18 18:13:20 +01:00
Edward Welbourne
8dea25d501 Add a note on the sign of daylight-saving offsets
Given that at least one zone has a negative offset (so that it's in
standard time for most of the year, including summer, and
daylight-saving time relatively briefly during winter), QTimeZone's
docs should explain what that means.

Change-Id: I6649b4cdefbd685dc97bf85d957960da44d07aed
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2021-11-18 18:13:20 +01:00
Edward Welbourne
b9021ed1f7 Eliminate a constant from qtimezoneprivate_win.cpp
Its MIN_YEAR was duplicating what's now provided by
QDateTime::YearRange::First, so use that instead.
In the process, tidy up an over-long line.

Change-Id: I109f5435f63cb5cc97d54529a172b640f919dec0
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-11-18 18:13:20 +01:00
Edward Welbourne
28088a3d74 Remove some unused constants from qtimezoneprivate_win.cpp
Recent commit 6845c444d0 elicits
warnings about two unused constants. Remove an unused macro at the
same time, and add missing LL suffix to remaining qint64 constants.

Change-Id: I4c84e10b512030e0e4f860d434382e62e6c936f5
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-11-18 18:13:19 +01:00
Marc Mutz
dca63b6ef6 QIODeviceBase: make dtor protected
Base class dtors should be virtual and public or else protected and
non-virtual. This one was neither of these.

[ChangeLog][Potentially Source-Incompatible Changes][QtCore] The
QIODeviceBase destructor is now protected to avoid deleting objects of
classes derived from it through a QIODeviceBase pointer, which would
be undefined behavior.

Change-Id: Id390ace75d5b64f746d9b1865b8800c9f0590977
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-11-18 17:13:19 +00:00
Ievgenii Meshcheriakov
0fa6e6b0ab QFileSystemEngine: Fix permissions query in Windows backend
Make fillPermissions() correctly set OtherExecutePermission
instead of OwnerExecutePermission.

Pick-to: 6.2
Change-Id: I77ef3c5bc59ac6110c5a461a599d03029c70493c
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-11-18 17:12:27 +01:00
David Schulz
35263fffea Always check keyboard modifiers when generating mouse events
This is basically a revert of: 634ce491e8

The cached keyboard modifier can get out of sync when switching to
another application while a modifier is pressed. In this case we get a
key press event but we might not get the key release event, which is
expected to reset the cached modifier. Switching back to the Qt
application after the modifier was released now still has the old
modifier cached.

Most prominent example is triggering alt + tab to switch to another
application and use the mouse to get back to it. In this case the alt
modifier is still cached.

Task-number: QTCREATORBUG-26581
Pick-to: 6.2
Change-Id: I9d64b7d730af089778bd1a4b3f1296bcccd5d16d
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-11-18 06:44:26 +01:00
Yuhang Zhao
16aa4eaa82 QOperatingSystemVersion: Add Win10 sub-versions
Change-Id: Icce32a17f285f0a0416ad8a7838a7424cda2bc2b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-11-18 13:34:49 +08:00
Edward Welbourne
3b84187cd1 Fix leak in date and time formatting on macOS
CFDateFormatterCreateStringWithDate() creates a CFStringRef that we
need to tidy up once we're done with it, so use the QCFType template
to take care of that.

Change-Id: Ibc3751426cc4496bce25307918fdb11722cde3b2
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2021-11-18 04:36:24 +01:00
Tor Arne Vestbø
a8a003aba2 Build ODBC driver as universal binary on macOS
Task-number: QTBUG-93204
Pick-to: 6.2
Change-Id: Ia373f41dbf247c8a5844ae365701bc457cfba79d
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-11-18 04:36:24 +01:00
Povilas Kanapickas
b00fe3c9aa CMake: Enable -bundled-xcb-xinput by default
This is done by disabling system-xcb-xinput feature by default. It will
require user to pass -no-bundled-xcb-xinput to the configure script to
override this.

The reason for the change is that touchpad gesture implementation
requires new code from libxcb, yet this new code is not even released
yet. Even if it was released today, at least several years will pass
until the new version is common enough.

[ChangeLog][Third-Party Code][X11] The xcb plugin is now compiled with
the bundled xcb-xinput library by default, in order to enable support
for touchpad gestures.

Change-Id: Iebb27ecee7facf070ef23f37a55aab0578698f16
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2021-11-18 02:32:58 +02:00
Marc Mutz
536471106d QAbstractFileEngine: fix UB (data race) on qt_file_engine_handlers_in_use
While all writers of the variable hold fileEngineHandlerMutex for
writing, the qt_custom_file_engine_handler_create() function checks
the value before entering a fileEngineHandlerMutex read-side critical
section, thereby causing a C++11 data race.

Fix by making the variable atomic. Interestingly enough, relaxed
atomic operations suffice here, since the actual synchronization
happens in read- and write-side critical sections, and if
qt_file_engine_handlers_in_use is wrong w.r.t. to the actual list, the
critical sections will still work. We just mustn't cause UB by reading
and writing to a simple bool without proper synchronization.

Pick-to: 6.2 5.15
Change-Id: I30469504cdbc90e2ab27125181e53d74305f13fd
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-11-16 21:16:28 +01:00
Marc Mutz
06dfbdf081 QItemSelection: fix (some) O(n²) behavior in merge()
Instead of taking a copy of the incoming data, followed by a quadratic
modifying algorithm (single-element erase loop), guaranteeing a
deep-copy detach of the original, just iterate over the incoming data,
building the new dataset by appending only valid items.

Also port to ranged for loop.

There's more quadratic behavior in that function, later on, but that's
for another patch.

Change-Id: I284f3b7c9694c8eb226a198f6f97538765113b19
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-11-16 20:37:32 +01:00
Eirik Aavitsland
997c052db9 Reject truncated and corrupt ascii pnm images
In contrast to the binary decoder code, the ascii decoder would not
abort and fail on premature end of file.

Pick-to: 6.2 6.2.2 5.15 5.12 5.12.12
Change-Id: If27bce0afa8d1de6c4dbeb2bc0e623c1dcc2f1e0
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-11-16 18:54:32 +00:00
Tor Arne Vestbø
99bb78f6c2 macOS: Clear NSOpenGLContext drawable when QNSView is about to go away
Calling doneCurrent() on a QCocoaGLContext only clears the current
context, but doesns't reset the drawable (view) of the context. In
most cases this is fine, but it has been observed to cause issues
when using the software GL renderer on Big Sur and above.

To be a good citizen we clear the drawable of any of our contexts
that are tied to the NSView this about to be go away.

Pick-to: 6.2 6.2.2
Change-Id: I8c845727c50871f30fbebc2ed62a7d0485651ecf
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2021-11-16 18:54:32 +00:00
Kai Köhne
550e02b809 Make missing xmlstarlet command just a status message
We don't list xmlstarlet in the install documentation, also
because the affect on code size is not too big. We therefore
also don't print a CMake warning then.

Pick-to: 6.2
Change-Id: Ifad3ef0106d09640a7c7d1736f4d5382bcf18e35
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-11-16 18:37:38 +01:00
Kai Köhne
b99adf7a81 Do not include qloggingcategory.h in public headers
Reduce overhead for including qguiapplication.h by splitting
up qnativeinterface.h into a public and a private part.

[ChangeLog][Potentially Source-Incompatible Changes] The
qguiapplication.h header no longer implicitly includes
qloggingcategory.h. If your code depends on the transitive
include, explicitly include <QLoggingCategory> where needed.

Pick-to: 6.2
Task-number: QTBUG-97601
Change-Id: Ic02327a1c3092e21730160af5c59a9d58dc1239c
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-11-16 17:26:04 +00:00
Zhang Hao
9a131b59ee QFontComboBox don't response qApp fontDatabaseChanged()
If QFontComboBox is instantiated in the form of new and call
QFontDatabase::addApplicationFont, QFontComboBoxPrivate::_q_updateModel()
will be called when the program exits, at this time qApp will crash.
Fix this by when program exiting, QFontComboBoxPrivate don't need
call _q_updateModel().

Fixes: QTBUG-98099
Done-With: Konstantin Ritt <ritt.ks@gmail.com>
Pick-to: 5.15 6.2
Change-Id: I3df3d19c3d1971288d60f2eef386262befbf396b
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2021-11-16 17:21:56 +08:00
Giuseppe D'Angelo
78a8e561b2 QRegularExpression: do not mark as dirty on no-op setters
Quite some code in Qt takes a copy of a QRegularExpression and then
changes something on it (e.g. the case sensitivity) based on some
other criteria:

  QRegularExpression copy = orig;
  if (cond)
    copy.setPatternOptions(copy.patternOptions() | CaseInsensitive);
  use(copy);

This pattern can be found in QAIM, QString-related classes, and so on.
The "problem" is that if the attempted modification is a no-op, we'd
still invalidate the copy object (by detaching). Even if no detaches
are involved, setting the same pattern or options on a QRE object
shouldn't require a relatively expensive pattern recompile.

In summary: don't detach/mark a QRE object as dirty if a setter didn't
actually do a modification.

Change-Id: Iae0ab4a5e443e7285a83d3d7e0f1dcfd66e8d51d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-11-16 10:21:09 +01:00
Marc Mutz
0b3f4f8f5a QReadWriteLock: replace a QHash with a QVarLengthArray<., 16>
The QHash was used to track the recursion level of concurrent
readers. But it makes no sense to optimize this data structure
for O(1) lookup speed, since once you go beyond a few threads,
a mutex-based solution falls apart, anyway.

So use an unordered QVarLengthArray with preallocated capacity
16 instead. Lookup and erasure are now O(N), but tracking the
first 16 threads that concurrently lock this shared mutex for
reading no longer allocates memory (except for the Private
class that contains the data structure).

Results on my machine (recursive only):

  thread count: 16
  ********* Start testing of tst_QReadWriteLock *********
  Config: Using QtTest library 6.3.0, Qt 6.3.0 (x86_64-little_endian-lp64 shared (dynamic) release build; by GCC 11.2.1 20211101), ubuntu 20.04
  [...]
   PASS   : tst_QReadWriteLock::uncontended(QReadWriteLock, read, recursive: 1)
   RESULT : tst_QReadWriteLock::uncontended():"QReadWriteLock, read, recursive: 1":
  -     51 msecs per iteration (total: 51, iterations: 1)
  +     38 msecs per iteration (total: 77, iterations: 2)
   PASS   : tst_QReadWriteLock::uncontended(QReadWriteLock, write, recursive: 1)
   RESULT : tst_QReadWriteLock::uncontended():"QReadWriteLock, write, recursive: 1":
  -     31 msecs per iteration (total: 62, iterations: 2)
  +     29 msecs per iteration (total: 58, iterations: 2)
   PASS   : tst_QReadWriteLock::uncontended(QReadWriteLock, read, recursive: 2)
   RESULT : tst_QReadWriteLock::uncontended():"QReadWriteLock, read, recursive: 2":
  -     89 msecs per iteration (total: 89, iterations: 1)
  +     75 msecs per iteration (total: 75, iterations: 1)
   PASS   : tst_QReadWriteLock::uncontended(QReadWriteLock, write, recursive: 2)
   RESULT : tst_QReadWriteLock::uncontended():"QReadWriteLock, write, recursive: 2":
  -     62 msecs per iteration (total: 62, iterations: 1)
  +     56 msecs per iteration (total: 56, iterations: 1)
   PASS   : tst_QReadWriteLock::uncontended(QReadWriteLock, read, recursive: 32)
   RESULT : tst_QReadWriteLock::uncontended():"QReadWriteLock, read, recursive: 32":
  -     1,357 msecs per iteration (total: 1,357, iterations: 1)
  +     1,154 msecs per iteration (total: 1,154, iterations: 1)
   PASS   : tst_QReadWriteLock::uncontended(QReadWriteLock, write, recursive: 32)
   RESULT : tst_QReadWriteLock::uncontended():"QReadWriteLock, write, recursive: 32":
  -     1,067 msecs per iteration (total: 1,067, iterations: 1)
  +     984 msecs per iteration (total: 984, iterations: 1)
  [...]
   PASS   : tst_QReadWriteLock::readOnly(QReadWriteLock, recursive: 1)
   RESULT : tst_QReadWriteLock::readOnly():"QReadWriteLock, recursive: 1":
  -     11,561 msecs per iteration (total: 11,561, iterations: 1)
  +     6,704 msecs per iteration (total: 6,704, iterations: 1)
   PASS   : tst_QReadWriteLock::readOnly(QReadWriteLock, recursive: 2)
   RESULT : tst_QReadWriteLock::readOnly():"QReadWriteLock, recursive: 2":
  -     16,173 msecs per iteration (total: 16,173, iterations: 1)
  +     13,053 msecs per iteration (total: 13,053, iterations: 1)
   PASS   : tst_QReadWriteLock::readOnly(QReadWriteLock, recursive: 32)
   RESULT : tst_QReadWriteLock::readOnly():"QReadWriteLock, recursive: 32":
  -     178,597 msecs per iteration (total: 178,597, iterations: 1)
  +     146,008 msecs per iteration (total: 146,008, iterations: 1)
  [...]
   PASS   : tst_QReadWriteLock::writeOnly(QReadWriteLock, recursive: 1)
   RESULT : tst_QReadWriteLock::writeOnly():"QReadWriteLock, recursive: 1":
  -     65,165 msecs per iteration (total: 65,165, iterations: 1)
  +     64,503 msecs per iteration (total: 64,503, iterations: 1)
   PASS   : tst_QReadWriteLock::writeOnly(QReadWriteLock, recursive: 2)
   RESULT : tst_QReadWriteLock::writeOnly():"QReadWriteLock, recursive: 2":
  -     70,665 msecs per iteration (total: 70,665, iterations: 1)
  +     69,812 msecs per iteration (total: 69,812, iterations: 1)
   PASS   : tst_QReadWriteLock::writeOnly(QReadWriteLock, recursive: 32)
   RESULT : tst_QReadWriteLock::writeOnly():"QReadWriteLock, recursive: 32":
  -     50,811 msecs per iteration (total: 50,811, iterations: 1)
  +     57,659 msecs per iteration (total: 57,659, iterations: 1)

Recursive mode is really, really expensive, even with this patch applied.

Change-Id: I36a164cf09462b69dce7e553f96afcebb49e3dbf
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-11-16 06:46:48 +01:00
Marc Mutz
98bb6d23a1 QString: prefer sliced() over mid() in split-like functions
These algorithms never call mid() with funky values, so they don't
need the mid() side-cases, and associated 7-branch deep conditionals.

Just use sliced().

Change-Id: I05b6a0e47da90f09b34a92211f7e783a2db709f7
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-11-15 23:37:31 +01:00
Ulf Hermann
1ea1e0d7f3 Document QLibraryInfo::Qml2ImportsPath as deprecated
Also, add a TODO for migrating to QmlImportsPath in qt.conf.

Task-number: QTBUG-98335
Change-Id: I3c321c99c6286ba64eef643876f5b56d5a8ca695
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-11-15 21:41:43 +01:00
Assam Boudjelthia
dfb4b7856a Android: check if objectClass() is not null in registerNativeMethods()
In case the class doens't have a default constructor, checking for
object.isValid() will give false because the object won't be created,
however, the class could still be loaded and we could have a valid
jclass.

Pick-to: 6.2
Fixes: QTBUG-96069
Change-Id: I8d59e26d9d7c0e8e363ce443937091a374a24473
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2021-11-15 19:00:21 +00:00
Edward Welbourne
f3e2689106 Revise (recently-added) yearSharingWeekDays() to take a QDate
This lets it avoid a two-digit year that would clash with month or day.
That shall make fixing up system locale date formatting run cleaner.

Add a test for QGregorianCalendar's two extensions.

Change-Id: I77083ff9d5e4035763250904a59fcf416286545b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-11-15 20:00:21 +01:00
Tor Arne Vestbø
e6364f9c9c Build PostgreSQL driver as universal binary on macOS
Task-number: QTBUG-93204
Pick-to: 6.2
Change-Id: I3e7c76411a7bebee9105a9d97b6ca2c4128a8ddc
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-11-15 19:02:07 +01:00
Volker Hilsheimer
22634e0079 Make sure we paint overlapped children and siblings when moving far
In paintAndFlush, QWidgetRepaintManager subtracts opaque children if
the target isn't overlapped and isMoved is set to true. So in moveRect,
set isMoved to true after the blitting of movable areas, and reset it to
false if we have overlapped sibling or child regions. Otherwise, moving
so far that sourceRect is invalid (none of the original pixels are
visible after the move) we end up in a code path that sets isMoved to
true even with overlapping children or siblings, which then breaks
paintAndFlush's assumptions.

Reuse the test case written by Sergiy Korobov <tiamatenko@gmail.com> in
earlier attempts to fix this bug.

Fixes: QTBUG-26269
Pick-to: 6.2
Change-Id: If7443863f5eee79a80220cd587522122f42a21e4
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2021-11-15 18:25:50 +01:00
Povilas Kanapickas
9879d41d05 xcb: Implement support for touchpad gestures
They map to the data exposed by libinput exactly the same way as
touchpad gestures on Wayland. The implementation is functionally the
same and follows the same patterns to preserve similar behavior across
X11 and Wayland.

For example, we use the last known pointer position as the position for
gestures, even though on X11 this data is available as part of events.

The new implementation is only enabled if the used xcb supports the
required APIs.

[ChangeLog][Platform Specific Changes][X11] Touchpads can now detect
multi-finger gestures and send RotateNativeGesture, ZoomNativeGesture
and PanNativeGesture events, since XInput 2.4 and X Server 21.1.

Change-Id: If404dcf8385210deadeb7e7c6d29171e9abc9e50
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2021-11-15 15:51:14 +00:00
Li Xi
a0e7fbd4d5 Test result of qobject_cast before dereferencing
Since QMainWindow::setMenuWidget accepts a QWidget (allowing users to
implement their own menu widget), we need to use qobject_cast on the
stored widget to see if it is a QMenuBar before calling QMenuBar APIs.

This qobject_cast may return nullptr.

Pick-to: 6.2
Fixes: QTBUG-98247
Change-Id: Iff1dbd24fa7ca09098fe49c179770356c966251d
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-11-15 16:51:14 +01:00
Volker Hilsheimer
61aa482241 QTabBar: Support scrolling with a kinetic wheel
QTabBar implements wheelEvent to move the current index up or down. This
is useful for clicky mouse wheels, but a bad user experience when using
a kinetic wheel or touch pad, as every pixel movement will change the
current index.

Instead, scroll the entire tab bar when the wheel event comes from a
device that supports scroll phases, without changing the current index.

As drive-by's, fix the test introduced in aa09bea00c to
not leak memory or leave a test-specific style set on the QApplication
instance, which can break other tests.
Also, make relevant layout code in QTabBar respect the usesScrollButtons
property, const'ify local variables, and return an accepted QWheelEvent
if the event resulted in a change.

[ChangeLog][QtWidgets][QTabBar] Scrolling with a kinetic wheel or touch
pad scrolls the entire tab bar, without changing the current index.

Change-Id: I990e51466dd25c741877bbf0e197449f897a9efb
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2021-11-15 16:23:42 +01:00
hjk
2fa29b00ca Fix return type documentation of QFileSystemModel::fileName()
Pick-to: 6.2
Pick-to: 5.15
Change-Id: I5de4214766eccd5b0086d1230b4267fb49e1b58f
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2021-11-15 13:46:46 +00:00
Sona Kurazyan
65d553ce52 QFuture: extend the docs to explain how to cancel continuation chain
Task-number: QTBUG-97582
Change-Id: Ib31d0dfb7a74bb88802a21c5875edd789e412529
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-11-15 13:24:24 +01:00
Sona Kurazyan
76a551588c Update documentation of QFuture continuations
Mention that the futures returned by continuations will stay
uninitialized, until the corresponding continuation/handler starts
executing and do some general improvments to make the docs more
readable.

Task-number: QTBUG-97582
Pick-to: 6.2
Change-Id: I141ff1630b22ec7a856a457a41a69efec980d44b
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-11-15 13:24:24 +01:00
Volker Hilsheimer
6ff07ec23b macOS: make the slider knob big enough for BigSur and Monterey
The slider is very touch friendly from macOS 11 on, and the knob is quite
large. Give it some extra pixels, and adjust the test accordingly.

Pick-to: 6.2
Task-number: QTBUG-98093
Change-Id: Iedf6db1081cdd4013ca29ce760aea1e0361b1123
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2021-11-15 09:30:25 +01:00
Sona Kurazyan
eab40726be QFuture: support cancellation of continuation chain through parent
This change allows canceling the chain of continuations attached to a
future through canceling the future itself at any point of execution of
the chain.

[ChangeLog][QtCore][Important Behavior Changes] The chain of
continuations attached to a future now can be cancelled through
cancelling the future itself at any point of the execution of the chain,
as it was documented. Previously canceling the future would cancel the
chain only if it was done before the chain starts executing, otherwise
the cancellation would be ignored. Now the part of the chain that wasn't
started at the moment of cancellation will be canceled.

Task-number: QTBUG-97582
Change-Id: I4c3b3c68e34d3a044243ac9a7a9ed3c38b7cb02e
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-11-13 18:13:08 +01:00
Povilas Kanapickas
746644a5a9 3rdparty: Add touchpad gestures support to bundled xinput xcb module
This feature can easily be backported to our bundled version of libxcb
because the feature is pretty much self-contained (just a couple of new
events and parsing support) and does not depend on newer features of
libxcb that have appeared since our bundled version of 1.13.

Change-Id: If965e3de8b898286cd61c7fddbf335894f3a3ff5
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2021-11-13 17:58:45 +03:00
Andrei Golubev
2a2fb306b8 QStack: simplify the class (even more)
Most methods just do the same thing that is implemented in QList,
so just use QList methods

The QStack::pop() implementation should no longer go through the
resize which is likely slower, expands to more-code (unless optimized
away neatly) than erasure of single element through QList API (which
we optimized at some point to be fast)

It is also meaningless (afair) to have `inline` keyword when a method
is both declared and defined within the class' body, so we can drop
that as well

Change-Id: If9de3429be7418ed0ae13c571e28556a358eab05
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-11-12 22:25:35 +01:00
Mårten Nordheim
3446313c7a Teach QOperatingSystemVersion to handle new OS entries in patch releases
Adding new entries to QOperatingSystemVersion in patch releases
was previously breaking our BC guarantees because the entries are
exported, thus users cannot freely switch between different
patch-releases without a recompile if they adopted the new entries.

Move the data itself to a base class so that the entries can be
constructed inline.

Task-number: QTBUG-97808
Change-Id: Ic44f07488af8a04a3bedc10bebb740c4d68f43f3
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-11-12 18:06:44 +01:00
Mitch Curtis
0d6438f808 Disable some tools and plugins if regularexpression feature is disabled
There are still more failures, but these are low-hanging fruit.

Pick-to: 6.2
Change-Id: I3d3a1dc9e754bd4865c850cc1549b0b6fd6fa2f8
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-11-12 09:57:44 +01:00
Richard Moe Gustavsen
7d90bee769 QLineEdit: always process an input method event
If a line edit is read-only, it only means that the _user_
should not be able to change the text. Qt itself (or the
application, by e.g calling setText()) should not have
this restriction.

For the QPA plugins to be able adjust the current selection from
selection handles, we should always process input method events.
It's the callers responsibility to ensure that the focus object
supports the actions it sends to the focus object (like ImReadOnly,
or ImhNoPredictiveText), and not QLineEdit.

This patch will therefore remove the check for
shouldEnableInputMethod() before processing the event. This will
allow us to adjust the selection from the QPA plugin (iOS/Android).

Task-number: QTBUG-91545
Change-Id: Id664ac3605a3fa0bf207635ed31d24c045d29a07
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-11-12 00:20:51 +01:00
Richard Moe Gustavsen
7c6e4af483 QWidget: always handle IM queries
A widget (e.g QLineEdit) will set WA_InputMethodEnabled to
false if it's read-only. But it can still contain selected
text (e.g from a mouse drag). In many cases, it therefore
makes sense to be able to query the focus object for what
that selection is, e.g to be able to show selection handles
from the QPA plugin (iOS/Android).

Therefore, remove the check if a widget has WA_InputMethodEnabled,
and always process the query. The caller can always check this
flag himself (or Qt::ImEnabled) before sending the query, if needed.

Task-number: QTBUG-91545
Change-Id: Ia3dfa289283b5c157ba47cf0b508f9fddadd2861
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-11-12 00:20:51 +01:00
Edward Welbourne
453695ec92 Avoid overflow for date-time in the first (partly) representable day
Computing the start of the first day's number of milliseconds since
the epoch overflows, but adding enough seconds within the day would
have brought us back inside the representable range. So, for days
before the epoch, add a negative number of milliseconds from the end
of the next day instead of a positive number of milliseconds from the
(possibly unrepresentable) start of the target day.  This is another a
follow-up to commit 2b26dea51b

Change-Id: I2e0c68d7012db85dfe7da4a8a20ba95368178ed1
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-11-11 22:44:10 +01:00
Edward Welbourne
6845c444d0 Replace enum with constexpr qint64 variables
It's the modern recommended way to do it.

Change-Id: I10db128348014b316c1772d18396f272b0a2b766
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-11-11 22:44:10 +01:00
Andreas Buhr
838edd9c48 Fix QMultiHash::operator== crash
QMultiHash::operator== crashes when comparing two unequal objects.
This patch fixes it.

Pick-to: 6.2
Fixes: QTBUG-98265
Change-Id: Ibf9fef3372a2b4581843be5f25e65cc9a55ef64d
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-11-11 22:44:10 +01:00
Thiago Macieira
090c7e3262 QDuplicateTracker: add clear()
I'll need it in QFactoryLoader.

Pick-to: 6.2
Change-Id: Ice04365c72984d07a64dfffd16b47f68d25252b4
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-11-11 13:26:14 -08:00
Thiago Macieira
fba4ca0ec1 QLibrary/QPlugin/QFactoryLoader: convert to category logging
This adds three categories:
 - qt.core.library
 - qt.core.plugin.loader
 - qt.core.plugin.factoryloader
plus the "qt.core.plugin.elfparser" category (only available in
developer builds).

All three use the new Q_LOGGING_CATEGORY_WITH_ENV_OVERRIDE technique
which enables their debugging if the QT_DEBUG_PLUGINS=1 variable is set.

As a consequence, some warnings were downgraded to debug messages. I've
only left as warnings situations where a real problem occurred, since
they now get printed by default: failures to open or mmap a file,
corrupt plugin metadata (but not scan of non-plugins), use of
QPluginLoader with a static build of Qt.

Drive-by update of some messages to make them prettier and/or use
qUtf16Printable().

Change-Id: I3eb1bd30e0124f89a052fffd16a752acfe89c19e
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
2021-11-11 13:26:14 -08:00
Alexander Volkov
d36249e975 QFileDialog: Fix adding default suffix when file path contains dot
Check that a file name, not the full path, contains a dot.

Fixes: QTBUG-59401
Pick-to: 5.15 6.2
Change-Id: I193b2ae457a3ac6a460524dbf200786eb3461cef
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2021-11-12 00:26:14 +03:00
Yuhang Zhao
000f1ee360 Windows QPA: Set SWP_NOCOPYBITS during resize to avoid jitter
Allowing Windows to re-use parts of the client area when resizing
might result in jitter. See discussion in:

https://stackoverflow.com/questions/53000291/how-to-smooth-ugly-jitter-flicker-jumping-when-resizing-windows-especially-drag

Fixes: QTBUG-97774
Pick-to: 6.2
Change-Id: Idc8f0d1953dd0a8b329312d8a9fd0509cc24d81f
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-11-12 04:59:00 +08:00
Richard Moe Gustavsen
30adaaedf7 QInputMethod: check if focusobject supports the "new" IM function before calling it
We use QMetaObject to invoke the "queryFocusObject" function. But if
the current focus object doesn't implement this function, we get a
"QMetaObject::invokeMethod: No such method" warning.

This patch will add a check if the focus object supports IM queries
before trying to call "queryFocusObject", to avoid the warning.

Task-number: QTBUG-91545
Change-Id: I3aa8bd2d4bf57bd42c2d77ed71174ec4f9951f81
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-11-11 21:24:30 +01:00
Richard Moe Gustavsen
30276cec3d QIOSTextInputOverlay: listen for selection changes, also for Qt::ImReadOnly
The focus object can emit selection updates (e.g from mouse drag), and
accept modifying it through IM when dragging on the handles, even if it
doesn't accept text input and IM in general (and hence return false from
inputMethodAccepted()). This is typically the case for read-only text fields.
So we should listen for selection changes and enable handles also for
this case (unless the IM hints tells us explicitly not to use handles/edit menu).

Fixes: QTBUG-91545
Change-Id: I2855505fc229e954b2c43f5e11374e64bba7eb4e
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-11-11 22:24:30 +02:00
Richard Moe Gustavsen
aae4d52cbb QIOSInputContext: use QIOSResponder when the focus object is Qt::ImReadOnly
In Qt, Qt::ImEnabled means that the focus object accepts text input from
input method (IM) events. But the IM API also contains API for dealing
with text selections. Text input and text selections are logically two
different operations, but since IM makes use of selections to implement
text input (like selecting a word to suggest a spelling correction), it's
understandable that they are combined into to same API.

So when a focus object reports Qt::ImEnabled to be false, it only means
that it doesn't accept input. E.g a TextArea in QML with "readOnly:true"
will set Qt::ImEnabled to false. At the same time, it can have
"selectByMouse:true", which lets you select text with the mouse.
This behavior is consistent in Qt, for both Quick, Controls 2 and Widgets.

Since we want to support any selections done in controls/widgets on iOS
with selection handles and edit menus, regardless if the focus object
accepts input or not, this patch will set the QIOSResponder (with read-only
actions) as first responder when we detect a focus object with Qt::ImReadOnly.
This means that if a query for Qt::ImReadOnly returns "true", we take that
to mean that it implements the IM API, but without accepting input.

Task-number: QTBUG-91545
Change-Id: I07349909a3bca81f484a2e9af9672428dca62c49
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-11-11 22:24:30 +02:00
Richard Moe Gustavsen
2211092aa5 QIOSTextInputResponder: factor out the "read-only" part to a QIOSTextResponder base class
QIOSTextInputResponder has two responsibilities; It takes care of
handling text input from UIKit, and to implement first responder
actions related to the edit menu, like copy and paste.

Currently the responder offers both writable (paste) and
readable (select, copy) actions. Because of the former, it means
that it can only be used for focus objects that accepts text input.

Since we also want to be able to show an edit menu for selections
done on a read-only input field, this patch will factor out the
read-only actions we want for that case into a QIOSTextResponder
base class. An instance of this class can be used as first responder
for a focus object that has read-only text, but otherwise doesn't
support text input. This part is implemented in a subsequent patch.

The remaining set of writeable actions, together with input method
handling, will continue to be in the QIOSTextInputResponder subclass.

Task-number: QTBUG-91545
Change-Id: I1c215bb509eb7820c6c60f7ad806f61a5de02ded
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-11-11 22:24:30 +02:00
Volker Hilsheimer
c7e8133a95 QSlider: Always set the sunken state and the active control
initStyleOption should initialize the state based on which controls are
pressed or hovered, not only when painting but also when calling other
style APIs.

Pick-to: 6.2
Task-number: QTBUG-98093
Change-Id: I482793b7de38657aa36a20d0abab8845155ad0e9
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
2021-11-11 20:08:18 +01:00
Morten Johan Sørvig
0a8a4698d6 wasm: fix native timer update for the no-timer case
QTimerInfoList::timerWait() does not update the timespec
out argument if there are no active timers, which caused
the current code to calculate an arbitrary toWaitDuration.

Instead use the timerWait() return value, and clear any
native timers if there are no active Qt timers.

Pick-to: 6.2
Change-Id: I7d5ec4c2930000bece6f6ea6c63e76f4df543b04
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
2021-11-11 15:24:36 +00:00
Morten Johan Sørvig
966f7cb5dd wasm: make timers work for the new event dispatcher
Don’t exit from the timer callback if there is no main
thread event dispatcher, since it could be that the main
thread event dispatcher is of the old event dispatcher type.

Pick-to: 6.2
Change-Id: Ibb7a34a99e2001b52d2a985022f5baa7cd2152bf
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
2021-11-11 17:24:35 +02:00
Michal Klocek
e6db4206b8 Fix not respected qt.conf settings
Change 6fb569af95 introduces reloadOnQAppAvailable for
QLibrarySettings, however it is missing a reload check
for hasPaths, this breaks essentially reading custom qt.conf

Add missing check.

Fixes: QTBUG-97382
Fixes: QTBUG-97383
Fixes: QTBUG-97947
Pick-to: 6.2
Change-Id: I28379d9dd38357c290edd44b93d3bea489b9cefe
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-11-11 14:30:00 +00:00
Venugopal Shivashankar
f9e6ee655f Doc: Fix qdoc warnings
In addition, added the missing warninglimit
entry to a few doc configs.

Change-Id: I51b9d2ad66123a2a9673a3b42870662641375e6b
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-11-11 11:34:49 +01:00
Alexey Edelev
f6d210a0d3 Add missing qt namespace in qthreadstorage.h
Wrap 'else QT_CONFIG(thread)' block in qthreadstorage.h with qt
namespace

Pick-to: 6.2
Fixes: QTBUG-98085
Change-Id: Ica1817fa6beeaf9e4883edaa8738f042b29f0c5e
Reviewed-by: Kirill Burtsev <kirill.burtsev@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-11-11 08:52:02 +01:00
Thiago Macieira
da326804ea qmetatype.cpp: provide missing initializer for const variable
qmetatype.cpp(1565): warning #854: const variable "metatypeHelper" requires an initializer -- class "struct <unnamed>" has no user-provided default constructor

Change-Id: I2bbf422288924c198645fffd16a9b868ff7adcb9
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-11-10 17:29:54 -07:00
Martin Storsjö
d7d9451361 Fix 32-bit builds broken by mul_overflow() on qint64
Use std::integral_constant to avoid instantiating QIntegerForSize<16>,
caused by 2b26dea51b

Change-Id: Ia6f49a1dcd82835c7e76200a650767fc519eab90
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-11-10 23:23:23 +01:00
Thiago Macieira
3ba1a196aa Q{XcbGl,EglFSDevice}IntegrationFactory: remove unused extra plugin path
Cargo-cult copied this from somewhere, unnecessarily. This just made the
code bigger for no reason.

Task-number: QTBUG-97950
Pick-to: 6.2
Change-Id: Ice04365c72984d07a64dfffd16b48520d42c7043
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-11-10 10:21:43 -08:00
Thiago Macieira
b0dc6abfb2 QGuiApplication: properly decode path command-line arguments
Using QFile::decodeName, not QString::fromLocal8Bit.

Pick-to: 6.2
Change-Id: Ice04365c72984d07a64dfffd16b47dcbfee23341
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-11-10 10:21:43 -08:00
Ievgenii Meshcheriakov
893990a67e QFileSystemEngine: Don't use _?W suffixes
We don't use W suffix for most of the Windows API so there is no
need to use it here either. Also remove W suffix for variables of
type TRUSTEE (was TRUSTEE_W).

Change-Id: Id67b772ba5d3232f882841a1e581fb1bbd392fa4
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-11-10 19:21:43 +01:00
Ievgenii Meshcheriakov
d7e1416580 Use nullptr to represent null pointers
Replace occurrences of NULL and 0 when used for pointers.

Change-Id: I485e73d22a1a85d1303f3e0967cd4e8f10ff5d33
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-11-10 19:21:43 +01:00
Ievgenii Meshcheriakov
65041967b6 QFileSystemEngine: Fix some code style issues in Windows backend
Wrap lines at column 101 so that it is easier to edit the
file and review the changes in Gerrit. Move comments when
they cannot be easily wrapped. Add curly braces to `if`
statements if they became multiline. Run `git clang-format`
on the file afterwards.

Change-Id: Ib21afd65147a7b202e031d4a865b5f615e5ad6d8
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-11-10 19:21:43 +01:00
Ievgenii Meshcheriakov
1cc9ac71ac Move toMode_t() from qfilesystemengine_unix.cpp to qfiledevice_p.h
The function is needed in multiple files to implement QDir::mkdir()
and QFile::open() methods that accept a permission argument on Unix.

Task-number: QTBUG-79750
Change-Id: Ib0853f7d12bcb5d6f1116b43ec1aa07b6554bb93
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-11-10 18:22:07 +01:00
Edward Welbourne
7db0eeae34 Clean up exports from qlocale_p.h
Explain why QSystemLocale needs to be an export. Unexport
QLocaleId::fromName() now that qttools no longer uses it.
QLocalePrivate was only Q_CORE_EXPORT for the sake of one use in
tst_QLocale, that can now be replaced by a call to a public QLocale
method.

Change-Id: I1efe8ee03488acfc6e1c36661f6e956a86e191c3
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-11-10 18:16:24 +02:00
ChunLin Wang
62b7130423 QPushButton: emit released signal when mouse dragged out of bounds
After special processing for hover, QPushButton::mouseMoveEvent()
needs to call the base class function, like every virtual override
should, to continue processing other logic.  Amends
3310e13a17

Fixes: QTBUG-97937
Pick-to: 6.0 6.2
Change-Id: Ic2e111d6c38371e0aa04423f5fb26c52717bf5fb
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2021-11-10 16:16:24 +00:00
Ievgenii Meshcheriakov
f28e161361 Remove useless blocks
Don't put the code inside two blocks for no reason.

Change-Id: I54b8d6fbfab50a26ddcd8ec07ba689e5094bcad3
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-11-10 16:45:52 +01:00
Edward Welbourne
34287c9eae Add QGregorianCalendar::yearSharingWeekDays()
When fixing up problems on system APIs with limited date ranges, we
need a year, inside the supported date range, in which Gregorian dates
fell on the same days of the week as a given year outside the range.
A year with the same last two digits makes handling of two-digit year
formats easier.

Change-Id: If64ee27e829f9dcfd5504ed8ba51f72c36297242
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-11-10 14:47:42 +01:00
Edward Welbourne
2b093450c3 Improve unicodeForDigit()'s comments
I'd typo'd the Suzhou one-digit. Record that our CLDR scanner verifies
this is the only number system with non-contiguous digits, rather than
merely recording a (now old) CLDR version in which that was true.

Change-Id: I6f5b5d1f0a5aa1cd0557f62f296777b90b603087
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-11-10 14:10:20 +01:00