Amends 4d90c4e74a, after which the test
became flaky. We need to wait for the functor to be called before
quitting the thread, otherwise we have no guarnatee that any of the
queued metacall events have been processed by the thread. Since
QThread::quit is thread-safe, we can just call it from within the
functor. This guarantees that at least one of the single-shot timers
is processed before we quit.
And since QTimer::singleShot has special code paths for 0-ms timers
(going through an explicitly queued QMetaObject::invokeMethod call
rather than through an actual QSingleShotTimer object), we need to run
the test logic with different timeouts to cover both code paths.
Task-number: QTBUG-112162
Pick-to: 6.5 6.2 5.15
Change-Id: Ide1e7b4b74dcbda72144a0d73ef5f64b0694ddbc
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
The test can collide with a 1960-01-01 transition in some zones, so
move it to Jan 2nd to avoid that.
Pick-to: 6.5
Change-Id: I5286cadc0de0b66283253b0ac736f23a2add0c8f
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
A foreign window can be used both for embedding a Qt window into a
native window hierarchy, or for embedding a native window into a Qt
window hierarchy. In the former case, we should not modify the foreign
window in any way. Since the platform does not know anything about the
intended use case at the time of the foreign window creation, it should
avoid modifying the foreign window in any way, and should instead pick
up the foreign window state and reflect that through QWindow.
Pick-to: 6.5
Change-Id: Id2e39d101277ecebd656d615cea3e7f734a4b0a6
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
The member variable indexBeforeChange is member-initialized with -1 and
changed to the current row, if a valid index is set.
It is used to check, if the model has been reset to an empty model
and/or the index has been invalidated. The result is used to decide, if
the currentIndexChanged signal is emitted or not.
If a combo box had a valid index and it is invalidated afterwards
(e.g. because the combobox has no more entries), indexBeforeChange is
not reset to -1. The redundant signal emission is therefore prevented
only the first time.
This patch resets indexBeforeChange if the index is invalidated or the
last item is removed from the combo box.
It also adds a no-op check to tst_QComboBox::currentIndex.
The test data sets "check that setting the index to -1 works" and
"check that current index is invalid when removing the only item" check
the respective use cases.
As a drive-by, variable names and QObect::connect syntax have been
cleaned up in tst_QComboBox::currentIndex.
Fixes: QTBUG-108614
Pick-to: 6.5 6.2
Change-Id: Ib6dfa887d9247f2c47df065039d69ba57c32fa24
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
QT_SCREEN_SCALE_FACTORS is in many cases set on behalf of the user,
instead of by the user, so we should apply the standard app
scale factor policies to it, instead of interpreting it
as a user override.
Specifically, make it subject to the rounding policy set by
QGuiApplication::setHighDpiScaleFactorRoundingPolicy(). This
means that applications which support integer scale factors
only will see integers only, also when QT_SCREEN_SCALE_FACTORS
specifies a fractional factor.
Users who want to override can set
QT_SCALE_FACTOR_ROUNDING_POLICY=PassThrough
to restore the default Qt rounding behavior.
[ChangeLog][QtGui] The high-DPI scale factor rounding policy (settable with
QGuiApplication::setHighDpiScaleFactorRoundingPolicy() or
QT_SCALE_FACTOR_ROUNDING_POLICY) now applies to scale factors set
with QT_SCREEN_SCALE_FACTORS.
Fixes: QTBUG-95930
Fixes: QTBUG-99546
Change-Id: I936e96671fe2a0a43c3e8129f0768875cb011103
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
The usual problem, the usual fix: default the addResult() template
argument to the class template argument, cf. e.g. wg21.link/p2218.
[ChangeLog][QtCore][QPromise] Added support for calls to addResult()
with braced initializers.
Fixes: QTBUG-111826
Change-Id: I9ad7294dbcefbc5d2609ca3d9e7304dbeb8b3f41
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Currently, Qt assumes that enums always have int as their underlying
type (both in QMetaEnum::keyToValue and in the QML engine). This change
makes it possible to to retrieve the underlying type from an enum's
metaype - or rather, a metatype of an integral type with the same size
and signedness. The use cases aobve don't really rely on the exact same
type. In most cases, we wouldn't even need the signedness, however that
is already available anyway, and it will come in handy once QML supports
bigint, and we need to decide whether we should return
While it would be possible for individual users of this function to
manually query the size and signedness, having a function returning a
metatype offers additional convenience - especially in QML, where the
conversion APIs generally operate on metatypes.
Task-number: QTBUG-27451
Task-number: QTBUG-84055
Task-number: QTBUG-112180
Change-Id: Icf733b42df0ea64017d69f4d94cb7c855d9e3201
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
... and also extend the documentation to explain this case explicitly.
Fixes: QTBUG-107545
Pick-to: 6.5 6.2
Change-Id: I9414cc677b037989de60e97871485018e5c8a569
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Add support for time zones in the IBASE driver, which was introduced in
firebird 4.x. TIMESTAMP WITH TIME ZONE data type is supported in order
to store and retrieve a QDateTime with the time zone.
Task-number: QTBUG-111879
Change-Id: I631b4262d17796a17630379b7d659f88244a23ad
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
A null QString used to make a QVariant containing it null in Qt 5, but
this is no longer the case. Add a test that get_if works as expected.
Task-number: QTBUG-111598
Change-Id: I0f3511e1b33f4a9d67755269455680feda22ddca
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This second patch of the series implements get().
Unlike other get() implementations in Qt, don't use my trick with the
constrained friend free function here. Instead, provide the four
overloads manually, like mandated by the standard library for
std::variant (and, indeed, tuple), such that these functions can also
be used on subclasses of QVariant.
[ChangeLog][QtCore][QVariant] Implemented the type-based std::variant
access protocol (get<T>()/get_if<T>()) to allow easier access to the
contained element than the previous solution of casting data(), as
well as to allow generic code to treat QVariant and std::variant the
same. The holds_alternative<T>() function is not provided, since it's
the same as get_if<T> != nullptr. The index-based variant access
functions (get<I>()/get_if<I>()) are also not provided, because,
unlike std::variant, QVariant does not have a bounded number of
alternative types, and QMetaType IDs are not (all) compile-time
constants.
Fixes: QTBUG-111598
Change-Id: Id7bc41f7d91761b3483ec5604f1a4685c8079844
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
QVariant supports non-default-constructible payloads, in principle
(QTBUG-105140). And fromValue() works with such types, but value()
insists on providing a wide contract and therefore accidentally
requires default-constructible.
We can now invent other "Qt-ish" API like optional::value_or() or a
value() that returns optional<T>, but we should first get the
interface in that generic code must use, and which at the same time is
the most versatile, because it gives write access to the element
stored in the variant: [variant.get], consisting of get_if(), get(),
and holds_alternative(). The latter is the same as get_if() !=
nullptr, so we won't provide it.
This first patch implements get_if(), adds test for it.
As a Hidden Friend supposed to be called with explicit template
arguments, we run into the problem that wg21.link/P0846 solved for
C++20. Add the usual work-around, and check it works.
The ChangeLog will be on the last patch.
Task-number: QTBUG-111598
Change-Id: I23f57ea2de3946944810c5552c68a7a3060a44f2
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
I must have broken this in the 6.5 work I did for QMetaType and
QVariant, but I haven't searched which commit exactly did it. Our
QVariant tests are old and thus only checked the type ID, which meant
that they caused the registration by the act of asking for the ID in the
first place; this commit adds a couple of explicit checks for the type
registered by name before the ID.
Fixes: QTBUG-112205
Pick-to: 6.5 6.5.0
Change-Id: Idd5e1bb52be047d7b4fffffd174f1b14d90fd7a3
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
For single-shot timers, at least. QSingleShotTimer had either an
optimization or the only way to make new-style slot invocations by
storing the QSlotObject pointer and calling it directly. Instead of
doing that, let's just actually connect and let QObject handle the
actual delivery.
[ChangeLog][QtCore][QTimer] Fixed a bug that caused slots connected to
single-slot timers using the new-style connection mechanism to be
delivered in the wrong thread.
Fixes: QTBUG-112162
Pick-to: 5.15 6.2 6.5
Change-Id: Idd5e1bb52be047d7b4fffffd174eadb227ab65ee
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
As usual, assign them to a [[maybe_unused]] variable, to avoid
potential future [[nodiscard]] problems, and to indicate to
readers of the code that there's a result that's being returned,
we're just not interested in it.
Pick-to: 6.5 6.2
Change-Id: I2bd47ca98418092ca885d50a1a6417a21a612a85
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
... conveniently wrapped in a generator, to not have to keep an
algoname() function in sync with QCryptographicHash::Algorithm.
The MaxCryptoAlgorithm constant was already stale following the
addition of BLAKE2b/s algorithms in
5d69aa3ee1.
Also make the data-driven tests have an actual Algorithm column
(was: int) to minimize casting.
Pick-to: 6.5 6.2 5.15
Change-Id: I89a6098e512a72f623fd50a6f88fc351c7bb1418
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Having a simple Dear ImGui bridge is not just useful for the manual
tests, which do not have any other means to displays GUIs, but is
in itself an important exercise for the QRhi machinery.
Have a new manual test that exercises the built-in ImGui demo window.
Then use it in the displacement test for real, to replace the myriads
of key presses with on-screen sliders and checkboxes (with less code).
Change-Id: I296bafae2a5cce6fc7a447d97e68e5bcec15f451
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Because it is the least documented one, and compared to the other
Vulkan examples it does not add anything new, it just dives deeper
into Vulkan.
Pick-to: 6.5
Change-Id: Iecf3e04625fba256ea8134da57f54498ee2010db
Reviewed-by: Christian Strømme <christian.stromme@qt.io>
The necessary QT_ENABLE_P0846_SEMANTICS_FOR is already provided by
qpoint.h) here. Add a test to confirm it works.
Amends 0e22001a3b.
[ChangeLog][QtGui][QVector2/3/4D] Fixed manual get<I>() calls
(Tuple Protocol) in C++17 mode.
Task-number: QTBUG-111598
Change-Id: Id4a118b6439c2d1471b921f8d92ee558f9902eab
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
In C++17, unqualified lookup doesn't find function templates that
require ADL from a call with explicit template arguments, unless
another function template of that name is in scope (otherwise, the <
is parsed as operator less-than instead).
P0846, merged for C++20, fixes this to repeat the name lookup, parsing
the < as indicating a template.
We have API in Qt (Tuple Protocol for some types, e.g. QPoint) that
work for the purpose of Structured Bindings, but don't work for manual
unqualified calls when P0846 semantics are missing, and we're adding
more, to QVariant, so add a macro to handle the issue.
The macro simply declares a function template overload of the given
name for a throw-away struct, thereby bringing, for that one name,
P0846 semantics into C++17.
When we require C++20, we can drop this again.
Amends:
- fb6b7869e8 for QPoint(F)
- 8ae9431c79 for QMargins(F)
- 0e22001a3b for the rest
[ChangeLog][QtCore][QSize/F, QMargins/F, QPoint/F] Fixed manual
get<I>() calls (Tuple Protocol) in C++17 mode.
Task-number: QTBUG-111598
Change-Id: I2ffaef12c5bb6d82f75ce78a7c03c6789dfa0691
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
This is useful for a lot of applications that render text coming from
sources which already support arbitrarily numbered lists (like chat
applications for example). Application-side workarounds usually have
significant overhead; and this feature has been requested multiple times.
It should be possible to both read and write HTML with the <ol start="x">
attribute, and read and write Markdown with arbitrary numbers for the
first item in a list.
[ChangeLog][QtGui] QTextList now supports specifying a start index using
the new QTextList::{setStart, start} functions. The HTML start attribute
on ordered lists in rich text documents is now parsed and used when
rendering a text list. Non-negative indices in markdown lists are now
also parsed and written properly. This allows starting a list with a
different number than 1.
Fixes: QTBUG-30407
Fixes: QTBUG-65384
Task-number: QTBUG-107562
Change-Id: Ib35b9378d9134ffedaa2d92f728b0984793aa7c1
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
At least on X11 this is a real hierarchy: slave devices come and go
as children of the master devices. The goal is to verify that this tree
and the output of `xinput list` are in sync. The model calls
[begin|end]InsertRows() and [begin|end]RemoveRows() as necessary to
attempt to keep the view updated.
Task-number: QTBUG-46412
Task-number: QTBUG-98720
Task-number: QTBUG-104878
Task-number: QTBUG-112141
Change-Id: I8a2252f041cd1de777eef225d0e7f0db5c90a706
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Change the signature of stateChanged(int) to emit Qt::CheckState
instead. This was forgotten during Qt6 porting so we have to wait for
Qt7.
Task-number: QTBUG-104688
Change-Id: Ica2504e5b9ae68612de81524faed0f31c9b10402
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
I got tired of being told off by the inanity 'bot for faithfully
reflecting existing #if-ery in new #if-ery. Retain only the
documentation and definition of the deprecated define.
Change-Id: I47f47b76bd239a360f27ae5afe593dfad8746538
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This reverts commit 9286d46ee2.
Reason for revert: Should be fixed by 5c6814fb18760f65bab0f8b9cd623ee5c874a58d
Change-Id: I3a161df445af8dcbb61138d57e931a093a319027
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
We test setKey() in repeated_setKey() these days, so speed up the test
of the test suite ever so slightly by passing the key to the ctor
instead of an explicit setKey() call.
Pick-to: 6.5
Change-Id: Ia2378c0f59cbfa9d95a0f3665b06655332247e2c
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Cleanup tst_databases.h: fix identation, replace qGetHostName() with
QSysInfo::machineHostName(), use QSqlTableModel::EditStrategy instead
int for submitpolicy data to avoid casts.
Change-Id: I4917ca23c4b39ab15bc0e006e6111baefb82d278
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Fix some tests so they will correctly work with Interbase (Firebird 3.x)
Change-Id: Ib3c8ceaf31fa01af3a00a9772350b49cee8b2342
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
A table name or identifier must not be longer than 30 (< Oracle 12.2) or
128 bytes (sadly not characters).
Change-Id: I49192afaf908e12f5cfd20c754640b6117b03a71
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
QColorDialog supports entering hex rgb values only with a leading #.
That makes copy/paste impossible whenever the copy source has plain
hex, without the leading #.
This patch automatically adds a leading # character, when missing.
As a drive-by, QObject::connect statements are altered to PTMF syntax,
amending 9eb1b9e86ce3d1004e39e8ab7c7ecb6796d6df1a.
The patch also adds an autotest for the new functionality.
Fixes: QTBUG-111742
Pick-to: 6.5
Change-Id: I4ced29dc8b543457f411a3fa0ac756b550cdb09f
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Capturing complete window for menu test cases makes it fail as there can
be different window shapes (such as rectangular or rounded corners). To
avoid this, its better to capture only minimal visual portion that can
be compared against.
Change-Id: I30e85589fce8c17115f511a7a345d46949e6c9e8
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
The window frame differs across ms-windows version and this makes
combobox test case either fail or more fuzzy. To avoid this provide
only window geometry for screen capture instead of complete window
rectangle.
Change-Id: I0f1a1a95c45218ccc69fc92f589baee0135db943
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Previously the widget stayed black and we printed
"QBackingStoreDefaultCompositor: the QRhi has changed unexpectedly,
this should not happen".
To make it work the compositor is recreated in addition to the rhi
and the widgets are informed with the internal events.
Change-Id: I982d08bd3530478fe0f827080154c008a92a812e
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Update tests so they take into account minimum QWasmWindow size
constraints.
Refactor test framework and make it easier to read and write new tests.
Change-Id: I621c5eee6577f1569eef93e883d1cf0828e3946f
Reviewed-by: Mikołaj Boc <Mikolaj.Boc@qt.io>
When this code was using QByteArray, whose data() is never nullptr,
the strings presented to the underlying C APIs were always valid NTSs
(nullptr is not a valid NTS).
With QByteArrayView, or with QT5_NULL_STRINGS != 1, this is no longer
the case. Check that all implementations are fine with that.
Pick-to: 6.5 6.4
Change-Id: I78251288a4784440af4a2daf095aed7c53867287
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
QCryptographicHash is move-only these days, so
QMessageAuthenticationCode should not be left behind.
[ChangeLog][QtCore][QMessageAuthenticationCode] Added move
constructor, move assignment operator and swap() function.
Fixes: QTBUG-111677
Change-Id: I420f24c04828e8ad7043a9e8c9e7e2d47dd183e0
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
This is private for now. It's very handy to have anonymous properties
for the QML model/delegate adaptors. There are models with only
"singular" model data that doesn't have any sub-properties. Such model
data should be available from the model object via an empty string as
role. This way we can get rid of a lot of special casing.
Task-number: QTBUG-104752
Change-Id: I229e355a7cab064ee1c9f89557bc0244a5d0c90a
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Signals of the vertical scroll bar were blocked when scrolling with
pageUp/pageDown keys or clicking on the scroll range outside the
scroll bar. This has lead to inconsistent signal emissions:
The vertical scroll bar's valueChanged signal was emitted only on
single steps and when the scroll bar was moved with the mouse.
When it was moved in page steps by clicking on the scroll range or
pressing pageUp/pageDown, it was not emitted.
This patch removes the signal blocker for page step movements, which
was added in 94fd108ea4 to replace
explicit calls to blockSignals(), which were added in
c14d442b08ac81327b173b0a220c7b1840667899.
The patch also adds test function to tst_QPlainTextEdit to check if
the valueChanged signal is emitted correctly.
Pick-to: 6.5 6.4 6.2
Fixes: QTBUG-8682
Fixes: QTBUG-25365
Change-Id: I4385a5387c91497f623978e35bbbe3e06f473afe
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Drive-by changes:
- Cleanup creating a QChar[], by creating a char16_t[] and
reinterpret_cast'ing it
- Use human-readable Unicode characters where possible
Pick-to: 6.5
Change-Id: Ice2c36ff3ea4b6a5562cf907a7809166a51abd28
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>