Commit Graph

13924 Commits

Author SHA1 Message Date
Thiago Macieira
13c3558fe9 tst_QDeadlineTimer: use the new QCOMPARE_xx() macros
Pick-to: 6.5
Change-Id: Ieec322d73c1e40ad95c8fffd17468cb805546aea
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-04-18 19:23:43 -03:00
Thiago Macieira
c9f4c0d45e QElapsedTimer: rewrite using std::chrono::steady_clock everywhere
This commit deletes the direct, low-level functionality that
QElapsedTimer has carried since it was introduced. Everything now uses
only std::chrono::steady_clock and std::chrono::nanoseconds.

QDeadlineTimer temporarily still uses qt_gettime(), which is moved to
qcore_unix.cpp.

Task-number: QTBUG-110059
Change-Id: Ieec322d73c1e40ad95c8fffd174641a469b1eee5
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-04-18 19:23:42 -03:00
Laszlo Agocs
62a4ca773a rhi: Make it safe to always call deleteLater on a resource
...even when the QRhi is already gone. This should not happen in
well-written applications and libraries, but we handle this
gracefully in the regular dtor and destroy() for resources that
register themselves to their creator QRhi, so by registering
everything we can offer this to all QRhiResource subclasses.

We still want to differentiate between native resource owning
QRhiResources and others (that do not create native graphics
objects), so do this via a flag passed to registerResource().
This way the behavior with QT_RHI_LEAK_CHECK=1 does not change.

Pick-to: 6.5
Fixes: QTBUG-112914
Change-Id: I9bafc81ef7a4ae76f356fc5f6248628d1f8791e0
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Christian Strømme <christian.stromme@qt.io>
2023-04-18 14:42:45 +02:00
Fabian Kosmale
cb30e45b9a Avoid capturing same property twice
Avoid capturing the same property multiple times in a binding by
storing them in the BindingEvaluationState. We store them in a
QVarLengthArray array, as the number of properties involved in a binding
is expected to be rather low, so a linear scan is fine.

Avoiding double capture is a good idea in general, as we would otherwise
needlessly reevaluate bindings multiple times, and also needlessly
allocate memory for further observers, instead of using a binding's
inline observer array.

Even more importantantly, our notification code makes assumptions that
notify will visit bindings only exactly once. Not upholding that
invariant leads to memory corruption and subsequent crashes, as
observers allocated by the binding would get freed, even though we would
still access them later.

Fixes: QTBUG-112822
Pick-to: 6.5 6.2
Change-Id: Icdc1f43fe554df6fa69e881872b2c429d5fa0bbc
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2023-04-18 13:23:48 +02:00
Volker Hilsheimer
fd879a38cc Fix another warning when comparing size_t and qsizetype
Amends 07f7ed2bad.

Change-Id: I0644e47e8e9ccd0bcaf074adf99e7481c692b5c1
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2023-04-18 00:10:56 +02:00
Liang Qi
14feb6792e tests: blacklist tst_QGraphicsEffect::draw() on Wayland
Task-number: QTBUG-109779
Pick-to: 6.5
Change-Id: I21ecd4910ba3d699e44d9ea922093e98e0b8a335
Reviewed-by: Inho Lee <inho.lee@qt.io>
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2023-04-17 16:05:24 +02:00
Ahmad Samir
c1e1d133c4 mimetypes/: port to qsizetype
Fixes compiler warnings about narrowing conversions.

Found by compiling with clang and -Wshorten-64-to-32.

Drive-by changes:
- use range-for instead of an iterator based loop
- use strlen("*.") instead of magic number 2

Pick-to: 6.5
Task-number: QTBUG-102461
Change-Id: I0bf2299049c0411ed496468238ca30b69946ffc2
Reviewed-by: David Faure <david.faure@kdab.com>
2023-04-15 17:21:10 +02:00
Christian Ehrlicher
d9bd46b2b8 SQL/Tests: make sure created procedures are cleaned up on exit
Similar to TableScope - create a helper class to make sure the
procedures are cleaned up on exit so they don't affect the result during
the next test run.

