Commit Graph

14090 Commits

Author SHA1 Message Date
Volker Hilsheimer
cf5d9e9eb5 QWidget: add overload to set tab order as a list of widgets
The "two widgets at a time" API to set the tab order is awkward and
easily misused (as the documentation explicitly explains). Add an inline
overload that takes an initializer_list, and call the existing function
for each consecutive pair of widgets in the list.

Add documentation with snippet, and a test.

Change-Id: I8e6f14a242866e3ee7cfb8ecade4697d6bdfb4d4
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2023-04-11 12:58:58 +02:00
Ahmad Samir
94a01cd6ec QDate: remove an old comment
QDateTime::addMsecs does check for overflow. I don't know when this
 has changed, but it doesn't matter.

Change-Id: I44c6ba5e88cce544c0d1ef33fa38a528a96b0b7e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-04-08 13:23:22 +02:00
Ahmad Samir
3202ab1eb1 QXmlStream: run the test suite from a method other than initTestCase()
Only unzip the test suite in initTestCase(), but run the tests from
runTestSuite(). This is mainly useful when running specific a unittest
locally, no need to wait for the whole zipped test suite to run.

Change-Id: I518a2de716d3d07fb5a78298f1bd3ab2759e744b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-04-08 13:23:06 +02:00
Ahmad Samir
d1140235e2 QDate: reformat a unittest
Change-Id: I323975db23f40fe2e7fc5062fbc8102dedbaaf5a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-04-08 13:21:51 +02:00
Ahmad Samir
b58606ed85 tst_qstringapisymmetry: silence a GCC warning
GCC complains:
inlined from ‘constexpr QAnyStringView::QAnyStringView(const Container&) [with Container = QVarLengthArray<QChar, 1023>; typename std::enable_if<disjunction_v<QtPrivate::IsContainerCompatibleWithQStringView<T, void>, QtPrivate::IsContainerCompatibleWithQUtf8StringView<T, void> >, bool>::type <anonymous> = true]’ at src/corelib/text/qanystringview.h:215:64,
    inlined from ‘void tst_QStringApiSymmetry::overload() [with T = QVarLengthArray<QChar, 1023>]’ at /home/ahmad/devo/qt6-git/qtbase-qglobal/tests/auto/corelib/text/qstringapisymmetry/tst_qstringapisymmetry.cpp:1178:17:
src/corelib/text/qanystringview.h:187:47: warning: ‘t’ may be used uninitialized [-Wmaybe-uninitialized]
  187 |         : m_data{str}, m_size{encodeType<Char>(str, len)}
      |                               ~~~~~~~~~~~~~~~~^~~~~~~~~~

Clang doesn't warn about this.

Change-Id: I3476236630e886b087856acd22054bfb35deb451
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-04-08 13:21:24 +02:00
Christian Ehrlicher
40045aeec8 SQL/Tests: use TableScope where possible
Use TableScope helper class to make sure the table used for the test is
really cleaned up before usage.

Change-Id: I45fffcd13acae6032636ae07097b14af174ede21
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-04-07 20:38:13 +02:00
Volker Hilsheimer
b40df32ea3 QtSql: don't use deprecated QSqlDatabase::exec in test
Change-Id: Id9e88eb874ce70c3dea6ddb0a324e589965ff9d9
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
2023-04-07 19:53:59 +02:00
Christian Ehrlicher
ca7e3bcf91 SQL/IBASE: Always escape the table names when creating the SQL statement
Sync the IBASE driver behavior for primaryIndex() and record() with the
rest by assuming that the given table name has the correct casing.
Change the tests for these two function to pass an unescaped table name.

Change-Id: I6d96359f97e1acc6970b9a22fdf0e968a616b7bc
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-04-07 15:48:57 +01:00
Christian Ehrlicher
3983babd71 QSqlQuery: add boundValueName()/boundValueNames()
[ChangeLog][SQL][SqlQuery] Added two new functions
boundValueName()/boundValueNames() to return the names of the bound
values.

Fixes: QTBUG-97847
Change-Id: I8df5f15e8df13141a34d38b0a2e13b37f4e7829c
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-04-07 14:25:28 +02:00
Morten Sørvig
a215e6650a Add DPI change tests
We can expand the testing a bit bit verifying that also
created windows work as expected, and that QWindow DPR
is updated when Screen DPI is changed.

Change-Id: I082aac18b6b086c69c16681977b7eaa6c3e54ee0
Reviewed-by: Jukka Jokiniva <jukka.jokiniva@qt.io>
2023-04-06 14:28:24 +00:00
Christian Ehrlicher
be8b3efae6 SQL/QSqlRelationalTableModel escape the auto-generated alias
The alias created by QSqlRelationTableModel to avoid duplicated field
names was not escaped which lead to an inconsistency in the returned
alias name from the database (e.g. postgres lowers all unescaped column
names).
Also adjust the test for QSqlRelationTableModel to use escaped table
names for it's tests and fix it for QIBASE.

Change-Id: I01426320c0c1a70cb9bf8e6dfa2f8b07dbb1c06b
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-04-06 05:41:16 +01:00
Volker Hilsheimer
27867de8ca Permissions: respect context object's thread and life time
When a context object is provided, then callers expect that the functor
or slot is executed in the thread of the context object. And if the
context object has been destroyed by the time the permission response
is received, the functor shouldn't be called at all.

To implement this, we either have to plumb the call back through a
signal/slot connection and benefit from QObject's infrastructure. This
is not practical here, as we don't have an "engine QObject" that would
emit a signal.

Instead, we can create a QMetaCallEvent explicitly, following what we do
in e.g. QHostInfo, and using a temporary QObject that handles the event
to then call the functor.

Add test coverage.

Pick-to: 6.5
Change-Id: Id878e45b304857304165ab4a7c6aae76fbee46ce
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-04-06 00:21:50 +02:00
Ivan Solovev
028c367f75 Deprecate QtFuture::makeReadyFuture()
[ChangeLog][Deprecation Notice][QtCore] The QtFuture::makeReadyFuture()
method and all its specializations are deprecated since Qt 6.10.
The reason for the deprecation is that the method has a
makeReadyFuture(const QList<T> &) overload, which behaves differently
from all other overloads (including other non-const ref QList
overloads).
Use QtFuture::makeReadyVoidFuture() when you need a ready void QFuture,
or QtFuture::makeReadyValueFuture() when you need to propagate the
input type to the returned QFuture, or QtFuture::makeReadyRangeFuture()
when you need to create a multi-value future based on an input
container.

Fixes: QTBUG-109677
Change-Id: I55125269989df0a02840d5ddd5763ef5f1070df5
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-04-05 13:38:15 +02:00
Ivan Solovev
9b4b32ec98 Long live QtFuture::makeReadyVoidFuture() and QtFuture::makeReadyValueFuture()
[ChangeLog][QtCore][QFuture] Added QtFuture::makeReadyVoidFuture()
and QtFuture::makeReadyValueFuture().

Basically, these methods behave like QtFuture::makeReadyFuture(), but
QtFuture::makeReadyValueFuture() does not have a "const QList<T> &"
specialization returning QFuture<T> instead of QFuture<QList<T>>,
which allows it to always behave consistently.

This patch also introduces usage of the new methods around qtbase.

Task-number: QTBUG-109677
Change-Id: I89df8b26d82c192baad69efb5df517a8b182995f
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-04-05 13:38:15 +02:00
Ivan Solovev
7f38f9f394 Long live QtFuture::makeReadyRangeFuture()
[ChangeLog][QtCore][QFuture] Introduce
QtFuture::makeReadyRangeFuture(). This method takes a container
which has input iterators and returns a multi-value
QFuture<ValueType>, where ValueType is the underlying type of
the input container.

This commit also replaces the usage of buggy
QtFuture::makeReadyFuture(const QList<T> &) overload with the new
method.

Task-number: QTBUG-109677
Change-Id: I019e62eac74c643d88a65b3cc0085bc7c33bc712
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-04-05 13:38:14 +02:00
Thiago Macieira
2f226336a2 QPluginLoader: don't instantiante multiple, identical instances
This can happen if the same project has two or more Q_IMPORT_PLUGIN
macros in their source. And that can happen when converting from qmake-
based builds to CMake, as qmake didn't generate a source file with the
macro but CMake does.

[ChangeLog][QtCore][QPluginLoader] staticInstances() will not call
duplicated registrations of the same instantiation function, which can
only happen as a result of duplicated Q_IMPORT_PLUGIN for the same
plugin name.

Fixes: QTBUG-102745
Pick-to: 6.2 6.5
Change-Id: Idd5e1bb52be047d7b4fffffd174fb9dd62d8583d
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-04-05 00:29:16 -07:00
Thiago Macieira
87103e04e9 QMultiHash: fix missing update to m_size
QMultiHash has access to two sizes: one of them is shared with QHash,
stored in QHashPrivate::Data::size, which counts keys; the other, which
is what our public size() function returns, is stored in
QMultiHash::m_size and counts plain (key,value) entries. We forgot to
update it in the non-const operator[] that created a node.

I've reviewed the rest of the code and can't find any more places where
the item count may be changed and m_size isn't updated.

[ChangeLog][QtCore][QMultiHash] Fixed a bug that caused an element that
was created by operator[] to not be counted, resulting in a hash map
with an incorrect element count and which could cause an assertion
failure depending on how the hash was later mutated.

Fixes: QTBUG-112534
Pick-to: 6.2 6.4 6.5
Change-Id: Idd5e1bb52be047d7b4fffffd17527ec274e1d99e
Reviewed-by: Lars Knoll <lars@knoll.priv.no>
2023-04-04 08:59:32 -03:00
Allan Sandfeld Jensen
c080d1e64d Create any callable using QRunnable::create
The overhead of making new custom classes appears to be less than
constructing a generic std::function.

[ChangeLog][QtCore][QRunnable] QRunnable::create can now take
non-copyable functions as argument.

Task-number: QTBUG-112302
Change-Id: Ied870f13ca6c7eaa14ed6eff9c4e676c7b73881c
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-04-04 01:05:47 +02:00
Christian Ehrlicher
5a334b3d2b SQL/tests: Add testcase for QODBC toSQLTCHAR()
Add a testcase for toSQLTCHAR() to make sure to pass the correct number
of encoded characters to the odbc functions.

Pick-to: 6.5
Task-number: QTBUG-112375
Change-Id: Ib67fab678fc3d0b098aedfc6fa9ec2139f2e75c7
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-04-03 17:52:32 +02:00
Christian Ehrlicher
2f709952cf QSqlError: also compare nativeErrorCode() in operator==() / operator!=()
A QSqlError is not equal when the native error code differs. The
database and driver text should not be considered during the
comparison because they might differ due to e.g. different locales.

[ChangeLog][QtSql][QSqlError] The comparison operators have been fixed to
take both error type and error code into account.

Change-Id: Ie7511f183f88dd454eb165c6ff237e51b79d1c08
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-04-03 15:52:03 +00:00
Volker Hilsheimer
07f7ed2bad Fix warning when comparing size_t with qsizetype
Change-Id: Id8e7ae20aea99f2acb03b665484615bf7f932873
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-04-03 17:12:18 +02:00
Marc Mutz
e848dd14f5 tst_qxmlstream: add non-US-ASCII hasAttribute() checks
One each of L1 and non-L1.

Will help porting that API to QAnyStringView.

Pick-to: 6.5
Change-Id: I51afc07c5b2384409c2627164e95265265fbb544
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-04-01 06:26:42 +02:00
Mårten Nordheim
7822b89aef Http2: Don't skip checking flag for trailing HEADERS frame if PRIORITY
If the trailing frame just had PRIORITY we would early-return, though
this meant we didn't check if the frame had the END_STREAM flag set,
leading some requests to certain servers to hang.

Fixes: QTBUG-111417
Pick-to: 6.5 6.4 6.2
Change-Id: Iac174dc5aeca30d5d19fae35f303983de9841847
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io>
2023-04-01 00:36:58 +02:00
Marc Mutz
a81ea3d114 tst_Q(Any)StringView: check conversion from winrt::hstring
Instead of adding more QString::fromMyFavoriteStringImpl(), just check
that

   QStringView{myFavoriteStringImpl}.toString()

works.

It does.

Pick-to: 6.5
Task-number: QTBUG-111886
Change-Id: I337282611360b4a56a10c8acfd2d7d53ea196d5b
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-03-31 21:41:35 +00:00
Christian Ehrlicher
46e909a37a QSqlIndex: add move ctor & move operator
Add the move ctor and move operator for QSqlIndex, also add an explicit
testcase for QSqlIndex

Task-number: QTBUG-109938
Change-Id: I46cc6a24c2e7d5b23d2ac3427cafd01b9ba257ed
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-03-31 18:36:29 +02:00
Ulf Hermann
b83de5f9a4 moc: Record types of enumerations
This will be helpful in a number of places, in particular in order to
support enums of different sizes in QML. We record the type as string in
the JSON output and as QMetaTypeInterface in the generated C++.

Task-number: QTBUG-112180
Change-Id: I943fac67f8b25b013d3860301416cdd293c0c69e
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-03-31 17:42:58 +02:00
Marc Mutz
e2b2bb7ff1 Short live q20::to_address!
An implementation of C++20 std::to_address, a prerequesite for
QSpan<>.

The test cases are inspired by libstdc++'s test suite, just to avoid
missing some cases, but the to_address implementation is white-room.

Fixes: QTBUG-108430
Change-Id: I4c092fdd7a56c0b279068e341bbf91a725ca3b1f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-03-31 13:10:12 +01:00
Axel Spoerl
a815c40e73 QListView: No-op, when a list item is dropped directly behind itself
QListView generates a move, when an item is dropped directly behind
itself. This causes unexpected behavior, e.g. item widgets getting
discarded.

This patch prevents a move from being generated in that case.

It adds an autotest to tst_QWidget, to verify item widgets and item
data do not get discarded in case of a no-op drag&drop.

