Commit Graph

38017 Commits

Author SHA1 Message Date
Tasuku Suzuki
7d93c6ef9c Fix build without features.library
Change-Id: I53eaaea149324d2495e794ba8bd58544e648e48e
Reviewed-by: Janne Koskinen <janne.p.koskinen@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-05-19 16:55:50 +09:00
Kimmo Ollila
5762bd236c Add EGLFS OpenWFD plugin for INTEGRITY
This enables OpenWFD EGLFS integration plugin and makes EGLFS the
default platform for INTEGRITY builds.

Change-Id: I65332ca0ae244f40013df435828e2e359200b325
Reviewed-by: Janne Koskinen <janne.p.koskinen@qt.io>
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2021-05-19 10:55:48 +03:00
Alex Trotsenko
9c7cabb880 QLocalSocket/Win: fix closed state detection in waitFor...() functions
A delayed close should only be completed in the _q_bytesWritten() slot
as a confirmation of a successful write operation on the socket.
Otherwise, a failed write operation may cause the socket to be closed
unexpectedly within the waitFor...() function, which may result in a
malfunction.

Change-Id: I14cff26734f64a89090b6b5c13037466a6400597
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
2021-05-18 20:03:47 +00:00
Alexandru Croitor
91c65dd80c CMake: Build plugin initializers as object libs
Instead of compiling the plugin initializers as part of a user
project, pre-compile them as object libraries while building Qt.

The installed object libraries can then be used with

    target_sources(qt_module INTERFACE $<TARGET_OBJECTS:plugin_init>)

so that they are linked into the final executable or shared library
via qt module usage requirement propagation.

This reduces the build times of user projects.

The link line placement of the object files should be correct for all
linux-y linkers because the only dependency for the object files is
Core and the Gui -> plugin -> Gui -> Core cycle does not hamper that
from empirical observations.

As a consequence of the recent change not to link plugin initialization
object files into static libraries, as well not having to compile the
files in user projects, we can get rid of the
_qt_internal_disable_static_default_plugins calls in various places.

A side note.

Consider a user static library (L) that links to a Qt static library
(Gui) which provides plugins (platform plugins).

If there is an executable (E) that links to (L), with no direct
dependency to any other Qt module and the intention is that the
executable will automatically get the platform plugin linked,
then (L) needs to link PUBLIC-ly to (Gui) so that the plugin usage
requirements are propagated successfully.

This is a limitation of using

  target_sources(qt_module INTERFACE $<TARGET_OBJECTS:plugin_init>)

which will propagate object files across static libraries only if
qt_module is linked publicly.

One could try to use

  target_link_libraries(qt_module
                        INTERFACE $<TARGET_OBJECTS:plugin_init>)

which preserves the linker arguments across static libs even if
qt_module is linked privately, but unfortunately CMake will lose
dependency information on Core, which means the object files might be
placed in the wrong place on the link line.
As far as I know this is a limitation of CMake that can't be worked
around at the moment.

Note this behavior was present before this change as well.

Task-number: QTBUG-80863
Task-number: QTBUG-92933
Change-Id: Ia99e8aa3d32d6197cacd6162515ac808f2c6c53f
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-05-18 22:03:46 +02:00
Tor Arne Vestbø
0855f62791 Fix single argument QT_OVERLOADED_MACRO with pedantic warnings enabled
The use of QT_OVERLOADED_MACRO combined with pedantic warnings would
result in

  warning: must specify at least one argument for '...' parameter of
  variadic macro [-Wgnu-zero-variadic-macro-arguments]

when used with a single argument, as the QT_VA_ARGS_COUNT macro would
end up not passing anything to the last ... argument of the helper macro
QT_VA_ARGS_CHOOSE.

To work around this we extend the arguments passed to QT_VA_ARGS_CHOOSE
by one, adding a zero-count, so that the variadic parameter always has
at least one argument.

Unfortunately this doesn't give us a count of 0 if a overloaded Qt macro
is used without arguments, due to __VA_ARGS__ always being treated as an
argument to QT_VA_ARGS_CHOOSE, even when empty, due to the comma after it.
The result is that we end up calling the 1-argument macro for this case
as well.

Getting a correct zero-count, for both MSVC and GCC/Clang, without using
GCC extensions, is quite involved, so we're opting to live with this
limitation. See https://stackoverflow.com/a/62183700 for details.

Fixes: QTBUG-93750
Pick-to: 6.1
Change-Id: Ib7b26216f36a639642a70387e0d73223633ba6b6
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-05-18 19:07:51 +00:00
Allan Sandfeld Jensen
1fe8ddc7fe Cherry-pick upstream patch for non-gcc/clang/msvc compilers
Fix build w/ non-GCC-compatible Un*x/Arm compilers

Fixes: QTBUG-93779
Change-Id: Ib52e9ded6e2814c7998d6cd798e945da0f87f7a1
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
(cherry picked from commit 4341f6763b8a737ebc07bb78ead22bc05a1a515b)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2021-05-18 18:57:25 +00:00
Joerg Bornemann
92185d417d Fix BASE argument of qt_add_resources
The BASE argument of qt_add_resources now denotes the root point of the
alias of the file.  Before, BASE was merely prepended to every file that
got passed to qt_add_resources.

Old behavior:
    qt_add_resources(app "images"
        PREFIX "/"
        BASE "../shared"
        FILES "images/button.png")

Alias is "../shared/images/button.png", and pro2cmake generated
QT_RESOURCE_ALIAS assignments to fix this.

New behavior:
    qt_add_resources(app "images"
        PREFIX "/"
        BASE "../shared"
        FILES "../shared/images/button.png")

The alias is "images/button.png".  No extra QT_RESOURCE_ALIAS assignment
is needed.

The new behavior is in effect for user projects and for Qt repositories
that define QT_USE_FIXED_QT_ADD_RESOURCE_BASE.  Qt repositories will be
ported one by one to this new behavior.  Then the old code path can be
removed.

Pick-to: 6.1
Task-number: QTBUG-86726
Change-Id: Ib895edd4df8e97b54badadd9a1c34408beff131f
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-05-18 16:02:52 +02:00
Giuseppe D'Angelo
861647e8a5 Item models: code tidies
Use QFlags::testAnyFlag instead of relying on implicit conversions.

Change-Id: I7ac8149535ad28e47fbf3e250042892bdf8c3a72
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
Reviewed-by: Samuel Gaist <samuel.gaist@idiap.ch>
2021-05-18 15:33:25 +02:00
Giuseppe D'Angelo
3b0c6bf486 QEventDispatcherCF: avoid QFlags->int implicit casts
Use toInt(), or an explicit cast. (I don't quite know why an atomic int
is involved here, but anyways, it makes these casts necessary.)

Change-Id: I8816ef96bd69a6f3e3f8e025e567e3451069462c
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2021-05-18 15:31:10 +02:00
Andreas Buhr
8278879c19 Fix QItemSelectionModel::selectionChanged emission
QItemSelectionModel has the property selectedIndexes with
the notification signal selectionChanged. When a row is deleted
or inserted above the current selection, the row number of the
current selection changes and thus the return value of
selectedIndexes changes. This should trigger its notification
signal.
This signal was not emitted. This patch fixes this and
adds a unit test to verify this.

[ChangeLog][Important Behavior Changes][QtCore]
QItemSelectionModel now emits the selectionChanged signal
if only the indexes of the selected items change.

Fixes: QTBUG-93305
Change-Id: Ia5fb5ca32d658c9c0e1d7093c57cc08a966b9402
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: David Faure <david.faure@kdab.com>
2021-05-18 08:49:56 +02:00
Giuseppe D'Angelo
9a94c4a415 Long live qToUnderlying
"Cherry-pick" of C++2b's std::to_underlying.

[ChangeLog][QtCore][QtGlobal] The qToUnderlying function has been
added, to convert an value of enumeration type to its underlying
value.

Change-Id: Ia46bd8e4496e55174171ac2f0799eacbcca02cf9
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-05-18 02:09:11 +02:00
Giuseppe D'Angelo
8f7873272a qglobal.cpp: build under QT_NO_EXCEPTIONS
The boostrap library is built with exceptions disabled, and its
sources include qglobal.cpp. Therefore, the file must work when built
w/o exceptions.

Amend/partially revert 282b724808 with
the necessary fixes.

Driveby, cleanup an unnecessary QT_THROW (just throw, if we do have
exceptions).

Change-Id: I370c295c21edd3d81a9fa670e60909b29d1c68aa
Pick-to: 6.1
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2021-05-18 02:09:02 +02:00
Li Xinwei
42b8bbbef0 CMake: remove unnecessary add_dependencies()
The dependencies to moc, uic and rcc have already been handled by
qt_manual_moc(), qt_enable_autogen_tool() and
_qt_internal_process_resource().

This allows not building some of the debug executables in a
multi-config scenario.

Task-number: QTBUG-88414
Change-Id: I6c162721f3ddf6b4b410345ad012073abbdfd9df
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-05-17 21:57:22 +00:00
Joerg Bornemann
76eefab088 Add proper dependencies to apk targets
Before, building ${target}_make_apk always re-built the apk, instead of
rebuilding the apk only when inputs changed. This patch fixes that by
moving the creation code from a custom target to a custom command with
proper dependencies.

The androidtestrunner tool now does not check for the existence of an
apk anymore and always runs the make command that is supposed to build
the apk.

The ${target}_prepare_apk_dir target is not needed anymore by the Qt
build but is still used by Qt Creator's Android support. Add a
clarifying comment.

Fixes: QTBUG-93431
Change-Id: I00d65d616fef9511b03b65f879c4bc6cb92dfc30
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-05-17 19:14:44 +02:00
Thiago Macieira
50c838d4b5 Make the exit() methods in QEventLoop and QThread be slots
The documentation for QCoreApplication::exit() even refers to it as
such. Instead of refactoring the documentation to explain that it isn't,
just make it a slot and do the same for the other classes.