Change-Id: Ic5b02ca63e03f330392797ed22313767557fc548
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-04-15 13:56:21 +02:00
Volker Hilsheimer
79ac430537 Test for QWindow getting enter/leave events when secondary window shows/hides
Equivalent to the test added to the QWidget test case, but since QtWidgets
code contains logic to both synthesize and compress/filter enter/leave
events, we can only verify that the QWindow does get the events.

The test is very flaky on Windows, so blacklisting it right away.

Change-Id: Ic1da9439f60f619a76a3653a23fef8e9ebc0e75d
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2023-04-14 20:13:41 +02:00
Edward Welbourne
b906796af6 Fix QDateTime tests in zones whose side of UTC varies
The classification of local time as ahead of UTC, behind it or equal
to it gets complicated by zones near the prime meridian - some of
which have varied which side of it they nominally are - or the
international date line, which a few zones have crossed.

So, instead of having one classifying variable, split to having three,
one for the distant past (when using local solar mean time), one for
the epoch and one for the distant future.

Change-Id: I7c0da376e1625372086dc51afa815756f0bde442
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-04-14 15:23:09 +02:00
Edward Welbourne
9f11574a7d Explain the cases where we must exclude some QDTE test cases
The stepIntoDSTGap() hour cases were already conditioned on hour > 0,
explain why. The month and year tests need similar checks for kindred
reasons; add and document those checks.

