Commit Graph

38775 Commits

Author SHA1 Message Date
Mårten Nordheim
e5e8e4f59b Make double-formatting code ready for QByteArray
Split off the actual logic in qdtoBasicLatin into a templated function,
qdtoString, which supports both QByteArray and QString. Since it uses
qullToBasicLatin_helper as part of its fallback path make the same
change to it.

Task-number: QTBUG-88484
Change-Id: Icac75ee74ba6a9ddc3aa8d4782a981ef50a88db4
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-08-17 00:31:26 +02:00
Mårten Nordheim
2696d5a71b QString::number(double): Disentangle from the QLocale path
By writing code to do formatting without considering locale

The code tries to not do any unnecessary (re)allocations, and as such
it reserves at the beginning and only appends.

Cuts execution times of benchmarks by between 30% and 80%:

 PASS   : tst_QString::initTestCase()
 PASS   : tst_QString::number_double(0, format 'f', precision 0)
 RESULT : tst_QString::number_double():"0, format 'f', precision 0":
-     0.0001774 msecs per iteration (total: 2,661, iterations: 15000000)
+     0.0001238 msecs per iteration (total: 1,858, iterations: 15000000)
 PASS   : tst_QString::number_double(0, format 'f', precision 0)
 RESULT : tst_QString::number_double():"0, format 'f', precision 0":
-     0.0002472 msecs per iteration (total: 3,709, iterations: 15000000)
+     0.0001407 msecs per iteration (total: 2,111, iterations: 15000000)
 PASS   : tst_QString::number_double(0.12340, format 'f', precision 5)
 RESULT : tst_QString::number_double():"0.12340, format 'f', precision 5":
-     0.0004769 msecs per iteration (total: 7,155, iterations: 15000000)
+     0.0001638 msecs per iteration (total: 2,458, iterations: 15000000)
 PASS   : tst_QString::number_double(-0.12340, format 'f', precision 5)
 RESULT : tst_QString::number_double():"-0.12340, format 'f', precision 5":
-     0.0005759 msecs per iteration (total: 8,639, iterations: 15000000)
+     0.0001664 msecs per iteration (total: 2,497, iterations: 15000000)
 PASS   : tst_QString::number_double(1.618033988749895, format 'f', precision 15)
 RESULT : tst_QString::number_double():"1.618033988749895, format 'f', precision 15":
-     0.0003644 msecs per iteration (total: 5,467, iterations: 15000000)
+     0.0001869 msecs per iteration (total: 2,804, iterations: 15000000)
 PASS   : tst_QString::number_double(2.220446049e-16, format 'g', precision 10)
 RESULT : tst_QString::number_double():"2.220446049e-16, format 'g', precision 10":
-     0.00070580 msecs per iteration (total: 10,587, iterations: 15000000)
+     0.0002277 msecs per iteration (total: 3,416, iterations: 15000000)
 PASS   : tst_QString::number_double(1.0E-04, format 'E', precision 1)
 RESULT : tst_QString::number_double():"1.0E-04, format 'E', precision 1":
-     0.00082213 msecs per iteration (total: 12,332, iterations: 15000000)
+     0.0002018 msecs per iteration (total: 3,028, iterations: 15000000)
 PASS   : tst_QString::number_double(1.0E+08, format 'E', precision 1)
 RESULT : tst_QString::number_double():"1.0E+08, format 'E', precision 1":
-     0.00082459 msecs per iteration (total: 12,369, iterations: 15000000)
+     0.0002016 msecs per iteration (total: 3,025, iterations: 15000000)
 PASS   : tst_QString::number_double(-1.0E+08, format 'E', precision 1)
 RESULT : tst_QString::number_double():"-1.0E+08, format 'E', precision 1":
-     0.00093840 msecs per iteration (total: 14,076, iterations: 15000000)
+     0.0002074 msecs per iteration (total: 3,111, iterations: 15000000)
 PASS   : tst_QString::cleanupTestCase()
-Totals: 11 passed, 0 failed, 0 skipped, 0 blacklisted, 153777ms
+Totals: 11 passed, 0 failed, 0 skipped, 0 blacklisted, 48753ms

Task-number: QTBUG-88484
Change-Id: I23234467801243b163dff5cccf8a9fe9d90c3e2a
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-08-17 00:31:26 +02:00
Ievgenii Meshcheriakov
fe9ddbe197 QUrl: Improve Punycode overflow handling
Add more overflow checks from the sample code in RFC 3492.
Also check if a code point to be inserted into output is in
the allowable range for Unicode.

Rewrite all overflow checks to use {add,mul}_overflow()
functions.

Do not try to process any inputs that are too long to be
part of a valid domain name label.

This fixes a test in tst_qurlinternal.

Fixes: QTBUG-95689
Pick-to: 6.2
Change-Id: Ice0b3cd640d8a688b63a791192ef2fa2f13444be
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-08-16 19:47:14 +00:00
Eskil Abrahamsen Blomfeldt
2f5695bed5 Fix printing with unhinted fonts
On high-dpi displays or when you explicitly select an unhinted font,
we pick a DirectWrite font engine. This hit an uncovered code path
on Windows, because we relied on being able to get the HFONT from
the font engine.

To fix this, we introduce an alternative code path which gets the
HFONT based on the DirectWrite font when this font engine is active.

[ChangeLog][Windows] Fixed an issue where the characters in printed
text would look too small.

Pick-to: 6.1 6.2
Fixes: QTBUG-95720
Change-Id: Ifd609e92512e1f25f0ee2aace35cb5ccedf09030
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-08-16 20:20:26 +02:00
Marc Mutz
874c8c56a4 QVarLengthArray: add missing default-ctor documentation
Was lost when we un-explicit'ed the default ctor in
c34242c679.

Pick-to: 6.2 6.1 5.15
Change-Id: Ifb4943b9e9647ae59c1cc6d5fc5076e8620b73ce
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-08-16 17:26:30 +00:00
Marc Mutz
0756b6a719 QDateTime: port away from takeFirst() use
Use the std-compatible API subset instead.

This is in preparation of using QVarLengthArray instead of QList here,
which (thankfully, because it's inefficient for arbitray T) doesn't
have pop_front().

As a drive-by, port at(0) to front() and introduce a temporary
variable. The front() call will briefly emit a detach attempt (but the
container isn't shared, so it won't actually detach), but only until
the next patch ports to QVLA.

Change-Id: I38ee123aa6730aee5ba1e14ec46fc71c5d74986e
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-08-16 19:26:29 +02:00
Marc Mutz
db8368f535 QMetaEnum: stop parsing when an invalid key is found
The old code obfuscated the algorithm by or'ing -1 into the return
value, which is equivalent to setting it to -1 on two's complement
architectures (which C++ these days requires), and happily continuing
to accumulate potential keys. But nothing that can be or'ed into -1
will ever change the value, so this is rather pointless, as we're not
emitting diagnostics apart from setting a bool to false.

Fix by simply returning -1. That makes it obvious what we're
returning, and we return early on error.

Pick-to: 6.2
Change-Id: I8957f44e03609ad58d6c25d5fa78c57190b14bdd
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-08-16 17:26:29 +00:00
Marc Mutz
29cfea3e82 QVarLengthArray: add support for emplacement
Take the rvalue insert() function and turn it into the emplace()
function. Reformulate rvalue-insert using emplace(). Lvalue insert()
is using a different code path, so leave that alone. This way, we
don't need to go overboard with testing.

[ChangeLog][QtCore][QVarLengthArray] Added emplace(), emplace_back().

Change-Id: I3e1400820ae0dd1fe87fd4b4c518f7f40be39f8b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-08-16 17:26:29 +00:00
Marc Mutz
e7ab888700 Short live namespace q20!
As proposed already for Qt 5 (then with q14 and q17), add
reimplementations of C++20 library features into a q20 namespace. The
advantage is that we can later just s/q20::/std::/ and be sure that a)
the q20 functionality works (within reason) like the std counterparts
and b) we don't have to re-indent the code after the replacement.

