Commit Graph

45839 Commits

Author SHA1 Message Date
Marc Mutz
48827dd41f tst_QShortcut: avoid int -> QChar conversions
They're being made explicit/deprecated/removed.

Change-Id: I2d849d85e51c58b1f837c6795f3d45371f773a92
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-05-12 07:43:26 +02:00
Marc Mutz
69ffd7b6c0 QUrl: replace some lower-case macros with functions
It's cleaner.

Change-Id: Ib2297b905f5dd242c5e7ab431393398e7c93ecbf
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-05-12 07:43:23 +02:00
Volker Hilsheimer
b7b17e719e Fix coverity warnings about uninitialized data members
Coverity alerts about uninitialized members. While this might be ok
in the code here (ie TreeNode::splitLeft is never used for leaf nodes)
it can easily result in undefined behavior and other hard-to-debug
issues.

Initializing the struct with initializer syntax; compiler explorer
indicates that the compile will be able to optimze the calls to avoid
duplicate initialization of data members.

Change-Id: I0eb5d26e34f466d8c659c1945f02601aef511fbf
Fixes: QTBUG-84160
Fixes: QTBUG-84156
Coverity-Id: 218601
Coverity-Id: 11398
Pick-to: 5.15
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
2020-05-12 05:57:03 +02:00
Giuseppe D'Angelo
902120c621 Rhi: improve qHash implementations
Use the combiners and an algorithm.

Change-Id: I577950bbd2e8b0556f28e2a8381e432c22bb0dc9
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2020-05-12 01:51:26 +02:00
Giuseppe D'Angelo
707129fd5a Long live qHashMulti(Commutative)
Add a helper function so that we have a shortcut.
Instead of writing:

  QHashCombine hash;
  seed = hash(seed, fieldA);
  seed = hash(seed, fieldB);
  // etc.
  return seed;

one can now simply write:

  return qHashMulti(seed, fieldA, fieldB, fieldC);

Port a few usages inside qtbase as a demonstration.

[ChangeLog][QtCore][QHash] Added the qHashMulti and
qHashMultiCommutative functions as convenience helpers
to calculate a hash from multiple variables (typically,
data members of a class).

Change-Id: I881a9ad41168df20ceecc6588a94abe7ddc6a532
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
2020-05-12 01:51:20 +02:00
Yuhang Zhao
2844631aa9 qmake: Remove the DISCARDABLE flag for icon resources
According to [1] the DISCARDABLE attribute is for 16-bit Windows,
and it is ignored. We can drop it.

[1] https://docs.microsoft.com/en-us/windows/win32/menurc/common-resource-attributes

Change-Id: I70e5b0441a9d20f6c76c3d7a84947f8bce5c8fbd
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-05-11 23:36:27 +00:00
Yuhang Zhao
745fae0dc1 CMake: Add more entries for rc files
As what we did for QMake.

Amends commit 317383217b

Change-Id: Iab3b755193b5483362896da20a03fe2d59f37192
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-05-11 23:36:11 +00:00
Yuhang Zhao
fc1e5d9877 qmake: Update the macro names
I generated a rc file using VS2019 and I found that it's
using other macros.

According to [1], both of VOS_NT_WINDOWS32 and VOS__WINDOWS32 refers to
"File was designed for 32-bit Windows", although they have different
values, and 0x0L is the value of VFT2_UNKNOWN. So I think it's safe to
update them. VS2019 is using them as the default template for rc files,
after all.

[1] https://docs.microsoft.com/en-us/windows/win32/menurc/versioninfo-resource

Change-Id: Ibaf91394668844492f1357da05b881b9d81aa15f
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-05-12 07:35:32 +08:00
Giuseppe D'Angelo
737635fa56 QDebug: sprinkle usage of QDebugStateSaver
Change-Id: I6dc134acca2bbc010139113f196869b36da9b240
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-05-11 22:17:46 +02:00
Giuseppe D'Angelo
18693916a4 QDebug: clean up handling of QMap/QHash
Prepare for the fact that the multi-key containers will no longer
inherit from the single-key ones. Refactor the code to follow
the existing.

