All of this connection management code is used only in QtCore and
mustn't be touched by other modules (not even qtdeclarative). So there's
no reason for it to be around and slow down the compilation time of
everything using QObjectPrivate.
Change-Id: If2e0f4b2190341ebaa31fffd16e31313f1b7020f
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Just to be pedantically correct, but also makes the construction code
slightly more readable.
Pick-to: 6.2 6.3
Change-Id: I29f1c141c0f7436393d9fffd16e2bbf0f361c024
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
In C++20, QDateTime is a direct equivalent of a sys_time<milliseconds>
time point. (Before, it might not have been, because system_clock before
C++20 was not guaranteed to be tracking Unix time, AKA UTC time without
leap seconds.) To be specific, sys_time<milliseconds> corresponds to
a QDateTime using the Qt::UTC timespec.
This patch:
1) adds named constructors taking time_points:
* a generic one taking any time_point convertible (via clock_cast) to
a system_clock (this obviously includes system_clock, but also e.g.
utc_clock)
* another couple taking local_time, interpreted as a duration from
1/1/1970 in local time.
2) adds a named constructor from zoned_time (i.e. a sys_time + a
timezone), that we can easily support via QTimeZone.
3) add conversion functions towards sys_time, matching the existing
to(M)SecsSinceEpoch() functions.
[ChangeLog][QtCore][QDateTime] QDateTime can now be constructed
from std::chrono::time_point objects (including local_time), as
well as from std::chrono::zoned_time objects. Moreover, they
can be converted to std::chrono::time_point using system_clock
as their clock.
Change-Id: Ic6409bde43bc3e745d9df6257e0a77157472352d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Required for porting away from QLatin1Char/QLatin1String in scope of
QTBUG-98434.
Change-Id: I308d86cefcbfd126929b68f9a853d420840c965f
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
std::chrono::year_month_day and related classes offer very
convenient to specify dates.
This patch adds implicit constructors to QDate to support this
convenience, e.g.:
// YYYY-MM-DD, DD-MM-YYYY, MM-DD-YYYY formats:
QDate d1 = 1985y / December / 8;
QDate d2 = 8d / December / 1985;
QDate d3 = December / 8d / 1985;
// Indexed weekday:
QDate d4 = 2000y / January / Monday[0];
QDate d5 = 2000y / January / Monday[last];
and so on.
These are all implemented using the conversion from the std
calendaring classes to sys_days. Conversions between sys_days
and QDate are also added, since they're basically "for free".
I don't expect "ordinary" users to stumble upon it, but it's
worthy mentioning that std::chrono::year *does* have a year
zero (hence, year_month_day in year 0 or below are offset
by one with the corresponding QDate). I've left a note
in the documentation.
[ChangeLog][QtCore][QDate] QDate (and therefore QDateTime)
is now constructible using the year/month/day/week classes
available in the std::chrono library. Moreover, it now
features conversions from and to std::chrono::sys_days.
Change-Id: I2a4f56423ac7d1469541cbb6a278a65b48878b4a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
QAbstractProxyModel::headerData tries to do the "smart" thing and
map sections in the proxy to sections in the source. However there's
no "mapSectionToSource" virtual. Instead, to map horizontal headers, the
code builds a proxy index at row 0 and section N, maps it to the source,
and finds out which source column it gets mapped to. (Same story
for the vertical headers).
... in general this can obviously fail, say you've got a "horizontal
scrambling" proxy model, but in the common case this is OK.
Except, if the proxy is empty (e.g. 0 rows or columns). In this case,
it asks for an illegal index, and if you reimplemented index() yourself
(which you must, since it's a pure virtual in QAPM) and you do bounds
checking, you'll not be pleased at the result.
This turns out to be a massive API liability. To fix this somehow properly,
we can decide that empty models don't get the section remapped (easy).
Less easy is the fact that, when the model does get some data, we have to
emit headerDataChanged() otherwise the views will get broken. So add
this logic too.
Note that QAPM does not normally forward any source model's signal -- a
subclass has to connect to them and handle them explicitly. That's
*another* API liability, all over the place -- data(), headerData(),
flags(), etc.
What I mean by this is that one can create a valid QAPM (by implementing
its pure virtuals) that however is immediately broken by the convenience
that QAPM provides for the rest (data(), headerData(), etc.).
This commit doesn't try and change this in any way, but I'm less and
less convinced of the usefulness of QAPM in its current shape.
Change-Id: I45a8c2139f2c1917ffbf429910fdb92f005f4feb
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: David Faure <david.faure@kdab.com>
We still mentioned the QMAKE_* variables.
Replace them with the OpenGL_DIR CMake variable.
Pick-to: 6.2 6.3
Change-Id: If53c2bff030cf03cb43d10f738949f59ac8dd730
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Whenever a source file is touched that belongs to the bootstrap library,
all bootstrap tools are rebuilt. This includes moc. The moc binary
however, is a dependency whose invalidation results in a rebuilt of
quite some parts of Qt.
There's no easy way to turn off this dependency. To mitigate the
rebuilds, the bootstrap lib now can use a copy of the corelib sources.
That means the bootstrap lib is not rebuilt if its sources are changed.
This is basically the situation we had in Qt5.
The sources are not updated on reconfiguration. There's a new target
'update_bootstrap_sources' that can be built to update the copied source
tree of the bootstrap lib.
This new behavior can be controlled with the variable
QT_USE_BOOTSTRAP_SOURCE_COPY. It's on by default for developer builds.
Fixes: QTBUG-92269
Change-Id: I50234df66590c39594d208424394c7a600dc5606
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
The example was refactored to use the PMF connection syntax.
However this introduced a problem: when connecting a QAbstractButton
to a slot that has a default parameter, the semantics of the connection
change between string-based connections and PMF.
Specifically: when connecting the
QAbstractButton::clicked(bool checked = false)
signal to a slot like
View::zoomIn(int level = 1)
then a string-based connection like
connect(button, SIGNAL(clicked()), this, SLOT(zoomIn()))
would call zoomIn without carrying the signal's parameter over.
In other words, zoomIn's parameter is defaulted. The same connection
using PFM instead is
connect(button, &QAbstractButton::clicked,
this, &View::zoomIn)
which would "connect" the arguments. This makes emissions that pass
false as clicked's parameter result in a zoomIn by 0.
Fix it by avoiding the default parameter of zoomIn -- just split
the function in two (zoomIn and zoomInBy).
Amends 8cf8122314.
Pick-to: 5.15 6.2 6.3
Fixes: QTBUG-100135
Done-with: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Change-Id: I10c150c648034449e3154140108de2d64326d965
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This adds significant run-time overhead and should not be on by default.
Pick-to: 6.3
Change-Id: I33d312e31bd714f696d8acf2066eb4b285ff04af
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
This little change fixes the build on CentOS 7
Pick-to: 6.3
Change-Id: Ic9717147c10ca78e36d6311944de417c6420211d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
QDateTime represents a specific point in time, so arithmetic
with durations makes perfect sense.
Moreover, we can finally equip QDateTime with a subtraction
operator, to calculate the duration between two QDateTime
objects.
[ChangeLog][QtCore][QDateTime] QDateTime now supports arithmetic
between QDateTime objects and std::chrono::duration objects.
A duration can be added to or subtracted from a QDateTime, yielding
another QDateTime; and two QDateTime objects can be subtracted
from each other, yielding the duration between them.
Change-Id: I656419f3bb9418c49f0e2fd0800c3dbaaf6aff32
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Use our usual if_x<> = true pattern to move the constraint to where it
belongs (absent C++20 requires-clauses): into the template argument
list.
Amends a00a1d8806.
Change-Id: I846b96bdeec3def221346897181d3d4d3a55316d
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
Clazy complained that the class has a dtor, but no copy ctor.
Pick-to: 6.3
Change-Id: Ida4024df1ff22c7758b8efa6e9383e03734720a8
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
QXmlStreamPrivateTagStack holds the string data in a single large
QString, which, on 64-bit platforms, can hold more than INT_MAX
characters' worth of data. However, the code managing this QString
still used int variables instead of qsizetype, making failure for such
large tag string data all but inevitable, even though I didn't go to
the length of actually constructing a failing test case.
Fix by using qsizetype instead of int where required.
Fixes: QTBUG-102467
Pick-to: 6.3 6.2
Change-Id: I50b7e194e43f3c7dce69c6e1fd4682fc517dd7d6
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
The XmlStringRef(const QString*) ctor calls the (const QString *, int,
int) ctor, passing QString::length() as the third argument. If the
input QString had more than 2 Gi characters, the resulting
XmlStringRef represents only the prefix of the input (mod
(INT_MAX+1)).
Fix by making the delegatee ctor use qsizetype instead of int,
allowing to pass data through without truncation.
[ChangeLog][QtCore][QXmlStreamReader] Fixed several bugs regarding
handling of documents larger than 2Gi characters on 64-bit platforms.
Pick-to: 6.3 6.2
Fixes: QTBUG-102466
Change-Id: Ie48274190ac359f62d3ec3d8fe60eb43cc2c362a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
A time_zone represents a timezone identified by its IANA ID. This
allows for a straightforward conversion to QTimeZone.
[ChangeLog][QtCore][QTimeZone] QTimeZone can now be constructed
from a std::chrono::time_zone pointer.
Change-Id: I093d9fc2e989475d30730a9dcdef491903a2aeb2
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
The code in the Q_TRACE_ENABLED case was doing the same sort of
qobject_cast that is done in the fileName() accessor; so it's both a
code deduplication and an optimization to get the filename into a
local variable once, and use it both for tracing and for the
@Nx suffix check below.
Task-number: QTBUG-100578
Change-Id: Id7bde4ddbab38e20694c09cc7b412fec091672de
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
No need to assert, returning when the window is already added or not
removed is enough.
Pick-to: 6.2 6.3
Fixes: QTBUG-100173
Change-Id: Id491f17612ce42c4e26e9d41ad38f0a6372775bd
Reviewed-by: Andreas Buhr <andreas.buhr@qt.io>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Make ~EventCallback() not clear properties belonging to
other EventCallback instances.
This fixes File::stream(), which creates a new EventCallback
before deleting the old one when updating the callback
function.
Pick-to: 6.3
Change-Id: Ib5f78ccc4158d94e8d3f5b9ebb9979c123b1966a
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
To make sure we don't end up use a dangling pointer for m_focusObject.
Pick-to: 6.2 6.3 5.15
Task-number: QTBUG-102447
Change-Id: I75058040be109a39f830bc706efe85969ffbc8ec
Reviewed-by: Andreas Buhr <andreas.buhr@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Required for porting away from QLatin1Char/QLatin1String in scope of
QTBUG-98434.
Change-Id: I48e2946c4cc8d0a6c3e0cc37e1f73510b878d574
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
When generating .pc files there is a warning when executing
QtFinishPkgConfigFile.cmake:
Ignoring empty string ("") provided on the command line.
This happens because the 'postfix' argument is a part of the script
command line even if it's empty. It also makes no sense to check if
'postfix' is empty using genex, use configuring-time check instead.
Pick-to: 6.2 6.3
Change-Id: If52d9634f4885caefb828976b3c99592a6db3d3c
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Previously there was a mixture of buf.constData() and buf.data() with
buf not being const QByteArray. As a result, buf.data() returned a
re-allocated buffer and texData was keeping pointers to that one, which
became invalid once the function returned and the re-allocated buffer
was cleaned up by destructor.
Change buf to const QByteArray so that there is no difference between
data() and constData(). Additionally convert all constData() calls to
data() to avoid confusion.
Detected by Address Sanitizer on testcase
tst_qtexturefilereader::checkMetadata()
Pick-to: 6.3 6.2
Change-Id: Idb6f6141898678bf95ed9233a92b7bb3ad12e250
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
These particular testcases request huge buffers from malloc() .This is
intentional and the test expects malloc() to return NULL. Address
sanitizer catches this and considers it a problem.
Could also be skipped in runtime by setting the environment variable:
ASAN_OPTIONS=allocator_may_return_null=1
Task-number: QTBUG-89400
Change-Id: Id3a9b586be9c0bad4a007e1731f2bc1a879cc76e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
The TLS v1.0 and v1.1 enums are all deprecated since 6.3. At the same
time, the test requires their use, because none of the peers seeem to
implement TLS v1.2, yet (cf. e.g. QTQAINFRA-4499).
Fix by copying the relevant enum values into global variables and
using those. This is a selective way to deal with the issue. The use
of the enums is so widespread in the test that the alternative would
have been to globally suppress deprecation warnings, which, however,
may suppress warnings we may actually want to fix.
Pick-to: 6.3
Change-Id: I4186be72209527fc404f3ba0a5a15f9719c64698
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
The Q(Basic)Mutex fast paths are entirely inline in the caller, which
means we need to annotate its operations directly or TSAN doesn't know
what's going on. Also annotate QRecursiveMutex.
The tryLock code could be in principle simplified via a QScopeGuard
but I didn't want to make a central class like QMutex depend on it.
[ChangeLog][QtCore][QMutex] QMutex now has annotations for
ThreadSanitizer.
Change-Id: Ibb130404e63a5ec9bcef9675f9addd16a2c38b7f
Reviewed-by: David Faure <david.faure@kdab.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
MSVC will export any function in an exported class, including inline
ones. Conversely: client code calling inline functions in imported
classes will end up simply calling the symbol of the function, even if
the function is fully inline.
This is a problem for adding post-C++17 APIs in Qt. Such APIs are added
as inline functions protected by feature-macro tests, so that both Qt
and client apps can use any C++ version they want (any combination
works).
However, if we add a function using post-C++17 API to an exported class,
then the combination "Qt built in C++17" + "client built in post-C++17"
won't work any more. The client will expect the symbol for that function
to be exported by Qt, but Qt won't have it (built in C++17).
As a workaround, add a marker that turns these functions into "faux
templates", like Q_WEAK_OVERLOAD does.
Change-Id: I2adab81e3129c881c5a8e0772948b176fa4db1b6
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
There is no need to limit the type to QOffscreenSurface here, QRhi does
not depend on the behavior in QOffscreenSurface. Users can use the
custom offscreen QSurface types if needed.
Task-number: QTBUG-102257
Change-Id: I47a064496f8c5f1986a0e11ec748ea32a03b903e
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Request 16 bit floating point backbuffers and set the color space
of the CAMetalLayer to kCGColorSpaceExtendedLinearSRGB if we set
up the swap chain to use extended SRGB.
Unfortunately the required CAMetalLayer.wantsExtendedDynamicRangeContent
property is not yet available on iOS, so for now this is a macOS
only feature.
Change-Id: I28ab12cc0b829eded721061da2679be8e31d6b9d
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Required for porting away from QLatin1Char/QLatin1String in scope of
QTBUG-98434.
Change-Id: Ibe32a11699f67df2aa80505ba2944f33e5e823e0
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Ensure that it's safe to call readAllStandardError()
when process channel mode is set to MergedChannels.
Pick-to: 6.3 6.3.0
Task-number: QTBUG-102177
Task-number: QTCREATORBUG-27196
Change-Id: I01073255d9347dee4654d602802a12d341372b73
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
There is no use case for QProxyStyle to forward events to its base
style. QApplication does not send events to it; a style using e.g.
timers or so will have them active on *itself*, not on the proxy.
Moreover, forwarding *all* events is broken: QTBUG-96213 has been
triggered by forwarding DeferredDelete events sent to the proxy (thus
accidentally deleting the base style). But one can concoct many other
similarly broken situations; for instance, setting a proxy onto a base
style will make the style a child of the proxy. That sends a
QChildEvent to the proxy (ChildAdded), and that event is then passed on
the base style, resulting in the base style receiving an event saying
"you have yourself as a child".
Change-Id: I3b92bb168ce3c54a32469c36b6d1da4380ed564f
Reviewed-by: Rafael Roquetto <rafael.roquetto@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
because the old xcb_randr_monitor_info_t was invalid very often
during update.
Pick-to: 6.3
Change-Id: I8c0bda93bde4e816fc98cde1a7205c6369ab39e1
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
tst_qmltc_examples failed because m_accessibilityContext
could become a dangling pointer if the object in points to gets
deleted. This resulted in a crash.
Amends e0c61193ea.
Task-number: QTBUG-101865
Task-number: QTBUG-95764
Pick-to: 6.3 6.2 5.15
Change-Id: Ie85118429b1afa6e4a41f899ca065f493e166570
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Jarkko Koivikko <jarkko.koivikko@code-q.fi>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
When PCRE2 is compiled using cmake, a pcre2 cmake file is installed
and Qt fails to configure because components isn't specified for
find_package.
In recent PCRE2 releases components needs to be specified for
find_package.
Fixes: QTBUG-102358
Pick-to: 6.2 6.3
Change-Id: Ib842b2c4b1c0bf38aa5da5475eaa2b3c56c6b822
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
The QBoolBlocker would end up using a stale d-pointer if the window
was deleted during delivery of the close event.
Fixes: QTBUG-102327
Pick-to: 6.3 6.2
Change-Id: I8f458581eeabf0d0f27a348ad1f926295caa3a58
Reviewed-by: Dimitrios Apostolou <jimis@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
getDisplayName() now returns QString instead of QJniObject. It's more
clear and allows to save some QJniObject::toString() calls in other
parts of code.
Pick-to: 6.3 6.2
Change-Id: I0f2061cf1dff21c09c2272bf1e9126ff1ea0ed3e
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Before the patch we tried to create a java Locale object by passing the
human-readable language, territory and variant strings. However, the
Locale constructor accepts ISO-defined codes.
Fix it by using a factory method Locale.forLanguageTag() [0] that
constructs a Java Locale object based on BCP 47 tag.
[0]: https://developer.android.com/reference/java/util/Locale#forLanguageTag(java.lang.String)
Fixes: QTBUG-101460
Pick-to: 6.3 6.2 5.15
Change-Id: If414c66cf0e5b7e8299ffc3a6038b6f9eb79d5ec
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
When the date-time string falls in a spring-forward (so is invalid)
and one of the fields of the parsed string doesn't match the format
it's meant to (e.g. a single-digit seconds field when format ss was
specified), a check that the current fall-back date-time is between
the minimum and maximum for the parser object failed, triggering an
assertion.
In any case, an invalid default-value wasn't useful to the code that
parsed a single section of the date-time string, so brute-force the
current value to a valid date-time (when possible) using the usual
round-trip via milliseconds since the epoch.
Added the test-case which first revealed the problem, plus a couple
more informed by it, to exercise the same code-paths with fewer things
failing.
Fixes: QTBUG-102199
Pick-to: 6.3 6.2 5.15
Change-Id: I658308614505ef25f4c97d0de6148acb54a65a0f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>