Complements 2e6c37fe51.

[ChangeLog][QtCore][QEventLoop] exit() is now a slot, like quit().

[ChangeLog][QtCore][QThread] exit() is now a slot, like quit().

Change-Id: Ic42004c9bf71440eb433fffd167f4a1b89bcac80
Reviewed-by: David Faure <david.faure@kdab.com>
2021-05-17 10:13:52 -07:00
Andre de la Rocha
92198efbd2 Windows QPA: Fix dock widget drag&drop failure
A previous change to fix QTBUG-85431 has caused this issue by emulating
the behavior of the non-enhanced mouse event handler in a particular
case, where mouse move events that did not change position were ignored.
However, some of these events seem to be involved in the dock drag&drop
implementation. This issue is also reproduced in pre-5.15 releases,
predating the QTBUG-85431 fix, by disabling the enhanced mouse event
handler by setting the QT_QPA_DISABLE_ENHANCED_MOUSE env var. However,
the ignored events in the current issue seem to be non-client events
only, while the QTBUG-85431 issue was related to client mouse events.
So we can restrict the test added in the QTBUG-85431 fix and have both
issues fixed.

Fixes: QTBUG-92182
Pick-to: 5.15 6.0 6.1
Change-Id: I98c0c8597912c7f4fe58af375a5a560695a82746
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2021-05-17 19:11:09 +02:00
Assam Boudjelthia
2e373e44ac Add isValid() call to QJniEnvironment
Task-number: QTBUG-92952
Change-Id: I3bce2881c10a8bfcc8771002a3349644c6f05cb3
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2021-05-17 16:30:14 +00:00
Giuseppe D'Angelo
536a4ab079 QFile: code tidies
There's no need of converting a QFlags to int in openExternalFile's
signature; just use the flag.

Also, avoid an implicit QFlags->bool conversion by using testAnyFlag.

Change-Id: Ia2d560bce235c842745d8a6a5fb5d8ac0851fc47
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-05-17 11:07:35 +02:00
Giuseppe D'Angelo
af38f72e13 Windows QFSFileEngine: avoid some QFlags implicit conversions
Go through fromInt/toInt instead.

Change-Id: I73097e21f59f9e8eb2c9714e22084af0787a53d5
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-05-17 11:07:13 +02:00
Giuseppe D'Angelo
dc5576895d QMetaContainer: code tidies
Turn some implicit conversions into calls to QFlags::testAnyFlag.

Change-Id: I755f8a1afb1ff02e823e747e021e9744d68b4f62
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-05-17 00:11:32 +02:00
Giuseppe D'Angelo
fca6021f5b QFileSystemMetaData: code tidies
Turn some implicit conversions into calls to QFlags::testAnyFlag.

In one case, move some code using QFlags operators *after* such
operators have been declared by the right macro.

Change-Id: Ib5713f028ce74d1c9054b87cc12eea5715f2bc94
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-05-17 00:11:28 +02:00
Giuseppe D'Angelo
18e6debca7 QFSFileEngine: code tidies
Turn a couple of implicit conversions into calls to QFlags::testAnyFlag.

Change-Id: I21a0b4c1644986a98a2d0d54ae4b95f9fdc92841
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-05-17 00:11:26 +02:00
Giuseppe D'Angelo
5ea50054a1 QArrayData: store the right flag type, not an int
There's no reason to be storing `int` in the array data header and
then using it as a QFlags. Just store the QFlags.

Change-Id: I78f489550d74d15a560dacf338110d80a7ddfdd2
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-05-17 00:11:12 +02:00
Giuseppe D'Angelo
8e82c30680 QIODevice: code tidies
Turn an implicit conversion into a call to QFlags::testAnyFlag.

Change-Id: Idbd80bb6a9b5d84952b76d8d7544f617fe693b91
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-05-16 17:22:38 +02:00
Giuseppe D'Angelo
c568257a52 Event dispatchers: code tidies
Turn an implicit conversion to bool in

* a call to testAnyFlag in one case;
* a comparison against 0 in another case, for consistency with the
surrounding code.

Change-Id: I1eee42ba82c59a72430bf507ea80408c553be889
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-05-16 17:22:34 +02:00
Giuseppe D'Angelo
5a1c3c29ac QSaveFile: code tidies
Turn a cast into a call to QFlags::toInt(), plus a cast.

This is in preparation for a future patch that will remove the
implicit conversion. So why not casting directly? Because we don't
know if the QFlags is backed by int or uint, so using the wrong
cast won't compile; and we MUST pass unsigned because of the %x
specifier. Granted, one could've used a static_assert, but I prefer
a more flexible and idiomatic solution.

Change-Id: I32a3e0ed69b925e8d56268ec84d9e668ca540188
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-05-16 17:22:30 +02:00
Joerg Bornemann
97228214bd Doc: Add CMake to the "Resource System" documentation
Pick-to: 6.1
Change-Id: I4c6a7cfb2f6351e9587d47ab6708d92a1a4e42a4
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2021-05-16 17:05:32 +02:00
Alexey Edelev
282b724808 Make qTerminate available when QT_NO_EXCEPTIONS flag is set
It seems that QtCore could only be compiled with exceptions enabled.
Therefore it doesn't make sense to keep conditonal code under
QT_NO_EXCEPTIONS in qglobal.cpp. qTerminate may be called whether
exceptions are enabled or not.

Pick-to: 6.1
Fixes: QTBUG-93739
Change-Id: Ie49c10f27cfa75360f018e8638603e6a1791450e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-05-16 15:26:26 +02:00
Giuseppe D'Angelo
0533695ddd QDir: remove an unneeded QFlags->int conversion
Just use the original QFlags. Drive by, use testFlag to check if
it contains a given value or not.

Change-Id: I4d5e8454df33a3f4727855d55f7587143450dda6
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-05-16 11:42:08 +02:00
Giuseppe D'Angelo
5f29ed0d5c QDir(Iterator): code tidies
* Turn some `flags & bit` statements that rely on QFlags->int->bool
implicit conversions, into some more idiomatic `return
flags.testAnyFlag(bit)`. This is in preparation for a future patch, and
to avoid inserting casts (return statements do not contextually convert
to bool).

* Remove a magic constant, replacing it by the symbolic one.

Change-Id: I62fc2b2bf6f0ab8fad121edd19cb2ea0d9e3582a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-05-16 11:42:05 +02:00
Thiago Macieira
4d24fcd3e1 QDateTime: fix our oversight in Qt 6.0 not changing the ShortData
For 32-bit systems. They're not important (to me), but might as well fix
this oversight.

Change-Id: I755911ae7d0341f49039fffd167b26617db93354
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-05-15 12:14:48 -07:00
Giuseppe D'Angelo
c4947c1c4c QFlags: add test(Any)Flag(s)
QFlags was lacking a named function for testing whether a QFlags object
contains _any_ of the bits set by a given enumerator/other QFlags.

Drive-by, add testFlags taking a QFlags, not just an object of the
enumeration; and simplify the implementation of testFlags to more
closely follow what its documentation says it does.

[ChangeLog][QtCore][QFlags] The testFlags, testAnyFlag and
testAnyFlags functions have been added.

Change-Id: Ie8688c8b0dd393d34d32bc7786cdcee3eba24d1c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-05-15 17:34:01 +02:00
Giuseppe D'Angelo
671ada5d82 QFileDevice: code tidies
Avoid QFlags->int implicit conversions.

Change-Id: I29905ff66888759c71d1e70064913520c9f09ec2
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-05-14 21:26:40 +02:00
Friedemann Kleint
db32369935 native interface plumbing: Fix ambiguities with existing classes named TypeInfo
As is the case in Qt for Python, causing:

QtCore/qcoreapplication.h: In member function I* QCoreApplication::nativeInterface() const:
QtCore/qcoreapplication.h:163:5: error: reference to TypeInfo is ambiguous
  163 |     QT_DECLARE_NATIVE_INTERFACE_ACCESSOR

Amends 7feeb7c34b.

Change-Id: I7d363e1d8c0a0f648d12f8040afb9d071356cbb8
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-05-14 16:35:34 +02:00
Andy Shaw
08cd5580df iOS: Accessibility: Set the correct traits for EditableText
Since the correct accessibility traits for EditableText are not
available as a direct enum value, then we depend on the defaults for a
UITextField to give us this information.

Done-with: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Fixes: QTBUG-93494
Pick-to: 6.1 5.15 5.12
Change-Id: If428414aec5ce571f0f8c0ecccffdbaf1c908120
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2021-05-14 08:12:10 +00:00
Andy Shaw
a8a6558a84 Allow for arguments that have an equals as part of it
Since you can pass a define to org.gradle.jvmargs that can have the
name=value approach, then we need to ensure that this is accounted for.

Task-number: QTBUG-88989
Pick-to: 6.1 5.15
Change-Id: I2a795bff7ce683eca521b3a987293b3320accb6a
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2021-05-14 08:12:09 +00:00
Marc Mutz
c8f380bd13 QPageSize: make PageSizeId ctor non-explicit
A QPageSize::PageSizeId is a faithful representation of a QPageSize,
so the corresponding QPageSize ctor shouldn't be explicit.

[ChangeLog][QtGui][QPageSize] Conversion from a QPageSize::PageSizeId
is now implicit.

Pick-to: 5.15 6.0 6.1
Change-Id: I2d32da370c032949686757400cb7c28583d9d8ac
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2021-05-13 17:06:42 +00:00
Giuseppe D'Angelo
e704ff8eba QFileInfo: code tidies
Avoid some QFlags<->int conversions; use the named conversions
instead.

Change-Id: If12c55ca362ed5c2c73182e10562a2d09e80aa49
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-05-13 17:57:50 +02:00
Giuseppe D'Angelo
aaaa5c6d82 QDateTime: code tidies
Move the ValidityMask / DaylightMask enumerators in the right
enumeration. This allows to use them in a type-safe way through
the StatusFlags flag type.