Start with std::identity in q20functional.h, required by
std::ranges::{any,all,none}_of() (ex ranges[1]) in q20algorithm.h,
which I happen to require in QLibrary next.

[1] We can't provide the nice range-based overloads (any_of(vector,
pred)), yet, because that would require to reimplement all the
range-related concepts, as the overloads are ambiguous if
unconstrained. First, we should check whether we can't just depend on
Nieber's ranges-v3 library instead. The q20 namespace is independent
of this decision, as it's more universally useful (q20::remove_cvref
comes to mind).

Unlike in q14/q17 times, a single header, q20.h, would become unwieldy
very soon, so use separate headers.

Change-Id: I14b98c865e242d2dc9674bc1bff5f7a9e4db9940
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-08-16 19:26:29 +02:00
Marc Mutz
8948f5cc78 QStandardPaths/Unix: use QStringTokenizer
Avoids having to allocate storage to hold the parts. Since the
startsWith('/') will fail for empty parts, remove the SkipEmptyParts
so we don't check for emptiness twice.

Change-Id: Id33a52d5fbd29f7a9d4ead758729195bb201a369
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-08-16 19:26:29 +02:00
Marc Mutz
dd3c4b66a1 QDir: use QStringTokenizer
Avoids having to allocate storage to hold the parts.

Change-Id: Ie4d877af959751139f4c098b644e4a57f63d03b9
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-08-16 19:26:29 +02:00
Marc Mutz
991c471aa5 QLibrary: succeed early for .dylib on Darwin
Drag the cheap check for 'fileName.endsWith(".dylib")' to before the
expensive operations (QFileInfo creation, extraction and splitting of
completeSuffix(), building of suffix candidate list, ...), at the cost
of a duplicated Q_OS_DARWIN check.

Change-Id: I8ed764f18f0beb8ad24c30ab806ecc5452159601
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-08-16 19:26:29 +02:00
Liang Qi
cfa631e0fb Update bundled Freetype to 2.10.4
Removed everything, imported with help of import_from_tarball.sh script,
and then added a pre-generated builds/unix/ftconfig.h

This also amends 58f5695084 because it is
not a clean update, some old files are still there.

Also redo the fix for wasm like 30f4ca4e4f.

Fixes: QTBUG-82480
Pick-to: 6.2
Change-Id: I45ee3230299908ca0372e035636dd64b6c549a27
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2021-08-16 17:26:29 +00:00
Tor Arne Vestbø
d4015a21a4 macOS: Add logging for keyboard and complex text input
Pick-to: 6.2
Change-Id: I098829e051d4f63950b2e35ee6dd4def8d70cf01
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-08-16 19:26:29 +02:00
Tor Arne Vestbø
853c350cca macOS: Map dead keys directly to their terminator when building key map
When a key press comes in we may end up in QAppleKeyMapper::possibleKeys()
as part of checking whether the key press should trigger a QShortcut.
The function builds on QAppleKeyMapper::keyMapForKey(), which provides
a map from the given virtual key to all the possible Qt::Keys that can
be produced by applying different modifier key combinations.

The map is built using the Carbon function UCKeyTranslate, that takes
the current keyboard layout, virtual key, and modifiers, and produces
the resulting characters. The function also maintains a running dead
key state via one of the arguments. When mapping a dead key, the state
variable will be updated to the current dead key state, which then
affects the next call to the function (for the next key press).

The problem is that we're not calling UCKeyTranslate for each key press.
We are calling it in a loop, for a single key press, to build up a map
of all the possible characters produced by varying the modifier keys.
And in doing so, we are passing on the dead key state from one call
to the next, even if these are for different modifiers. The result is
that the first call, for the dead key, results in mapping to \0, as
UCKeyTranslate produces no output, it only modifies the dead key state.
And then the next call, for the next modifier key combination, results
in mapping to a character that incorrectly incorporates the dead key
state (resetting it in the process).

What we really want is to directly map the initial modifier combination
to the dead key terminator character, if one is defined. This is the
character produced if the dead key state is cancelled, for example by
pressing a key that's not defined in the dead key state.

To achieve this we pass kUCKeyTranslateNoDeadKeysMask as the translate
options to UCKeyTranslate, and always reset the dead key state before
every call. Another common way to achieve the same result would be to
call UCKeyTranslate a second time when detecting that the first call
produced a dead key state, for example with a synthetic space key, to
trigger the terminator output. But this can potentially fail if the
space key actually has a defined output in the dead key state.

Fixes: QTBUG-95471
Pick-to: 6.2 6.1
Change-Id: Icdae7639fd9a641a86c9d6615679bd93d380ff5c
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2021-08-16 19:26:29 +02:00
Tor Arne Vestbø
99a4419647 macOS: Don't treat null-key as potential shortcut key
When mapping virtual keys and modifiers to their corresponding characters
via a keyboard layout we may hit combinations that do not produce any
characters. This can happen if there's no <key> element defined for the
virtual key, or if the output attribute of the element is empty (despite
the spec saying there should always be one UTF-16 code point in the output).

 https://developer.apple.com/library/archive/technotes/tn2056/_index.html

When that happens QAppleKeyMapper::keyMapForKey() will map the combination
to a null-QChar, resulting in the "key" being 0. We do not want to propagate
this back to the QShortcutMap machinery, as QShortcutMap does not validate
the keys coming out of QKeyMapper::possibleKeys(). In particular, it doesn't
check the isEmpty() or count() of the QKeySequences it creates. And even if
it did, QKeySequence itself seems to treat Qt::Key(0) + Qt::SomeModifier
as a non-empty sequence, so passing on 0-keys would still give weird bugs.

The user-visible result of passing back 0-keys is that QShortcutMap will
treat it as a partial match for any incoming key combination (as long as
some modifier is pressed that triggers the QShortcutMap machinery), which
resulting in eating the key press. This compounded the issue in QTBUG-95471.

Regression after fab3dfff7d.

Task-number: QTBUG-95471
Pick-to: 6.1 6.2
Change-Id: I2e51ec86f4df2a708e1757be827ab74859be3c8b
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2021-08-16 19:26:29 +02:00
Sona Kurazyan
9009a36c01 Fix some errors in docs of string-related classes
- Fixed various texts in docs for QStringView, QUtf8StringView and
QAnyStringView copied from QString, that are still talking about string
or string reference instead of string view.