Change-Id: I5fd4d7e33f8184c015e18e169af72e11a5e84f0d
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-05-11 22:17:38 +02:00
Tor Arne Vestbø
f35745a30c iOS: Remove deprecated image-based launch screen
Change-Id: I50a7121c55170e1fb6950fdf7bb854cf6699df67
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2020-05-11 16:22:25 +02:00
Tor Arne Vestbø
24e83de8d1 Rewrite Qt Testlib selftest to not rely on Qt Testlib itself
We use the Catch2 testing framework to test Qt Testlib, which also opens
up the possibility of using it for other internal testing once it's made
available through the build system.

The test now has a --rebase mode which will write out the actual results
as new expected files. Once we add the required post-processing to the
results to remove timestamps and other testrun-specific data we can
remove the standalone python script generate_expected_output.py that
today has to be kept in sync with the test itself.

No attempt has been made to clean up the comparison-functions, but
these could all benefit from moving their logic from the comparison
to the sanitization step. This will both make the expected files
more generic, and will reduce the diff once a failure occurs, since
we're not seeing all the hunks that the comparison-functions ignored.

Change-Id: I1769d42e7958d56d1ad5da958db0e8fe3a2a3c23
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-05-11 15:42:28 +02:00
Yuhang Zhao
ef8640596c qmake: Fix handling of manifest file of msvc
Setting the QMAKE_MANIFEST variable doesn't have
any effect for MSVC. This commit fixes that.

If the developer is setting this variable,
he/she will definitely use CONFIG-=embed_manifest_exe
or CONFIG-=embed_manifest_dll at the same time,
so I think there is no need to check this.

Change-Id: Ie32b7e0cded71efcf14bf4c0eecab5ab1944fa2c
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-05-11 21:23:18 +08:00
Alexandru Croitor
a1ccedeb44 CMake: Workaround fix for failing RC file generation on Windows
For some reason the Help target doesn't get its RC file generated
when building qttools, which leads to a build failure.

We don't quite know yet why all this is happening, but a workaround
fix seems to be to use an OBJECT library instead of an INTERFACE
library to propagate the generated RC file.

Amends 657fa0462d

Fixes: QTBUG-84155
Change-Id: I1e1c2f3b05bae2ed009020d031c6510a517c01ec
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-05-11 15:04:44 +02:00
Laszlo Agocs
b56ed4da74 re_escape QMAKE_INCDIR_VULKAN
Avoid getting errors like the following:

Encountered invalid regular expression 'C:\VulkanSDK\1.2.131.2/include'"

Change-Id: I734995878d24bc124f486fb5145ea64d0d5a9c64
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-05-11 14:59:17 +02:00
Friedemann Kleint
21a66c167d uic: Adapt to ActiveQt module restructuring
Task-number: QTBUG-78167
Change-Id: I827db1bf519a6ffcc609d215e08622bf910d519e
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-05-11 12:45:31 +00:00
Timur Pocheptsov
479c3bd93b CA fetcher - do not add CA root if it's already present
As it was found recently CA fetcher, while building a chain with a missing
intermediary, may return the root we are already aware of (had in the "ROOT"
store). While this is in general harmless, it can be a bit surprising if
some code is analyzing the list of CA certificates after a handshake.

Pick-to: 5.15
Change-Id: I1df3b537e2a812de17e2c94ad4643cf36e7e946f
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-05-11 14:18:44 +02:00
Andrei Golubev
b428e98052 Make qtbase compile without QT_CONFIG(timezone)
Fixes: QTBUG-83795
Pick-to: 5.15
Change-Id: I05eaaf57d87a9111d3609ebab81bc707f8af98f0
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2020-05-11 14:42:00 +03:00
Marc Mutz
255cc55d74 QXmlStreamReader: port Private::put...() to QStringView
This enables the use of QChar::fromUcs4() instead of
QString::fromUcs4() in a call to putStringLiteral().

Change-Id: I6ed933cc92bfbb70ed2b168b7deeeb466bc6bfeb
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-05-11 13:17:09 +02:00
Marc Mutz
3bc9f35771 QSettings: port iniUnescapedKey() from int to char16_t
The 'ch' never had to be a 32-bit variable. It only ever gets assigned
16-bit unsigned values, so make it a char16_t and thus implicitly
convertible to QChar, even when QChar(int) is being deprecated or
removed.