Also, define the flag operators for StatusFlags.

Change-Id: Icdba7c3f49f18ffb4aff9921d8012ddc3f7cbed7
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-05-13 14:32:15 +02:00
Giuseppe D'Angelo
37e3b988c2 QMetaObjectBuilder: replace an int with QFlags
The int was used as a flag the entire time, except in one stance.
So just use the right QFlags type instead, and replace that one usage
with a call to toInt().

Change-Id: I3670e6afdc244df69189dd15b8c2c34573476e2f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-05-13 14:29:50 +02:00
Giuseppe D'Angelo
81bb764e98 QFlags::testFlag: code tidies
If the condition Int(flag) != 0 is false, it means that flag == 0.
So just check i against 0, which is more in line with what testFlag
behavior is documented to do.

Change-Id: Ia75fa07eee65e67a769fda7c020bf17ada77e9a3
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-05-13 14:28:45 +02:00
Assam Boudjelthia
23780891a5 Add tests for QAndroidApplication's sdkVersion and activity
While at it, move tst_android under corelib/platform/android.

Change-Id: Icf91cd75cb5e04d03fe6a81d52fba52a485ca41f
Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
2021-05-13 01:41:36 +03:00
Giuseppe D'Angelo
6e04664a95 QDebug: code tidies
Use the newly introduced QFlags::toInt().

Change-Id: I45337a299d20738767461c36641519a3e9b625d7
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-05-12 23:04:57 +02:00
Giuseppe D'Angelo
9887f32df9 QAbstractItemModel::match: code tidies
Remove a magic number from the code, by adding it (as a private value)
to the right enumeration. Use toInt() to convert to integer.

Change-Id: Id1b00dde900619684b5a3df247d46938439150ca
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-05-12 23:04:57 +02:00
Giuseppe D'Angelo
cdd6a1f138 QLibrary: fix some implicit QFlags->int conversions
Either be explicit, or just use QFlags directly.

Change-Id: I18cbea4eaa1a0a4bce7665b735e7d785f7a196b2
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-05-12 23:04:57 +02:00
Giuseppe D'Angelo
a3d7028a0e QUrlTwoFlags: add support for operator&=, |=, ^= taking QFlags
Rather than forcing an implicit conversion to int, accept a QFlags
(over either one of the two enumerations) directly.

Change-Id: I56af3a85982ecb66369e4a7105d07de0d6e0c40a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-05-12 23:04:57 +02:00
Tor Arne Vestbø
7feeb7c34b Rejig native interface plumbing
The initial approach for providing public access to native
interfaces via T::nativeInteface<I>() was based on the template
not being defined, and then having explicit instantiations of
the supported types in a source file, so that the accessors
were exported and available to the user.

This worked fine for "simple" types such as QOpenGLContext
and QOffscreenSurface, but presented a problem in the context
of classes with subclasses, such as Q{Core,Gui}Application.

To ensure that a native interface for QCoreApplication was
accessible both from QCoreApplication and its subclasses,
while at the same time preventing a native interface for
QGuiApplication to be accessible for QCoreApplication, the
nativeInterface() template function had to be declared in
each subclass. Which in turn meant specializing each native
interface once for each subclass it was available in.

This quickly became tedious to manage, and the requirements
for exposing a new native interface wasn't very clear with
all these template specializations and explicit instantiations
spread around.

To improve on this situation, while also squashing a few
other birds at the same time, we change the approach to
use type erasure. The definition of T::nativeInteface<I>()
is now inline, passing on the requested interface to a per
type (T, not I) helper function, with the interface type
flattened to a std::type_info.

The type_info requested by the user is then compared to the
available types in a single per-type (T) "switch statement",
which is a lot easier to follow for someone trying to trace
the logic of how a native interface is resolved.

We can safely rely on type_info being stable between the user
application and the Qt library as a result of exporting the
type info for each native interface, by explicitly ensuring
they have a key function. This is the same mechanism that
ensures we can safely dynamic_cast these interfaces, even
across library boundaries.

The use of a free standing templated helper function instead
of a member function in the type T, is to avoid shadowing issues,
and to not pollute the class namespace of T with the helper
function.

Since we are already changing the plumbing for how a user
resolves a native interface for a type T, we take the opportunity
to add a few extra safeguards to the machinery.

First, we add a static assert in the T::nativeInteface<I>()
definition, that ensures that only compatible interfaces,
as declared by the interface themselves, are allowed.
This ensures a compile time error when an incompatible
interface is requested, which improves on the link time
errors we had prior to this patch, and also offsets the
one downside of type erasure, namely that errors are only
caught at runtime.

Secondly, each interface meant for public consumption through
T::nativeInteface<I>() is declared with a revision, which
is checked when requesting the interface. This allows us
to bump the revision when we make breaking changes to the
interface that would have otherwise been binary incompatible.
Since the user will never see this interface due to the
revision check, they will not end up calling methods that
have been removed or renamed.

One advantage of moving to a type-erased approach for the
plumbing is that we're not longer exposing the native
interface types as part of the T::nativeInteface symbols.
This means that if we ever want to rename a native interface,
the only exported symbol that the user code relies on is
the type info. Renaming is then possible by just exporting
the type info for the old interface, but leaving it empty.
Since no class in Qt implements the old native interface,
the user will just get a nullptr back, similarly to bumping
the revision of an interface.

Change-Id: Ie50d8fb536aafe2836370caacb22afbcfaf1712a
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2021-05-12 22:02:05 +02:00
Richard Moe Gustavsen
3224c6d7d1 QDockWidget, macOS: don't drag on native widgets
When using native dock widgets on macOS, it will currently
fail if you try to drag on a dock widget inside QMainWindow
to make it floating. The reason is that the drag will
basically start as as drag inside one NSWindow (QMainWindow),
but continue as a drag on another NSWindow (QDockWidget).
And this is not handled well by AppKit, especially since the
NSView where the drag was started is reparented into a new
NSWindow (the floating QDockWidget) while the dragging is
ongoing. And there seems to be no practical solution to how
we can support this from the cocoa QPA plugin

This patch will therefore change the logic in QDockWidget to
simply make the dock widget floating if you drag on it, rather
than actually starting a drag (but only for the described case).

Pick-to: 6.1 5.15
Fixes: QTBUG-70137
Change-Id: Ic309ee8f419b9c14894255205867bce11dc0c414
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-05-12 20:50:02 +02:00
Karsten Heimrich
776a969bfd Implement QFileSystemEngine::createLink() on MS-Win
Fixes: QTBUG-74271
Change-Id: I9e414dd16546f65e85b5a1a6c70c40dfa4284a6f
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>
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2021-05-12 14:53:12 +02:00
Pekka Gehör
37d6fd60a8 Android: Fix position issue of the EditPopupMenu
Set y for the EditPopupMenu from the previous correct value if select handles values are zero.
The SelectionHandle.bottom() is zero if selection handles have not yet been displayed on the screen.

Task-number: QTBUG-71900
Change-Id: I3694a8edd4f0d8f8799dbac1217a75c375038e66
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2021-05-12 12:49:46 +00:00
Fabian Kosmale
5b681bea90 QPropertyBinding: Do not reevaluate if not installed on property
Since we changed binding evaluation to be always eager, we notify and
evaluate all bindings as soon as any dependency changes. This includes
bindings which have been initially installed on a property, but which
were later removed.
With lazy evaluation, we would only notify those bindings and mark them
as dirty, which is unproblematic. With eager evalution, we attempt to
evaluate the binding, though. While that part is still fine, afterwards
we would attempt to write the new value into the property. However,
there is no property at that point, as the binding is not installed.
Instead of adding a check whether the propertydataptr is null, we skip
the reevaluation completely by removing the bindings observers - and
thus the cause for the binding function's reevaluation. As soon as the
binding is set, we reevaluate the function anyway, at which point we
also capture the observers again.