- Replaced 'string-view' with 'string view', which is the more commonly
used form.

- Fixed the wrong usage of uppercase 'If' in some places.

- Did minor adjusments, to make the docs consistent with docs of
QByteArray/QByteArrayView.

Change-Id: Ifb905e00957e869a8befad5a36d6b00b6e621a04
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-08-16 18:53:56 +02:00
Volker Hilsheimer
06235d36ae QGraphicsProxyWidget: fix propagation of high-precision events
In order to fix QTBUG-95552 properly we have to add APIs to
QGraphicsSceneWheelEvent that informs QGraphicsProxyWidget about
whether the event is a high-precision event where Qt grabs the
wheel.

If it is, then the wheel grabber will be the QGraphicsView's viewport,
and any wheel event sent to any widget will be grabbed by it. This
results in infinite recoursion, partly fixed in change
I78400ceae8da7a4e22a988c06ed58f99f1a979f4.

The proper fix is to re-grab the wheel by the embedded widget
if it (or any of its children) accepts the ScrollBegin event (and if
not, return the grab to the QGraphicsView).

This fixes the scenarios that failed in the test case, so now scrolling
through nested widgets and scrolling in nested widgets works as the
user would expect.

Fixes: QTBUG-95552
Pick-to: 6.2
Change-Id: I3e1f31cbff999c70f8c63c034f77cd2ae567d7e3
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2021-08-16 16:37:26 +00:00
Volker Hilsheimer
4982c872ef Don't crash in high-precision wheel scrolls on a QGraphicsProxyWidget
For high-precision wheel scrolling sequences, the widget that gets
the first (typically ScrollBegin) event grabs the wheel. Qt directs
all future wheel events within the same sequence (i.e. until ScrollEnd)
to that widget.

QGraphicsView passes wheel events through to the item under the mouse,
and QGraphicsProxyWidget implements wheelEvent to forward a synthesized
QWheelEvent to the embedded widget. Since QGraphicsView's viewport has
already grabbed the wheel, any forwarded event would end up back in
QGraphicsView, resulting in infinite recursion (if the assert doesn't
fail first in debug builds).

The correct fix requires that QGraphicsProxyWidget knows that this is
a high-precision wheel event, allowing it to adjust the wheel grabber
temporarily to the embedded widget. However, QGraphicsSceneWheelEvent
doesn't provide this information.

To fix the infinite recursion, mark the generated event as synthesized
by Qt (but still send it spontaneously to enable propagarion within
the proxy widget hierarchy). In QApplication's notification routine,
interpret such events then to override the wheel grabber.

Add a test case for the various scenarios. This 6.1 compatible fix
does not pass all situations. A follow up commit that introduces the
missing APIs to QGraphicsSceneWheelEvent then fixes those as well.

Task-number: QTBUG-95552
Pick-to: 6.1 6.2
Change-Id: I78400ceae8da7a4e22a988c06ed58f99f1a979f4
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2021-08-16 18:37:26 +02:00
Volker Hilsheimer
1653ae13db Accept the QWheelEvent before each propagation step
Input events in Qt are accepted when constructed, and ignored by the
default event handler (so overriding the event handler is enough to
accept an event).

Since we use the same QWheelEvent instance for each propagation step,
we need to reset the event to be accepted before each delivery so that
an earlier child ignoring the event doesn't result in the event being
ignored without explicit acceptance.

Amends the refactoring of wheel event delivery in
92df790f46.

Task-number: QTBUG-95552
Task-number: QTBUG-79102
Task-number: QTBUG-67032
Pick-to: 6.1 6.2
Change-Id: Ib3f99792518364cf6e635cf4c6fda088051a7848
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2021-08-16 18:37:26 +02:00
Ievgenii Meshcheriakov
864ecea83b QUrl: Make Punycode encoding code less surprising
Move the code that modifies the encoding loop variables from
appendEncode() back to qt_punycodeEncoder() instead of passing
the variables by reference. This gives better overview of how those
variables change.

Remove comment claiming overflow detection inside appendEncode()
where no overflow detection is done.

Task-number: QTBUG-95689
Pick-to: 6.2
Change-Id: I8830e75370646f0c9b78cae883f778a12e32919d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-08-16 11:45:14 +02:00
Assam Boudjelthia
dc90755541 Fix Style java code format and warnings
The code had many bad formating and syntax or API usage warnings,
as well as some unused methods or classes which are fixed with this
patch.

Pick-to: 6.2 5.15 6.1
Task-number: QTBUG-71590
Change-Id: Ib113a0dc05703afb5190ec880b27daf75274cb1e
Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
2021-08-15 14:02:41 +03:00
Eirik Aavitsland
c1643e6547 Remove unused internal flag in QImage
The "locked" flag was only added for a particular use in the Freetype
font engine in 070d9c00c488a5ee6811f04170cf488ead79bf80,but that usage
was refactored away long ago in afb326f071.

Pick-to: 6.2
Change-Id: I7347c91f49ba59041f6ff35bd5a6b537d6c704d4
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2021-08-13 06:55:20 +00:00
Povilas Kanapickas
de9d486d2f Properly scale gesture positions in hi-DPI case
The local/global positions for gestures should be handled the same as
for other events as they mean effectively the same thing.

Change-Id: Ic5ad995607ecd3daf385a7c7be3b67cbae312e7b
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2021-08-12 23:14:47 +03:00
Alexandru Croitor
ab2669a9fa CMake: Fix testlib compile definitions not to be overridden
Amends 70464b355e

Pick-to: 6.2
Change-Id: I92424d830afc0aaad9001817be82a06adabd014b
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2021-08-12 15:07:56 +02:00
Alexandru Croitor
e599be12d6 CMake: Fix plugin target names to end in Plugin suffix
Pick-to: 6.2
Task-number: QTBUG-95731
Change-Id: I56a34dd26656613c95fbc8f081d39561cb691852
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-08-12 13:50:14 +02:00
Volker Hilsheimer
adafa5ee1f StyleSheet: Use rule for ComboBox in embedded QLineEdit
An editable combobox uses an embedded QLineEdit as an implementation
detail. That lineedit should use the rules that are set for the combobox
to render itself, similar to what was already implemented for the lineedit
used in a QAbstractSpinBox.

The containerWidget helper function provides the logic for identifying
the container of the rendered widget, returning the QAbstractSpinBox or
the QComboBox for an embedded QLineEdit. Use that method rather than
duplicating the logic.

Pick-to: 6.2 6.1 5.15
Fixes: QTBUG-95631
Change-Id: I50bc92a62715608b11c2c923f8f9215f56bfd15e
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
2021-08-12 13:10:27 +02:00
Tang Haixiang
a7b1aaa98b Close all popup windows when the screen is rotated
Changing the screen orientation will cause the menu position to be
displayed incorrectly. When the screen is rotated, the geometry of
the application changes. We can refer to the handling of the menu
on Android or IOS. Close the popup window when the screen
orientation changes.

