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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
- 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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>