Task-number: QTBUG-89505
Change-Id: Ie1885ccd8be519fb96f6fde658275810b54f445a
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2021-05-12 14:49:46 +02:00
Topi Reinio
718ade3b5f Doc: Correctly mark QLocale::Territory as an alias
Change-Id: Id165f0ef0803432e1458589319f7c344b97beec9
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Reviewed-by: JiDe Zhang <zhangjide@uniontech.com>
2021-05-12 14:49:45 +02:00
Richard Moe Gustavsen
78b6050d60 cocoa: be more careful about rejecting frame strut events
The m_buttons property is meant to hold the currently pressed mouse
buttons done on the contents part of a QNSView. But m_buttons can
sometimes get out of sync with AppKit (NSEvent.pressedMouseButtons).
One way this is shown to happen is if you do a mouse press on a native
child widget (that is backed by it's own QNSView), and then convert the
widget to a top-level window before the release. In that case, the
underlying QNSView will be reparented from one NSWindow to another,
which will result in the old NSWindow getting the mouseUp call instead
of the new window. The result is that we don't update m_buttons for
the reparented QNSView, which will instead be left as "pressed".

As a result of m_buttons being stuck in a faulty state, we also refuse
to send out QEvent::NonClientAreaMouseMove events to the top-level
widget. This because QNSView thinks that it's already in a dragging
state that started on the content part of the view (and not on the
strut). As a result, it can sometimes be impossible to dock a
QDockWidget back into a QMainWindow, since we basically don't send
out any frame-drag events to Qt for the new dock window.

We can reason that if you start a mouse press on the frame strut, you
cannot at the same time have an active mouse press on the view contents.
This patch will therefore remove the buttons that we know was pressed
on the frame strut from m_buttons. This will at least (be one way to)
clear the faulty pressed state, and will let us send mouse
press/drag/release (and after that, move) frame strut events to Qt.

Pick-to: 6.1 5.15
Task-number: QTBUG-70137
Change-Id: If51e1fe57d2531b659d39de85658893dae6391e3
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-05-12 12:49:45 +00:00
Assam Boudjelthia
531d12edaf Android: check that app's lib_name value doesn't contain spaces
android.app.lib_name is used for the app's lib that contains the main()
function, *.so lib files usually have non-spaced names, thus to avoid
wrong changes done to the manifest file, it's better to throw an error
in this case.

Change-Id: I4d4f0235612b308c78fd06a77690604c5c69f8ff
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
2021-05-12 12:49:45 +00:00
Volker Hilsheimer
d85794c231 Respect Password and NoEcho mode while pre-editing
During composition of text using an input method, incomplete characters
should not be visible at all in NoEcho mode, and should be replaced by
the password character in Password mode.

In NoEcho mode, when the cursor is always at position 0, the pre-edit cursor
should also always be at that position so that the UI doesn't give
away the length of the text entered so far.

Task-number: QTBUG-84664
Change-Id: I44a30eee3f5c6fe9fa00073b0a8ac3c333fbaa59
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-05-12 14:49:45 +02:00
Lorn Potter
35396e12eb fix build for no feature future
This amends afd7460aff
Add new app permissions API under QCoreApplication

Which added QFuture use without protection for platforms with no
real future.

Change-Id: Iac50a71c9821255621d7582481270b2023610405
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2021-05-12 22:49:45 +10:00
Lars Knoll
a8a38f7caa Fix thread-sanitizer warning about a data race
Not 100% sure if this is a bug in tsan, but turning expected into an
atomic variable will avoid the warnings.

Change-Id: I6d6a5d58f90258d201ae3880473228638de0a215
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2021-05-12 13:49:45 +01:00
Mike Achtelik
08d8c59629 androiddeployqt: Check if apk is already aligned
Newer versions of the android gradle plugin already align the apk
internally. Therefore it is not necessary to indiscriminately align
every apk. So let's first check, if it is already aligned and only
align it if necessary. This prevents possible alignment errors,
which might occur when aligning it again. If it is already aligned,
we can just copy and continue signing the apk.

Fixes: QTBUG-88989
Change-Id: If29004e372e7927c88a900dc56f490bf9bce9ec7
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2021-05-12 10:09:17 +02:00
Lorn Potter
7c233d4034 wasm: fix unicode keyboard handling
We can simplify and reduce the lookup table by casting to
unicode for all printable keys.
This means that non US/ASCII keyboards will have better support.

Pick-to: 5.15
Fixes: QTBUG-84494
Change-Id: I60aa6320cf1b5d82910ed77e136246d301bfc09a
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2021-05-12 10:35:11 +10:00
Fabian Kosmale
524c187af3 QProperty: Cleanup QPropertyAlias leftovers
This removes traces of QPropertyAlias which is internal API which is
a) not really working even before this change (no compatibility with
   QBindableInterface due to QPropertyAlias not being derived from
   QUntypedPropertyData)
b) not used anywhere

For BIC reasons, we need to keep some methods still around until Qt 7,
though.

Change-Id: I5bb4735a4c88cba275dc2cc6e29a46ca09622059
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2021-05-11 22:22:08 +02:00
Allan Sandfeld Jensen
6d87f9a526 Tell code-checker drawPolygon can't be called with negative count
Change-Id: I082ab823ca039d1d611bfdab6b69e3650d724844
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2021-05-11 22:00:09 +02:00
Ivan Solovev
bdaaf99228 QSFPM: make filterRegularExpression and filterCaseSensitivity bindable
This takes care of the last two QSFPM properties. They were postponed
because of the tricky relation between them and some bugs in handling
the changes.
The bug was fixed in bcbbbdb2d6 and
now the behavior is well-determined: updating filter regexp does
trigger case sensitivity change and vice versa. However updating
only regexp pattern (via QString overload or setFilterFixedString
or setFilterWildcard) does not change case sensitivity.

Task-number: QTBUG-85520
Change-Id: Idc41cf817de9e6263ed65a80fa40fc8415c8c856
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Andreas Buhr <andreas.buhr@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-05-11 21:05:09 +02:00
Ivan Solovev
9134113c4f QSortFilterProxyModel: port to new property system
filterRegularExpression and filterCaseSensitivity
will be handled in a separate commit

Task-number: QTBUG-85520
Change-Id: I848c5c6cbe8642efa156f4f5d33467976bbf0351
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
Reviewed-by: Andreas Buhr <andreas.buhr@qt.io>
2021-05-11 21:05:09 +02:00
Luca Beldi
811a6c6b77 Fix QStandardItemModel signals on takeChild
takeItem and takeChild do not signal the change correctly to the
external world, this change fixes the problem

Fixes: QTBUG-89145
Pick-to: 6.1 5.15
Change-Id: Ib4844ace53007068a2cd62eba64df99e6e45fdc0
Reviewed-by: David Faure <david.faure@kdab.com>
2021-05-11 18:55:09 +01:00
Allan Sandfeld Jensen
0bbccfe001 Initialize FirstPtBlock.next to make static analysis happy
Could in theory be triggered with a 0 line spanning elipsis.

Pick-to: 6.1
Change-Id: I2166ee354d2f7488e1fcddfcb8c949c8ca2452fe
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2021-05-11 19:55:09 +02:00
Allan Sandfeld Jensen
9d2850bda9 Avoid potential read of uninitialized clip data
Set clip->count to 0 unconditional not just when hasRegionClip or
hasRectClip is true.

Pick-to: 6.1
Change-Id: Ib3d1c4dc24373df3d4dbc393241226a8730bb9fc
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2021-05-11 18:57:17 +02:00
Craig Scott
f5c69a5195 CMake: Walk link dependencies recursively to work out finalizers
When versionless targets are used, they are defined as INTERFACE
IMPORTED targets. These will sit between the executable target created
by qt6_add_executable() and the underlying Qt6::XXX module library
where the finalizers are defined. We need to recurse through the link
dependencies to ensure we pick up these finalizers. This will also
ensure we pick up finalizers in deeper targets from transitive
dependencies.

Fixes: QTBUG-93387
Change-Id: If8524ebf0e75c8790858dd7e42aa1cf4ebdfd989
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-05-11 18:57:17 +02:00
Piotr Srebrny
867c0b8d8a Do not remove non-widget items when removeWidget() called with nullptr
child->widget() returns null if the layout item is not a widget.
Thus, calling removeWidget(nullptr) will remove all non-widget items
such as layouts or strechers.

Change-Id: I772c1158d0f7e8e2850b6e571b0405a2896f09b8
Pick-to: 6.0 6.1 5.15
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: David Faure <david.faure@kdab.com>
2021-05-11 16:57:17 +00:00
Morten Sørvig
1e85dfacf3 Make resizeMaximizedWindows() preserve native geometry
Previously, resizeMaximizedWindows() would use the device
independent screen size as the source of truth when
setting window sizes. However this size may have been
rounded, which means that e.g. a fullscreen window may
fail to cover the entire screen.

Instead, use the native screen size as the true screen
size. Set QPlatformWindow geometry, and let the
platform update QWindow geometry via geometry change
events.

Pick-to: 6.1
Fixes: QTBUG-87334
Change-Id: If6e4852dea46ab03c83e469808c0047bc933ee47
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-05-11 18:39:07 +02:00
Giuseppe D'Angelo
89f55f13fd QFlags::testFlag: clarify the behavior in the docs
The name made me fall in a trap: I thought that testFlag returned
true if *any* of the bits in the argument were set in the QFlags
object. In reality, it returns true if *all* the bits are set, and
an argument equivalent to 0 is treated specially. Clarify this
in the documentation.

Change-Id: I9e8088c48038b4e6ba5830fdb7e473c6d7884b29
Pick-to: 5.15 6.0 6.1
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-05-11 17:19:34 +02:00
Friedemann Kleint
26638dfe3b Windows QPA/Vista style: Fix placeholder color
Bring back the code that was removed by
62c3dd5632 to the Windows theme.

Pick-to: 6.1
Fixes: QTBUG-93635
Change-Id: I066e89d482a584c1719f6bfb6160710ee73e1b81
Reviewed-by: André de la Rocha <andre.rocha@qt.io>
2021-05-11 17:19:34 +02:00
Giuseppe D'Angelo
aafea67cf6 QFlags: add operator== and !=
It's a value type, and we don't need detours through implicit
conversions (which are a real disgrace, as they make nonsense like
`flags != 3.14` well-formed).

[ChangeLog][QtCore][QFlags] Added overloads of operator== and
operator!= between QFlags objects, and between a QFlags object
and an object of the flag's enumeration.

Change-Id: I36701dea8fcd4cc64941e78af58fa7d38a15a8c7
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-05-11 16:54:57 +02:00
Alexandru Croitor
3a62f9e0c9 CMake: Resurrect test_import_plugins cmake build tests
Now that we run tests for static Qt builds in the CI, it makes sense
to restore the CMake build tests that check that static plugin
importing works correctly.

Resurrect the previously commented out test_import_plugins project and
port the mockplugins qmake projects to CMake.

mockplugins is a CMake project that uses the internal Qt CMake API to
build and install some Qt modules and plugins.

test_import_plugins depends on that test (via a CMake fixture) to
build public projects that use those plugins.

The installation of the mockplugins modules pollutes the Qt install
prefix, but in the CI that only happens on the test VM, which means
the release packages are not affected.

Locally on a developer machine the Qt install path will be polluted,
but it's not that much of a big deal. We could try and address that in
a future change by using the QT_ADDITIONAL_PACKAGES_PREFIX_PATH
functionality added for Conan to allow the installation of Qt packages
into a non-standard prefix.