Fixes: QTBUG-95607
Pick-to: 6.2
Change-Id: I55e1cd6a8b89e375c6714a9163dfb1902d52f101
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2021-08-12 19:10:27 +08:00
Assam Boudjelthia
b5b9c264dd Fix hidden API access for Android style
Use public API and attributes to retrieve part of the Android
style values instead of using reflection to access hidden or
private fields. This latter method, was throwing lots of warnings
or exceptions at the start of apps making it big annoyance to deal
with.

This patch doesn't handle drawables though, so the "full" and
"default" Android style will be somehow broken still for now.
For that reason, the default style extraction method is set to
minimal to avoid getting warnings about it, and Fusion style
could be used for Widgets apps, and for QML apps, it's recommended
to use the Material style from Quick Controls 2.

Pick-to: 6.2 5.15 6.1
Task-number: QTBUG-71590
Change-Id: If87895dc66751e23c9f4ea840e9f3e611aaa8833
Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
2021-08-12 09:46:34 +03:00
Edward Welbourne
54b1ed6798 qlocale_win: return null QVariant on failed look-ups
Various functions were still returning a null QString wrapped as a
QVariant; the caller distinguishes these cases, so should get a null
QVariant so it knows the backend failed to answer the query and can
attempt whatever fall-back it may have at its disposal.

Pick-to: 6.2
Change-Id: I0983b9f3b1026f17c3f13ab92b713bee90be466c
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-08-11 22:32:42 +02:00
Edward Welbourne
6f833eff92 Add QByteArrayView::trimmed()
Unlike simplified(), it just moves the end-points, without needing to
modify contents, so it makes sense (as for QStringView and
QLatin1String) to provide it. Moved QByteArray's trimmed() tests to
tst_QByteArrayApiSymmetry so that QBAV can now share them.

[ChangeLog][QtCore][QByteArrayView] Added trimmed().

Change-Id: Ifd7a752adb5f3d3e2ad0aa8220efa7e7d2d39baa
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2021-08-11 22:32:42 +02:00
Ievgenii Meshcheriakov
2b4ffe914f QUrl: Fix handling of invalid sequences starting with xn--
Return ASCII sequences that start with xn-- but fail Punycode
decoding as is when converting URLs to Unicode. This is consistent
with handling of sequences that do decode successfully but fail other
validity checks.

This fixes one test in tst_qurlinternal.

Task-number: QTBUG-95689
Pick-to: 6.2
Change-Id: I63d7197f25102c96f5dc21d9fecec5e015c531cb
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-08-11 19:12:00 +00:00
Edward Welbourne
dfbb2d6e1d Clarify documentation of QEXPECT_FAIL()'s mode
Present behavior is to continue or abort, according to the mode,
regardless of whether the condition marked does fail.

Change-Id: I2eb5eefbbf173326101d08f3bbb378d214e93e71
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2021-08-11 21:10:00 +02:00
Edward Welbourne
40bfc2d8a0 Clean up some notes in QtTestLib documentation
Use \note instead of \b{Note:}, don't refer to functions as macros,
and don't lie. The data-table set-up functions can delegate their
calls to addColumn(), addRow() and newRow() to functions not called
directly by the test framework.

Change-Id: I3bef22cf1a45df91dc822ac04f07e7d15053825f
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-08-11 21:10:00 +02:00
Cathy Park
3727683bd5 Fix button type to update coordinates when dragging
A move position (x,y) can be delivered to the MouseArea only if
button is Qt::NoButton during mouse move (dragging). Otherwise
mouse move does not cause positionChanged in MouseArea.

Task-number: QTBUG-95453
Pick-to: 6.1 6.2
Change-Id: I298943dc4f6f30714e940f4029c62dd52c176b93
Reviewed-by: Jaeyoon Jung <jaeyoon.jung@lge.com>
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2021-08-11 12:38:35 +00:00
Edward Welbourne
bb49d2ec02 Correct QStorageIterator::next()'s use of qstrtoll()
The end-pointer out-parameter of qstrtoll() is set to the start of the
subject string on failure, never to nullptr; and this only happens
when ok gets set false in any case, so there's no need to check for it
as well as checking ok.

Change-Id: I852a77a2398ffdcd5cb0671a586362cd578b6df4
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-08-11 14:01:55 +02:00
Yuhang Zhao
1e085b9e15 d3d11rhi: remove pre-win10 code
CreateDXGIFactory2() is always available from Windows 8.1
No need to load it dynamically.

Pick-to: 6.2
Task-number: QTBUG-84432
Change-Id: I84d82f30327df416e1fdbac256b63512900c07b7
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2021-08-11 19:35:25 +08:00
Tasuku Suzuki
c2cbd80425 Fix a typo in the comment for TrueType fonts with embedded bitmaps
Change-Id: I1484c32af03070b8c15c90f21a1ed8a8efde7797
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2021-08-11 18:14:29 +09:00
Andy Shaw
a68e1b96b8 Undeprecate QFont(QString) since this is still useful for many
Fixes: QTBUG-95441
Pick-to: 6.2
Change-Id: Ib1f78a5a797c7b7d7eb252a7bfa11b5c003ce0d3
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2021-08-11 08:19:45 +02:00
Robert Löhning
76e2409cc9 Fix memory leak if eXIf has incorrect crc
Change eb6767 from upstream repo.

Fixes oss-fuzz issue 23376.

[ChangeLog][Third-Party Code][libpng] Fix for possible memory leak in
libpng was backported.

Change-Id: Id0c2f8b8bd60438ae8b5a61c83b6e50d55c6eb65
Pick-to: 6.2 6.1 5.15
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-08-10 18:52:41 +00:00
Thiago Macieira
472520afb9 MySQL: properly fix setting the character set
Commit e4bd73dc54 moved the
mysql_set_character_set() call above the mysql_real_connect() but that
doesn't actually work, as there's no connection to send the "SET NAMES"
statement on.

So do it in two steps: first, by setting the charset in the MYSQL
structure, then by asking the server to match.

Pick-to: 6.2
Task-number: QTBUG-55444
Change-Id: I4a40ccbd3321467a8429fffd1699bd829f342124
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
2021-08-10 10:43:03 -07:00
Thiago Macieira
aa93b4835a MySQL: don't format QDateTime with timezones
Neither MySQL nor MariaDB like it. According to the documentation[1],
MySQL now accepts timezones using the [+-]HH:MM format (and -00:00 is
rejected). MariaDB does not accept timezones at all[2].

This has apparently been broken since Qt 5.0 (the "Z" suffix was
introduced in commit 2528f4ffe5), but this
issue was never noticed because the of prepared queries: when they're in
use, we transfer the time using a MYSQL_TIME structure, which does not
support timezone offsets either. We've only noticed this issue when the
code to determine if the MySQL client library supported prepared
statements broke.

[1] https://dev.mysql.com/doc/refman/8.0/en/date-and-time-literals.html
[2] https://mariadb.com/kb/en/date-and-time-literals/

Task-number: QTBUG-95071
Change-Id: I4a40ccbd3321467a8429fffd1699cc4c050ae746
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
2021-08-10 10:43:03 -07:00
Thiago Macieira
211369133c MySQL: remove the version number checks in favor of actual functionality
MariaDB library version 3.2 no longer returns the server version in the
10.x range but the library version itself, which is lower than 4.x. That
meant we concluded the server did not support prepared statements.