Change-Id: I8391c393ca860f8f73f1495d7764dacd57275ea7
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-05-11 12:47:01 +02:00
Giuseppe D'Angelo
20f3ec461d Update PCRE2 to 10.35
[ChangeLog][Third-Party Code] PCRE2 has been update to version
10.35.

Change-Id: I9793bdd3d25b88eea0d4479f544b297d065b5fb6
Pick-To: 5.15
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-05-11 11:56:29 +02:00
Paul Wicking
0515bd8d2e Doc: Use nullptr instead of 0 in example
Pick-to: 5.15
Fixes: QTBUG-84101
Change-Id: Ia0b5a87bf9776ee14eff0483b955dd99389cb6ae
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
2020-05-11 11:48:57 +02:00
Volker Hilsheimer
90210c8d28 Remove dead code from src/widgets
Code that's removed via QT_VERSION(6, 0, 0) check is already no
longer compiled.

Change-Id: I70865f330a6260ac2e9cf2770d599a5b6f7bb7d4
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
2020-05-11 11:05:15 +02:00
Marc Mutz
219e7bafa2 QtGui: fix deprecated QChar conversions
Conversions from non-char-types to QChar are going to be deprecated.
Use QChar::fromUcs2(), fromUcs4(), QLatin1Char(), or convert the
constructor argument to char16_t.

Change-Id: Ib45ebd5560aa3a2bc460037ab09773607485c6e2
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-05-11 09:02:44 +00:00
Marc Mutz
9e56d28663 QRegularExpression: cast to PCRE2_SPTR16
It seems that PCRE2_UCHAR16 is exactly ushort, even though it's
documented to be uint16_t. There's no requirement for these to be the
same type, nor for the PCRE typedef to continue to point to the same
type, so add explicit casts.

Change-Id: I89f65d29feaada84ea00688976a123364857bc58
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2020-05-11 11:01:13 +02:00
Allan Sandfeld Jensen
8a0f100e97 Split PixelLayout to separate source file
Change-Id: I0beafa39d92550ea78e78a07b25ce1253cc6668d
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2020-05-11 10:57:05 +02:00
Marc Mutz
2ed048fa8d QString: optimize insert() of a substring
The old code malloc()ed a buffer to hold a copy of the data if a
substring of *this was to be inserted. Instead, use a QVarLengthArray.

Pick-to: 5.15
Change-Id: Ia3b4d7509bff2375ec0da5c890ecff2e9f7f335c
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-05-11 10:47:26 +02:00
Tor Arne Vestbø
ba3b53cb50 Fix scanned resources in static builds
Fixes: QTBUG-81621
Change-Id: Ica23e99054c7b2498bdb1e256c256c8b430938b4
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2020-05-11 10:24:18 +02:00
Giuseppe D'Angelo
1018dba04f Torrent example: fix crash
Yet Another Side Effect of not keeping iterator stability.

Although not idiomatic, the pattern

  while (i != e) {
    auto cur = i++;
    if (cond)
      erase(cur);
  }

was actually correct. Move to the idiomatic erase pattern
instead (it = cont.erase(it)).

The example still has memory problems all over the place on
shutdown. At least now it doesn't crash when running.