Task-number: QTBUG-87580
Task-number: QTBUG-92933
Change-Id: I0841064a60a5ffba5118640d3197527a38ba6c30
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-05-11 14:35:30 +02:00
Assam Boudjelthia
f379446230 Handle checkPermission() below api 23
Although Qt 6 supports API 23+, it's still not bad to do this fix, it
achieves two things:
* Avoid the use of reflection when checking for permission state
* It works for all api versions

With this we would be sure we don't need to do a check in c++

if (androidSdkVersion < 23)
    return true;

The platform api checks if permission is granted or not, irrelevant of
the api version.

Change-Id: I9766dc35bbc8347ad0d60fde54b95710c8866736
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2021-05-11 12:35:30 +00:00
Chen Bin
aeef92c3c3 Check scrollbar visibility when computing QListView margins
When the listview setWordWrap is true and ScrollBarPolicy is
ScrollBarAsNeeded, if the text needs a newline display and the
vbar is not shown, the width of the item was subtracted from
the width of the scrollbar.

In most cases, the listview needs to reserve the size of the scrollbar.
But if the flow is TopToBottom and the vertical scrollbar is not
visible, the width of the vertical scrollbar cannot be reserved.

Fixes: QTBUG-92366
Pick-to: 5.15 6.0 6.1
Change-Id: I73cce691099a253d409019dbb3fe9a16e1830bb1
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-05-11 20:35:30 +08:00
Giuseppe D'Angelo
2be9e6cc26 Q_DECLARE_OPERATORS_FOR_FLAGS: also define operator&
Bitwise ANDing an enum and a QFlags should yield identical results
as ANDing a QFlags and the enum. This latter operator already existed,
so add support for the former.

Plus, ANDing two enumerators of a flag type should yield a QFlags, and
not a plain int. (Note that an arbitrary amount of bits can be set
in the result of such operation, as the enumerators themselves may be
masks with more than 1 bit set.)

This is slightly source incompatible, as we're changing the return
type of operator&. Code that was assigning that result to `int` still
works as expected, but code that wanted the value back in a QFlags may
have inserted some conversions like:

  flag = Enum(enumerator & otherFlag);
              ^---------------------
                used to yield int, now QFlags

which are now going to break as there's no QFlags->Enum conversion.

An earlier attempt of this patch, introduced -- and immediately
deprecated -- such a conversion, under the form of

  explicit operator Enum() const;

in order to keep such old code working both before and after this
change. The problem is that MSVC has a bug with explicit conversions to
enumerations [1], which get accidentally considered when they shouldn't,
and thus making a lot of code stop compiling due to (false) ambiguities.
So, I'm not adding that operator any more.

Note that there's a way to keep code working before and after this
change: just use

  flag = Flags(enumerator & otherFlag); // Flags, not Enum

(thanks Edward), which goes through a int -> QFlag -> QFlags conversion,
and arguably is the idiomatic way of writing such code; or use

  flag = otherFlag & enumerator;

which, as discussed above, has always returned a QFlags.

[1] https://developercommunity2.visualstudio.com/t/explicit-conversion-operator-to-enum-is/1412616

[ChangeLog][Potentially Source-Incompatible Changes][QFlags] Bitwise
AND-ing two values of an enum type for which flag operations have been
declared now produces a QFlags object. Similarly, AND-ing a value
of enum type and one of type QFlags now produces a QFlags object.
Before, it produced an integer in both cases. This may introduce a
slight incompatibility in user code; it is possible to keep the code
working in Qt versions before and after this change by inserting
enough conversions to QFlags, and/or by changing expressions such as
`enum & flag` to `flag & enum` (the latter has always produced a QFlags
object).

Change-Id: I6e645c010d3aa677820545b0c25678f1dc9a3295
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-05-11 13:22:44 +02:00
Giuseppe D'Angelo
d2759e0e32 QFlags: add operator& / &= overloads taking a QFlags object
It makes no sense to offer the "type-unsafe" operators taking a plain
int, and not offer the ones taking a QFlags object. Using these
operators has actually always worked by going through a conversion to
int, but we're going to limit that possibility in the future.

[ChangeLog][QtCore][QFlags] The operator& and operator&= now accept
a QFlags object.

Change-Id: Iee0845640014d35b646787e8bdb77854f180a9ef
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-05-11 13:22:44 +02:00
Giuseppe D'Angelo
53049d6027 QFlags: plaster Q_IMPLICIT
Change-Id: Ic56a32d354e6868f2e01771975c00509a9d91296
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-05-11 13:22:44 +02:00
Giuseppe D'Angelo
ddee595d58 QFlags: add qHash overload
Stop going through the implicit int conversion.

[ChangeLog][QtCore][QFlags] QFlags now has a qHash() overload.

Change-Id: Id380ed252695f24af2e8c239b650dcb6f44e2893
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-05-11 13:22:44 +02:00
Giuseppe D'Angelo
e906bb84fb QFlags: add (named) explicit conversion from/to int
There are some use cases where one may want to convert a QFlags object
from/to an integer deliberately; for instance, to store it in a
bitfield, saving some space. So far this worked by means of a implicit
conversions; instead, also add named conversions for this.

[ChangeLog][QtCore][QFlags] Added the fromInt() and toInt() functions
for explicit conversions from/to a plain integer.

Change-Id: I705559bf75b28c30b4446bb6d0753aedfc808eed
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-05-11 13:22:44 +02:00
Eskil Abrahamsen Blomfeldt
f385b8827a Windows: Add synthesized fonts also when there is a style name
Since Windows can synthesize certain font traits for us, we
used to register these in the font database so that we could
match against them. But after change
469b139169, this in principle
no longer happens, because we opt out whenever there is a
style name (which there usually is, this could be e.g.
"Regular" for a normal font). The result of this was that
if we looked for a bold variant of a font, we would not find
it.

In cases where a multi-engine was used, the request for bold
would still survive in the multi engine's fontDef, so we would
still pick it up later and apply the synthesis. But when
NoFontMerging was set, then we would override the weight in
the fontDef with the one from the font database.

Since the comment documents that the additional registrations
are there to make sure all the variants that Windows can
synthesize are available for matching, it does not make sense
to skip them just because the font has a style name. So this
is a partial revert of 469b139169.

Note: This exposed an error in QFontDatabase::isSmoothlyScalable().
The style parameter here is not the "styleName" (as in sub-family),
but actually predates that API. Instead it is the "style" as
returned by QFontDatabase::styles(), which may be the style
name, but it can also be the generated description of the style
and weight. In the latter case, we would return false for fonts
that are actually smoothly scalable, which is incorrect. This
caused a failure in tst_QFontMetrics::metrics(). To remedy this,
we add an additional condition, and also match the style if it
matches the generated descripion of the style key.

[ChangeLog][Windows] Fixed an issue where bold/italic would not
be synthesized for fonts if QFont::NoFontMerging was set.

Pick-to: 5.15 6.1
Fixes: QTBUG-91398
Change-Id: Id2166a47ae2d386536cf6e5e27ff09165ae8a23a
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2021-05-11 13:22:44 +02:00
Tor Arne Vestbø
8929e90e86 macOS: Remove MIME plumbing from QCocoaNativeInterface
The functions are available as private API though
qt_mac_addToGlobalMimeList and qt_mac_removeFromGlobalMimeList for
those that need it.

Task-number: QTBUG-83252
Change-Id: Ibc17aedd9aaced236a082d3d8de4b28313406a02
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2021-05-11 13:22:44 +02:00
Karsten Heimrich
2a5ac24917 Purge QFILESYSTEMENTRY_NATIVE_PATH_IS_UTF16
This was probably introduced for Symbian and did not change since
the Qt4 import (except for the Symbian code cleanup). Since it seems
only to effect Windows, use Q_OS_WIN instead.

Change-Id: I36f4d83ed5254d8b77073fc216551dfa0cc64a9f
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2021-05-11 13:22:44 +02:00
Karsten Heimrich
ec9e856563 Fix QSaveFile and QTemporaryFile issues with windows network shares
The commit amends commit 3966b571 to take UNC prefix into account as
well. Fixes the weird file name output as reported in QTBUG-74291 and
QTBUG-83365. Replace manual separator normalizing in qt_cleanPath(),
this is another spot where UNC prefix handling needs to be applied.

Also make QTemporaryFile operate on '/' as file separators to fix
creating both file types with native path separators on network shares.

Fixes: QTBUG-74291
Fixes: QTBUG-76228
Fixes: QTBUG-83365
Pick-to: 5.15 6.0 6.1
Change-Id: Iff8d26b994bf4194c074cd5c996cda3934297fa5
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-05-11 13:22:44 +02:00
Lars Schmertmann
a120d11cb5 Prefer previously used channels in QHttpNetworkConnection
When IPv4 and IPv6 are supported by a server, QHttpNetworkConnection
will start up two connections and pick the network layer of the one
that finish first. In this case the channel with index 1 is used for
IPv6. When IPv6 wins, there is no channel at index 0. This situation
needs to be respected and we should try to use existing channels first
when there is a next request.

This is especially important when TLS session resumption is used.
Creating a new channel will cause to lose the ephemeralServerKey
used in the first connection.

Fixes: QTBUG-93295
Pick-to: 5.15 6.1
Change-Id: Ic9dc6a24ef793a29c2652ad37bc11120e2e6ceef
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-05-11 09:29:58 +02:00
Robert Löhning
1a63217021 rhi: Fix memory leak
The leak can be reproduced by running the test project from QTBUG-63557
with asan, although that report is about yet another leak.
[ChangeLog][gui][QRhiGles2] Fixed a memory leak in QRhiGles2

Task-number: QTBUG-63557
Pick-to: 6.1
Change-Id: Ic4d346abb36a5666feb3ceb881865b029f5a6945
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-05-10 22:16:41 +00:00
Tor Arne Vestbø
edceff30b4 Move QtX11Extras into QtGui as private API
from qt/qtx11extras 0e67fb41cfc4b4bfbaa7dc75f8ddebdf5a08e836.