And because of the lack of prepared statements, all QDateTime
conversions failed, because of the timezone. I don't know if this was
intended or what, but it's a side issue.

[ChangeLog][QtSql][MySQL] Fixed the detection of whether the client and
server support prepared statements. This was caused by the mariadb
connector library reporting its own version numbers (starting in version
3.2) instead of the server version.

Fixes: QTBUG-95071
Pick-to: 5.15 6.2
Change-Id: I4a40ccbd3321467a8429fffd1699bc089ba706e6
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
Reviewed-by: Fabian Vogt <fabian@ritter-vogt.de>
2021-08-10 10:43:03 -07:00
Edward Welbourne
d055abd195 Assert that special handling of '0' padding does what it should
When formatting numbers, if the fill character used to left-pad to
field widths is '0', the code delegates that padding to the
QLocaleData's ZeroPadded formatting option. Since we want the zeros
before any minus sign, and don't want to subsequently add more zeros
before it, check that this has worked as expected when calling
replaceArgEscapes(), to confirm that it doesn't need to worry about
that.

Add some tests that verify the expected behavior.

In the process, tidy up the code doing this. Rename a local variable
to match our coding style, split a long line.

Pick-to: 6.2
Change-Id: I7cc430c5bceb006cf4e226bca33da16bd2bb1937
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-08-10 19:43:03 +02:00
Volker Hilsheimer
33f9591e37 Implement missing support for 'em' and 'ex' lengths in style sheet
The Qt style sheet reference claimed that Length properties can be
specified in 'em' or 'ex' units, but that was never implemented.

Add the missing implementation. Since the sizes depend on the size of
the font of the current element, we cannot convert the units in the CSS
parser, but have to do so in the QRenderRule constructor, where we can
make a decision about which font to use if the style sheet itself doesn't
specify a font. Fall back to the widget font if possible; otherwise it
will be the application default font.

The implementation translates em into QFontMetrics.height, identical to
what is already done in the QCssParser. This is in line with the CSS
specification, but contradicts our previous documentation which stated
that 'em' means "width of M". Fix the documentation.

Fixes: QTBUG-8096
Pick-to: 6.2
Change-Id: I145e2504ae3b19101a0d0dd63653466b6c2cec1d
Done-with: Cristian Maureira-Fredes <Cristian.Maureira-Fredes@qt.io>
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2021-08-10 19:43:02 +02:00
Tor Arne Vestbø
41d6a26731 Add default constructor and Q_DISABLE_COPY_MOVE to native interfaces
We currently define a non-default destructor, but without defining a
constructor, copy constructor, copy assignment operator, move constructor,
or a move assignment operator

Pick-to: 6.2
Change-Id: I0dcaef61d86292df5963fac410d22cb3fcf12af3
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-08-10 19:31:03 +02:00
Tor Arne Vestbø
f0757d2fcd testlib: Remove unused QTestCoreElement and QTestElementAttribute types
The "documentation" has also been removed for all types, as it didn't
add anything, and maintaining it to be in sync with the values just
adds overhead.

Pick-to: 6.2
Change-Id: Iab1dd7b9804c05559b4674342d6059b68ecf3ecf
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-08-10 16:06:36 +00:00
Tor Arne Vestbø
d9fd41a1fe testlib: Let loggers know which test function is being left
None of the loggers rely on this at the moment, but one could imagine
one that does. Plus, doing any sort of debug logging in leaveTestFunction
will at the moment be attributed to  UnknownTestFunc().

Pick-to: 6.2
Change-Id: I284b2785a276e028b9f57c26357679fd9e045ca7
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-08-10 18:06:36 +02:00
Tor Arne Vestbø
072e5d2a8f testlib: Document order of QTestResult completion functions
Pick-to: 6.2
Change-Id: I34adbcc2bd02887a93cd1e86692401e840afe8bd
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-08-10 18:06:36 +02:00
Tor Arne Vestbø
4632be1b4d testlib: Don't write redundant log message information in JUnit reporter
The separation between <system-out> and <system-err> is sufficient, and
we can't expect consumers to interpret our custom comment format.

The type of the text node has been renamed to more accurately identify
its purpose.

Pick-to: 6.2
Change-Id: I63c8ff17529fc087e1b695698350a6711eb5e68d
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-08-10 18:06:36 +02:00
Tor Arne Vestbø
c08d56be1f testlib: Treat qCritical messages as system-err in JUnit reporter
Pick-to: 6.2
Change-Id: Ia34fbc59dc430b7ef39a94bd6836d9675cde58f5
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-08-10 18:06:36 +02:00
Tor Arne Vestbø
ca15cc0049 testlib: Rename QAbstractTestLogger::QSystem to QCritical
It's used to handle qCritical() messages, and corresponds to QtMsgType's
QtCriticalMsg, so change its name to reflect what it really is.

In the process, reclassify the -maxwarnings overflow message as a warning,
rather than a critical message.

Pick-to: 6.2
Change-Id: I87626117a547ae4498d5dc352b93bd6db8bfb332
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-08-10 18:06:36 +02:00
Tor Arne Vestbø
308280e7a9 testlib: Move stdout/stderr reporting into individual <testcase> elements
The original Ant JUnit reporter only writes <system-err> and <system-out>
to the <testsuite>, but more modern reporters such as Maven Surefire
scopes output to each individual <testcase>.

This is also handled by both the Jenkins JUnit and xUnit plugins, e.g.:

 https://github.com/jenkinsci/junit-plugin/commit/145eb5c98

Pick-to: 6.2
Change-Id: I20c87276004a4e0910fc18e05e6ffa0f5e5a7b7c
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-08-10 18:06:36 +02:00
Tor Arne Vestbø
825e4291cd testlib: Produce <error> elements on fatal errors in JUnit reporter
Test errors represents unanticipated problems, e.g., an unhandled
exception, or a problem with the implementation of the test.

Pick-to: 6.2
Change-Id: I87219e7ffdea56862278f005de44526ad97545f0
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-08-10 18:06:36 +02:00
Alexandru Croitor
5161d8d525 CMake: Remove qt6_enable_object_libraries_finalizer_mode
qt6_enable_object_libraries_finalizer_mode is not needed anymore
now that static Qt builds require CMake 3.21 and thus CMake takes
care of placing object library object files at the beginning of
the link line.

Rename qt6_enable_import_plugins_finalizer_mode to a more generic
qt6_set_finalizer_mode that can enable or disable multiple
different modes.

For now the only available mode is "static_plugins" which handles
the behavior of the old function name.

The mode can be enabled by calling

 qt6_set_finalizer_mode(${target} ENABLE MODES "static_plugins")

Note that the function is re-tagged as being in Technical Preview.

Ideally we would not need it at all. But we need to provide some
workaround for the limitations of linking Qt static plugins in CMake
on Linux-y platforms that use bfd ld or ld.gold.

The workaround does not work well with dependencies wrapped in
generator expressions which is why we can't confidently advertise it
as a proper solution.
Our hope is that this can be fixed in future upstream CMake versions
and the function can be removed.
See 6fcc272ac9 for details.

Adjust the tests due to the renamed and removed functions.

