Commit Graph

52767 Commits

Author SHA1 Message Date
Mårten Nordheim
de9c03dc6e QByteArray: Disentangle number(double) from QLocale
Previously number(double) would go through QLocale which takes a lot of
factors into consideration (which we don't need in this case) and
outputs a QString in the end, which we then have to convert back to
QByteArray. Avoid all that extra work and format it directly into a
QByteArray.

The other number() functions do not use QLocale, so are left alone for now.

Task-number: QTBUG-88484
Change-Id: I4c2eaf101a55ba16e858f95017fb171589a0184e
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-08-17 00:31:26 +02:00
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
01fdc17493 Add benchmark for QMetaEnum
Change-Id: If57f00b14713f2083260a00fd833da62d6f1cd57
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
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
Kai Köhne
d6661c5622 CMake: Warn if qt_internal_plugin(target) does not end with 'Plugin'
The logic for linking plugins in a static build in Qt6*Plugins.cmake
looks up plugins that are named Qt6*PluginConfig.cmake, and the file
name is computed by the target name.

Not naming the target 'Plugin' therefore means it won't be picked up
in static builds.

Pick-to: 6.2
Task-number: QTBUG-95731
Change-Id: Ic83a29d7c91492c302eb413a69577a0c550e1a1b
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-08-12 12:43:49 +02: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
Volker Hilsheimer
761f32ae2a Fix some compiler warnings from deprecated QFont constructor
QFont should be constructed with a list of font families.

Pick-to: 6.2
Change-Id: I61141b25d3f6e25f4fea141acbfa8e164d7af58f
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
2021-08-11 21:50:51 +02:00
Alexey Edelev
f0bb95cb63 Use _qt_module_has_headers instead of INTERFACE_MODULE_HAS_HEADERS
After introducing the _qt_module_has_headers target property, it's
better to replace the INTERFACE_MODULE_HAS_HEADERS use by
_qt_module_has_headers since properties duplicate each other.

Pick-to: 6.2
Change-Id: I4d62ed71b8ed8263f51d8575628693122580b4a7
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-08-11 21:39:53 +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
Ievgenii Meshcheriakov
22bf383519 tst_qurlinternal: Add another Punycode overflow test
The test string "xn--l0902716a" encodes 2**32. Currently
the IDNA code returns an empty string when encoding this
to Unicode instead of expected original string.

Task-number: QTBUG-95689
Pick-to: 6.2
Change-Id: I5ce7bcc744c9d5426f66b8a7d0ae76c7c92f552b
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-08-11 21:12:00 +02: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
Alexandru Croitor
06c2400f5d CMake: Warn when using CMake 3.21.0 due to issue in AUTOMOC/AUTOUIC
There can be cases where trying to incrementally rebuild an already
built Qt will cause a ninja dependency cycle error due to incorrect
dependency information created by AUTOMOC and AUTOUIC.

Example error when building qtscxml tests

ninja: error: dependency cycle:
auto/scxmlcoutput/default/tst_scxmlcoutput_default_autogen/timestamp
->
auto/scxmlcoutput/default/ids1.h ->
auto/scxmlcoutput/default/tst_scxmlcoutput_default_autogen ->
auto/scxmlcoutput/default/CMakeFiles/tst_scxmlcoutput_default_autogen
->
auto/scxmlcoutput/default/tst_scxmlcoutput_default_autogen/timestamp

Example error when building Qt Creator

ninja: error: dependency cycle:
src/shared/help/shared_help_autogen/include/ui_filternamedialog.h ->
src/shared/help/shared_help_autogen/timestamp ->
src/shared/help/shared_help_autogen/include/ui_filternamedialog.h

Warn and advise to use a different CMake version instead.

Pick-to: 6.1 6.2
Change-Id: I6f529ba6a526663bc6ed699b1bfe8a9094129887
Reviewed-by: Craig Scott <craig.scott@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-08-11 21:03:56 +02:00
Ievgenii Meshcheriakov
c859b335b9 tests: Use QT_TESTCASE_SOURCEDIR define
Replace custom SRCDIR define with QT_TESTCASE_SOURCEDIR. The latter is
automatically available to all tests to use and serves the same purpose
but is not terminated by a slash.

Change-Id: I62896d0fd84ac63ac1b74a459ec1646c6bde0a46
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-08-11 21:03:56 +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
Ievgenii Meshcheriakov
58e32ae198 tst_qurlinternal: Use a lambda for bad IDN tests
Use a lambda to simplify testcases for bad IDNs.

Task-number: QTBUG-95689
Pick-to: 6.2
Change-Id: Ia4f3a5dbc73c74968628d89bd64d7aa6692b1c46
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-08-10 23:47:52 +00: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