The plan is to expose these as native interfaces, so this is a first
step.

Task-number: QTBUG-83251
Change-Id: Iecba8db9a4f616a08a3750ddaae08cc30ec66f89
Reviewed-by: Liang Qi <liang.qi@qt.io>
2021-05-10 21:19:46 +00:00
Pekka Gehör
066a1de8e7 Android: Remove NoSuchMethodException error
CleanUp NoSuchMethodException error(QtActivity.notifyQtAndroidPluginRunning)
appears on application start up.

Fixes: QTBUG-93620
Pick-to: 5.15 6.1
Change-Id: Ic835e00d02af17e1b48c0ff66d82e5957c635deb
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2021-05-10 17:43:40 +00:00
Allan Sandfeld Jensen
ab216eaebf Fix antialiasing of rotated non-smooth scaled images
The fast-path can't antialias edges, and shouldn't be used when
that is requested.

Pick-to: 6.1 5.15
Change-Id: I3a0ce120ab96a6f95d11c165d1f5b356dae009fe
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2021-05-10 16:48:31 +00:00
Sona Kurazyan
78d8afed1f Remove the broken qToVoidFuture() function
QFuture already has a constructor from QFuture<T> to QFuture<void>. It's
safe to remove this function, since it couldn't be ever used: it tries
to access QFuture's private member, which leads to compilation error. It
was never documented or tested.

Change-Id: Iaed9602e2737455d159012ea18ca241954e1f7df
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-05-10 18:01:49 +02:00
Assam Boudjelthia
3b096530e1 Add hideSplashScreen() back temporarily to qjnihelpers_p
This causes a build fail for androidextras, bring it back untill
the full refactoring to use qtbase APIs is done.

Change-Id: I3528c92d7c36818b105ae300ed1df9a7b281bb92
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2021-05-10 16:01:49 +00:00
Alexandru Croitor
2a86ea10ae CMake: Allow passing arguments to tests/auto/cmake test command
Useful to pass -V if the test command is 'ctest'.

Change-Id: I77193ff2c15d8df4de71730f66afc0ee87953384
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-05-10 16:52:23 +02:00
Giuseppe D'Angelo
e830a8c7b6 PRIx macros: add missing \relates to the docs
Otherwise they won't appear.

Change-Id: I19d93aef9acb9d7afced8acbc76813a30b572953
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-05-10 11:38:19 +02:00
Alexandru Croitor
0d8eb8a5ab CMake: Don't build cmake build tests as macOS universal
We want standalone tests added by qt_internal_add_test to be built as
universal executables, so we can build them on an intel machine and
run them on an ARM machine.

But CMake build tests will be built on the final machine that runs the
tests and it might lack a universal SDK. That's why they should be
built only targeting the architecture of the machine they're running
on.

Change the generated qt.tooclhain.cmake file to allow opting in or out
of building projects with the same architectures as Qt was configured
with.

Now standalone tests will be multi-arch, but CMake build tests will be
single-arch.

Amends e379147f95

Task-number: QTBUG-85447
Task-number: QTBUG-87580
Task-number: QTBUG-92933
Change-Id: I41ab047983115f84eb2333cc9ac2d19ca08d621f
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-05-10 11:20:44 +02:00
Tor Arne Vestbø
b0e8c52fd4 Move QNativeInterface helpers to their own header file
The machinery is not needed for all translation units, so keep it out
of qglobal.h.

Change-Id: Ib0459a3f7bc036f56b0810eb750d4641f567f1fe
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2021-05-10 10:56:56 +02:00
Marius Kittler
590f70a849 Fix passing QJniEnvironment to ANativeWindow_fromSurface
The function ANativeWindow_fromSurface (as declared by
`$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/android/native_window_jni.h`
from version r22.b of the Android NDK) takes a `JNIEnv*` so `.jniEnv()` must be used.

This prevents the following compilation error:

```
error: no matching function for call to 'ANativeWindow_f
romSurface'
        m_nativeWindow = ANativeWindow_fromSurface(env, m_androidSurfaceObject.object());
                         ^~~~~~~~~~~~~~~~~~~~~~~~~
/opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/android/native_window_jni.h:45:16: note: candidate function not viable: no known conversion from 'QJniEnvironment' t
o 'JNIEnv *' (aka '_JNIEnv *') for 1st argument
ANativeWindow* ANativeWindow_fromSurface(JNIEnv* env, jobject surface);
               ^
1 error generated.
```

Pick-to: 6.1
Change-Id: I70d75cb7edc5875314fcb8a70d51d0ef40442101
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2021-05-10 10:49:25 +02:00
Jan Arve Sæther
4d4eb11fe3 Improve handling of minimumHeightForWidth()
This also aligns the implementation with QWidgetItem::heightForWidth()

Fixes: QTBUG-92599
Pick-to: 5.15 6.1
Change-Id: I0de68c61ec37a16a8c338575d07ff9e8168a0b98
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2021-05-10 08:24:13 +00:00
Allan Sandfeld Jensen
036c13a0f4 Avoid coverage overflow
We end up excluding more than 65536 from 65536 of rowHeight.

Perhaps better fixed earlier, but I can't figure this logic out right
now.

Pick-to: 6.1 5.15
Change-Id: I5721c469441f15ac112180f971c857cd67edbf96
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2021-05-10 08:16:23 +00:00
Allan Sandfeld Jensen
ddc5af9f17 Avoid fast transform paint path on values it can't handle
It has a problem with very small targets, and coordinates can't exceed
the same bounds we have on dimensions.

Pick-to: 6.1 5.15
Fixes: QTBUG-93475
Change-Id: If5b3af324f4e525cee3dc448ba41fdd8a91cc880
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2021-05-10 10:16:19 +02:00
Assam Boudjelthia
ee05af296f Move Android Extras as private APIs under qtbase
To the option to users to use some needed APIs until we make them
ready as proper cross-platform public APIs.

Change-Id: I53006397463331ebae8314bf8a3a019474aec617
Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
2021-05-10 10:40:40 +03:00
Andy Shaw
75d8623752 SQLite: Update SQLite to v3.35.5
[ChangeLog][QtSQL][SQLite] Updated SQLite to v3.35.5

Pick-to: 6.1 5.15 5.12
Change-Id: I7e1f5a4b6eb48d9f6105d7f08b35a2c62fc79660
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-05-09 20:12:55 +02:00
Assam Boudjelthia
8221b6b8c1 Add objectClass() and className() for QJniObject
This can be handy sometimes to avoid doing a env->GetObjectClass() call
to get the jclass object.

Change-Id: I015fe5ed73304338826e468e59778bcd3ceadc3b
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2021-05-08 15:32:39 +00:00
Assam Boudjelthia
3d430935cf Simplify setAndroidSdkVersion in qjnihelpers
Change-Id: Ib4695ffa1443a0b393d152a51a811f4afb163100
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2021-05-08 16:04:07 +03:00
Assam Boudjelthia
b621edddd5 Move hideSplashScreen() from qjnihelpers_p to QNativeInterface
Hiding the splash screen require one JNI call instead of having to keep
it as a global in qjnihelpers, and since it's not really easy to have a
cross platform way for it it makes sense to have it under
QNativeInterface. The alternative is probably removing it altogether
since it's not useful often.

Task-number: QTBUG-90500
Change-Id: I9b375c52afbf07e1ddd7957c1ec60af5c258f404
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2021-05-08 13:04:05 +00:00
Assam Boudjelthia
fcbba3c622 Remove unused functions in qjnihelpers
* Remove setNative{Activity,Service} and runOnUiThread functions
which are not used anywhere, probably left overs.

Change-Id: Ic7502dfd50d8eb4a9fa7abbe540a594a3614f14b
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2021-05-08 16:04:04 +03:00
Allan Sandfeld Jensen
f94b0e1dd9 Allow background inheritance between non-body block elements
Most nested block elements are merged together, so while we shouldn't
do real inheritance we need to do it when block elements are combined.

Pick-to: 6.1
Fixes: QTBUG-91236
Change-Id: I9e37b15f705db92c79a620d0d772f25d0ee72b8d
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2021-05-08 09:28:02 +02:00
Fabian Kosmale
300dec66ce QMetaMethod: Store method constness in metaobject system
[ChangeLog][QtCore][QMetaMethod] It is now possible to query the
constness of a method with QMetaMethod::isConst.

Change-Id: I8a94480b8074ef5b30555aeccd64937c4c6d97d4
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2021-05-07 21:50:58 +02:00
Andy Shaw
5c29f981fa iOS: Accessibility: Don't cut off the last character from the text value
The second parameter is the position of the first character not to be
returned when calling text(). So it needs to be passed the length of
the text, otherwise the last character is cut off.

Task-number: QTBUG-93494
Pick-to: 6.1 5.15 5.12
Change-Id: I7dd8324b3939220de125ba819b7b77588b21bd4b
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-05-07 18:59:00 +00:00
Shawn Rutledge
688602704d Support CSS text-decoration-color in underlines, overlines, strikethrough
Also add a feature to the textedit example to set this value.

[ChangeLog][QtGui][CSS] The CSS text-decoration-color attribute is now
supported in rich text spans with underlines, overlines and strikethrough.

Fixes: QTBUG-82114
Task-number: QTBUG-39617
Change-Id: I0065cb5431833da55b0f503ce7ff2b83b74b718a
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2021-05-07 17:00:20 +02:00
Doris Verria
05f7dd5ead Don't draw focus frame if widget has style rules that affect border
Skip drawing the focus ring if the widget has a custom styled
border, custom focus ring, or any rule that affects the border.
For QPushButton, if the style rule has a background
set, the bevel will be drawn in the Windows style.
Skip drawing the Mac focus frame in that case too.