Amends 19e789bace
Amends cdbb390c4a
Amends a25027eecb
Amends 6fcc272ac9
Amends a3c430f390

Pick-to: 6.2
Fixes: QTBUG-95169
Task-number: QTBUG-95601
Task-number: QTBUG-95603
Change-Id: I51b85f776ec29fc04fed1a637eba7d1f60609e69
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-08-10 16:51:53 +02:00
Tor Arne Vestbø
32725806c8 Improve documentation signature for native interface accessor
Pick-to: 6.2
Change-Id: I8fd0633fb993cf1544a1fd5d897fe59f8687705a
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2021-08-10 15:53:03 +02:00
Jeremy Katz
81411cb3a8 Doc: fix QStyleOptionMenuItem::menuHasCheckableItems typo
Change-Id: I2553f3e799e57e688ae98090e34f30122fea1142
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2021-08-10 05:42:58 -07:00
Tianlu Shao
0ef190fcc4 QCompleter: QCompleter unexpectedly changes QLineEdit text
When qcompleter and qlineedit are used together, the currentcompletion()
of qcompleter is its first item by default. Therefore, when qlineedit
makes the initial value, then selects the text and enters, qcompleter
will modify the default first item to qlineedit text. The judgment that
completionprefix() of the completer is not empty is modified and added
here, because completionprefix() is always empty when there is no match.

Fixes: QTBUG-20894
Pick-to: 6.2 6.1 5.15
Change-Id: Id47f7f4da0a93d03a4e7b056ec731615b0803d13
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Reviewed-by: Tianlu Shao <shaotianlu@uniontech.com>
2021-08-10 20:21:59 +08:00
Gatis Paeglis
e946e6895a xcb: implement missing bits from ICCCM 4.1.4 WM_STATE handling
ICCCM 4.1.4 says:

Clients that want to re-use a client window (e.g. by mapping it again) after
withdrawing it must wait for the withdrawal to be complete before proceeding.
The preferred method for doing this is for clients to wait for a windown manager
to update or remove the WM_STATE property.

This patch implements the required logic. Qt 4 had something similar. Without
this patch we are calling various setter functions on a native window while it
is in an undefined state.

Fixes: QTBUG-69515
Pick-to: 6.2 5.15
Done-with: Liang Qi <liang.qi@qt.io>
Change-Id: I377a66ad3d5e43f14465d0ea670b2f43f96ed7d3
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2021-08-10 14:21:59 +02:00
Liang Qi
02248eea55 xcb: add a timeout control when reading INCR property
For the first call of QXcbClipboard::clipboardReadProperty()
inside of clipboardReadIncrementalProperty() in getSelection(),
it will get a XCB_NONE reply before the contents arrived via
property change. Then we give a chance to read more.

Manually tested with following setups:
* examples/widgets/mainwindows/application with gvim(gtk3)
* examples/widgets/widgets/imageviewer with GIMP 2.10.18(based on
gtk2) and GIMP 2.99.6(based on gtk3 via flatpak)

Fixes: QTBUG-56595
Pick-to: 5.12 5.15 6.1 6.2
Done-With: JiDe Zhang <zhangjide@uniontech.com>
Change-Id: Ib45f08464d39ad79137b1da99808c89b7dca2d08
Reviewed-by: JiDe Zhang <zhangjide@uniontech.com>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-08-10 12:21:58 +00:00
Ievgenii Meshcheriakov
f636a1efa5 QCalendarRegistry: Explicitly disable moving and copying
Add Q_DISABLE_COPY_MOVE to QCalendarRegistry to silence the following
warning produced by QtStaticAnalysisBot:

    class 'QCalendarRegistry' defines a non-default destructor but does
    not define a copy constructor, a copy assignment operator, a move
    constructor or a move assignment operator

QCalendarRegistry is a singleton so it does not need to be moved or
copied.

The warning was introduced by d0ae1ef33a.

Task-number: QTBUG-93004
Pick-to: 6.2
Change-Id: I5e018346415b9d0a1ebc3bbde2ab7c3ad5e6d9d0
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-08-10 14:21:58 +02:00
Ievgenii Meshcheriakov
9bd2ab85ac QUrl: Fix Punycode handling for non-BMP codepoints
Iterate over Unicode codepoints instead of UTF-16 characters
when converting to/from Punycode as described in the specification.
Additionally reject strings with invalid surrogate pairs when
encoding to Punycode, reject strings with any encoded surrogates
when decoding.

Remove expected failure marking from the test for this issue
in tst_qurlinternal.

Fixes: QTBUG-95577
Pick-to: 6.2
Change-Id: I3dd68f95ada6d652e2fa5c0c3118dcfa0a5f4c4d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-08-10 14:21:58 +02:00
Sona Kurazyan
d61820e5ab Improve docs for QFuture continuations
Replace phrases like "future has been running", "parent" with more
precise descriptions.

Pick-to: 6.1 6.2
Fixes: QTBUG-95273
Change-Id: Ibd5a464007d41cc437da49ba250b9ea0a46078c6
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-08-10 13:07:18 +02:00
Edward Welbourne
f5aeb4f970 qlocale_win: Rename a misnamed local variable
Although the function is called get{Dat,Tim}eFormat(), the content
it's filling the buffer with isn't a format, it's a formatted date or
time. So name the variable we transcribe the buffer into text instead
of misleadingly calling it format.

Change-Id: Ia3a51184963109a50dbc41e205bd8c83d83c04d7
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-08-10 13:07:18 +02:00
Ulf Hermann
6f8ef8c64d QVariant: Tolerate QObject* metatypes without QMetaObject
QMetaType does. QVariant should do the same.

Pick-to: 6.2
Change-Id: I3419276b78b3b5ce8bd144dee92685195797d568
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Daniel Nicoletti <daniel.nicoletti@kdab.com>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-08-10 13:07:18 +02:00
Volker Hilsheimer
79a219862f Document that hiding/disabling a menu is best done via the menuAction
Task-number: QTBUG-95072
Pick-to: 6.2
Change-Id: I83afe13b129a35b39c62abe553061cc4a390fd65
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2021-08-10 12:00:13 +02:00
Thorbjørn Lund Martsum
7502598ef5 QListView: fix AdjustToContents (sizeAdjustPolicy)
Unlike an acceptable effect in QTableView + QTreeView
setAdjustPolicy(QAbstractScrollArea::AdjustToContents)
unfortunately didn't work for QListViews (and QListWidget).

This patch corrects QListViews AdjustToContents
behavior.

[ChangeLog][QtWidgets][QListView] A more correct implementation
of QListView::viewportSizeHint has been made. That
implies that setting the sizeAdjustPolicy to AdjustToContent
on QListView and QListWidget will now cause the view to
size after the contents and avoid scrollbars.

Pick-to: 6.2
Task-number: QTBUG-58749
Change-Id: I1675115f2348e2fcf0b2c39b451ef337e10eb872
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2021-08-10 12:00:13 +02:00
Eirik Aavitsland
84aba80944 Refix for avoiding huge number of tiny dashes
Previous fix hit too widely so some valid horizontal and vertical
lines were affected; the root problem being that such lines have an
empty control point rect (width or height is 0). Fix by caculating in
the pen width.