Change-Id: I30bd2c4e2b3fa7fe4e28d4426ff3d894b9bae103
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
2020-05-11 10:21:29 +02:00
Shawn Rutledge
30be6c41d5 eglfs: Send proper enter/leave events when multiple screens are in use
Given that there is only one mouse (which might change some day, but
hasn't yet), there can only be one window containing the mouse,
regardless of which screen it's on.  The implementation before was only
able to send enter/leave events when moving from one window to another
on the same screen; but we need the enter/leave events to be sent when
moving between two full-screen windows on two screens as well.

Also send an enter event the first time the mouse moves, to whichever
window that happens to be.  A Wayland compositor that renders its own
cursor will need to know which screen is in use at the beginning.

Pick-to: 5.15
Fixes: QTBUG-83973
Task-number: QTBUG-55161
Task-number: QTBUG-79924
Change-Id: Ie6f36cd33b103955a70bac73c1485bf475c08468
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2020-05-11 09:06:43 +02:00
Marc Mutz
36e5a9d025 Port QtPrivate::findString() from ushort* to char16_t*
Lots of casts disappear...

Change-Id: I21be426c9e4629657990ed4c896e4fce537aa1f0
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-05-11 08:45:44 +02:00
Marc Mutz
2c1425898d Modernize foldCase() internal functions
Overload uint/ushort versions with new char16_t/char32_t ones, and
[[deprecate]] the old ones. There's too much churn for doing the
replacement in one patch.

Change-Id: Ib1f90a1c46b80aa0fb1ea00ce614af49f49bd712
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-05-11 08:45:36 +02:00
Marc Mutz
1030d934c4 QXmlStreamSimpleStack: port to qsizetype
Change-Id: Ie4ea7ca83dc1870d1a4a4cfbe4447b5d971b33bf
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-05-11 08:32:49 +02:00
Marc Mutz
0c17dca4f0 QXmlStream: use even more ranged for loops
Write a small range adapter that maps begin() to rbegin() and end() to
rend() of the underlying range, use it to replace indexed reverse
loops with ranged for ones.

Change-Id: I5498a23106b0432ce885e72e5e3912910f50b5c1
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-05-11 07:01:34 +02:00
Marc Mutz
2e298c5f82 Port qt_to_latin1() (and it's variants) from ushort to char16_t
Change-Id: Id341257f0ac1d6fd1d3176fb34fad253d2bddfb9
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-05-11 07:01:30 +02:00
Marc Mutz
00f6258fb6 Adapt qxmlstream.g to older changes to qxmlstream_p.h
Change-Id: I35c0700ed29d756949b95c3a26fdf9f087b5ef1c
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-05-10 12:56:41 +02:00
Marc Mutz
0beaed7384 QXmlStream: use more ranged for loops
More compact and isolates against decltype(size()) issues.

Had to make QXmlStreamSimpleStack iterable.

Change-Id: Icfa7b2ab09995c7a442fd8a5b2f5d6ce90120822
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-05-10 12:49:01 +02:00
Marc Mutz
f490ac6712 QXmlStreamReader: avoid double QHash lookups
Replace

  if (hash.contains(x)) { // lookup #1
     ~~~ hash[x];         // lookup #2

with

  if (auto it = hash.find(x); it != hash.end()) { // lookup
      ~~~ *it;                                    // no lookup

halving the number of QHash lookups. The container is not shared, so
there's no danger of a detach when going directly to the non-const
function.

Change-Id: Ifae409f98e0be972b31a24326ad548723831fda8
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-05-10 12:48:23 +02:00
Marc Mutz
8ed88d8d14 Port qt_from_latin1() from ushort to char16_t
Change-Id: I054e2f604be7253d3322751d55d03b5bac09aefc
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-05-10 12:46:45 +02:00
Marc Mutz
c3d2e0e60a Replace uses of QString::fromUtf16(ushort*) with (char16_t*)
Ditto fromUcs4(uint*) with fromUcs4(char32_t*).

The ushort/uint forms will be deprecated.

Change-Id: Ia4ce45ed8679951b24af13109e3e498f51fc3c89
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-05-10 12:46:23 +02:00
Marc Mutz
90ad722fb2 QXmlStreamReader: fix a qint64 -> int truncation
QIODevice::read() returns qint64, not int, and nbytesread is qint64,
too.

Pick-to: 5.15
Change-Id: I6d41c5c656336a95bb115b461282e9f247493c25
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-05-10 11:32:06 +02:00
Lars Knoll
a4eea312ed Correctly parse non BMP char refs in the sax parser
Update the auto test accordingly, and at the same time remove
all uses of QTextStream (as they aren't required).

Change-Id: I71b7cf6a6b54ea59507f27d5d2d04cc5ae5885fc
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2020-05-10 11:31:57 +02:00
Lars Knoll
babcabfbc8 Clean up state handling for ICU and iconv based codecs
Get rid of the hack for the FreeFunction and instead add a proper
function pointer to clear the data to the ConverterState struct.

Change-Id: I104aae1a4381c69f1a254713ec76e1aeaa862cdc
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-05-10 11:31:50 +02:00
Andre de la Rocha
a77b19a911 Windows QPA: Fix missing accessible name change events
Accessible name change events were not being relayed through UI Automation.
This caused changes in the state of combo boxes and possibly other quick
controls to be missed by UI Automation clients. This would result, for
instance, in Narrator not reading the state of a combo box when its current
index was changed with the keyboard.

Fixes: QTBUG-70621
Pick-to: 5.15
Change-Id: I16de0ff2bb0fb5227111d5347c25f442e9b0a533
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2020-05-10 01:33:05 +00:00
Giuseppe D'Angelo
c54279a1ad Explain what the QStringView levels mean
Insofar the information was just in the commit message
(00a8be85d1); add that explanation
to the code itself.

Change-Id: Ice1919c803a31918e8228091b3192728cbbc32f4
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-05-09 23:49:42 +02:00
Marc Mutz
a34fa92c29 QVncClient: fix an int -> QChar conversion
It was masked by all QChar ctors being made explicit, except the char16_t one,
which was left as the only viable choice.

Change-Id: I68da90730de0a7bdcd0825b4557b8534fbda2533
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-05-09 13:41:45 +00:00
Marc Mutz
928d57d8da QChar: add fromUcs{2,4}()
The fromUcs2() named ctor is designed to replace all the non-char
integral-type constructors of QChar which make it very hard to control
the implicit QChar conversions, which have caused a few bugs in Qt
itself. As a classical named contructor, it simply returns QChar.

The fromUcs4() named "ctor", however, needs to expand surrogate pairs,
and thus can't just return QChar. Instead, it returns a small struct
that contains one or two char16_t's, can be iterated over and be
implicitly converted to QStringView.  To avoid bikeshedding the name
(FromUcs4Result, of course :), it's defined inline and thus can't be
named outside the function. This function replaces most uses of
QChar::requiresSurrogates() in QtBase.

[ChangeLog][QtCore][QChar] Added fromUcs2(), fromUcs4().

Change-Id: I803708c14001040f75cb599e33c24a3fb8d2579c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-05-09 06:26:08 +00:00
Marc Mutz
19e7c0d2b5 QChar/QString: centralize case folding in qchar.cpp
There are (at least) two implementations of the low-level case-folding
algorithm, one of which (for QChar::toLower()) seems to be wrong (it
doesn't deal with special cases which expand to more than one code
point).

The algoithm hidden in QString and entangled with the QString
detaching code makes reusing the code much harder.

At the same time, the dependency of the algorithm on the unicode
tables makes exposing a non-allocating result type in the public API
hard. std::u16string would be an alternative if we can assure that all
implementations use SSO with at least four characters.

So, for the time being, leave this as internal API for use in an
upcoming QStringView::toLower() as well as case-insensitive hashing.

Change-Id: Iabb2611846f6176776aa20e634f44d8464f3305c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-05-09 06:25:05 +00:00
Marc Mutz
f6b96bc347 QString: fix UB in replace()
Comparing with <, >, <= or >= such pointers as are not pointing into
the same array is UB. A clever compiler could look at the code,
determine that the only valid execution is for it to return true, and
just always take the copy.

While that would be benign, it's not guaranteed that this would be the
outcome (it's UB, after all), and, of course, we don't want to take
the performance hit if we don't need it.

Pick-to: 5.15
Change-Id: I48cda232ff10a3c9fd4babcd7e7103a3aed126e8
Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
2020-05-09 08:24:39 +02:00
Marc Mutz
c3b5efa250 QString: fix UB in insert()
Comparing with <, >, <= or >= such pointers as are not pointing into
the same array is UB. A clever compiler could look at the code,
determine that the only valid execution is for it to return true, and
just always take the copy.

While that would be benign, it's not guaranteed that this would be the
outcome (it's UB, after all), and, of course, we don't want to take
the performance hit if we don't need it.

Fix by using std::less, which guarantees a total ordering for all
pointers.

Pick-to: 5.15
Change-Id: If07b9363b2ecd573f259e4fa972b629362061ce5
Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
2020-05-09 08:24:31 +02:00