Fixes: QTBUG-93032
Pick-to: 5.15 6.1
Change-Id: I7c4d4bf6f6ce7bbcd17cd620586c5efa44f2b8d6
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-05-07 12:41:02 +00:00
Volker Hilsheimer
441ff065e5 Fix compiler warning, explicitly use 64bit shift
The 1 literal is an int, shifted by an int, and then passed into resize,
which takes a 64 bit value. This makes MSVC complain about

warning C4334: '<<': result of 32-bit shift implicitly converted to 64
bits (was 64-bit shift intended?)

Silence that warning by explicitly making the 1 a 64bit long long.

Change-Id: Ica354166de4adae20e05e176dc72b7ccd1af053f
Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2021-05-07 14:41:02 +02:00
Volker Hilsheimer
6fd480142b Add note about the risk of setting min-width/height in a style sheet
Task-number: QTBUG-86677
Pick-to: 6.1 5.15
Change-Id: I1e5e10ee79d80fee40d04afe439489d6ce16a43e
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
2021-05-07 14:41:02 +02:00
Tang Haixiang
acb0065cc7 xcb: Update _NET_SUPPORTED when the window manager changes it
In some cases, the application may start before the window manager, and in some window managers
_NET_SUPPORTED may be changed. These situations will cause the _NET_SUPPORTED value obtained by Qt
to be inconsistent with the window manager.

Fixes: QTBUG-91396
Change-Id: I63c6934ad2538cdb9f05926b3748216bd0dcf04e
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-05-07 12:41:01 +00:00
Allan Sandfeld Jensen
f02c69547b Remove Qt6 ifdef switches from plugins
Removing dead code

Change-Id: I368fcec95d230e1face18062ff19704608354654
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2021-05-07 01:01:56 +02:00
Giuseppe D'Angelo
1c34bf1d6b QScopedPointer: remove doc mention of take()
It is deprecated so it shouldn't get mentioned by the ordinary docs.

Pick-to: 6.1
Change-Id: Ic867fd45396871245d6f5714f6a886c706e99c04
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-05-06 23:49:20 +02:00
Allan Sandfeld Jensen
5fa80f6cd7 Apply specialData font capitalization to non-rawFont text
We were not using the capitalization details from specialData in the
regular path of QTextEngine::itemize() causing it to be ignored.

Pick-to: 6.1 5.15
Fixes: QTBUG-90840
Change-Id: I7bb71fad4009f6d0685905a946c36ac1d24d8d3c
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2021-05-06 22:01:23 +02:00
Volker Hilsheimer
b24da5449b macOS: in password lineedits, pass dead keys to the input method
Otherwise the IM cannot correctly compose the input, making it impossible
to enter e.g. ü or ~ on certain keyboard layouts. Note that the native
macOS NSSecureTextField does not allow that either, which is however a
very bad user experience.

With this change, the modifier characters like ¨ diacritics will be visible
when entering them in either NoEcho or Password line edits. The follow-up
commit will remove those as well.

Fixes: QTBUG-84664
Change-Id: Ib4c5ab85634c17c407623f82b46c4849c72d9e69
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-05-06 22:01:23 +02:00
Alexey Edelev
11ae678b9d Put the GLX related code under the xcb_glx_plugin condition
If the xcb-glx-plugin feature is not enabled we should not compile
classes and methods that use the GLX related code of the
QOffscreenIntegrationPlugin.

Pick-to: 6.1 6.0
Change-Id: I63eff9d0a2afc1bc1fa21ee1b49f854f13b94c93
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-05-06 21:09:45 +02:00
Assam Boudjelthia
175e3ac8fa Move JNI_OnLoad implementation to qjnihelpers
To keep the Android implementation details as concise and close as
possible.

Change-Id: I8452e29ec4fc4b0a0c5e1861e159e7aea88c17b5
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-05-06 21:06:44 +03:00
Assam Boudjelthia
3a4a8398ab Add sdkVersion() to QNativeInterface::QAndroidApplication
The androidSdkVersion() is probably the most used call from
QtAndroidPrivate, so instead of waiting long time for a cross platform
api that could offer this functionality, it's better to have it now
under the NativeInterface.

Task-number: QTBUG-90497
Change-Id: I008d4c77d347d36e0a7e8ca4d6f33f993b02511b
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-05-06 21:06:44 +03:00
Assam Boudjelthia
c4961c0fbe Use templated QJniObject::object() instead of static_cast
Change-Id: I3bf366967d7995621aba1a7c1bec6732f3ef957d
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-05-06 18:06:44 +00:00
Alex Trotsenko
ca14ed494c QLocalSocket/Win: implement duplex communication in blocking mode
[ChangeLog][QtNetwork][QLocalSocket] The waitFor*() functions on
Windows now support duplex operation, as they already did on Unix.

As a side effect, this restores the behavior that a single call to
waitForReadyRead() won't emit both readyRead() and disconnected(),
which also matches Unix behavior. The groundwork for that misbehavior
was laid by incorrect refactoring in d1a671b69 already, but at this
point it was harmless, as the pipe couldn't be newly closed after a
successful read. That changed with f265c87e0, which made the queuing
of signals async.

Change-Id: I1eb80e8f147bb58825143e0fe1e4300c59ae0fbb
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
2021-05-06 21:06:44 +03:00
Volker Hilsheimer
3d71c4b740 QWindow: synthesize a QContextMenuEvent from relevant mouse events
QWindow receives keyboard originated context menu events, so it should
also receive events originating from a right-button mouse event.

Remove the incorrect statement about the special acceptance flag for
context menu events. There is no such thing, the event gets delievered
after the corresponding mouse press/release event.

Fixes: QTBUG-59988
Task-number: QTBUG-93486
Change-Id: I148310440604e74f600932cc1898fa152c483a61
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-05-06 18:06:44 +00:00
Volker Hilsheimer
718d1f88d7 Silence MSVC warning about int/size_t mismatch
Warning was

qmetaobjectbuilder.cpp(1439): warning C4267: '+=': conversion from
'size_t' to 'int', possible loss of data

Instead of adding another cast in that line, fix the warning by making
the size variable a qsizetype, and remove the now unnecessary
static_cast to int.

Pick-to: 6.1
Change-Id: Ieff9330501f5a07c4bbe1e851a3ef211f8bf2d24
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-05-06 20:06:44 +02:00
Volker Hilsheimer
e3b2b12a91 QTabBar: take a style sheet's font into account when laying out tabs
If a tab has a font assigned to it through a style sheet, then take the
font size into account when calculating the contents rectangle.

Add a test, which hardcodes the windows style to avoid flaky behavior
when e.g. macOS lays tabs out in the center.

Fixes: QTBUG-92988
Pick-to: 6.1
Change-Id: Ifb0ac97db7647cc25367972737be8878e50f6040
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2021-05-06 20:06:44 +02:00
Tor Arne Vestbø
a5c760a325 Remove duplicated declaration of QCocoaGLContext native interface
The interface is already declared in qopenglcontext_platform.h,
so the inclusion in qcocoanativeinterface.mm was unintentional.

Change-Id: Ic6d4a86527d03787efd858c1a6568933be8a4327
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-05-06 20:06:44 +02:00
Eskil Abrahamsen Blomfeldt
76d3cda884 macOS: Fix synthesized bold
When a user requested bold and there was no available font for
this (which is quite common with CJK fonts and in fact is the case
for the official Japanese font on the system), we should synthesize
the boldness.

This was done by checking if the requested font weight boldness
matched the one in the font's traits, and if not, we flag the
font boldness to be synthesized.

But when initializing the font, we would first override the requested
weight with the selected font's weight, *before* performing the check
above. So even if there was a mismatch, we would not catch this and
as a result, e.g. the system Japanese font would never be bold.

[ChangeLog][macOS] Fixed an issue where boldness would not be
correctly synthesized for families with no bold variant.

Fixes: QTBUG-85634
Pick-to: 5.15 6.1
Change-Id: I36da59d7689455e29cca283cb0724a0841095918
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-05-06 15:46:37 +02:00
Eskil Abrahamsen Blomfeldt
a1e405ce11 Windows: Work-around misreporting of Script and Roman
Two legacy bitmap fonts are misreported as TMPF_VECTOR on
Windows: Roman and Script. This causes them to be marked as
scalable, and the automatic fallback to NativeRendering in
Qt Quick does not kick in - causing the text elements to look
empty instead.

To work around this, we exploit the peculiarity that the type
of these two fonts is reported as "0" in the enumeration, which is
not a valid value. No other fonts on the system is reported as type
0, so we simply detect this error case and mark the fonts as
non-scalable, which is the safer choice.

[ChangeLog][Windows] Fixed text in "Roman" and "Script" bitmap
fonts not showing in Qt Quick applications.

Pick-to: 6.1 5.15
Fixes: QTBUG-85826
Change-Id: Id889f0dedb1d529e6dd64c6da9e17e303f4a9d04
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2021-05-06 13:19:44 +02:00
Friedemann Kleint
8886462872 QMdiArea: Fix top level window title when using DontMaximizeSubWindowOnActivation
When trying to find the original window title, check for another
maximized sub window and use its title. Protect the calls to
setWindowTitle to prevent the original title from being cleared.

Pick-to: 6.1 5.15
Fixes: QTBUG-92240
Change-Id: I55175382ab261b4cf8b5528304adaaec4fbe2c31
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2021-05-06 13:08:14 +02:00
Allan Sandfeld Jensen
50b9a4b357 Remove Qt6 switches from QtGui
Removing now dead code

Change-Id: I021539da6517fdb8443f8ae9431fc172b7910cfc
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2021-05-05 19:26:56 +02:00
Bartlomiej Moskal
93038767b7 QWidgets: show SoftwareInputPanel for key release
Virtual keyboard should be shown when editable widget get focus by key
(like Tab or BackTab). Before this change SoftwareInputPanel was
handled only for mouseKeyRelease event