Pick-to: 6.2 6.1 5.15
Change-Id: I7a436e873f6d485028f6759d0e2c6456f07eebdc
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2021-08-10 12:00:13 +02:00
Marc Mutz
aa25e8d87e QGuiApplication: move two static variables from DATA to BSS
The {mouse,touch}DoubleXDistance variables were initialized to -1,
which forces them into the DATA segments.

But this value is completely unused, since these variables are also
set in initThemeHints(), called from QGuiApplicationPrivate::init(),
before their only user, QGuiApplicationPrivate::processMouseEvent(),
can possibly execute.

By changing the default value to 0, then, we allow the compiler to
place these variables into the BSS segment.

Change-Id: I86144559ee2410b844f70a4f2499c8d3140d14cf
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-08-10 08:11:38 +02:00
Marc Mutz
8da891a7f4 QMetaStringTable: disable copy and move
This class is an algorithm, and shouldn't be copied or moved.

Change-Id: I6f517f53a242dbfd61975ef885c358eef139a272
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-08-10 08:11:13 +02:00
Tor Arne Vestbø
ab70aa362e macOS: Fix leaked NSMutableArray in applicationActivationChanged
The +[NSObject new] method is a combination of alloc and init.

Fixes: QTBUG-95619
Pick-to: 6.2 6.1 5.15
Change-Id: I341f8a3958fb7a016cf4c346750ea6d46eeebe9f
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2021-08-08 13:54:37 +02:00
Alexandru Croitor
b2f00dfb46 CMake: Rename qt6_add_plugin TYPE option to PLUGIN_TYPE
The intention is to remove TYPE as a keyword completely before 6.2.0
release, but in case if that's not possible due to the large amount
of repositories and examples, just print a deprecation warning for
now and handle both TYPE and PLUGIN_TYPE.

Task-number: QTBUG-95170
Pick-to: 6.2
Change-Id: If0c18345483b9254b0fc21120229fcc2a2fbfbf5
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-08-06 21:08:21 +02:00
Tor Arne Vestbø
eb4fb9fa32 testlib: Don't report blacklisted tests as failures in JUnit reporter
We don't produce <failure> elements for them, so we shouldn't include
them in the total count of failures.

In the future we might produce <skipped> elements instead, but for now
remove the incorrect increment.

Pick-to: 6.2
Change-Id: Ia89a5cdaf79f6aa2f92be53180112c40ad6da2c6
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-08-06 20:05:15 +02:00
Ievgenii Meshcheriakov
84a93d94ac QCalendar: Delete registered calendar backends on program exit
Add code to check if the calendar registry is destroyed to all
QCalendar methods that dereference QCalendarBackend pointer.

Pick-to: 6.2
Change-Id: I9b562355e2e0579396b52968f6065c6927cc9ca8
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-08-06 19:46:18 +02:00
Ievgenii Meshcheriakov
d0ae1ef33a QCalendar: Thread-safe calendar backend registration
All calendar backend accounting was moved into QCalendarRegistry class
(renamed from Registry). Calendar backends are no longer registered
inside constructors, because in multithreaded environment
this may lead to incompletely initialized instances becoming visible
via QCalendar API in multithreaded environment. All system backends are
registered by QCalendarRegistry itself when they are needed. New method
QCalendarBackend::registerCustomBackend() is provided to register
any 3rd-party calendar backends.

Registration by names was also simplified. The list of names is now
passed to QCalendarBackend::registerCustomBackend(). The checks are
provided to ensure that all system backends have non-conflicting names.
Name conflicts for custom backends are resolved in favor of earlier
registered backends, as it is already the case in the existing code.
The documentation was updated to reflect that.

Method QCalendarBackend::names() was added to query the list of names
associated with a backend after it is registered.

Calendar backend deregistration was completely removed because it is
not possible to perform it safely without reference counting.

Fixes: QTBUG-93004
Pick-to: 6.2
Change-Id: I0ab1eccc02fdd1e1c66b5e5dd076c93de32d5a49
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-08-06 19:46:18 +02:00
Marc Mutz
f84adba102 Qt namespace: add a Qt 7 note about enumerator order
LayoutDirectionAuto is the default in qguiapplication.cpp's
layout_direction. Because the numeric value isn't zero, it forces the
variable into the DATA segment instead of the more efficient BSS one.

At a less technical level, LayoutDirection{} should really produce the
default, Auto, instead of LeftToRight. APIs have been changed for
lesser violations of inclusivity :)

Change-Id: I06b42f0bc00ea539805280ef0aa9694e6d739f41
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-08-06 18:11:37 +02:00
Andrei Golubev
d4e62f2c5a moc: Support BINDABLE for private properties
Hopefully we won't need it but let's have it still at least for
consistency

Change-Id: I72289e65e5e5613174ad4d98cf8d614f9caae8e6
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-08-06 17:25:50 +02:00
Marc Mutz
6ba6e7585d QXpmHandler: clean up write_xpm_image: cut out the QBA middle-man
Instead of appending to a QByteArray and then streaming that one, just
stream the components of a line directly. QTextStream's op<<(const
char*) is not subject to QT_NO_CAST_FROM_ASCII, etc., so can be used
unconditionally.

Change-Id: Idd97a75a1b5b939de7176d40880a2f328d01927d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-08-06 17:08:10 +02:00
Tor Arne Vestbø
1272b60d9e testlib: Fix name of current test case element in JUnit reporter
Pick-to: 6.2
Change-Id: I0bd77e5f1d0540b87568a0c69a4b96442d4000eb
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-08-06 17:00:22 +02:00
Tor Arne Vestbø
a2026e4116 testlib: Write failure details as <failure> content in JUnit reporter
Pick-to: 6.2
Change-Id: Ica48769e7dfcabdc4bc8f0ed058bc22e29a0b632
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-08-06 17:00:22 +02:00
Tor Arne Vestbø
0ce70a29b3 testlib: Indent CDATA element in JUnit reporter
The data itself is not indented, as consumers may read it as verbatim
data.

Pick-to: 6.2
Change-Id: Ia934616cea273feadc3a45d7c74726d4f804f0dc
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-08-06 17:00:22 +02:00
Mårten Nordheim
9b860ece42 QString/QByteArray: Fix setNum docs and add tests
Amends 260168d9d7

Task-number: QTBUG-53706
Pick-to: 6.2
Change-Id: I01c8cdc6a3cb46ec8e49e15ad71b6d707c0d272f
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-08-06 16:49:08 +02:00
Marc Mutz
65512f8505 QInputDeviceManager: make QT_NO_KEYWORDS-clean
Change-Id: I1ba43c4dce82a8488e51c471fa3409fc08be1529
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2021-08-06 16:49:08 +02:00
Tor Arne Vestbø
f5203eeada Add native interface for X11 application, exposing display and connection
The major use-case of the now private QX11Info from Qt X11 Extras was
getting hold of the Xlib display and XCB connection, for example in KDE:

  https://lxr.kde.org/search?%21v=kf5-qt5&_filestring=&_string=QX11Info

A new native interface for QGuiApplication has now been added that
exposes these two properties, e.g.:

  if (auto *x11App = app.nativeInterface<QX11Application>())
      qDebug() << x11App->display() << x11App->connection();