Pick-to: 6.5
Change-Id: Ibcb69449fcd572ee94306a805fd680e9b5155322
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-04-14 15:22:16 +02:00
Edward Welbourne
ee46c645a6 Skip some tests that fail in the Indian/Cocos timezone
The zone had a transition at the start of 1900, so QDTP's default date
ends up being 1900-01-01 at 00:02:20 instead of at 00:00:00; and any
parsing of date-time strings that doesn't set the minutes and seconds
consequently ends up "wrong" (about a field that wasn't specified).

Change-Id: If4b9864616fa08bc023a6974dae255f96ca90f83
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-04-14 15:21:50 +02:00
Edward Welbourne
90d4957c12 tst_QDateTimeParser::intermediateYear(): adapt for Indian/Cocos zone
The zone had a transition at the start of 1900, used as default date
by the parser. This leads to the default minutes and seconds being 2
and 20, rather than 0. Since this test is parsing a date-only string,
only check the date of the result, to avoid failing in Cocos.

Pick-to: 6.5
Change-Id: Ifb307eadb747097988bcf0afc6f307835ff2c8ec
Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-04-14 15:21:39 +02:00
Edward Welbourne
b81515c58a Correct a test's precondition on the system zone
America/Sao_Paulo was not alone in starting 2008-10-19 with a spring
forward. Include the other affected zones in the check to tune the
expected start-of-day time. See [0] for details.

[0] https://github.com/eggert/tz/blob/main/southamerica

Pick-to: 6.5
Change-Id: If251d8b715090319441790696983273637765d2e
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-04-14 15:21:22 +02:00
Edward Welbourne
bab9af5891 Fix where possible, else avoid, failures in western Mexico
Some QDateTime tests get tripped up by a transition at the epoch in
Baja Mexico. For the operator_eq() and time-difference test, simply
using startOfDay() instead of QTime(0, 0) - which was skipped - solves
the problem. For addDays() and fromStringDateFormat(), skip the
affected tests.

Change-Id: I3620f0d1e4b05d9f799662eea96a40c8284de331
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-04-14 15:19:08 +02:00
Edward Welbourne
ca4aa06523 Add new test-case for startOfDay_endOfDay() for Baja Mexico
The zones in Baja Mexico had a transition at the epoch.

Change-Id: Ic70e23bcc980bf371e925fcb8fb83ca5ef000c9f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-04-14 15:19:03 +02:00
Edward Welbourne
919d2e0c5a Correct time zone in tst_QDateTimeEdit::stepIntoDSTGap()
Given that QDTE only supports local time and UTC, using Europe/Oslo as
zone was disconnected from reality, especially as various QDateTime()s
were constructed using local time. Use the system zone.

Pick-to: 6.5 6.2
Change-Id: I95b3a6a6acf9ffc2b8c7f05d3dd9440ff173abfe
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-04-14 13:19:03 +00:00
Edward Welbourne
d43391422a Correct the start of a QDTE::stepIntoDSTGap() test
The test wants to start shortly after the transition, then step an
hour backwards, into it, to check we land safely on the other side.
However, it assumed the gap witdh was an hour, which is not reliable.
Use the gapWidth already used in computing springGap instead.

The -3590 seconds in the result time is correct, as it's the ten extra
seconds we started beyond the gap, minus the hour we step backwards.

Pick-to: 6.5
Change-Id: I4399af7e54a60bd55ea51d054d3cd2ecfcb0e354
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-04-14 15:19:03 +02:00
Edward Welbourne
5432a8040f tst_QDateTimeEdit::springForward(): use u'0' instead of QLatin1Char('0')
Pick-to: 6.5
Change-Id: I0c13c6b658cac3472d21b8d92b1e5eb73c094a7c
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2023-04-14 15:19:02 +02:00
Edward Welbourne
4e69b6de4b Correct row names in tst_QDateTimeEdit::springForward_data()
The "{forward,back} to %s, correct to nearest" tests were reporting
the time of the transition as %s but, like the jump test, were using
the middle of the gap as the time to set. So compute that mid-time's
string once and use it in all three test names. Also renamed some
local variables to accommodate the new one for this text.

Pick-to: 6.5
Change-Id: Ic6c40c470fc74ae8bcfc0dc9d1596af06318a883
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-04-14 15:19:02 +02:00
Edward Welbourne
28c6868611 tst_QDateTimeEdit: correct computation of width of gap
Although the zone's daylight time offset is usually the width of the
gap, it's possible the transition is (or includes) a change to
standard time; so determine the actual gap width by comparing the
difference between time a day earlier and later to the usual duration
of two days. Also skip the test if the transition isn't really a gap.

Pick-to: 6.5
Change-Id: I56e381c9f74cfa1806d43b3ed5e4637436ebdf57
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-04-14 15:19:02 +02:00
Edward Welbourne
f06cc22509 tst_QDateTimeEdit: Use correct zone for findSpring()'s transition
The function is passed a zone to work in, so setting the transition to
local time made no sense; set to the given zone's time, instead.

Pick-to: 6.5
Change-Id: Icaa0955fe5fcd5bc257322afcb7e25e932dedd1b
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Mate Barany <mate.barany@qt.io>
2023-04-14 15:19:02 +02:00
Edward Welbourne
a076fdfec6 tst_QDateTime: Remove two duplicate test cases
Pick-to: 6.5 6.2
Change-Id: I36541b5c6f7c35deee9678e2f736e1db9f36039f
Reviewed-by: Jason McDonald <macadder1@gmail.com>
2023-04-14 15:19:02 +02:00
Edward Welbourne
91fedd50f0 tst_QDateTime constructor: adapt the year check to vary year
We check three sample dates, in different years, so don't compare
their year() to 1970, but to their respective actual years. In the
process, package the arrays iterated for these checks into a constexpr
struct array and reverse them so that, instead of reverse-iterating
and indexing, we can use a ranged-for loop.

Change-Id: I214685346c637875a4ea31125c324851eb4308db
Reviewed-by: Øystein Heskestad <oystein.heskestad@qt.io>
Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-04-14 15:19:02 +02:00
Edward Welbourne
9aa87643d7 tst_QDate::startOfDay_endOfDay(): rename variables, add comments
The name final is suboptimal, given that it's also a keyword.
Rename initial at the same time.

The local-time parts of the test are apt to fail if local time
coincides with the zone being tested, as previously noted. Document
known cases of such coincidences, to help someone studying a failure
to know why it happened.

Change-Id: I1f1f302f161373a154066df210e03725b9a5f9ed
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-04-14 15:19:02 +02:00
Edward Welbourne
c8c5b8ac1a tst_QDateTime::addMSecs(): check for failure after calling helper
When the test failed, it did so in triplicate.

Pick-to: 6.5
Change-Id: Ia871aed0a5960120a2659a6778c10dccd4b2953a
Reviewed-by: Jason McDonald <macadder1@gmail.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-04-14 15:19:01 +02:00
Edward Welbourne
ac653abc41 Name a numeric_limits locally to save verbose repetition
Change-Id: I443eb1f5a38e79a28827ac3e664100e6a23a9ef2
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Mate Barany <mate.barany@qt.io>
2023-04-14 15:19:01 +02:00
Tatiana Borisova
42d3e242fa Put timezone related code under ifdef
In case FEATURE_timezone=OFF auto-tests should still be built successfully

Change-Id: I0226a7d7781a412bf9e9935c2cf1a48b1ce427b5
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2023-04-14 10:34:45 +00:00
Alexey Edelev
4fb7eebc70 Rid of 'special case' markers
It's unlikely we will ever use pro2cmake at this project stage,
so it doesn't make any sense to keep the 'special case' markers
in the CMake scripts. Remove them and replace with TODO where
needed.

Change-Id: I84290c20679dabbfdec3c5937ce0428fecb3e5a7
Reviewed-by: Amir Masoud Abdol <amir.abdol@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2023-04-13 18:30:58 +02:00
Tor Arne Vestbø
06499383ca Use LANGUAGE OBJCXX rather than COMPILE_FLAGS "-x objective-c++"
We sometimes use Objective-C++ code in files with a .cpp extension,
to avoid the churn of adding a foo_mac.mm file. Instead of manually
telling the compiler to build these files in Objective-C++ mode, we
use CMake's intended mechanism, which means genex constructs such as
$<$<COMPILE_LANGUAGE:OBJCXX> will work for these files as well.

Pick-to: 6.5 6.2
Change-Id: If295c3f34f6bee9f4d9f877f519c9c7770665fee
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2023-04-13 14:36:26 +02:00
Marc Mutz
2f95cd8f8b Long live QPromise::emplaceResult/At()!
And implement the rvalue overload of addResult() using it.

[ChangeLog][QtCore][QPromise] Added emplaceResult() and
emplaceResultAt() member functions.

Fixes: QTBUG-112270
Change-Id: Id369542215a60c0818f1afa8d564498be84732e8
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-04-12 01:57:15 +02:00
Laszlo Agocs
82112db29d rhi: Remove readback result type alias
Change-Id: I1b14d3230ab4011506892c64ea03d5431d82a90d
Reviewed-by: Christian Strømme <christian.stromme@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-04-12 01:11:12 +02:00
Volker Hilsheimer
f334a22eae QAccessible test: skip focusChild on wayland
The test implicitly relies on window activation as QWidget only emits
accessibility events for focus changes in the active window. So skip it
on platforms that don't support WindowActivation and remove it from
the blacklist.

Fixes: QTBUG-109763
Pick-to: 6.5
Change-Id: I67d9a95f4f36b5271fe53ae90140a28770566c83
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2023-04-11 19:03:52 +02:00
Volker Hilsheimer
7199498fb9 QPushButton: use QMenu::popup instead of exec to show menu
QMenu::exec opens a blocking loop, which is problematic for webassembly.
Replace with QMenu::popup, and reset the down-state of the button when
the menu is about to hide. QMenu emits aboutToHide immediately before
existing the event loop in the hideEvent override, so the timing is the
same.

Change-Id: Iccb418d10fcb25f6ad1f73f9cdce6ea6581bd73b
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2023-04-11 12:58:58 +02:00
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