Fixes: QTBUG-100128
Pick-to: 6.5 6.2
Change-Id: I02a755320a7b71dad218293c9c94c88da6507423
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-03-31 13:09:39 +02:00
Marc Mutz
b1b0f42c97 tst_qtconcurrentrun: fix UB (uninit'ed values)
While doubleFunction's body is empty, it takes its argument by value,
which means copying. Copying an uninitialized double is a gray zone
(if you follow the partially-formed paradigma, it's UB; though the std
may allow it some types, most notably std::byte and uchar; probably
not double, though). Converting an uninitialized int into double is
most certainly UB.

Fix by initializing both d and i.

Found by GCC 11's -Wmaybe-uninitialized.

Pick-to: 6.5 6.2 5.15
Change-Id: I103fb72bf4b8792a292346007f498dc6349e9c68
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-03-31 11:32:46 +02:00
Marc Mutz
1cc1d39f3e tst_QThreadPool: reduce the number of infinite timeouts
... by supplying a TestThreadPool that waitsForDone() with a defined
timeout in the dtor.

When tests hang, this will now print an intelligible message instead
of just the generic watchdog-killed-process one.

Also replace all QVERIFY(waitForDone()) with the same code used in
TestThreadPool's dtor and add a comment in a place we'd rather not use
these tools.

Pick-to: 6.5 6.2
Change-Id: Ifd2b3372eb7c7337a3ba77d003e45dcd77e23545
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-03-31 11:32:45 +02:00
Axel Spoerl
7350088ab7 tst_QSslSocket_onDemandCertificates_member: Blacklist Windows & debug
The test function occasionally can fail on CI/Windows, when a
certificate update on www.qt.io requires installing a new root
certificate on the test VM.

This patch blacklists the test class (which has only one test function)
on Windows. It adds diagnostic output, so future failure reasons can
be established from CI artifacts.

Pick-to: 6.5
Task-number: QTBUG-63481
Change-Id: If686d006f379fe6dbfb0d11d80b8455f72fdbb09
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-03-30 17:17:26 +00:00
Volker Hilsheimer
fc319a8f8b Fix QTimer::crossThreadSingleShotToFunctor test
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>
2023-03-30 19:17:25 +02:00
Edward Welbourne
496ebd8677 tst_QDateTimeEdit::stepModifierPressAndHold(): tweak start date
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>
2023-03-28 21:40:53 +02:00
Tor Arne Vestbø
f3e27d3688 Pick up initial state of foreign windows instead of reflecting QWindow
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>
2023-03-28 16:31:17 +01:00
Tor Arne Vestbø
aab71c7bb8 Ensure QHighDpiScaling::set(Screen/Global)Factor() results in QScreen signals
Change-Id: I328b288b3fd83df0cc81c62bce1d946f90f1cd0d
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2023-03-28 17:31:17 +02:00
Axel Spoerl
c4b62ee501 QComboBox: reset indexBeforeChange to -1 if index is invalidated
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>
2023-03-28 14:45:24 +01:00
Morten Sørvig
9a39b3c796 Apply ScaleFactorRoundingPolicy to QT_SCREEN_SCALE_FACTORS
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>
2023-03-28 09:14:09 +00:00
Marc Mutz
f8dba0395f QPromise: add support for addResult(braced-initializer)
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>
2023-03-28 09:09:14 +00:00
Fabian Kosmale
e7cb3cb041 QMetaType: Provide underlyingType for enums
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>
2023-03-28 10:59:53 +02:00
Ivan Solovev
502a7706b9 QFutureInterface: add a warning when an existing continuation is overwritten
... 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>
2023-03-28 09:45:55 +01:00
Andreas Bacher
5af5738980 SQL/IBASE: Time Zone support (firebird 4.x)
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>
2023-03-24 23:43:54 +01:00
Liang Qi
0a37f944bf tests: blacklist tst_QImageReader::setClipRect() and
setScaledClipRect() svg tests on Wayland

Task-number: QTBUG-112275
Pick-to: 6.5
Change-Id: Iaae1781df09b8402b349fd41111ea16ca26215f8
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2023-03-24 10:49:16 +01:00
Marc Mutz
690761a4ad tst_QVariant: add a test contrasting Qt 5/6 isNull behavior
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>
2023-03-24 06:40:27 +01:00
Marc Mutz
a9e8034e8c Implement [variant.get] for QVariant [2/2]: get()
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>
2023-03-24 06:40:19 +01:00
Marc Mutz
de3e970889 Implement [variant.get] for QVariant [1/2]: get_if()
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>
2023-03-24 06:40:11 +01:00
Thiago Macieira
8570e86fff QVariant: ensure the type custom is registered on construction
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>
2023-03-23 13:40:15 -10:00
Thiago Macieira
4d90c4e74a QTimer: fix new-style slot invocation for receiver in another thread
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>
2023-03-23 13:22:23 -10:00
Marc Mutz
a1889b2a67 Verify fix for manual get<I> calls for QVector<N>D
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>
2023-03-22 15:59:10 +00:00
Marc Mutz
eb9c8042cf Short live QT_ENABLE_P0846_SEMANTICS_FOR!
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>
2023-03-22 15:59:10 +00:00
Nicolas Werner
3f40a8b5b1 Add QTextListFormat::start: html and markdown ordered list index offset
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>
2023-03-22 10:50:58 +01:00
Christian Ehrlicher
37b47ebf94 Widgets/QCheckBox: change signature of stateChanged() for Qt7
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>
2023-03-21 20:33:10 +01:00
Edward Welbourne
db5279825c Corelib: s/Q_OS_MAC/Q_OS_DARWIN/wg except for doc and definition
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>
2023-03-20 19:18:52 +01:00
Edward Welbourne
9896ebf93d Testlib: fix the last few s/Q_OS_MAC/Q_OS_DARWIN/w
Change-Id: I6fe6a865aea37c6a2d153bd2c3aace5242362c88
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
2023-03-20 19:18:52 +01:00
Mårten Nordheim
6a66554d3b Revert "Skip socket and server tests on Ubuntu 22.04 and QEMU"
This reverts commit 9286d46ee2.

Reason for revert: Should be fixed by 5c6814fb18760f65bab0f8b9cd623ee5c874a58d

Change-Id: I3a161df445af8dcbb61138d57e931a093a319027
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2023-03-20 17:39:18 +01:00
Marc Mutz
f4f49523ad tst_QMessageAuthenticationCode: avoid setKey() calls
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>
2023-03-20 14:42:11 +01:00
Christian Ehrlicher
d184c66ad5 SQL/Tests: Cleanup of tst_databases.h
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>
2023-03-17 23:08:44 +01:00
Christian Ehrlicher
acb6131a4d SQL/IBASE: fix tests
Fix some tests so they will correctly work with Interbase (Firebird 3.x)

Change-Id: Ib3c8ceaf31fa01af3a00a9772350b49cee8b2342
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-03-17 20:33:16 +01:00
Christian Ehrlicher
1981ebe8ad SQL/OCI: add maximumIdentifierLength()
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>
2023-03-17 20:33:16 +01:00
Christian Ehrlicher
f49f3f2f94 SQL/Tests: Cleanup tst_QSqlDatabase
Remove driverQuotedCaseSensitive() as it's no longer needed, fix view
creation for PostgreSQL.

Change-Id: I72437252cfad762a5a245475d6652de3c7b5ef46
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-03-17 20:33:15 +01:00
Axel Spoerl
b04f9388ac QColorDialog: Support hex rgb values with and without leading #
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>
2023-03-17 18:06:28 +01:00
David Redondo
141d626029 Handle device loss for texture widgets
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>
2023-03-17 14:45:21 +01:00
Marc Mutz
96dc4acb23 QCryptographicHash: check addData() with null QByteArrayView
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>
2023-03-17 00:41:33 +01:00
Marc Mutz
c5d4dde678 QMessageAuthenticationCode: add move SMFs and swap()
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>
2023-03-16 17:27:29 +01:00
Ahmad Samir
41fea4f5fa QDate: add epochDate() helper to unittests
Drive-by change: add an assert for JULIAN_DAY_FOR_EPOCH.

Change-Id: I891ef253f1f16b1efb8354d1b179f319b3553feb
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-03-16 17:52:20 +02:00
Tor Arne Vestbø
13951b44cd Add basic test for QWindow foreign windows
Only implemented on macOS and Windows for now.

Change-Id: Ib6330bc7024453d23675c1770367e8da6c4c9a34
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2023-03-16 14:17:24 +01:00
Ulf Hermann
566e5e1acf moc: Allow anonymous properties
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>
2023-03-16 14:17:24 +01:00
Axel Spoerl
09c3cd8503 QPlainTextEdit: Don't block signals on page step
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>
2023-03-15 23:45:00 +01:00
Ahmad Samir
9d05fd9fa2 QString: change test data to compile with QT_NO_CAST_FROM_ASCII [10/13]
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>
2023-03-15 22:25:57 +02:00
Ahmad Samir
f325bdacb6 Replace ushort*/uint* with char16_t*/char32_t* in private API [1]
Task-number: QTBUG-110403
Pick-to: 6.5
Change-Id: Ie20a831f22212d56659cf3c6940d17134ab5f2c5
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-03-15 20:25:57 +00:00
Amir Masoud Abdol
11ae4b70a1 Fix tst_qfilesystementry in unity build
Previous setup of the test was failing in minimal static build if built
using  the unity build because of the explicit inclusion of the qtcore
source files. By removing them, it surfaced that QFileSystemEntry
doesn't export all its necessary symbols for testing. So this patch does
that, as well as removing the qtcore sources from the test. It also
makes sense to make the test private.

Pick-to: 6.5
Task-number: QTBUG-109394
Change-Id: Icdabe32485b7ce4ed6049bcc24918f531406b4bd
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2023-03-15 18:18:01 +01:00
Axel Spoerl
8b84374892 emit QAbstractSlider::valueChanged() only on value change
The signal has been emitted also, when the slider position has changed
without a value change (e.g. on QWidget::show() or on resizing).

This patch stops emitting the signal without a value change.
It adds a verification to tst_QAbstractSlider::setValue(), that
valueChanged is not emitted on a no-op value change.

As a drive-by, the patch removes an unnecessary assignment and
changes signal spy constructions to PTMF syntax.

Pick-to: 6.5 6.4 6.2
Task-number: QTBUG-25365
Change-Id: I9932e45d4e680aa53422ca75aa42a16306213a38
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2023-03-15 14:32:35 +01:00
Ahmad Samir
5cea5fc80b QLockFile: tryLock(): use chrono first
I.e. tryLock(chrono::milliseconds) shouldn't call the int overload as
that truncates the timeout (milliseconds is typically int64_t).

Add a note to the tryLock(millisecons) docs that passing
milliseconds::max() will make it wait forever to obtain the lock.

Task-number: QTBUG-110059
Change-Id: Ib48d9b1b117ce816348625331543d6ba8a788973
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-03-14 22:15:35 +02:00
Axel Spoerl
425e635ecd QCompleter::setPopup() - refactor and cleanup
QCompleter::setPopup() sets window flags, focus policy, parent, focus
proxy, item delate and installs an event filter, before the popup
argument is assigned to d->popup.

In the QCompleter::eventFilter override, QObject::eventFilter is called
(under more) if d->popup is nullptr.

If a custom class is inherited from QCompleter and it overrides
QObject::eventFilter(), this causes an infinite loop.

This patch re-factors the method.
- early return is added if the new popup != d->popup
- remembering the existing widget's focus policy is constified and
  moved ahead of the delete secion.
- assignment of d->popup to popup argument is moved after the delete
  section.
- after assignment, the argument variable is no longer used.

The refactoring eliminates two issues:
- potential risk of double-installing event filter due to missing
  early return.
- inifite loop if inherited class installs another event filter.

The patch adds a test function to tst_QCompleter, which implements an
inherited class, installs an event filter on a popup and checks if a
ChildAdded event hass been recorded.

Fixes: QTBUG-111869
Pick-to: 6.5 6.2
Change-Id: I3f7a2434a11476077a5260e7686a912da9f6c60d
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2023-03-14 21:15:31 +01:00
Amir Masoud Abdol
d203f82916 Fix for CMake tests when build with unity
Some of the mockplugin tests needed to be excluded from the unity build
manually. In addition, MSVC's complain about include <QtCore/QString>
instead of <QString> was addressed here since it was breaking the unity
build as well.

Some other independent executable and libraries have to be excluded
manually as well.

Pick-to: 6.5
Task-number: QTBUG-109394
Change-Id: I1f21f8484b4d3b1c399e2118ab3a71e682a3006a
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2023-03-14 17:28:43 +01:00
Amir Masoud Abdol
608c2501e5 Fix tst_qfreelist when build with unity
Previous setup of the test was failing in minimal static build if built
using the unity build because of the explicit inclusion of the qtcore
source files. In order to resolve this, I removed the inclusion of
qtcore's headers and made the test private.

Pick-to: 6.5
Task-number: QTBUG-109394
Change-Id: Id1c7b3b65ca2078354c235a718ff3e93a65362e6
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2023-03-14 17:28:43 +01:00
Amir Masoud Abdol
e512734278 Use qt_internal_add_executable in auto tests
When possible, I replaced add_executable with
qt_internal_add_executable.

Pick-to: 6.5
Task-number: QTBUG-109394
Change-Id: I643d2e27f0d880fe9b6cec7af790e4c99227fb0c
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2023-03-14 17:28:43 +01:00
Ahmad Samir
0d29a406f7 QThread: add sleep(std::chrono::nanoseconds) overload
All the other overloads are implemented using the new one.

Windows change relies on the pre-check in the code review making sure it
compiles.

[ChangeLog][QtCore][QThread] Added sleep(std::chrono::nanoseconds)
overload.

Task-number: QTBUG-110059
Change-Id: I9a4f4bf09041788ec9275093b6b8d0386521e286
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-03-13 23:26:28 +02:00
Assam Boudjelthia
f314e821c1 Android: skip two qrhi tests to enable Android 12 in CI
This is expected to be temporary and to be investigated afterwards.

Task-number: QTBUG-108844
Pick-to: 6.5
Change-Id: I0a571dad2b99ceaa0fd48e5cdd81057e49e55ddf
Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
2023-03-13 21:12:38 +00:00
Christian Ehrlicher
30de1f74de SQL/MySQL: Add support for Bit-Value Type - BIT
Add support for MYSQL_TYPE_BIT. Since the bitfield can be max 64bits,
store it in a uint64_t. Writing such a value as MYSQL_TYPE_LONGLONG
works as expected but receiving it needs a special handling.

[ChangeLog][SQL][MySQL] Added handling for Bit-Value Type - BIT.

Fixes: QTBUG-21326
Change-Id: Id20e3316caf6703b3bec8a828144494a20693fd8
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-03-12 16:21:17 +00:00
Christian Ehrlicher
18bd15a9ea SQL/Tests: remove safeDropTable() / add helper class
Add a helper class which makes sure that the used table does not exist
before usage (e.g. due to leftovers from previous tests) and is properly
cleaned up on exit. This also allows to remove all usages of
safeDropTable().

Change-Id: Iefeffbd10e2f2f67985183ea822d7b6dd2b80be7
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-03-12 17:21:17 +01:00
Ahmad Samir
46b483ace0 Make sure helper executables used by unittests are built
E.g. tst_qprocess_and_guieventloop uses write-read-write.

This is useful e.g. when not building all of qtbase, but only a specific
unittest while hacking code.

Change-Id: Id97c6c09c180ba35554d75877a434cb258a6243d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2023-03-11 12:40:14 +02:00
Ahmad Samir
957ed5e71e QMimeDatabase: cleanup unittest
Use QLatin1StringView directly, instead of const char[].

Change-Id: Iae15b9f92d959efc6414ec8549b86560604dfb01
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-03-11 12:39:56 +02:00
YAMAMOTO Atsushi
f80b0aee60 Add test function for private network
Add a function QHostAddress::isPrivateUse to test
for IPv4 private networks and IPv6 unique local unicast addresses.

Task-number: QTBUG-111211
Change-Id: Ic8abefa7aa974fa83118aeb9f2506a5713f79f0d
Reviewed-by: Tasuku Suzuki <tasuku.suzuki@signal-slot.co.jp>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-03-11 09:43:10 +09:00
Giuseppe D'Angelo
a25644aecf QVariant: fix comparisons between strings and integer 0
250ca8d5f8 changed the qConvertToNumber
to have a std::optional return instead of a boolean out-argument.

In doing so a code path that was supposed to report a failure (string
could not be converted to an integer) accidentally starting reporting
success (and converting the string to 0).

The problem is that the `ok` check from QString::toLongLong was
accidentally dropped in the refactoring; previously the function set
`ok` to false and returned 0, now the function just returns 0.

Instead, amend that return to return nullopt (because the conversion has
failed).

Change-Id: Iaedef5463f3ec500a97bd4c9bbddf977f66df61a
Pick-to: 6.5 6.5.0
Fixes: QTBUG-111867
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-03-10 21:55:17 +01:00
Amir Masoud Abdol
8bf46d7a21 Silence some conversion warnings
Change-Id: I3087bff60e77c0eaa5818a5405c97628ce7f6b79
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2023-03-10 17:36:13 +01:00
Mårten Nordheim
fa4b7495b7 Fix overflow in SHA-3/Keccak
state->rate is always larger than or equal to state->bitsInQueue;
when bitsInQueue == rate the queue is consumed and bitsInQueue is set to
0 again.

Done-with: Marc Mutz <marc.mutz@qt.io>
Pick-to: 6.5.0 6.5 6.4.3 6.4 6.2 5.15
Change-Id: I56d268a19fb3cd542cc027edc962253f09d97a14
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-03-10 14:39:37 +00:00
Volker Hilsheimer
4f02973e2f Make it possible to use QObjectPrivate::connect in private code
In most QObjectPrivate-subclasses, the Q_DECLARE_PUBLIC macro is used in
the private segment of the class declaration. In that case, the q_ptr
becomes a private member of the private class, and then the
QObjectPrivate::connect function can no longer be used, as it needs to
access the d_ptr.

Fix this by declaring QObjectPrivate, and the static-assert-helper, as
friends of the class using the Q_DECLARE_PUBLIC macro.

Adapt the QObject test by moving the Q_DECLARE_PUBLIC macro into
the private section of the test-private, and add a compile test.

Pick-to: 6.5 6.5.0
Change-Id: Ifc04be3b305221e138b1e08bb3a3838d871f4fcb
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-03-10 15:39:37 +01:00
Christian Ehrlicher
0bcb0062ba SQL/Tests: remove usage of 'foreach'
And fix coding style a little bit around the change.

Change-Id: Idfc232a751ccc08d0680351d48d4a68f09f18c1f
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-03-09 19:57:42 +01:00
Volker Hilsheimer
5bd93821e5 Cleanup QPushButton auto test code
Fix coding style, replace QVERIFY(a == b) with QCOMPARE, use nullptr,
use a lambda for a local slot, and wait for the test widget to go away
so that it doesn't break following tests.

Change-Id: I1a4f790084b92301444a96a1449c84bf3317b88a
Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2023-03-09 19:57:42 +01:00
Marc Mutz
f7ea9b36b7 tst_QCryptographicHash: Extract Method ensureLargeData()
... to make large data usable from other test functions.

Pick-to: 6.5 6.5.0 6.4 6.4.3 6.2
Change-Id: I302070121a8bb49f373c7711bc3ab9e6418874ef
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-03-09 18:27:00 +01:00
Giuseppe D'Angelo
7261a22987 QAbstractItemModel: fix match() with Qt::MatchWildcard
QAIM::match() supports different matching modes. The wildcard match mode
was never meant to be specifically a filepath globbing wildcard, but
rather a generic one -- something like "*" should match into a
string like "a/b/c". This is a regression from Qt 5, where
QRegExp::Wildcard was ported to only allow for path globbing
rather than generic matching.

[ChangeLog][QtCore][QAbstractItemModel] QAbstractItemModel::match()
now uses more generic wildcard matches rather than file path globbing.
Please refer to the documentation of
QRegularExpression::wildcardToRegularExpression() for more information
about the differences.

Change-Id: I28b8a76b01fdd9c5dd8f99528fac1c7b704564bc
Fixes: QTBUG-104585
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-03-09 18:26:59 +01:00
Giuseppe D'Angelo
057a3ddc17 QRegularExpression: extend wildcard tests
Test for non-anchored wildcards too.

Change-Id: I98cb47d76861d145bc409112981f52e246beb0a7
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-03-09 18:26:59 +01:00
Volker Hilsheimer
054fb061d7 Fix warnings from deprecating QFileOpenEvent::openFile, update snippet
Amends 76c63936d3 by adjusting the test case.
We still just test that we can open a file based on a filename that we came
up with ourselves.

Also, update usage documentation and make the snippet a bit more relevant.

Change-Id: I5bf00210d74e2a73d5a71a09a5beb1b3f6f8e225
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2023-03-09 17:15:53 +01:00
Mårten Nordheim
e5f295c8a4 QNetworkDiskCache: use QSaveFile
QTemporaryFile is not designed to promote temporary files
to non-temporary files. So, it, quite importantly, does not
care if the content of the files are flushed to disk before
renaming it into its 'final' destination. This is what
QSaveFile is for.

This was much more time-consuming than intended since I had to debug
this quirk about calling size().

Pick-to: 6.5 6.4 6.2
Fixes: QTBUG-111397
Change-Id: I15b300f6a5748ad3a0be983545ea621269a12ecd
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-03-09 16:24:45 +01:00
Ben Fletcher
4201cdab18 rhi: Metal tessellation shader input output interface blocks
Add support for shader input output interface blocks in Metal
tessellation pipelines.  This feature is builtin to other rhi supported
tessellation backends (OpenGL/Vulkan).

Metal tessellation is implemented as compute pipelines for vert and
tesc, and a render pipeline for tese and frag.  The shader conversion
from GLSL is handled by SPIRV-Cross, which has a particular way of doing
things.  Rhi must setup the vertex inputs for the tese - frag render
pipeline to read from buffers written by the tesc compute pipeline,
following SPIRV-Cross conventions.  This includes ensuring correct
memory alignment per MSL Specification.

In order to enable input output interface blocks, reflection of struct
members of QShaderDescription::InOutVariable is required.  Reflection of
QShaderDescription::BuiltinVariable array dimensions is also required to
support variable size tese builtin input gl_ClipDistance.

An acompanying patch to QtShaderTools is required.

Change-Id: Id94e86caef211485afc187bb79fe3d0619d02cf0
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2023-03-09 15:24:45 +00:00
Fabian Kosmale
17c9001a53 Fix QPropertyAlias::addNotifier
QPropertyAlias might be deprecated, but using it should still not fail
to compile.

Pick-to: 6.5
Fixes: QTBUG-111735
Change-Id: I486cddb424b60cd3e5c539e26afca3726e29bb09
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2023-03-09 16:24:45 +01:00
Volker Hilsheimer
9255820ad5 Handle tab order inception
If a composite widget is put behind one of it's contained children via
QWidget::setTabOrder, then our logic might replace the composite widget
with the contained child. In that case, we'd end up with a broken tab
chain, possibly resulting in incomplete clean-ups and triggering asserts
when shutting down the UI.

Handle this by stopping the last-child searching logic at the respective
other widget, and by not allowing both widgets to be the same.

Augment test case, and apply some minor refactoring to the code.

Pick-to: 6.5 6.2
Change-Id: I7d97dfa85315b6c01daa283253025d94a1727048
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2023-03-09 09:41:33 +01:00
Tor Arne Vestbø
f2fc2013de QErrorMessage: Reset 'again' check box between each error message
The choice of whether to show a message again is per message,
so when showing a new message we need to reset the check box
back to its default checked state, otherwise the user might
mistakenly dismiss more than the indented message.

[ChangeLog][Widgets] QErrorMessage will now reset the check
box for showing a message again for each new message shown,
as each individual message has its own suppression state.

Pick-to: 6.5 6.5.0
Change-Id: I86d4bb5eabdb5b7a478c03516108a5edf87fcbe3
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-03-09 06:12:05 +01:00
Mårten Nordheim
1352e294d2 QTest: Rename QCOMPARE_XX parameters to add meaning
The parameter names were previously "lhs" and "rhs", which is incredibly
abstract for a testing framework. One of the parameters will tend to be
a baseline value to compare against while the other is the result of
some action we want to test. Thus I suggest they be renamed "computed"
and "baseline".

This way we can, hopefully, retain the semantic that the 'left'/first
argument is the computed ('actual' in QCOMPARE) value while the
'right'/second argument is the baseline ('expected' in QCOMPARE.)

Change-Id: I3e0fdce2a3f1faca06fdf7184ef6e0eb9724d990
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2023-03-08 15:10:21 +01:00
Giuseppe D'Angelo
4b197c3f52 QRegularExpression: add support for non-filepath wildcards/globbing
A glob pattern has different semantics depending on whether
it's used in "filepath mode" (FNM_PATHNAME) or not.
QRegularExpression only implemented the former, but the latter
is also useful, and possibly more "intuitive" for certain use
cases (e.g. offering users a simplified version of regexps that
however still need "*" to match a "/").

Add this support. The problems highlighted by QTBUG-111234 have
not been addressed, I've just amended a bit of documentation
relating backslashes.

[ChangeLog][QtCore][QRegularExpression] Support for non-filepath
wildcards has been added to wildcardToRegularExpression().

Fixes: QTBUG-110901
Task-number: QTBUG-104585
Task-number: QTBUG-111234
Change-Id: If9850616267980fa843bda996fcb4552b5375938
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Samuel Gaist <samuel.gaist@idiap.ch>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-03-07 20:57:43 +01:00
Laszlo Agocs
8e27e31649 Add workaround for threeDimTexture case failing with some drivers
Not relevant for the CI as that does not run with any real Vulkan
implementation. (and Lavapipe works if that's used)

As the investigation in the Jira issue shows, there is no proper
conclusion yet on why rendering to a slice of a 3D texture breaks
the content of other slices that have image data written to them
before that render pass targeting the slice. It would seem that
transitioning to COLOR_ATTACHMENT_OPTIMAL has some unexpected
consequences for slices that are not targeted by the render pass
with Mesa on Intel.

(NB rendering to a given 3D texture slice works via
VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT; and how often this is needed
in practice is unclear, typical volume rendering cases will anyway
likely just upload data to the slices of a 3D texture, not rendering
to them)

The problem is still clearly visible in the tex3d manual test (when run
on affected Linux machines), this we keep unchanged for the time being
so that the issue can be examined further. However, the autotest is
changed to prevent the issue from occurring (render to slice first,
then upload to other slices) since it causes confusion when the test
is run locally on various developer machines.

Pick-to: 6.5
Task-number: QTBUG-111772
Change-Id: I4dc4c2413f8c518f377a33065992ad786a5ff44f
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2023-03-07 16:48:32 +01:00
Laszlo Agocs
9c84036d4f rhi: Clean up 1D and 3D texture feature flags
Separate 1D mipmap generation support from rendering into an 1D texture.
Those are two independent features, so have a separate feature flag for
both instead of using just one.

This will then be symmetric with the 3D texture features, where now we
have a new flag to report support for generating mipmap for 3D textures.
(whereas 3D texture as a render target is already covered by
RenderTo3DTextureSlice)

Change-Id: Ie5e1f056a7d1c341d90cd7fc522877a3f2da3290
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2023-03-07 16:48:32 +01:00
Mikolaj Boc
79cc3ae201 Support filter list for file input when opening a file on WASM
The polyfill for file input on WASM now makes use of the supplied
filter list.
Some changes were introduced in the abstraction for filters so that
they are usable both for the new file API and the legacy file input.

Change-Id: Id6341be4d6a1647e17382d13da7be42491cfaf80
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2023-03-07 12:50:41 +01:00
Christian Ehrlicher
12909d7c3d QSqlDatabase: deprecate QSqlDatabase::exec()
The note that QSqlDatabase::exec() is deprecated was added more than 12
years ago so it's time to also mark the function as such.

Change-Id: Ic5e7c31b3ff5b21e16e2640548cba1a4baaeeb1c
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-03-06 23:14:49 +01:00
Volker Hilsheimer
386dcbf6b9 Silence warning about unsafe sprintf, use snprintf instead
Apple lets us know that:
  warning: 'sprintf' is deprecated: This function is provided for
  compatibility reasons only.  Due to security concerns inherent
  in the design of sprintf(3), it is highly recommended that you
  use snprintf(3) instead.

Pick-to: 6.5
Change-Id: I3130b3c7b636466b5e77adc5cb05ad4ce1faee11
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-03-06 23:14:08 +01:00
Volker Hilsheimer
73f04faa07 Silence warning about deliberately using deprecated API
We test moc's support for [[deprecated]], so don't warn about it.

Pick-to: 6.5
Change-Id: Ifda2b81c14cb9802db4bb1d0a1eb17d978ad492a
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-03-06 22:34:39 +01:00
Amir Masoud Abdol
93a378b295 Silence a few unused-but-set-parameter warnings in some of the tests
Change-Id: I8cf3e4764ae50011d691dec6f52a355ddfb0ce7b
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2023-03-06 17:16:14 +01:00
Christian Ehrlicher
28d5da386f SQL/Tests: remove some unused functions
remove toHex() as it's not used at all and qTableName() with two params.
Also remove some SQLite 2 specific stuff

Change-Id: If285febdfbee5833f7174d70f386bd54674bd539
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-03-06 15:06:07 +01:00
Volker Hilsheimer
9e31631557 Doc: fix link to QTest::failOnWarning
Also fix incorrect failOnWarning*s* elsewhere in comments.

Pick-to: 6.5 6.5.0
Change-Id: I0bbc5e71060348153876f3d9a7c77c67f3c2e00d
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2023-03-05 06:00:39 +01:00
Volker Hilsheimer
9ec61d4460 Port QPathClipper test away from home-grown QCOMPARE
Use a scope guard to print debug info in case of an early return.
Silences clang warning about sprintf being unsafe and deprecated.

Change-Id: Idcbfde1a6f2eb1143f51c1e5ecedbf3fe90d8ec8
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2023-03-05 06:00:18 +01:00
Edward Welbourne
58f5ec35f1 Doc fix in QIntValidator::validate() and comment on a test
The doc said positive values for a negative range were intermediate
but the code actually rejects them if the value has an overt plus
sign, so make clear that intermediate is only for the case without a
sign. Incidentally comment on a test where it might not have been
obvious to the reader that a space is the locale's digit-grouping
chracter.

Pick-to: 6.5 6.5.0
Change-Id: I3edab74fe8c2cbe8448c0e523676f1fd0d0d8a9f
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-03-03 23:19:23 +00:00
Ahmad Samir
2a495c2596 QTestEventLoop: add enterLoop(std::chrono::milliseconds) overload
Task-number: QTBUG-110059
Change-Id: Ibf1d76afd313e390103be4a22e44af7fb41ace1b
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-03-03 21:36:48 +02:00
Ahmad Samir
855a6cb676 Use utimensat instead of utimes
From the manual page:
Note: modern applications may prefer to use the interfaces
described in utimensat(2).

Change-Id: Ib20d8b9b50626233852ca351452ce90841a39603
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-03-03 21:36:01 +02:00
Marc Mutz
fd17eaca83 tst_QVariant: check fromValue() with a non-default-constructible type
... by just using fromValue() instead of the QVariant(QMetaType,
void*) ctor.

Code coverage isn't reduced, because fromValue() will, of course, call
that exact ctor itself.

Amends df0085d3a2.

Pick-to: 6.5 6.4 6.2
Task-number: QTBUG-105140
Task-number: QTBUG-111598
Change-Id: I02464803090fa7078947625616e6fc20e623ef31
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-03-03 20:05:27 +01:00
Liang Qi
cd0301a78e tests: skip tst_QScreen::grabWindow() on XWayland
Pick-to: 6.5
Task-number: QTBUG-104595
Change-Id: Icb56a587dfbad84533616160817a3d43411146f1
Reviewed-by: Kalle Viironen <kalle.viironen@qt.io>
Reviewed-by: Simo Fält <simo.falt@qt.io>
2023-03-02 15:58:37 +01:00
Christian Ehrlicher
2adb22fba5 tst_QSqlDatabase: avoid some runtime warnings
Make sure to properly close the cloned database connections and allow
one test for sqlite

Change-Id: Ia4eb4a684a3c432844e4b2a77bff69655b53f9b2
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-03-02 15:02:02 +01:00
Marc Mutz
52c7f699ac QDebug: fix std::string/view stream operators; add u8 versions
Make them templates, for two reasons:

- so they can accept std::pmr types and, in general, any basic_string
  with custom allocators and char_traits

- to break overload ambiguities with the Qt string view types

Also, add the missing C++20 char8_t overloads.

Also, avoid creation of a QString in the sizeof(wchar_t) == 2 case
(Windows). Add a comment to optimize for the sizeof(wchar_t) != 2 case
later.

Found in API review.

Pick-to: 6.5
Change-Id: I30139520f582a38863a0936f8eca4b1ed33e37c8
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-03-02 06:33:35 +01:00
Jan Arve Sæther
a84b2e5973 Move Weather Anchor Layout example to manual tests
Pick-to: 6.5
Change-Id: I8782a83b5c12b4f57bf9ef9063818cb124bddd56
Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
2023-03-02 05:55:57 +01:00
Harald Sitter
5317ff74fd a11y: even checkable buttons are pressable
otherwise there is no way to synthesize a "click" through the a11y API.
toggleAction only leads to a toggled() signal but the user may be more
discerning and only listen to clicked() (or QAction::triggered) to react
to **user** events not all toggle events. as such pressAction is always
superior to toggleAction when user input is meant to be synthesized
through a11y tooling.

Change-Id: I7f024d57087b545d3cfd1805026ea538b0b3e166
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
2023-03-01 22:05:23 +01:00
Marc Mutz
b8966021ff tst_QMutex: use constexpr variables instead of 'enum-trick'
C++20 doesn't like arithmetic with enums anymore. While this hasn't
caused immediate pain, yet, fix it pro-actively for an imminent patch.

As a drive-by, fix the missing space at start of comment.

Pick-to: 6.5 6.4 6.4.3 6.2
Change-Id: Id08bb227c587bc7b900c593a7b6d2655ca32eefd
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-03-01 19:14:39 +01:00
Marc Mutz
e7c792ba71 tst_qvarlengtharray: add test for QVLA(n) ctor
Also add one for types that are neither copy- nor move-constructible.
In contrast to resize(n), the QVLA(n) ctor worked for such types, so
make sure it stays that way.

Pick-to: 6.5 6.4 6.4.3 6.2 5.15
Change-Id: If54fbc9dd6a4808175c4bcb0ffb492b33c879746
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-03-01 18:14:39 +00:00
Marc Mutz
6990f23813 Long live QMessageAuthenticationCode::resultView()!
Use it in a few places.

[ChangeLog][QtCore][QMessageAuthenticationCode] Added
QCryptographicHash-style resultView().

Change-Id: I745d71f86f9c19c9a9aabb2021c6617775dab1cf
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-03-01 17:20:41 +01:00
Thiago Macieira
5f32c9edce tst_QTimer: suppress the cross-thread timer stopping warnings
Both QTimer's and QObjectPrivate's destructors print a warning if the
current object lives on another thread and has an active timer:

QWARN  : tst_QTimer::moveToThread() QObject::killTimer: Timers cannot be stopped from another thread
QWARN  : tst_QTimer::moveToThread() QObject::~QObject: Timers cannot be stopped from another thread

This timer is used to ask the thread to quit, which in turn allows us to
destroy this QObject without a cross-thread warning. Because it's
already fired once and done its duty, we can make sure it's not active
by simply making it single-shot.

Pick-to: 6.4 6.5
Change-Id: Ieec322d73c1e40ad95c8fffd17465067b27c044b
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-02-28 20:19:52 +00:00
Volker Hilsheimer
3f2d02e2f4 QAbtractItemView: deselect before click opens editor
A click on the selected item should deselect all other items before
editing starts.

Remove the part of the test case that assumes that we can have multiple
items selected in ExtendedSelection mode, and click on an item to start
editing while maintaining selection. That can never happen.

Pick-to: 6.5 6.4 6.2
Fixes: QTBUG-111131
Change-Id: I0312eed4614502cfb77eca26d3f7615427493d7d
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2023-02-28 17:19:24 +00:00
Jan Arve Sæther
afbfe30093 a11y: Test and document relations better
The documentation for the RelationFlag enum was not very clear on what
was the "first" and "second" object.
And the fact that the AT-SPI backend (which these enum values originates
from) inverses "first" and "second" makes it harder to understand what
how it all fits together.

So when (with this change) Qt documents 'QAccessible::Labelled' as
    "The returned object is labelled by the origin object"

AT-SPI documents ATSPI_RELATION_LABELLED_BY as:
    "The origin object is labelled by the returned object"
(Documentation for AT-SPI is rewritten so that it shares the same
terminology)

Notice that the two objects are exchanged, which means that even if they
use the same 'Labelled' relation, the semantic gets 'inversed'.

This is already the case today, so we cannot change it. Therefore, to be
clear, the relation mapping will remain to be like this:

Qt Relation     | Maps to AT-SPI                | Qt explanation
----------------+-------------------------------+--------------------------------------------------------------------------------
Label           | ATSPI_RELATION_LABELLED_BY    | The returned object is a Label for the origin object
Labelled        | ATSPI_RELATION_LABEL_FOR      | The returned object is Labelled by the origin object

Controller      | ATSPI_RELATION_CONTROLLED_BY  | The returned object is the Controller for the origin object
Controlled      | ATSPI_RELATION_CONTROLLER_FOR | The returned object is Controlled by the origin object

This mapping can already be seen in qAccessibleRelationToAtSpiRelation()

For the record, these future relations should then be mapped to like
this:

Qt Relation     | Maps to AT-SPI                | Qt explanation
----------------+-------------------------------+--------------------------------------------------------------------------------
Described       | ATSPI_RELATION_DESCRIPTION_FOR| The returned object is described by the origin object
DescriptionFor  | ATSPI_RELATION_DESCRIBED_BY   | The returned object provides a description for the origin object

FlowsTo         | ATSPI_RELATION_FLOWS_FROM     | The returned object has content which flows logically to the origin object
FlowsFrom       | ATSPI_RELATION_FLOWS_TO       | The returned object has content which flows logically from the origin object

Change-Id: Ib245ec95564e4886dc6dbbb68abec2b23cd0e534
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2023-02-28 17:53:10 +01:00
Ben Fletcher
9ffa16baf0 rhi: Add support for half precision vertex atttributes
Runtime support is indicated via QRhi::Feature::HalfAttributes.

OpenGL support is available in OpenGL 3.0+, OpenGL ES 3.0+, and in
implementations that support the extension GL_ARB_half_float_vertex.

Other RHI backends (Vulkan, Metal, D3D11, and D3D12) all support this
feature.

Note that D3D does not support the half3 type.  D3D backends pass half3
as half4.

tst_qrhi auto unit test included.

Change-Id: Ide05d7f62f6102ad5cae1b3681fdda98d52bca31
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2023-02-27 09:23:05 -08:00
Volker Hilsheimer
f75b29fbbd QListView: Reset style after using a temporary proxy
Amends 0242be9060, and removes unwanted
side effect of having a modified style behavior for later functions.

Pick-to: 6.5 6.4 6.2
Change-Id: If3dff0d7ab9e6c6c10e7a92d0a3eaff98fa1457f
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2023-02-27 10:10:04 +01:00
Marc Mutz
a62aa18178 tst_QMessageAuthenticationCode: check that setKey() reset()s
It's documented as such.

Pick-to: 6.5 6.4 6.2 5.15
Change-Id: I7299d289117e52dcefe3c4ab917d7ecad6dd02be
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-02-26 07:51:29 +01:00
Ahmad Samir
caa21ffc65 tst_benchlibcallgrind: silence a compiler warning
Change-Id: I68cc530fa8eaf941a6ddb7e6987ff37ec270bc4d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-26 03:14:46 +02:00
Marc Mutz
0411d98192 QCryptographicHash: auto-calculate MaxHashLength
Add Algorithm::NumAlgorithms and use it to iterate over all
statically-available algorithms, querying their hashLengthInternal().

This avoids having to statically_assert(<= MaxHashLength) everywhere,
and auto-adjusts the buffer size in SHA1_ONLY builds.

Yes, the extra case labels for NumAlgorithms are a nuisance, but at
least the compiler will remind us when we forget, unlike a missing
static_cast(<= MaxHashLength) that might easily be forgotten.

Adjust the test (which iterates over the QMetaEnum for
QCryptographicHash::Algorithm, so finds NumAlgorithms and tries to
pass it to the hash() function which responds with a
Q_UNREACHABLE(). Only test hashLength() == 0 for that enum value.

Pick-to: 6.5
Change-Id: I70155d2460464f0b2094e136eb6bea185effc9d5
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-25 16:50:03 +01:00
Edward Welbourne
cb54da2366 Support Cyrillic's equivalent of 'E' as exponent separator
Only Ukrainian is actually recorded in CLDR as using U+0415 as
exponent separator; all other Cyrillic-using locales officially use
plain ASCII 'E'. However, it seems reasonable, in all Cyrillic
locales, to recognize both (given that they look very similar).

Task-number: QTBUG-107801
Change-Id: I70a1e60a2d9fe7e254e01d32c5bad909ea4b8c76
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
2023-02-24 13:37:07 +01:00
Edward Welbourne
4931fe9b02 Fix parsing of numbers to cope with non-single-character tokens
In some locales signs and the exponent are not single character
tokens. Replace QLocaleData::numericToCLocale() with a tokenizer that
will cope with this. At the same time, cache the locale data needed in
support of that, so that we don't repeatedly recreate QString()
objects just to compare them against input tokens.

The caching class is inspired by Thiago's proposal for fixing the
performance, which also inspires the optimization of the C locale in
the tokenizer used here.

Add some testing that round-tripping numbers via strings works for the
locales with signs and exponents that use more than one character.

Task-number: QTBUG-107801
Change-Id: I9fd8409a371ed62ed969d9ebc8b09584e752f7fb
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-24 13:37:07 +01:00
Thiago Macieira
1d167b515e QHash: fix GrowthPolicy::bucketsForCapacity
It was confusing entry capacity with the bucket capacity. The value
maxNumBuckets() returned was the maximum number of entries. This issue
was harmless: we would just fail to cap the maximum to an allocatable
size. But the array new[] in the Data constructors would have capped the
maximum anyway (by way of throwing std::bad_alloc).

So instead of trying to calculate what the maximum bucket count is so we
can cap at that, simplify the calculation of the next power of 2 while
preventing it from overflowing in our calculations. We continue to rely
on new[] throwing when we return count that is larger than the maximum
allocatable.

This commit changes the load factor for QHashes containing exactly a
number of elements that is exactly a power of two. Previously, it would
be loaded at 50%, now it's at 25%. For this reason, tst_QSet::squeeze
needed to be fixed to depend less on the implementation details.

Pick-to: 6.5
Change-Id: I9671dee8ceb64aa9b9cafffd17415f3856c358a0
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-02-23 10:36:36 -08:00
Thiago Macieira
e836c4776f tst_qmessagehandler: fix QtTest warnings about duplicate row names
Pick-to: 6.5
Change-Id: Ieec322d73c1e40ad95c8fffd17464fcb2ca96f5f
Reviewed-by: Kai Köhne <kai.koehne@qt.io>
2023-02-23 10:33:39 -08:00
Thiago Macieira
644c06b48f Logging: fix crash when decoding a symbol that isn't a function
Saw this on my FreeBSD VM. The backtrace() function thought the nearest
symbol to something was "_ZTSNSt3__110__function6__baseIFbPvS2_EEE",
which decoded to

 typeinfo name for std::__1::__function::__base<bool (void*, void*)>

The function pointer type inside parameter threw the decoder for a loop
and caused it to crash with the failed assertion in qbytearray.h:

 inline char QByteArray::at(qsizetype i) const
 { Q_ASSERT(size_t(i) < size_t(size())); return d.data()[i]; }

I noticed this
 - because tst_qtimer hung
 - because qFormatLogMessage deadlocked acquiring QMessagePattern::mutex
 - because the logging recursed
 - because qCleanupFuncinfo failed an assertion while formatting the
   backtrace (my QT_MESSAGE_PATTERN has %{backtrace})
 - because QTimer::~QTimer -> QObject::killTimer printed a warning
 - because tst_QTimer::moveToThread produces warnings

Pick-to: 5.15 6.2 6.4 6.5
Change-Id: Ieec322d73c1e40ad95c8fffd17464f86e9725991
Reviewed-by: Kai Köhne <kai.koehne@qt.io>
2023-02-23 10:33:39 -08:00
Thiago Macieira
e69d80e14d qalgorithms.h: fix mistake that MSVC has constexpr bitops in C++17 mode
<bit> exists in C++20 and is properly both constexpr and optimized. But
in C++17 mode, we don't have constexpr bitops and instead elect to have
performance at runtime instead. But somewhere along the line, either
when they were added, when C++20 <bit> support was, or in any of the
bugfixes for other compilers, the nesting of #ifdef got messed up and we
declared that we had constexpr builtins for MSVC in C++17 too.

The macro QT_HAS_CONSTEXPR_BUILTINS isn't supposed to be used by anyone
else... but we ended up not being able to use it ourselves either. So
I'm renaming it to a more precise label.

Pick-to: 6.5
Change-Id: I9671dee8ceb64aa9b9cafffd1741b9b4060c9753
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2023-02-22 11:06:49 -08:00
Marc Mutz
05f913d57d qstrncpy: NUL-terminate even when src is nullptr
The goal of this function is to ensure that dst is _always_
NUL-terminated. The only exception is if there's no space to write
even one NUL byte, of course, but not when src is nullptr but dst
would have space.

Update the docs to the new behavior and make them more precise.

Fix a test that assumed qstrncpy() would not write to dst for
(dst, nullptr, 10).

[ChangeLog][QtCore][qstrncpy()] Now NUL-terminates the target
buffer even when the source pointer is nullptr, provided the
target buffer has space for at least one byte.

Pick-to: 6.5 6.4 6.2 5.15
Change-Id: I7806d8c71e260f8f02b79af7b6ce94f23599dd69
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-22 19:24:16 +01:00
Mikolaj Boc
a596ea0fe2 Support always on top/bottom window flags on WASM
The window stack will now upkeep three groups of windows, always
on bottom (1), regular (2), always on top (3). Windows belonging to
(3) will always appear on top of (2) and (1), and windows from (2) will
always appear on top of (1).

The first window created in the application gets the (1) status, which
is in line with the root window mechanism used before.

Activation has now been decoupled from the top position on the window
stack as a window in (1) or (2) may be active, in spite of the top
window belonging to a higher group.

Fixes: QTBUG-110098
Change-Id: I51f4d2d47163fab26ce5ef28f7a4f23a522c7f91
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
2023-02-22 18:07:35 +01:00
Ahmad Samir
96e031edd7 QDateTimeParser: add more unittests for the unquote() static helper
Test documented behavior and serv as a baseline for future changes.

Change-Id: I36a914694d5244c89f28f3e403e11d65492a5eef
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2023-02-22 17:41:20 +02:00
Christian Ehrlicher
37032b1590 SQL tests: remove unused tests
They were leftovers from QTDS driver removed with Qt6

Change-Id: I34863912bd41e0b4ca54bf443001f1cb3f20511a
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-02-20 20:28:38 +01:00
Rami Potinkara
eb0d7b5dcf Android: SKIP cases failing on Android 12 CI with 16GB RAM
SKIP tst_QRhi::tessellation(Vulkan)
SKIP tst_QOpenGLWidget::reparentHidden()
SKIP tst_qvulkan cases

Task-number: QTBUG-108844
Task-number: QTBUG-111235
Task-number: QTBUG-111236
Task-number: QTQAINFRA-5391
Task-number: QTQAINFRA-4733
Pick-to: 6.5
Change-Id: Id227367477173b6ad4cf9433af8eab5976596e70
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2023-02-20 20:10:48 +02:00
Fabian Kosmale
b124171309 QObjectBindableProperty: Avoid use-after-free in notifyObservers
We so far refetched the first observer after evaluating bindings, as
binding evaluating might change the list of observers.
However, that approach did not take into account that the 'this' pointer
might no longer be valid after binding evaluation: In case of a
QObjectBindableProperty (or a QObjectCompatProperty), binding evaluation
might cause a reallocation of the binding storage, and consequently the
invalidation of the QPropertyBindingData.
Fix this by refetching the QPropertyBindingData from the storage (if a
storage has been provided, which is always the case for the affected
classes).

Fixes: QTBUG-111268
Pick-to: 6.5 6.4 6.2
Change-Id: Ie7e143a0bbb18f1c3f88a81dd9b31e6af463584f
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2023-02-20 18:07:16 +01:00
Fredrik Ålund
0efd8854c4 A QtSql driver for Mimer SQL
The QtSql for Mimer SQL sqldriver makes it possible to work with the
Mimer SQL database on different plattforms. There are drivers for
several other databases in QtSql and a driver for Mimer SQL will
benefit many users.
To build the Mimer SQL driver, download Mimer SQL from
https://developer.mimer.com

[ChangeLog][QtSql]
Added a QtSql plugin to work with the Mimer SQL database

Fixes: QTBUG-111219
Change-Id: Id6ba5de4de01189d0516ffbfa89efcb0d013115f
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-02-20 14:18:18 +00:00
Ahmad Samir
360f69b74b QString: build tst_QString::arg() without ASCII casting [13/13]
Drive-by change: use UTF-16 instead of UTF-8 for Eastern Arabic
Numerals, both are not human-readable but UTF-16 is one code point
instead of the two for UTF-8, less \x.

Pick-to: 6.5
Change-Id: I721f3989b7d776ddc4f9d337b21dca9d398fcc0d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-20 14:44:31 +02:00
Ahmad Samir
ff7848318f QString: build tst_QString::contructor() without ASCII casts [12/13]
Constructing from const char* etc is already covered by
constructorQByteArray.

I took a guess that the "// b(10)" comment is about testing constructing
a QString from a QChar[] that has an explicit \0 charcater. I tried
finding what the initial intent was but the trail went cold at the
"Initial import from the monolithic Qt" commit.

Pick-to: 6.5
Change-Id: I15bcdb24e55286eb6cd3056af0714a1eed581635
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-20 14:44:31 +02:00
Volker Hilsheimer
fb09c82a2c QGesture: make sure we copy timestamp value for event clones
Otherwise, double-click recognition will fail.

Use QEvent::clone when possible, or set the timestamp explicitly when
not.

As a drive-by, remove some long-dead code in affected code lines.

Fixes: QTBUG-102010
Pick-to: 6.5 6.4 6.2
Change-Id: I882bf6e8090bf6f182b7a0a3c62aa3a4c8db2e14
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2023-02-17 23:41:04 +01:00
Friedemann Kleint
97bfacf1e2 tests: Remove remains of qmake conversion from CMakeLists.txt files
Pick-to: 6.5
Change-Id: I8d106554bb86ac1ec9bb7a4083de4c376bcbab1d
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2023-02-17 21:56:49 +01:00
Ahmad Samir
eb4641210c QString: change unittests to compile with QT_NO_CAST_FROM_ASCII [7/13]
I.e. the second arg to QCOMPARE isn't what's being tested.

Drive-by changes:
- More _L1 usage, less blocky and easier to read
- QCOMPARE's second arg can be a View, it is smart enough and can
  compare them just fine
- Replace a "//15 chars" comment with a QCOMPARE check

Pick-to: 6.5
Change-Id: I4f4b84b16b543df37b0ba2f9dd781b045b2ed397
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-17 22:34:49 +02:00
Tor Arne Vestbø
c26c91b208 macOS: Pick up QWizard background from keyboard assistant via NSBundle
As of macOS 10.14 the keyboard assistant background is shipped as part
of the compiled asset catalog of the app, so looking it up via a URL
will fail.

Instead we look it up via NSBundle's dedicated image lookup function,
which handles both cases.

The logic has also been moved to qwizard.cpp, since the additional
plumbing via QPlatformNativeInterface was unnecessary.

The keyboard assistant itself no longer shows the background image
as of macOS 12, so we might consider doing the same, but the design
of the assistant has also changed significantly, so as long as our
QWizard layout looks like the old keyboard assistant we keep the
background as well.

Pick-to: 6.5 6.2
Change-Id: I7d42dd79b285f3518837458864bca6bc353b3b6d
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2023-02-17 18:02:25 +01:00
Ahmad Samir
4499600fc7 QString: split toNum unittests
- Port macros to QTest data rows in separate unittests
- Move DOUBLE_TEST-related data to toDouble() unittest
- Drop one redundant unittest:
    QTest::newRow("const-charstar") << (const char*)0;

Pick-to: 6.5
Change-Id: Ie809895e9f5d58c2d3ec419689f409b55e24fcf7
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-17 10:36:05 +02:00
Ahmad Samir
fdf112fd1d QString: unittests: clean-up creating a QChar[]
Pick-to: 6.5
Change-Id: I3864d145c05ae4268fe576f84723acc5eba3c2cb
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-17 10:36:05 +02:00
Ahmad Samir
4f1d3426ac QString: change test data to compile with QT_NO_CAST_FROM_ASCII [3/13]
Pick-to: 6.5
Change-Id: I5127831d5f9dcf200d0892b1ab58760180dda610
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-17 10:36:05 +02:00
Ahmad Samir
5a2ebc9f40 QString: build count/contains() unittests with no ASCII casting [11/13]
Drive-by change: Test more count/contains() overloads.

Pick-to: 6.5
Change-Id: Ife3afe9aab68e18cc1587c11108a18a413c339c3
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-17 10:36:05 +02:00
Ahmad Samir
2ade07b39e QString: change test data to compile with QT_NO_CAST_FROM_ASCII [9/13]
Pick-to: 6.5
Change-Id: I20dcf2d69c1446faef79bd24a78b1b86feec4ccb
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-17 10:36:04 +02:00
Ahmad Samir
448683809b QString: change test data to compile with QT_NO_CAST_FROM_ASCII [8/13]
Pick-to: 6.5
Change-Id: I72ebb7bb19e35a10aa85ea7da6ee6b1b332050a5
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-17 10:36:04 +02:00
Ahmad Samir
19b52ad2e5 QString: change test data to compile with QT_NO_CAST_FROM_ASCII [6/13]
Pick-to: 6.5
Change-Id: Ib747bd69f15c3e1d2deaa5a0168fcbcddbbb8f8e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-17 10:36:04 +02:00
Ahmad Samir
fcb9ef5062 QString: split some double/Nan/Inf unittests
And switch to using test data rows (rooting out two macros in the
process).

Pick-to: 6.5
Change-Id: Ib31e6b59f90f0983c0efc4bef7cb246aedfcab5b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-16 23:38:25 +02:00
Ahmad Samir
5c56fc6d2c QString: change test data to compile with QT_NO_CAST_FROM_ASCII [5/13]
Drive-by change: change C-style cast, (qlonglong)0, to C++ style cast
qlonglong(0).

Pick-to: 6.5
Change-Id: Ie7a36c17ac9c14f0606fcb4b112eba3f0180232e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-16 21:17:52 +02:00
Ahmad Samir
4f30d4f456 QString: change test data to compile with QT_NO_CAST_FROM_ASCII [4/13]
Pick-to: 6.5
Change-Id: I086d20547912da45282b88e290fdae9d2029c6bf
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-16 21:17:43 +02:00
Ahmad Samir
6542f4174e QString: change test data to compile with QT_NO_CAST_FROM_ASCII [2/13]
Pick-to: 6.5
Change-Id: If3b5eaf9964b3834c116522bc9a6bb89cd5b1626
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-16 21:17:10 +02:00
Ahmad Samir
6e5c6ef739 QString: change test data to compile with QT_NO_CAST_FROM_ASCII [1/13]
Change test data to compile with NO_CAST_FROM_ASCII uncoditionally where
casting from ASCII isn't what's being tested by a unittest.

The goal is to add a variant of tst_qstring that is compiled with
QT_NO_CAST_FROM_ASCII so that the unittests cover that code path too.

The commits are split into smaller chunks (where there is a common
link between changed code, that code is put in a commit, otherwise I
kept the number of changed lines below ~150) to make reviewing them
easier.

Pick-to: 6.5
Change-Id: I14256f1bde7749a3023753dbb7ed8be72cb6bc14
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-16 21:17:04 +02:00
Marc Mutz
93060e1b0e tst_ContainerApiSymmetry: fix -Wsign-compare
Amends 7cbdc8abbd.

Change-Id: Ieed5e771bb716475d6e0fe9566627f664e04a432
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2023-02-16 16:48:45 +01:00
Volker Hilsheimer
557dcd8a87 QAbstractItemView: don't start editing on Ctrl-Click
Amends 17c1ebf8bf, after which dragEnabled
item views toggled selection on click rather than on press. If the edit
trigger included SelectedClicked at the same time, then Ctrl-Clicking a
selected item would start editing the item, instead of toggling
selection.

Fix this by ignoring clicks with modifier when evaluating whether
editing should start.

Extend the mouseSelection test case by including a column for the
editTrigger, and cover the respective combinations.

Fixes: QTBUG-111131
Pick-to: 6.5 6.4 6.2
Change-Id: I9605f9b3d5a49e292551a34c3c4c7a5f9ecb2a89
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2023-02-16 15:28:18 +01:00
Thorbjørn Lindeijer
3e7226f107 Fix QStatusBar::removeWidget to hide the right widget
`QStatusBar::removeWidget` was hiding the wrong widget (the next one),
since the `removeAt` call changed the item that the `item` variable
is referencing.

This fixes a regression in Qt 6.3.0 (7166a82844).

Pick-to: 6.5 6.4
Change-Id: I9977b47e6208f8d451ff1037bcb9f4e8414cb431
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Thorbjørn Lindeijer <bjorn@lindeijer.nl>
2023-02-16 12:40:07 +01:00
Ivan Solovev
b34bea5e96 QFuture: fix continuation cleanup
Not clearing the continuationData could lead to use-after-free when
there is an attempt to cancel an already finished future, which belongs
to an already-destroyed promise.

This patch fixes it be explicitly resetting continuationData to nullptr
in the clearContinuation() method, which is called from the QPromise
destructor.

Task-number: QTBUG-103514
Pick-to: 6.5 6.4 6.2
Change-Id: I6418b3f5ad04f2fdc13a196ae208009eaa5de367
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-02-15 15:12:12 +01:00
David Edmundson
ec8e6ed200 Fix connections in QWidgetWindow
A recent update moved handleScreenChange out of being a private slot.
Porting to the new syntax fixes the warning and moves to a compile-time
check.

Pick-to: 6.5
Change-Id: Ibd85c6caf7dca051d669250a94a82fbddbd3435d
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-02-15 15:12:12 +01:00
Mikolaj Boc
3dc6fdc6d8 Fix the handling of dead keys and test the mechanism
An effort has been made to support more keyboard layouts that provide
dead keys (US international, Mac-specific dead keys).

The dead key is translated now at the event conversion phase, not
when it is actually used for modifying keys, which simplifies the logic.

Unittests have been created to check the translation mechanism.

Fixes: QTBUG-86272
Change-Id: I07f7d63f5a37f8469c693b034b400da99379f519
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
2023-02-14 23:18:42 +01:00
Thiago Macieira
6d17697913 QFileSystemWatcher/Win: remove the pre-QFileInfo path normalization
It's completely unnecessary, since QFileInfo will query the file system
anyway and that has a much better view of what is normalized and what
isn't. More importantly, this fixes the mistake in failing to normalize
properly in removePaths(), which removed the ending slash of a root
directory such as "C:\\". That caused the path to become "C:", which
QFileInfo interprets as "current path on drive C:".

[ChangeLog][QtCore][QFileSystemWatcher] Fixed a bug that prevented
removePaths() from removing the root of a drive on Windows.

Fixes: QTBUG-110986
Pick-to: 5.15 6.2 6.4 6.5
Change-Id: I9671dee8ceb64aa9b9cafffd17419b6d69670876
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-02-14 11:27:24 -08:00
Mikolaj Boc
0e520e5814 Skip the tst_QStringConverter::threadSafety test on WASM temporarily
The test needs investigation. Skip it for now so that we can enable
CI for WASM but leave a note to investigate it.

Task-number: QTBUG-109954
Change-Id: I9448312c2c16ec4f31279dcbe4e2213681cabe8a
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2023-02-14 20:24:15 +01:00
Fabian Kosmale
9483fcd68a QObject: Handle pointers to incomplete types in auto-connections
The code for the QMetaMethod queuedConnectionTypes overload relied on
QMetaMethod::parameterMetaType and QMetaType::flags() to detect whether
we're dealing with a pointer (and then use the VoidStar metatype instead).
However, if the type was incomplete when the slot was defined, and the
type was not registered when connect was called, we would not find a
metatype for the argument.
However, in that case we might still be able to handle the method, by
checking whether the type name of the arguments ends with a "*".
This patch does that, fixing a regression from 5.15.

Pick-to: 6.5 6.4 6.2
Fixes: QTBUG-108537
Change-Id: I54cc48a3343444480ab9094fe1ebaaa5aa75cee0
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-02-14 19:24:22 +01:00
Laszlo Agocs
c20336fe03 Update recent rhi autotest to skip on D3D12 as well
Change-Id: I4da78cd0cd1fd5015bc28bf01e59884abafa6995
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2023-02-14 17:48:09 +01:00
Ben Fletcher
dc0b2466f8 RHI: Metal SPIRV-Cross buffer size buffers
When SPIRV-Cross encounters a GLSL storage buffer runtime sized array,
it generates MSL code which expects a "buffer size buffer" containing a
list of storage buffer sizes to be bound.  This patch adds RHI backend
support for Metal "buffer size buffers" on compute and graphics
(including tessellation) pipelines.  Includes unit tests.

An accompanying patch to qtshadertools is required.

Change-Id: I9392bfb21803e1a868d7de420fedc097a8452429
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2023-02-14 17:48:09 +01:00
Mate Barany
fd70555b33 Deprecate usage of qt_ntfs_permission_lookup
With the introduction of a new atomic variable the users should use the
class QNtfsPermissionCheckGuard or the helper functions
- qEnableNtfsPermissionChecks()
- qDisableNtfsPermissionChecks()
- qAreNtfsPermissionChecksEnabled()
to enable/disable permission checks instead of manually managing the
variable qt_ntfs_permission_lookup (which is a non-atomic variable and
as such prone to data races).

Also moved the variable qt_ntfs_permission_lookup to qfile.h to make it
clash with the user-side declarations the documentation suggested to
use (and it is probably also a better fit thematically anyway).

[ChangeLog][QtCore][Deprecation Notice] Deprecated the variable
qt_ntfs_permission_lookup to avoid race conditions while enabling or
disabling permission checks. It can be replaced by the RAII class
QNtfsPermissionCheckGuard or with the functions
qEnableNtfsPermissionChecks(), qDisableNtfsPermissionChecks() and
qAreNtfsPermissionChecksEnabled().

Fixes: QTBUG-105804
Change-Id: I93a563864ffb3f9945551c34004d8ca393603b25
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-02-14 13:23:19 +01:00
Volker Hilsheimer
52ce4d2d29 QMenu: guard for destruction when emitting action signals
If a slot connected to a QMenu-action destroys the QMenu, then
we must not touch data members in subsequent code, and instead return
immediately.

We cannot use QBoolBlocker here, as that would reset the data
member of QMenuPrivate even when trying to return early.

Fixes: QTBUG-106718
Pick-to: 6.5 6.4 6.2
Change-Id: I6b5ea471b1bf1f9864e1384382100f8f6c01346f
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2023-02-13 18:20:25 +01:00
Sebastian Beckmann
f11e5435c7 QAbstractItemView: Don't unselect on click on empty area in SingleSelect
dfb4697e4a made a change to selection
behavior that resulted in a regression where clicking on an item view
but not on an item would cause the current item to get unselected.
Changes the behavior to not update in this case.

Added a new test that specifially checks for this scenario and ensures
that the current item is still selected, even after the user clicks on
empty area.

Fixes: QTBUG-105870
Pick-to: 6.2 6.4 6.5
Change-Id: I191c3878819b99897083039fba0ab43908da5429
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-02-11 12:47:24 +01:00
Marc Mutz
49fca96d88 tst_qvarlengtharray: fix MyBase trackers for swap()
I don't begin to understand the semantics of the trackers here, but
whatever they are, they break with the fallback std::swap() 3-moves
implementation and lose track of alive objects, so provide an ADL swap
that does the right thing.

Amends dd58ddd5d9 (I think).

Pick-to: 6.5 6.4 6.2 5.15
Change-Id: I1cd49c95dca2d103a26c2c7ac0a896929135a6c8
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-02-10 23:31:37 +01:00
Marc Mutz
224930726b Long live QScopedPropertyUpdateGroup
A RAII wrapper around Qt::{begin,end}PropertyUpdateGroup().

[ChangeLog][QtCore][QScopedPropertyUpdateGroup] New RAII class
wrapping Qt::beginPropertyUpdateGroup() and
Qt::endPropertyUpdateGroup().

Fixes: QTBUG-110710
Change-Id: If2619e9584dd9d57985d63e3babca75421499ab9
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-02-10 18:27:08 +00:00
Eskil Abrahamsen Blomfeldt
fc33fea999 Don't do font merging for PUA characters
The "Private Use Area" are subsets of Unicode which are not
considered regular characters, but reserved for fonts to provide
custom glyphs.

If these were used and the main font did not have support for them,
we would look them up in other fonts and sometimes display an
arbitrary selection of glyphs, based on whatever existed on the
platform. This is unexpected and different from how native apps
work on Windows, for instance.

[ChangeLog][QtGui][Text] Font merging (automatic assignment of
alternative fonts) is no longer applied for characters in the
Private Use Areas of Unicode.

Pick-to: 6.5
Fixes: QTBUG-110502
Change-Id: Id2c63786aafda59bf170e0d7263eb78a391fe46d
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2023-02-10 14:56:34 +01:00
Ahmad Samir
b5a54d488c QDir: use QCollator when doing locale-aware sorting
And don't use toLower() as QString::compare() and QCollator::compare()
can compare case-insensitively.

Change-Id: I999d787cb77e10a101da75d1bf0a5baf096a5c9b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-10 01:19:21 +02:00
Ahmad Samir
eb60e94020 QString: don't detach in replace_helper()
I.e. don't detach in the replace() overloads that delegate to
replace_helper() if this string is shared, instead create a new string
and copy characters from this string to it, along with the "after"
string, then swap it with this.

Do the same thing if "before" is shorter than "after" and there isn't
enough capacity to do the replacement without reallocating.

Use std::copy* and std::move*, which will both fallback to
memmove/memcpy, but they have C++ API, which is more readable.

[ChangeLog][QtCore][QString] Using replace() on a currently shared
QString is now done more efficiently

Task-number: QTBUG-106184
Change-Id: If74ffa1ed47636dc23d543d6dc123d8f2b21d537
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-09 22:52:01 +02:00
Ahmad Samir
5f73f48556 QString: optimize insert(qsizetype, QUtf8StringView)
Utf8 data is variable-width, ideally we want to write characters at most
once, so insert directly into the QString buffer if inserting at the end
(by delegating to append(QUtf8SV)), and use an intermediate buffer to
hold the converted data before inserting anywhere else.

Task-number: QTBUG-108546
Change-Id: Iabfaeecaf34a1ba11946bd67951e69a45d954d6d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-09 16:49:54 +02:00
Ahmad Samir
cc6324665e QString: don't detach in insert()
Instead of detaching when the string is shared, or if the the insertion
would cause a reallocation, create a new string and copy characters to
it as needed, then swap it with "this" string. This is more efficient
than detaching which would copy the whole string before inserting, as
some characters would be copied multiple times.

Use detachAndGrow(), otherwise QStringBuilder unitests fail:
PASS   : tst_QStringBuilder1::initTestCase()
FAIL!  : tst_QStringBuilder1::scenario() 'prepends < max_prepends' returned FALSE. ()
   Loc: [tests/auto/corelib/text/qstringbuilder/qstringbuilder1/stringbuilder.cpp(61)]
PASS   : tst_QStringBuilder1::cleanupTestCase()

The issue is that now when inserting, if the string is going to
reallocated, we create a new string, so the freeSpaceAtBegin()
optimization doesn't work the same way.

void checkItWorksWithFreeSpaceAtBegin(const String &chunk, const Separator &separator)
{
    // GIVEN: a String with freeSpaceAtBegin() and less than chunk.size() freeSpaceAtEnd()
    String str;

    int prepends = 0;
    const int max_prepends = 10;
    while (str.data_ptr().freeSpaceAtBegin() < chunk.size() && prepends++ < max_prepends)
        str.prepend(chunk);
    QVERIFY(prepends < max_prepends);
    ...
    ...

each str.prepend() would have reallocated.

[ChangeLog][QtCore][QString] Calling insert() on a currently shared
string is now done more efficiently.

Task-number: QTBUG-106186
Change-Id: I07ce8d6bde50919fdc587433e624ace9cee05be8
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-09 16:49:26 +02:00
Ahmad Samir
26fec96a81 QString, QByteArray: don't detach in removeIf/erase/eraseif()
If the object is shared, instead of detaching, copy characters from
"this" to a new object except for the chacters that would be erased,
this is more efficient than detaching (which would copy the whole data
then erase).

- Extend tst_QString::removeIf() to catch a corner-case (that I saw
  with tst_QByteArray::removeIf()).

- Add q_uninitialized_remove_copy_if, which works like
  std::remove_copy_if but for uninitialized memory like
  q_uninitialized_relocate_n (but copies rather than relocates/moves).
  With the same static_assert from q_relocate_overlap_n that the type
  destructor is non-throwing.

Added q_uninitialized_remove_copy_if in this commit rather than a
separate one so that it's unittested by its usage in eraseIf().

[ChangeLog][QtCore][QString, QByteArray] Removing characters from a
currently shared string or byte array is now done more efficiently

Task-number: QTBUG-106181
Task-number: QTBUG-106183
Change-Id: Icc0ed31633cef71d482b97e0d2d20d763163d383
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-09 16:46:39 +02:00
Christian Ehrlicher
66a1a71f1f Fix QVariant(QString) <-> enum conversion
A QVariant(QString) was not convertible to an enum not registered with
Q_ENUM() which worked fine in Qt5.
The same problem exists for QVariant(enum) to QString.
Fix it by not bailing out when no metatype for the enum was found and
try to convert it to a qlonglong instead (which is then correctly
converted to the enum type).

Fixes: QTBUG-109744
Pick-to: 6.5 6.4
Change-Id: Ie7bb016a860455b69508f0f46b36474c9c294f3a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-08 23:20:42 +01:00
Dennis Oberst
7cbdc8abbd QVarLengthArray: add STL-style assign()
Implemented assign() methods for QVarLengthArray to align
with the criteria of std::vector, addressing the previously
missing functionality.

Reference:
https://en.cppreference.com/w/cpp/container/vector/assign

[ChangeLog][QtCore][QVarLengthArray] Added assign().

Fixes: QTBUG-106200
Change-Id: If671069808ff561b0f4c77b6c7f7aca360a0c663
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-02-08 21:13:08 +01:00
Fabian Kosmale
7a415a051a Avoid accessing deleted binding data in grouped updates
This fixes a use-after-free in QPropertyDelayedNotifications::notify.

Before this patch, evaluateBindings or a notify from a property index
might have caused the originalBindingData to become reallocated.
However, at that point, we've already restored the original bindingData
in evaluateBindings, so we won't track updates, and thus won't adjust
originalBindingStatus, which will then point to already freed data.

To remedy this, we no longer do the notification with data fetched from
originalBindingData, but instead use the information we have in the
proxyData.
We also need to enure that referenced bindings do not get deleted; for
that we keep the PendingBindingObserverList alive for the whole duration
of the endPropertyUpdateGroup.

As we now have the PendingBindingObserverList, we use it for the
notification logic, and only notify change handlers in
QPropertyDelayedNotifications::notify. That will allow a follow-up
cleanup of QPropertyObserverPointer::notify, and aligns the logic for
grouped updates with the logic for "nornal", non-grouped updates.

Amends f1b1773d0a.

Task-number: QTBUG-110899
Pick-to: 6.5 6.4 6.2
Change-Id: Iae826e620d9614b7df39d86d8a28c48c8a5c4881
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-02-08 16:54:26 +01:00
Fabian Kosmale
f69bcf8d80 Deprecate QPropertyAlias
That use case for the class never materialized, and it was actually
meant for internal use. However, we put it into the public header, so
we cannot remove it (and while undocumented, someone actually used it at
some point, compare e4d62651c2).

Mark it as deprecated instead so that it can be finally be removed in Qt
7.

Change-Id: I058c5831a44610121fbec6eaddebd8b33d4a16c9
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2023-02-08 16:54:25 +01:00
Mate Barany
84f0596c0c Avoid potential data races caused by qt_ntfs_permission_lookup
qt_ntfs_permission_lookup is a global, non-atomic variable which
could cause problems in case of multiple threads. Introduce a
new atomic variable to handle permission lookups but instead of
manual incrementation/decrementation, implement a class to manage
the variable.

Since the atomic variable is not directly available to the user,
implement helper functions to increase/decrease/check the status
of the variable.

Task-number: QTBUG-105804
Change-Id: If6cbcdd653c7f50ad9853a5c309e24fdeb520788
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-02-08 12:59:19 +01:00
Alexey Edelev
214c3a033a Add simple project generation based on existing source files
Introduce the qt-cmake-create script. The script generates the simple
CMakeLists.txt based on the source files located in the current or
specified directory. The initial version can generate a CMake code for
the following file types:
  - .c .cc .cpp .cxx .h .hh .hxx .hpp - generates the qt_add_executable
    call with prerequisites.
  - .qml .js .mjs - generates the qt_add_qml_module call with
    prerequisites.
  - .ui - adds the found ui files to the existing executable. Requires
    C++ files be present in the directory too.
  - .qrc - generates the qt_add_resources call and adds the resources
    to the existing executable. Requires C++ files be present in the
    directory too.
  - .proto - generates qt_add_protobuf call with prerequisites.

The QtInitProject.cmake script contains the 'handle_type' function that
allows extending the script capabilities and establish simple relation
chains between the file types.

Note: The initial implementation doesn't deal with sub-directories, so
all files from sub-directories will be added to and handled in the
top-level CMakeLists.txt file. This can be extended by user request.

Task-number: QTBUG-104388
Change-Id: I5abd9e07da109e867ff95986572ed2bf02ef9d3d
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2023-02-08 12:59:19 +01:00
Thiago Macieira
b41c44d966 qdbusxml2cpp: don't emit Q_DECL_DEPRECATED for the adaptor
The adaptor is a server-side implementation that must exist anyway and
is called by the QtDBus runtime. We don't want warning on the server
side because it must call those methods to implement the client API.

Since we have the XML introspection saved in a class property anyway,
the runtime won't be inspecting the method tags to see if
Q_DECL_DEPRECATED is there, to add to the XML (which it isn't
generating).

Pick-to: 6.5
Change-Id: I9671dee8ceb64aa9b9cafffd17416596135d26ca
Reviewed-by: David Faure <david.faure@kdab.com>
2023-02-07 16:32:23 -08:00
Thiago Macieira
f67b32e735 qdbusxml2cpp: invert Q_DECL_DEPRECATED and inline in the output
Commit 93dad2bf91 (6.0) changed
Q_DECL_DEPRECATED to use the [[deprecated]] attribute, which must appear
before inline and other keywords.

To keep it next to Q_NOREPLY, I also moved the "inline" into the next
string.

Added missing tests for both.

Pick-to: 6.2 6.4 6.5
Fixes: QTBUG-110979
Change-Id: I9671dee8ceb64aa9b9cafffd1741656e86f40453
Reviewed-by: David Faure <david.faure@kdab.com>
2023-02-07 16:32:22 -08:00
Thiago Macieira
0128c3742e tst_qdbusxml2cpp: test the old-style QDBusReply interface output too
Pick-to: 6.2 6.4 6.5
Change-Id: I9671dee8ceb64aa9b9cafffd17416487c07f148a
Reviewed-by: David Faure <david.faure@kdab.com>
2023-02-07 16:32:21 -08:00
Fabian Kosmale
55ca636180 Fix proxy-data handling
This addresses two different issues:
- Firstly, we were casting the resolved binding data pointer to
  QPropertyProxyBindingData, instead of the d_ptr of
  QPropertyBindingData. Fix this by introducing a helper function,
  and consistently using it to access the proxy data.
- Secondly, we were not resetting the originalBindingData when the
  pointed to object was destoyed. Fix that, too.

Pick-to: 6.5 6.4 6.2
Task-number: QTBUG-110899
Change-Id: I7691c9df5cc26e761f6b0e5f16d152f7f2183208
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2023-02-07 22:27:37 +01:00
Mate Barany
9a8b9473d5 Update CLDR to v42
New languages (and one local for each) added with v42
- Haryanvi
- Moksha
- Northern Frisian
- Obolo
- Pijin
- Rajasthani
- Toki Pona

It also appears that Canada has changed its date format. Modify the
relevant test case to reflect this change.

Task-number: QTBUG-110333
Pick-to: 6.5
Change-Id: Ia8975c2866cd54c9e565543d05bacd52f4987909
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2023-02-07 19:04:11 +01:00
Laszlo Agocs
84fb0de413 rhi: Add D3D12 support
- The optional nice-to-haves DebugMarkers, Timestamps, PipelineCache
  are not yet implemented (features reported as false, to be
  implemented later, although buffer/texture resource name setting
  already works as-is, regardless of DebugMarkers).

- Mipmap generation for 3D textures is missing. Won't matter much
  given that 3D textures are not used in Qt for anything atm. For
  generating mipmaps for 2D (or 2D array) textures, the MiniEngine
  compute shader and approach is used. 3D support for the mipmap
  generator may be added later. 1D textures / arrays are supported
  except for mipmap generation, and so the
  OneDimensionalTextureMipmaps feature is reported as false.

- Qt Quick and Qt Quick 3D are expected to be fully functional.
  (unforeseen issues are not impossible, of course)

- Uses minimum feature level 11.0 when requesting the device. It is
  expected to be functional on resource binding tier 1 hardware even,
  although this has not been verified in practice.

- 2 frames in flight with the usual resource buffering
  (QRhiBuffer::Dynamic is host visible (UPLOAD) and always mapped and
  slotted, other buffers and textures are device local (DEFAULT).
  Requests 3 swapchain buffers. Swapchains are mostly like with D3D11
  (e.g. FLIP_DISCARD and SCALING_NONE).

- The root signature generation is somewhat limited by the SPIR-V
  binding model and that we need to map every binding point using the
  nativeResourceBindingMap from the QShader. Thus the root signature
  is laid out so each stage has its own set of resources, with shader
  register clashes being prevented by setting the visibility to a
  given stage.

  Sampler handling is somewhat suboptimal but we are tied by the
  binding model and existing API design. It is in a fairly special
  situation due to the 2048 limit on a shader visible sampler heap, as
  opposed to 1000000 for SRVs and UAVS, so the approach we use for
  textures (just stage the CPU SRVs on the (per-frame slot) shader
  visible heap as they are encountered, effectively treating the heap
  as a ring buffer) would quickly lead to having to switch heaps many
  times with scenes with many draw calls and sampledTexture/sampler
  bindings in the srb.

  Whereas static samplers, which would be beautiful, are impossible to
  utilize safely since we do not have that concept (i.e. samplers
  specified upfront, tied to the graphics/compute pipeline) in the
  QRhi API, and an srb used at pipeline creation may change its
  associated resources, such as the QRhiSampler reference, by the time
  the shader resources are set for the draw call (or another,
  compatible srb may get used altogether), so specifying the samplers
  at root signature creation time is impossible.

  Rather, the current approach is to treat each sampler as a separate
  root parameter (per stage) having a descriptor table with a single
  entry. The shader visible sampler heap has exactly one instance of
  each unique sampler encountered during the lifetime of the QRhi.

- Shader-wise no different from D3D11, works with HLSL/DXBC 5.0
  (i.e. existing .qsb files with DXBC in them work as-is). But unlike
  D3D11, this one will try to pick 6.7, 6.6, ..., down to 5.0 from the
  QShader, in that order.

- Uses D3D12MA for suballocating. As a result it can report vmem
  allocation statistics like the Vulkan backend, and it does more
  since the DXGI memory usage (incl. implicit resources) is also
  reported.  This is optional technically, so we also have the option
  of going straight with the heavyweight CreateCommittedResource()
  instead.  That is what we do if the adapter chosen reports it's
  software-based or when QT_D3D_NO_SUBALLOC=1 is set.

- PreferSoftwareRenderer (picking the WARP device) and the env.var.
  QT_D3D_ADAPTER_INDEX work as with the D3D11 backend.

- It is not unexpected that with large scenes that generate lots of
  draw calls with multiple textures/samplers per call the performance
  may be slightly below D3D11 (probably mostly due to descriptor
  management). Similarly, the reported memory usage will be higher,
  which is partly natural due to creating heaps, descriptor pools,
  staging areas, etc. upfront. Will need to be evaluated later how
  these can be tuned.

Change-Id: I5a42580bb65f391ebceaf81adc6ae673cceacb74
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-02-07 13:33:01 +01:00
Ville Voutilainen
9286d46ee2 Skip socket and server tests on Ubuntu 22.04 and QEMU
Task-number: QTBUG-107696
Change-Id: Ic9cecd0c8624e7e8211633ef8a8ce0339662b4f6
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-05 18:50:30 +00:00
Axel Spoerl
b464119dd4 Unblacklist stable tst_QWidgetRepaintManager
Failing test functions fastMove, moveAccross, moveInOutOverlapped seem
to be stable in the meanwhile. This patch removes the blacklisting.

Task-number: QTBUG-109036
Pick-to: 6.5
Change-Id: I9a2b015572e4d8a4eac196d3985c052030fd84e2
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2023-02-03 18:44:55 +01:00
Edward Welbourne
b62ac40987 Move qtLocalTime() to qtenvironmentvariables.cpp as qLocalTime()
The new name better matches the names of existing functions there.
A comment on the old code noted that such a move should really be
done, so as to correctly share the environment-mutex locking.

In the process, move the (now three) time-related internal functions
from qglobal_p.h to a new qtenvironmentvariables_p.h since that's the
natural place for them given where they're defined (and the fact that
they're for internal use only).

Change-Id: Ib028baebaf31a806a2c0c97caaaba0a466c11cea
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-03 14:45:31 +01:00
Mårten Nordheim
78c5ca4c85 Update the public suffix list
Pick-to: 6.5
Task-number: QTBUG-110333
Change-Id: I741feee3a19d0a104496f543d35a1f311a7228d6
Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2023-02-03 12:56:59 +01:00
Thiago Macieira
9d2f3e63b8 QMimeDatabase: add a test to ensure we can detect Unix specials
Pick-to: 6.4 6.5
Change-Id: I570832c9ac8b4e03bde8fffd173f7e743f42f22b
Reviewed-by: David Faure <david.faure@kdab.com>
2023-02-02 12:17:25 -08:00
Thiago Macieira
40dd38813c QMimeDatabase: don't stat() something that isn't a local file
We must check that the path is an actual file on the filesystem before
using native APIs. This regression was introduced by commit
047d8f36de.

[ChangeLog][QtCore][QMimeDatabase] Fixed a regression from 6.4.0 that
made certain QMimeDatabase functions that inspected file contents to fail
on Unix systems, if the file was not a native file (e.g., a Qt resource).

Fixes: QTBUG-110707
Pick-to: 6.4 6.5
Change-Id: I570832c9ac8b4e03bde8fffd173f7b4c6b164192
Reviewed-by: Igor Kushnir <igorkuo@gmail.com>
Reviewed-by: David Faure <david.faure@kdab.com>
2023-02-02 12:17:24 -08:00
Thiago Macieira
bfe42ebdeb tst_QMimeDatabase: rename test to indicate what it really is
This test is calling mimeTypeForFileNameAndData(), so it doesn't
actually use the files.

Change-Id: I570832c9ac8b4e03bde8fffd173f77f138ef3434
Reviewed-by: Igor Kushnir <igorkuo@gmail.com>
Reviewed-by: David Faure <david.faure@kdab.com>
2023-02-02 12:17:24 -08:00
Ulf Hermann
41248f2590 moc: Allow calling ctors on pre-allocated data
When calling a ctor this way, an object is created in the memory pointed
to by _a[0] using the other arguments for the ctor.

This allows separate allocation and initialization of an object through
the metaobject system.

Fixes: QTBUG-108879
Change-Id: Ifb154373ee42faab281cfb62aa14334980ec6b7d
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-02-02 15:57:09 +01:00
Ahmad Samir
b291217457 QString: remove some redundant unittests
The QChar::toLatin1() args in:
str.replace(index, len, QChar(after[0]).toLatin1())
s2.replace(ch.toLatin1(), after, cs)

will be converted to QChar, so it's always calling the same QString
overload, I argue that we're not testing QChar implicit conversions
here.

Change-Id: I3962cab2b34684f970638575e6bd15dd1067a8c6
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-02 15:57:18 +02:00
Marc Mutz
3f33ed249b Q{Contacts,Calendar}Permission: bool readWrite → enum AccessMode
The fact that read-access is always included makes a bool readWrite
property a little awkward to document and explain. An AccessMode enum
with values ReadOnly and ReadWrite is much easier, and will also lend
itself more easily as a constructor argument than a boolean.

Found in API review.

Pick-to: 6.5
Change-Id: I4f20dbe9f19c7bdb52248a6e544e36d731d5a2ee
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2023-02-02 14:34:02 +01:00
Friedemann Kleint
441c152d85 QtNetwork: Split out QNativeSocketEnginePrivate
The aim is to have fewer files including <windows.h>.

Pick-to: 6.5
Task-number: QTBUG-109394
Change-Id: Id9cc08f54b5daf6d7e317fad27036dc2efaacbb8
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Amir Masoud Abdol <amir.abdol@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-02-02 13:19:06 +01:00
Ahmad Samir
d4f72b4de6 QStandardPaths/unix: ignore relative paths in all $XDG_* env vars
This is a continuation of commit 5c9d671bfb.

[ChangeLog][QtCore][QStandardPaths] Improved conformance to the
Freedesktop basedir spec by ignoring any relative paths in XDG_*
environment variables.

Fixes: QTBUG-58043
Change-Id: I7c34143ced97d6d3de6ecbf13bccf9e935462d1e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-02-01 19:46:02 +00:00
Axel Spoerl
593ffd3859 Add right and middle mouse button to tst_QLabel::mouseEventPropagation
The test function used only the left button to test mouse event
propagation.

This patch adds the right and middle buttons to the test data.

Task-number: QTBUG-110055
Pick-to: 6.5 6.4
Change-Id: I02683168216843919e889987a8b0e8a0f1592d3a
Reviewed-by: Doris Verria <doris.verria@qt.io>
2023-02-01 17:41:58 +00:00
Friedemann Kleint
1fad7aa73e QtGui: Remove define Q_TEST_QPIXMAPCACHE
It causes clashes in CMake Unity (Jumbo) builds.
Change the function to be Q_AUTOTEST_EXPORT'ed helpers.

Pick-to: 6.5
Task-number: QTBUG-109394
Initial-patch-by: Amir Masoud Abdol <amir.abdol@qt.io>
Change-Id: I2e4032e07e1c39432cae1eb2dfff94be33846c09
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2023-02-01 18:09:05 +01:00
Ahmad Samir
28c974ba97 QMimeDatabase: use unique QTest data tag names
Change-Id: I5f0b270df344b0a8511d48f3cde34643f3115445
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-01 18:54:21 +02:00
Thiago Macieira
b22ae069ac QRegularExpression: fix count() when the RE matches a surrogate
When the match finds a surrogate pair as the first true Unicode character,
then we need to skip both code units of the pair in order to restart the
search. PCRE2 does not allow us to search for individual UTF-16 code
units.

That actually means that counting "." gives us the count of Unicode
characters.

Fixes: QTBUG-110586
Pick-to: 5.15 6.2 6.4 6.5
Change-Id: I194d0a32c94148f398e6fffd173d5b5be8137e19
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-01-31 19:38:01 -08:00
Eskil Abrahamsen Blomfeldt
bfe080debb Update Harfbuzz to version 6.0.0
Note: This requires an update to the tst_qtextlayout test, because
the test assumed that the Arabic string would always yield a run
of two glyphs. This was a side effect of how Harfbuzz handled
Qt's test font, which has zero font tables and cannot be used for
shaping. With the Harfbuzz update, the Arabic text here yields a
single cluster instead, which actually makes more sense, so the
test has been made a bit more robust to support both cases.

Pick-to: 6.2 6.5
Task-number: QTBUG-110338
Change-Id: I93d4cf8e3046dc93224e144d4c81d86bef4918d1
Reviewed-by: Lars Knoll <lars@knoll.priv.no>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-01-31 08:20:03 +00:00
Ahmad Samir
26f8ea1224 QString: don't detach in replace(QChar, QChar, case)
If the string is shared, instead of detaching, create a new string and
copy the characters from this string, replacing the ones matching "before"
with "after", to the new string.

Change-Id: I2c33690230d40f3121e60e242666460559258b7b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-01-30 23:52:42 +02:00
Ilya Fedin
763884cfb7 Pass short time format to GetTimeFormat from GetLocaleInfo
TIME_NOSECONDS doesn't really switches to short time format,
just removes the seconds from long time format

Fixes: QTBUG-110627
Pick-to: 6.5 6.4 6.2 5.15
Change-Id: Ie799958f3942c657f00bc8196588258661ddc1d9
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-01-30 23:10:25 +04:00
Shawn Rutledge
78ba5056e6 Make tst_QFocusEvent::checkReason_ActiveWindow pass on macOS
It seems that on macOS 13.2 and newer, it requires explicit activation,
just as on the offscreen and minimal platforms.

Pick-to: 6.5 6.4 6.2
Task-number: QTBUG-110703
Change-Id: I519eec872505ea3673111ae300c2494113f85c36
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-01-30 13:19:41 +00:00
Jani Heikkinen
2fa21f4821 Revert "Revert "Add binary compatibility file generated against 6.4.0""
This reverts commit cebcb7991a.

Reason for revert: We need to enable BIC tests again

Pick-to: 6.5
Change-Id: Ibabe2c50547972d040d933a1027833426b018e81
Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
2023-01-23 14:51:55 +00:00
Marc Mutz
577276d12c tst_QUrlQuery: fix Clang 15 -Wself-move
Says Clang 15:

  tst_qurlquery.cpp:193:11: warning: explicitly moving variable of type 'QUrlQuery' to itself [-Wself-move]
    moved = std::move(moved);
    ~~~~~ ^           ~~~~~

It's amazing how little it takes to throw this warning off guards:
just use an alising reference instead of the same variable. Makes you
wonder whether the time spent on detecting such trivialities in the
compiler is really well spent.

Amends fc8dad2f10.

Pick-to: 6.5
Task-number: QTBUG-109842
Change-Id: I165af2a786aa0ba28b8dcd039a500f3494bc29a9
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-01-23 10:12:35 +01:00
Ahmad Samir
5d356ae2bd Fix two variables' "may be used uninitialized" compiler warnings
Change-Id: Ie6063d7124b16681b3e39d465da21dd67206ebc3
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-01-22 21:19:36 +02:00
Thiago Macieira
7e64ecacb6 IPC: switch the default key type on Unix to POSIX realtime
Instead of the System V one. An important difference is that
QSharedMemory does not clean after itself.

Updated the configure summary output to include this information.
Drive-by update to sorting order and I removed cpp-winrt from the
listing because there's a warning at the end if it is not set.

Change-Id: I12a088d1ae424825abd3fffd171e0eadcfd33426
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-01-22 13:02:11 -03:00
Thiago Macieira
0740ab56d7 IPC: add support for multiple backends to QSharedMemory
Simultaneously.

Change-Id: If4c23ea3719947d790d4fffd17152760989b9bc6
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-01-22 13:02:11 -03:00
Thiago Macieira
32a06e9830 IPC: add support for multiple backends to QSystemSemaphore
Simultaneously.

Change-Id: If4c23ea3719947d790d4fffd17152a29e6c217d3
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-01-22 13:02:10 -03:00
Thiago Macieira
4141c5e221 IPC: fix cleaning up after tst_QSharedMemory tests
If a previous test in the same process or previously leaked a shared
memory or semaphore handle, tests could fail and cascade down. They
could also interfere with one another. So prevent this issue by
assigning a monotonically-increasing identifier per test function or row
tested and improving how we clean up those we did create.

This shows we need the API to explicitly clean up.

Change-Id: I12a088d1ae424825abd3fffd171db61d6b68a411
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-01-22 13:02:08 -03:00
Thiago Macieira
6bc3a89c90 IPC: clean up #ifdef in tst_qsharedmemory.cpp
Change-Id: I12a088d1ae424825abd3fffd171db0debf823a12
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-01-22 13:02:07 -03:00
Thiago Macieira
2c286561bb IPC: add native key support to QSharedMemory
And deprecate the non-native key support API. Qt 7 may not even store
the old, non-native key.

Documentation in a new commit, when the dust settles.

Drive-by updates to the tst_QSharedMemory::attach row names, to fix
grammar and remove spaces and apostrophe.

Change-Id: I12a088d1ae424825abd3fffd171d3025c77f94d2
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-01-22 13:02:04 -03:00
Thiago Macieira
3ae052d3bb IPC: add native key support to QSystemSemaphore
And deprecate the non-native key support API. Qt 7 may not even store
the old, non-native Qt.

Documentation in a new commit, when the dust settles.

Change-Id: I12a088d1ae424825abd3fffd171d2b549eeed040
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-01-22 13:02:04 -03:00
Thiago Macieira
7a37083817 IPC: Long live QNativeIpcKey key
Common to both QSharedMemory and QSystemSemaphore, this will hold the
native key and will replace the concept of non-native key in those
classes.

Change-Id: Id8d5e3999fe94b03acc1fffd171c03197aea6016
Reviewed-by: Nicholas Bennett <nicholas.bennett@qt.io>
2023-01-22 13:02:00 -03:00
Thiago Macieira
7809caa924 IPC: move makePlatformSafeKey to qtipccommon.cpp
This removes the second portion of the #if mess of shared code between
QSharedMemory and QSystemSemaphore for SystemV.

Change-Id: Id8d5e3999fe94b03acc1fffd171c073c2873206e
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-01-22 13:01:55 -03:00
Thiago Macieira
fc14f1a467 IPC: move the feature check to the ipc/ dir for tst_qsharedmemory
Change-Id: Id8d5e3999fe94b03acc1fffd171c22d2e8752ffb
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-01-22 13:01:54 -03:00
Thiago Macieira
53e8982434 IPC: Move QSharedMemory and QSystemSemaphore from kernel/ to ipc/
It's not a lot of files, but it's actually more in the same dir than
mime/ does right now. I'm about to add two more files, though I'll also
merge a few more later.

Change-Id: Id8d5e3999fe94b03acc1fffd171bfe2ea36a35a7
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-01-22 13:01:53 -03:00
Axel Spoerl
7689d4ad2f QWidgetTextControl: Ignore unconsumed mouse release events
QWidgetTextControlPrivate::mouseReleaseEvent() has early returns
implemented, e.g. when link has been right clicked or no selection
anchor has been found. These early returns, however, still consume
the event.

This leads to events getting lost instead of getting propagated:
As an example, a QLabel with rich text uses QWidgetTextControl. While
it propagates mouse press events back to its parent, mouse release
events get lost. A QLabel with plain text propagates both events
back correctly.

This patch adds QEvent::ignore() to the early return.
Since no test class exists for QWidgetTextControl, it adds a test in
tst_QLabel.

Fixes: QTBUG-110055
Pick-to: 6.5 6.4
Change-Id: I950f8c3f135793b01c59832835bb429db2282169
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-01-21 17:04:14 +01:00
Christian Ehrlicher
87662bcf10 SQL tests: Fix for PostgreSQL 12 and above
The 'WITH OIDS' was deprecated some time ago and removed with
PostgreSQL 12 so we have to adjust our test table creations. Don't know
why it was used in the first place at all.

Pick-to: 6.2 6.4 6.5
Change-Id: I6e18ac01e64368b1dd64e02bcb75fa70e05467a3
Reviewed-by: Dimitrios Apostolou <jimis@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-01-20 15:51:17 +01:00
Marc Mutz
51e5a2376a QVarLengthArray: fix off-by-size() bug in growBy()
The growBy() function takes the _increment_ of the size(), so needs to
add size() to increment for the call to realloc().

Add a test which hangs (vanilla build) or explodes (valgrind build)
without the fix.

Amends 26b227e128.

Done-with: Eirik Aavitsland <eirik.aavitsland@qt.io>
Pick-to: 6.5 6.4
Fixes: QTBUG-110412
Change-Id: I7ea91342fdcb779825c88013a3f86ba6d90ef530
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-01-20 14:48:20 +01:00
Thiago Macieira
8772005a4b tst_QUrlQuery: replace a few QVERIFY(~~ != ~~) with QCOMPARE_NE
Pick-to: 6.5
Change-Id: I69ecc04064514f939896fffd17376aae3b8072b5
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2023-01-20 00:19:22 -03:00
Thiago Macieira
fc8dad2f10 QUrlQuery: add missing move constructor
It wasn't added when this class was created in 5.0 because we couldn't
add move constructors and still keep the ability to compile Qt with
C++98 compilers. We've forgot to correct this shortcoming since 5.6.

Fixes: QTBUG-109842
Pick-to: 6.5
Change-Id: I69ecc04064514f939896fffd17376b8243b73c52
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-01-20 03:19:21 +00:00
Thiago Macieira
3d584b1093 QUrlQuery: fix operator== for emptied object case
If an object had elements and then was emptied, it will have a non-null
d pointer, which wasn't taken into account in the comparison.

Fixes: QTBUG-109840
Pick-to: 6.5 6.4 6.2
Change-Id: I69ecc04064514f939896fffd17376aa18184653c
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-01-20 03:19:19 +00:00
Peter Varga
5686824229 tests: remove PlatformInputContext::filterEvent()
This overridden function is not used and also can't be triggered by a
synthetic input event in an auto test.

Change-Id: Id8b69b440a90c18cf5870e34804fae3e6607e49f
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2023-01-18 13:21:06 +01:00
Qt CI Bot
2e8b75477f Merge integration refs/builds/qtci/dev/1673982362 2023-01-18 00:51:53 +00:00
Thiago Macieira
a14a3a5487 QUrl: restore empty-but-not-null for components that are present
This got lost during the QStringView port that happend in Qt 6.0
(commit 548dcef089) because
QString::operator+=(QStringView) does not copy the nullness of the right
side, whereas QString::operator+=(const QString &) does.

Pick-to: 6.2 6.4 6.5
Fixes: QTBUG-84315
Change-Id: Ide4dbd0777a44ed0870efffd17399b772d34fd55
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-01-17 16:51:53 -08:00
Thiago Macieira
a7c3b747db tst_QHostInfo: use python3
Because Python 2 reached end of life. I wonder how this even works on
macOS, as my Monterey doesn't even have "python" any more.

Pick-to: 6.2 6.4 6.5
Change-Id: Ibddb9b0ada5a4bbaa64bfffd173b239c6c4b66f3
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2023-01-17 10:43:17 -08:00
Ahmad Samir
a67e7e3bb7 QLocale: add unittests for qstrtod of "NaN" and "nan"
The tests pass.

Drive-by change: Amend qstrntod API docs, the addition is heavily
inspired by cppreference's strtod docs.

Change-Id: Ic8e138e117a3249c752ae5ef2a8a21feb010befa
Task-number: QTBUG-74325
Pick-to: 6.5
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-01-17 20:41:48 +02:00
Marc Mutz
800ebd84f5 QVarLengthArray: cope with vector<unique_ptr>'s copyability
Despite being move-only, std::vector<unique_ptr> advertizes
is_copyable:
  https://quuxplusone.github.io/blog/2020/02/05/vector-is-copyable-except-when-its-not/

Our combined reallocation and resizing function, reallocate_impl(),
runs afoul of this when it uses std::is_copyable in a constexpr-if to
implement resize(n, v) without running into problems with move-only
types: the trait is true, but actual instantation runs into a
static_assert in the STL implementation.

To fix, move the problematic resize functionality out of
reallocate_impl() and into the resp. resize_impl overloads. The shrink
functionality remains in reallocate_impl(), because there are many
more users, and it only requires destructible<T>, which isn't
constraining at all.

Amends a00a1d8806.

Fixes: QTBUG-109745
Pick-to: 6.5 6.4
Change-Id: Ibc5b9cf5375108eb3d8f6c8a16d4fd02dadd73b1
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-01-16 22:44:13 +01:00
Marc Mutz
ce104cac50 QPermission: replace T data<T>() with std::optional<T> value<T>()
As discussed in API review, the default-constructed T() returned from
a mismatched data<T>() call is indistinguishable from a real T with
default state.

To make them distinguishable, return optional<T>. Call the new
function value<T>(), mimicking QVariant::value<T>(), and suggested in
API review, because data() is usually used to return raw pointers, not
values.

Remove the qWarning() on requestedType and actualType mismatch, as the
new function can be used in std::get_if/dynamic_cast-like if-then-else
chains, in which failure is part of the normal operation, and a
warning message misplaced:

  if (auto loc = perm.value<QLocationPermission>())
     ~~~ use *loc ~~~
  else if (auto con = perm.value<QContactsPermission>())
     ~~~ use *con ~~~
  ~~~ etc ~~~

Pick-to: 6.5
Change-Id: I799a58e930307323ebce8f9ac50a42455e9c017f
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-01-13 21:07:18 +01:00
Mikolaj Boc
2e97ccc8d0 Add QString<->emscripten::val conversion functions
Following the QRect, add functions converting the QString to native
emscripten::val and back: fromJsString, toJsString

Change-Id: I2d0625ede3bbf7249e2e91b8de298b5b91df8ba2
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2023-01-13 21:07:14 +01:00
Marc Mutz
8f8d8f71dd tst_QPermission: add more tests
The new test:

- checks the properties of stateful Q<Typed>Permissions work

- ensures that piping a Q<Typed>Permission through QPermission
  maintains state

- also ensures that assignment of a Q<Typed>Permission to a
  QPermission works (via QPermission(Type) + move ctor)

Pick-to: 6.5
Change-Id: I340e49b1ecc665702ccab26d9050ca158b0e7885
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2023-01-13 17:10:43 +00:00
Marc Mutz
595360506d QSqlRecord: add missing C++11 move SMFs
[ChangeLog][QtSql][QSqlRecord] Added move constructor, -assignment
operator, and swap().

Task-number: QTBUG-109938
Change-Id: I54f2666defbf56f5ba2faea6358722ebd7cac157
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2023-01-13 17:20:55 +01:00
Mikolaj Boc
ae3ffc1d4b Remove tst_QTextBoundaryFinder::thaiLineBreak
The test body has been inside an #if 0 for long, remove the test
altogether. The part that loads libthai does not check anyhing
meaningful.

Task-number: QTBUG-109954
Change-Id: I8ce006a14e4cf926b668e958d4b2343f965a5fb6
Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
2023-01-13 17:20:55 +01:00
Edward Welbourne
25e10d9636 Give tst_QStorageInfo a QCOMPARE_op() makeover
It had various QVERIFY()s of != and >= checks: convert these to
QCOMPARE_NE() and QCOMPARE_GE() checks.

Change-Id: Ida6f7dca726187f7837da0d805549d9c582f946a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Ivan Komissarov <ABBAPOH@gmail.com>
2023-01-13 15:08:25 +01:00
Volker Hilsheimer
c3a5fe2fd7 QFormLayout: don't access out-of-bounds layout data
When rows are hidden (implicitly or explicitly), then their layout data
does not get fully updated. If rows get hidden after the layout data has
been calculated once, then we must make sure that their indices are
reset. Otherwise we might access array indices that are out of bounds
when the layout data structure gets resized to fit only visible rows.

For good measure, skip entirely over hidden rows when accessing the
layout data when arranging the widget.

Fixes: QTBUG-109237
Pick-to: 6.5 6.4
Change-Id: I4d6943b6a110edb61f60ce78d31f0fc64b5cc03d
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2023-01-13 14:38:16 +01:00
Volker Hilsheimer
51272017a7 QCalendarWidget: Add reset functions for minimum/maximumDate
QDateTimeEdit has such reset functions for the minimum/maximum
range properties, this makes QCalendarWidget consistent with the
simpler editors.

Fixes: QTBUG-62448
Change-Id: Iabb89f599e4996f00488a885a5b8a009471838b3
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2023-01-13 12:26:06 +01:00
Edward Welbourne
73e7ffb2fd Verify land-preservation in locale construction
For most territories, if we specify only that territory, we should get
a locale specific to that territory. There are exceptions for various
reasons, but check that it's true in most cases, at least. In the
process, convert two QVERIFY(... == ...) into QCOMPARE(..., ...)

Task-number: QTBUG-64940
Change-Id: I7590f20f37b0b459aafb3d1d08f6eb77932fa027
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-01-12 19:03:17 +01:00