To avoid type clashes one of the enum values of QXcbNativeInterface's
ResourceType had to be renamed.

Pick-to: 6.2
Task-number: QTBUG-93633
Change-Id: I2e366a2bb88bd3965ac6172ad000ae32209f43e7
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-08-06 15:09:39 +02:00
Edward Welbourne
e158502e33 Turn off feature timezone for emscripten
We don't (yet) have a workable back-end for it.

Pick-to: 6.2 5.15
Task-number: QTBUG-95314
Change-Id: I8cf0fd11f315bc7d6cac351d485f4cbc676ed95d
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
2021-08-06 14:31:11 +02:00
Edward Welbourne
57da4a4f76 Tidy up QString's replaceArgEscapes() helper function
Eliminate wasted space, add spaces required by coding style, reflow an
arithmetic expression to read more gracefully.

Change-Id: Id04dfc7710f5cdb560a8d4655608139fb4c36191
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-08-06 14:29:18 +02:00
Edward Welbourne
d0c7f718ca replaceArgEscapes(): rework nested conditional to avoid repetition
Change-Id: I42306cb38d745bde33b93d3f66e86f19f58a868a
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-08-06 14:29:18 +02:00
Edward Welbourne
54abc61af1 replaceArgEscapes(): correct a comment and assert what it relies on
Change-Id: I1d0c82b1cac0d59bd1fbda65f6a3e5be346b4c70
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-08-06 14:29:18 +02:00
Edward Welbourne
2452a7e184 replaceArgEscapes(): rework local variables to make code simpler
Change-Id: I188dc6f7a0d81d8587cc5a750d8773c3d389644f
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-08-06 14:29:18 +02:00
Edward Welbourne
0dca7afaee replaceArgEscapes(): use qsizetype in place of int ant uint
The uint, particularly, was requiring some contortions to avoid
getting a "negative" value, where using qsizetype makes it harmless,
as the resulting loops are then no-ops. In the process, document the
slightly eccentric semantics of one of the retyped variables.

Change-Id: Idaad4cfde9ed9d24e1bcbf03c2bdb10b62e07916
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
2021-08-06 14:29:18 +02:00
Edward Welbourne
47ead6ce2c replaceArgEscapes(): use a local variable to avoid duplication
Two blocks of code branched on the same local variable and, in each
block, one branch acted on a C-locale text, the other a localized
version, but doing the same to each in the two branches. Branch to set
a variable to the selected text so that we only have to write the code
to do each branch's actions to that one text.

Change-Id: I8bbc1210f2c14b19f41a9974c7b6ec2ae612cc70
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
2021-08-06 14:29:18 +02:00
Marc Mutz
ccec95fda6 QCoreGlobalData: use QHash, not QMap, for dirSearchPaths
No user of the variable iterates over the container, they only
manipulate or inspect individual entries, so order doesn't matter. If
order doesn't matter, use the more efficient QHash over QMap.

Change-Id: Id28913a57bb14eb328e668624f236f76cad86def
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-08-06 14:19:52 +02:00
Fabian Kosmale
87973325f1 Handle even more include in enum cases
The solution in d3ed7dac8a was needlessly
complicated, and broke a valid use case.
The issue of no identifier being available to parse after the include
has been processed can instead be solved by moving the test for the
closing brace after the include processing.

Fixes: QTBUG-94790
Pick-to: 6.2 6.1 5.15
Change-Id: Ieec4b89e1d117637f11479e8bddc4060f93da43d
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-08-06 11:54:11 +00:00
Marc Mutz
71334c324e QXpmHandler: actually limit characters-per-pixel to four
The following code assumed, and all comments indicated, that the cpp
variable was limited to a max of 4. Yet, as coded, cpp could be five,
in which case the XPM would be corrupt, as the header suggested five
characters-per-pixel while the data was formatted in only four.

Add a warning and error out when we encounter this situation.

[ChangeLog][QtGui][QImage] Instead of writing a corrupt file, rejects
to write XPM files with more than 64^4 colors (more than four
characters per pixel) now.

Pick-to: 6.2 6.1 5.15 5.12
Change-Id: I458873cf7d179ab2e2dacd4c17dc837d640591a9
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-08-06 13:50:39 +02:00
Marc Mutz
066dd1cdc0 QInputDeviceManager: ++explicit, ++out-of-line-dtors
It's private API, but exported, so de-inline the dtor to pin the
vtable in QtCore instead of potentially duplicating it in every plugin
that uses the class.

Change-Id: Ia948985bb94677c8453a8e7be27a14085303aaf5
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2021-08-06 13:02:44 +02:00
Morten Johan Sørvig
6336b5350b Improve WM_DPICHANGED handling
Resize QPlatformWindow on DPI change, so that QWindow
size can stay approximately constant.

For example, a 100x100 QWindow at 100% scaling will
have a 100x100 QPlatformWindow. If the scaling is changed
to 200% then the QPlatformWindow is resized to 200x200,
while the size of the QWindow stays at at 100x100.

In practice the QWindow size will also change slightly,
due to inaccuracies in how we adjust for the size of the
non-client window area. This will be addressed in a later commit.

We can get DPI change independently of screen change,
so no resizing should happen in screen change events.
Disable the resize code in QGuiApplication for Q_OS_WIN,
and remove the WithinDpiChanged flag.

The new flow for handling DPI change is:

  1) Send screen change (if any), so that the correct
     screen will be used when calculating scale factors
     during the following resize.
  2) Resize the native window, which will trigger geometry
     change events, possibly also for the QWindow.
  3) Resize child windows; WM_DPICHANGED is sent to
     top-level windows only.

Fixes: QTBUG-89294
Pick-to: 6.2
Change-Id: I0e2d44bae72d20ebdafc3d410db7be9964ad851b
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2021-08-06 13:02:44 +02:00
Morten Johan Sørvig
f988386560 Track current window DPI
The WM_DPICHANGED event gives us the new DPI, but we
also need the current DPI in order to determine the
scale factor corresponding to the DPI change.

Pick-to: 6.2
Change-Id: Ia61388415f57aa739397d3125b8751952e8fd392
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2021-08-06 13:02:44 +02:00
Nico Vertriest
7d7b484429 Doc: Fix link error to qFuzzyIsNull()
Pick-to: 6.1 6.2
Change-Id: I17d890d4d61199dd74598ffa4c670ed65894047c
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2021-08-06 12:04:28 +02:00
Marc Mutz
726119c431 QXpmHandler: clean up write_xpm_image: use conventional pointer arithmetic
... instead of *(array + index).

Also fix a pointless cast from QRgb to int which the next line
implicitly undoes (because colorMap has QRgb as key, not int) and get
rid of the local variables that facilitated said fallacy in the first
place.

Change-Id: I71a92822ee2404646f6fb5533e40252f38e6b21f
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-08-05 11:32:02 +02:00
Marc Mutz
2658f95d3c QXpmHandler: clean up write_xpm_image: scope variables better
... and fix spacing around operators and after flow-control keywords.

Change-Id: Iefaa03074536d13a655c91fb42aef6aa96c2665b
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-08-05 07:35:20 +02:00