Task-number: QTBUG-61652
Pick-to: 5.15
Change-Id: I85f80422b596592a04c2f9af214f991c471485c8
Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
Reviewed-by: Rami Potinkara <rami.potinkara@qt.io>
2021-05-05 16:07:17 +00:00
Topi Reinio
d831035435 Doc: Fix documentation warnings for QJni* classes
Pick-to: 6.1
Change-Id: Iab836fbdf649f1b3b60e88d32266361299ac4bb2
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2021-05-05 16:07:17 +00:00
Eirik Aavitsland
127f617387 Update bundled libjpeg-turbo to version 2.1.0
[ChangeLog][Third-Party Code] libjpeg-turbo was updated to version 2.1.0

Pick-to: 6.1 6.0 5.15 5.12
Change-Id: I82a58609120923c18f6031fec7d597138ec473ee
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2021-05-05 18:07:17 +02:00
Eirik Aavitsland
5df88b85c6 Simplify bundled libjpeg build
Move the config headers of the bundled libjpeg back into its source
directory, where they originally live, to avoid having to trick with
the include path to find them.
The goal is unification across maintained Qt branches, making version
updates simpler.

Pick-to: 6.1 6.0 5.15 5.12
Change-Id: I5b574446bbd264b0a1cb3efceb4c1cb7203cac7d
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2021-05-05 18:07:17 +02:00
Paul Olav Tvete
e2bdff3555 Fix rare integer overflow in text shaping
With extreme painter scaling, linearAdvance may be too large to fit in
an unsigned short.

Fixes: QTBUG-91758
Pick-to: 6.1 5.15
Change-Id: I7bbe6e77ec9bcef4aa5259da1d3000ed1a8eb27a
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2021-05-05 17:14:12 +02:00
Giuseppe D'Angelo
31defb8339 Edid parser: fix performance issues
A) When a QEdidParser gets built, the code populates a QMap by parsing
the system's pnp ids file. With > 2000 entries in the file, that's 2000+
allocations for the QMap, plus 4000+ allocations for key/value
(QStrings), plus a bunch of temporaries created for processing.

What's more, on XCB and EGLFS, a QEdidParser gets built *per screen*;
the map is not shared and gets rebuilt for each screen.

It's however completely unnecessary to keep this map in memory.  The
lookup is required only once per monitor change event, which, apart from
application startup, is an extremely rare event.

When such an event happens, and we have to lookup a vendor id, we can
just process the pnp database "on the fly", therefore removing the
constant memory usage from the application run.

In order to also avoid an allocation spike, just don't build a map at
all: simply process the file, using no memory allocations, one line at a
time while searching for the vendor id. I was unable to find
information about the file format, so I am not sure if it's guaranteed
that it's kept sorted by id (this could allow for a faster fail path).

B) In case of a cache miss, a hardcoded vendor table is used to try and
identify the manufacturer.

Look up in the hardcoded table using binary search, rather than a linear
scan, and don't allocate memory for each element processed in the list
(!). The size of the list (2000+) is big enough to completely justify
binary search.

C) Drive-by, remove a TOCTOU bug when opening the system file.

D) Drive-by, fix the includes in the header to IWYU.

Change-Id: I57c7cbd09a145c6efe3023c227ed36b24bed96f9
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2021-05-05 17:14:12 +02:00
Andy Shaw
72a5151403 Write out the HTML correctly for nested lists
When we are having nested lists then we need to ensure that the HTML is
outputted correctly so that the closing list and item tags are placed
in the right order.

[ChangeLog][QtGui][QTextDocument] The output of toHtml() now handles
nested lists correctly.

Fixes: QTBUG-88374
Pick-to: 6.1 5.15
Change-Id: I88afba0f897aeef78d4835a3124097fe6fd4d55e
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2021-05-05 15:14:12 +00:00
Allan Sandfeld Jensen
720defd2ca Export text-decoration
It used to be ignored because we couldn't disable it, but that works
fine now. So re-enable it.

Fixes: QTBUG-91171
Change-Id: I4cf966211bb200b73326e90fc7e4c4d3d4090511
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2021-05-05 16:28:54 +02:00
Edward Welbourne
358df462a0 Fix assertion on matchingLocales(Abhkazian, Any, Any)
CLDR v39 has no locales for Abkhazian, so the locale_index[] entry for
it actually indexes the last entry before the next language up the
enum. This has m_language_id less than Abkhazian.

Change-Id: If8b88f30476a981b3ee00ff8760a46ede0b7aab7
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2021-05-05 16:28:53 +02:00
Tamás Martinec
3b155973c4 iOS: Keep undo/redo widgets enabled on the undo shortcut bar after undo
Having two undo/redo operations on the rebuilt undo stack always enables
the undo/redo widgets on the shorcut bar. This might be more desirable than
the current behavior that only allows one undo from the shortcut bar.

Pick-to: 6.1 6.0 5.15
Fixes: QTBUG-63393
Change-Id: I2c99f27895def47b58534035461ceb7b4e5c3057
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2021-05-05 16:28:28 +03:00
Assam Boudjelthia
45daea19c3 Fix set*Field JNI template calls
The calls were trying to pass a JNIEnv* from a QJniEnvironment using
conversion operator which was removed, and weren't detected since they
are templates and were missing tests. This fix that and add test cases
for setField() and setStaticField() calls.

Pick-to: 6.1
Change-Id: I6e1e6b7f557bbc664248ad364c48d63f58b70756
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-05-05 16:28:27 +03:00
Assam Boudjelthia
afd7460aff Add new app permissions API under QCoreApplication
The API allows users to request and check the status of various
permissions. A predefined enum class of the common permission types
on different platforms is used to allow requesting permission with
a common code. Platform specific permissions are defined only on their
relevant platform. For permissions that are not predefined, they can
be requested via a string variant of this API.

This adds the Android implementation only.

[ChangeLog][QtCore] Add new API for handling app permissions with an
initial implementation for Android.

Task-number: QTBUG-90498
Change-Id: I3bc98c6ab2dceeea3ee8edec20a332ed8f56ad4f
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-05-05 16:28:27 +03:00
Bartlomiej Moskal
e5686b35f0 Android: handle ImEnterKeyType flag
Replace KEYCODE_ENTER to KEYCODE_TAB if IME_ACTION_NEXT or
IME_ACTION_PREVIOUS flag is set.

Before this change any of imKeyEntryType [1] was handled as default
return key. After the fix, event is changed to Tab or Backtab (if any of
mentioned flag is set)

[1] https://doc.qt.io/qt-5/qt.html#EnterKeyType-enum

Fixes: QTBUG-61652
Pick-to: 5.15
Change-Id: Ia27aa308fdae75bc17d1e892d17048c5afa3e2cb
Reviewed-by: Rami Potinkara <rami.potinkara@qt.io>
Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
2021-05-05 07:43:10 +00:00
Liang Qi
9f8d5bceb4 cocoa: move DEBUG_PASTEBOARD into logging category
Pick-to: 5.15 6.1
Change-Id: I8f49c030588122adff3c0eab4189bfa7e6aeff09
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-05-05 09:34:11 +02:00
Ivan Solovev
8161a9e5c0 QAbstractProxyModel: port to new property system
The biggest trick here is the getter (QAbstractProxyModel::sourceModel),
which is returning nullptr, while internally using a global
staticEmptyModel() instance.
This lead to inconsistency while binding to a proxy model without
source model. The bound object would point to staticEmptyModel()
instance, while sourceModel() getter returns nullptr.
To solve this issue a custom QBindableInterface is implemented.

Task-number: QTBUG-85520
Change-Id: I597df891c7e425d51b55f50ccbacabdfe935cbac
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2021-05-04 22:58:59 +02:00
Timur Pocheptsov
3ab7449f12 Fix changes' doc
The name of attribute has a suffix 'Attribute' which was missing.

Pick-to: 6.1
Fixes: QTBUG-93416
Change-Id: I9ce96efb38caa03957ddbdb13a5e61767e8e74f1
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-05-04 22:11:24 +02:00
Tor Arne Vestbø
f9f64cd344 Tweak naming of QT_OVERLOADED_MACRO variants
Add a _ suffix before the number of arguments, to improve readability
of the argument-specific functions.

Change-Id: I1dfc4f381450825dd143ece524bb10e117c09971
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-05-04 22:11:24 +02:00
Giuseppe D'Angelo
3a7d0e516b QPrintEngineMac: code tidies
In preparation for a change (operator&(enum, flags) producing a
QFlags, not an int), just go through operator&(flags, flags).
This removes the need for a cast to the _enum_ type (although it
requires a enum->flag conversion, which however makes perfect sense.)

Change-Id: I159ee14d894c10365f53ca378bcb18bcf3f89dff
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-05-04 16:21:50 +02:00
Edward Welbourne
517745fc9d Ensure setDateTime clears status also when short
Previously, if multiplication overflowed when trying to set the date
and time of a formerly short-form QDateTime, its status didn't get set
to reflect the failed validity check. Added a test that now correctly
detects that it's produced an invalid date-time on overflow, where
previously it produced a wrong valid date-time.

Change-Id: Id46ca34d1e32e9b9b0630f3723cefd1c13b5761e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-05-04 15:21:48 +01:00
Volker Hilsheimer
5e89c1406e Delete less-than operator for QKeyCombination
QMetaType relies on QTypeTraits to identify whether a type provides
operator<. Due to the the deprecated implicit conversion to int, this
results in several screens of deprecation warnings when using
QKeyCombination in a signal parameter or as a property type.

QKeyCombination has no ordering semantics (is Alt+F5 larger than
Control+Up?), so delete the operator.

[ChangeLog][QtCore][QKeyCombination] Potentially source-incompatible change:
the less-than operator for QKeyCombination has been deleted. Code relying
on the deprecated implicit conversion to int will no longer compile.
Use QKeyCombination::toCombined explicitly.

Change-Id: Ic8522b88d68063f74b5a5582c51aee8e18982331
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-05-04 11:52:38 +00:00