After the recent changes we only have a single implementation of
QSlotObjectBase, which can handle free functions, member functions,
functors, and lambdas. Rename it to callable, and explicitly hide
the static implementation function so that it doesn't become a symbol
of static libraries using Qt.
Also rename makeSlotObject to makeCallableObject, and polish coding
style and comments in the qobjectdefs_impl header a bit.
Change-Id: Id19107cedfe9c624f807cd8089beb80e9eb99f50
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Header field names are always considered to be case-insensitive.
Pick-to: 6.5 6.5.1 6.2 5.15
Fixes: QTBUG-113392
Change-Id: Ifb4def4bb7f2ac070416cdc76581a769f1e52b43
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
According to the Freedesktop spec[1], a mimetype that has glob-deleteall
overwrites other glob-pattern definitions for a mimetype if it is in a
higher precedence dir, the default order is (from high to low)
~/.local/share/mime, /usr/local/share/mime, /usr/share/mime. Or if the
XDG_DATA_DIRS env var is set, then it takes precedence. The
QMime*ProviderS in m_providers are constructed/stored in that same
order, high to low).
For QMimeXMLProvider, we can just clear the glob patterns associated
with those mimetypes from the lists/maps. For the QMimeBinaryProvider
however, we can't change the binary (mmap'ed) cache file, instead check
mimetype names against the exclusion list before modifying a
QMimeGlobMatchResult.
[1] https://specifications.freedesktop.org/shared-mime-info-spec/latest/ar01s02.html
This test uses XDG_DATA_DIRS so only viable when USE_XDG_DATA_DIRS is
defined.
Fixes: QTBUG-101755
Pick-to: 6.5
Change-Id: Icadbdf1027155296377c5a6ab3be8e41b6668325
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: David Faure <david.faure@kdab.com>
[ChangeLog][QtCore][QDebug] Added pretty formatting of C++ <chrono>
durations.
[ChangeLog][QtTest] Added pretty formatting of C++ <chrono> durations
for QCOMPARE expressions.
Change-Id: I3b169860d8bd41e9be6bfffd1757cc087ba957fa
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Since we don't have different environment variables for the plugin paths,
users have to set QT_PLUGIN_PATH to where plugins for both Qt 5 and 6
(and future versions) are located. This causes Qt to print warnings that
those couldn't be loaded because the major version mismatches. So don't
print them any more.
QT_DEBUG_PLUGINS and the category logging filter can still be used to
enable them.
Fixes: QTBUG-107459
Pick-to: 6.5
Change-Id: Idd5e1bb52be047d7b4fffffd175318ca1f8017bd
Reviewed-by: Lars Knoll <lars@knoll.priv.no>
Add helper that allows us to determine the argument list and return type
of a functor. This triggers a compile time error if the functor has
operator()() overloads (we only support zero-argument call operators, but
there might be const/noexcept variations). Use that helper to declare a
ZeroArgFunctor type which also declares a ReturnType and Arguments alias.
Add a Callable alias that now combines FunctionPointer and ZeroArgFunctor
into a single type that we can then use to merge the specializations of
QMetaObject::invokeMethod.
[ChangeLog][Potentially source-incompatible changes] Using a functor
with several operator() overloads in QMetaObject::invokeMethod now causes
a compile time error. Qt would previously ignore const and noexcept
overloads and always call the mutable version on a copy of the functor.
Change-Id: I3eb62c1128014b729575540deab615469290daeb
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
As this is a strong indication that Qt was also built in debug.
Otherwise the test will fail locally for a debug build.
Pick-to: 6.5
Change-Id: I5f494017f1d89f4076ccaca89aaa67738ef405a9
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Preparation for debugging failures in the 6.2 branch
Pick-to: 6.5 6.2
Task-number: QTBUG-112892
Change-Id: Ib6428fb86be834c84be361a848c0f1306bfc2637
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
QTableWidgetItem uses additional enum flag ItemIsHeaderItem which has
the same numerical value as ItemFlag ItemNeverHasChildren.
This causes conflict since the user can set the latter flag using
the setFlags, while the ItemIsHeaderItem is only used internally
to mark header items.
Remove the additional flag and use boolean instead to fix the conflict.
Pick-to: 6.2 6.5 6.5.1
Fixes: QTBUG-113209
Change-Id: Icff549c7e452d9f84575a524361719204817274e
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Amends ca15f650a1, after which scrolling
right to fill any gap might have resulted in overshooting to a negative
scrollOffset.
When we scroll right to fit the current tab, then we never want to end
up with a negative scroll, so clamp the result accordingly.
Augment test case accordingly. Since some styles align the tab bar in
the center, replace the calculation of the scroll offset with access to
the private data member (which inverts the sign when compared to the
calculated value).
Task-number: QTBUG-113140
Fixes: QTBUG-113376
Pick-to: 6.5 6.5.1
Change-Id: Ibdc6686b9dbd41b1ae3560e2227fa121d9b20e18
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
The removed testdata is no longer valid because their entries were
removed from the list.
Fixes: QTBUG-113339
Pick-to: 6.5 6.5.1
Change-Id: I34bd56394ab3c0ef2f930d5b21c3fe1089262dbd
Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
If there is an effect on the selected item we want to show it,
but if there is no item to highligh we just close the combo.
Fixes: QTBUG-113311
Pick-to: 6.5
Change-Id: I287af75d27e6f6ff969e4706e16cc8c4812129ea
Reviewed-by: Thorbjørn Lund Martsum <tmartsum@gmail.com>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
It fails locally for me on Lucida Calligraphy.
Lucida Calligraphy only has one style though: Italic.
Change-Id: I42442cb922132a00f09084cef9c739196a9a53c2
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
We never copy the function so only need it to movable. Moves the
functions to templates using the new QRunnable create version.
[ChangeLog][QtCore][QThreadPool] Methods taking callable functions,
can now take move-only lambdas.
Fixes: QTBUG-112302
Change-Id: I2cb200f0abcf7e0fdbef0457fe2a6176764ad93d
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
It turns out glibc stops varying DST changes past where a 32-bit
signed day-count from 1970 reaches (which, all things considered, can
hardly be called a bug, for all that it's ...), at odds with QTZ's
extrapolations from the current IANA DB rules. As the last date QDT
can represent happens to be in the opposite side of everyone's DST
from the one that leaves zones in, this lead to the 2038
local-time-type not reliably being useful for predicting the max-date
behavior. So add a distant-future time-type that probes beyond glibc's
cut-off, and have relevant tests check that instead of the 2038 one.
Change-Id: If4e244d80fe2447da3bb9d5c406808c6c22c0a73
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
There's no need to check the year or day-of-month (which involve
calendrical calculations) when we can perfectly well just check the
Julian Day number that's implied by the day-number parameters to
setType(), which could just as well return the LocalTimeType to be
assigned to the relevant parameter instead of doing the setting
itself. With that rearrangement, making it into a private static
method, the members it's used to initialize can then be const and
initialized during construction.
Change-Id: Ib7d295c3fbb9b90652952627456cdfb6176b8119
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
It's a private static used to optimize internal use, so we can freely
get rid of its out parameter this way.
Change-Id: Id62612987f10ecbbd9702610fd172286adbfd442
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
The test is accessing an out of bounds index into an array on purpose.
Change-Id: I23cce4093fdfabd177eb34639f26fcd6752c8b34
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Amends 642f799fc6 to avoid unnecessary
copies in between the calls to the QFunctorSlotObject construcotr. We
can't use a univeral reference in the QFunctorSlotObject constructor
as the call is not deduced. So provide two overloads for lvalue and
rvalue references instead.
The compile check in the test now no longer fails as we delay the
storage until one level later, but that's acceptable.
Change-Id: Ide95b4a73c70f6f47698dd1e95138aa5d48ee95d
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Remove duplicate test and outdated comment about move-only functors,
and include return value in move-only functor test.
Change-Id: I58dffe0ccf3ec12e7e05e2c9588303da4a7e75ff
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Making them static constexpr class constants is tidier than
duplicating them in diverse tests.
Change-Id: I5a24c10d6db6f946581fa0523d28bdc80358e95e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
The second pass through each test case, going via UTC, applied an
adjustment to the time; however QTime wraps around modulo the day, so
applying a negative adjustment to a time too near the start of the day
could produce a time at the end of the day. I'm preparing to add some
test-case variants for which the transition's UTC date differs from
the date in the zone doing it, which trigger this. Combine the time
with the date before applying the adjustment, so that the date gets
decremented to match the time's wrap-around and conversion from UTC
duly gets back to the correct place, not a day later. The new test
cases (in an imminent commit) thus pass.
Change-Id: I1bd5f191c7673a56ac3fbfc69eab0bc03c9e40b3
Reviewed-by: Mate Barany <mate.barany@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
It seems glibc's extrapolation of existing DST-rules cuts off at some
point in the distant future, where the IANA DB gives no end-time for
such rules, leading QTimeZone to keep applying them. This lead to
tst_QDateTime::fromSecsSinceEpoch() not getting an invalid date in one
of its bounds-probing tests, due to a within-bounds datetime getting
glibc's offset and then the out-of-bounds one falling back to the IANA
rule's offset that put it back within the bounds.
This directly affected Australasian zones (which glibc locks into
daylight-saving time in this distant future) which were fixed by using
the IANA DB's offset; but the relevant date is in August so other
zones, north of the equator, that glibc locks into standard time, then
had the reverse problem, so we have to take the minimum of the two
sources' offsets to get all zones on board.
Change-Id: I0c94af2ba108dea31bee46aafa4a8cca8d373a5c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io>
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Check that the private pointer is not null before attempting
to dereference it. This can happen, for example, when
a QDBusServer instance was constructed with an empty string
as address. Attempting to destroy an object constructed
this way was causing a segmentation fault on Linux.
Add a test case that attempts to construct a QDBusServer
object with an empty string as address to check that this
does not cause a segmentation fault anymore.
Pick-to: 6.5 6.2
Change-Id: I5fe63134026e2a9f509b61d452285891b1ec624d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
The native style may not match the program style and it
makes sense to give an option rather than forcing native style.
Before it could only be done with setting AA_DontUseNativeDialogs
on the app, but it is reasonable to use native file dialogs and
Qt styled messageboxes - and it is extremely cumbersome - especially
since messageboxes often can start save dialogs.
It can look a bit strange that these introduced options has just one
option (DontUseNativeDialog) and four functions, but this way it works
similar to QColorDialog, QFileDialog and QFontDialog.
[ChangeLog][QWidgets][QMessageBox] Added options functionality to
QMessagebox. The currently only option available is DontUseNativeDialog.
Change-Id: I70282fcfaa66f245f7e679b8897c607bcaff333f
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Amend 3c6e9dcc623c9d7281a81174bb3a696e030f30a7 by making sure that
we explicitly move move-only functors into the slot object in the
respective tests, and that failing to do so doesn't compile.
Also add test coverage for mutable lambdas, which work as they do
with connected functors: the connection stores a copy, and calls
don't modify the original functor.
Change-Id: I637e6f407133e2f8f72109b3fe5369a11d19da93
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This reverts commit 9958edba41, which
incorrectly tested a move-only functor without actually moving the
functor.
Change-Id: I3707f9f8e5055102f7edfb3e1cb9750978356dd7
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
- Add missing includes
- Use std::all_of, that also fixes a narrowing conversion warning
(qsizetype).
Change-Id: I0f7f4b91bda4c187b8f8094e3039079c43fbf478
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
[ChangeLog][QtCore] Introduced Q_NODISCARD_CTOR which resolves to
[[nodiscard]] attribute for constructors on compilers that support
it, and does nothing on other compilers.
Using [[nodiscard]] attribute on a constructor is a C++20 feature,
however in practice it is supported on most of the compilers that
we use in Qt 6. Clang generates a [-Wunused-value] warning, GCC
and MinGW generate a [-Wunused-result] warnings, and MSVC
generates a C4834 warning.
However, there are some exceptions.
The Integrity compiler provides the following warning:
"tst_qglobal.cpp", line 699: warning #3435-D:
the "nodiscard" attribute doesn't apply to constructors,
destructors, or routines with void return type
[[nodiscard]] explicit Test(int val) : m_val(val) {}
The QNX compiler (QCC 8.3.0) and GCC 9.3.1 on OpenSUSE generate
the [-Wattributes] warning:
tst_qglobal.cpp: In member function
'void tst_QGlobal::nodiscardConstructor()':
tst_qglobal.cpp:699:44: warning: 'nodiscard' attribute applied to
'tst_QGlobal::nodiscardConstructor()::Test::Test(int)' with void
return type [-Wattributes]
[[nodiscard]] explicit Test(int val) : m_val(val) {}
These warnings will lead to build failures when compiled with
-warnings-are-errors flag, so for these compilers the macro
does not do anything.
An attempt to use __attribute__((__warn_unused_result__)) was
also unsuccessful on these compilers, so this patch goes for
an easy solution, and simply checks
__has_cpp_attribute(nodiscard) >= 201907L
to decide if the attribute is supported or not.
This commit also introduces a syntax-only test, and also applies
the new macro to QMutexLocker, because not all platforms in the
CI build and run unit tests.
Fixes: QTBUG-104161
Change-Id: Ib4230661a5ad5e8af0d67b21b034486ebcd67562
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
QWeakPointer can do the same, so there's no reason to not allow it for
QPointer.
[ChangeLog][QtCore][QPointer] QPointer<T> can now be (move- and
copy-)constructed from QPointer<X>.
Fixes: QTBUG-112464
Change-Id: I77cf5d39974bf2b3ec849b4afc33e286e864821e
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Now the tst_qstring is compiled three times:
- with QT_NO_CAST_FROM_ASCII defined
- with QT_RESTRICTED_CAST_FROM_ASCII defined
- with neither of the above defined
so as to cover more code paths.
Pick-to: 6.5
Task-number: QTBUG-109228
Change-Id: I65eca0f6f6aea66fed6eeda1eb77a50a97210807
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This follows up on commit b906796af6.
Fix an off-by-one error - I was testing the last days of December 1799
and June 1800.
Change-Id: I79ab622978d35f91e3e1b1b8d00d93b0d4b31c07
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Use static constexpr int values instead of abusing enum.
[ChangeLog][QtCore][QTimeZone] The MinUtcOffsetSecs and
MaxUtcOffsetSecs constants are now static constexpr members of
QTimeZone, rather than members of an anonymous enum. Their values are
now 16 hours either side of zero, to allow for some historical zones.
Change-Id: I1c3a0f85a2b83b5010f021ca0f5ca5baefbf32e4
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io>
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
In Qt >= 6.1, < 6.5, a trivially constructible type would have the
NeedsDestruction flag set, but it's dtor pointer would have been null.
In Qt 6.5, the meaning of the NeedsDestruction flag was changed to be
more aligned with what the name suggests, and thus would only be set for
non-trivially destructible types. For QMetaType this was fine, but
QVariant has a check for acceptable metatypes which attempts to verify
whether a QMetaType is usable for QVariant. The check assumes the
semantics of Qt 6.5, and thus fails for metatypes created by older Qt
versions.
To fix this issue, we increment the QMetaType revision field, and only
check the metatype's destruction support if the revision is high enough.
In theory, that allows passing unsuitable metatypes from older Qt
versions to QVariant; however, such code would have been broken in prior
Qt releases already (which didn't attempt the check), and no code that
used to work in any released Qt version will break (as we simply skip a
check that was passing before).
Fixes: QTBUG-113227
Pick-to: 6.5
Change-Id: I12e02bd97d2c410ea1a36efb0ce2389f21d50a30
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Amends 207aae5560 to make it easy to
create human-friendly error messages. Since the functor-accepting member
functions are not removed from the API, the first compile error will be
that there is no suitable overload of the makeSlotObject helper, which.
With the assert helper, the first error message is easier to understand.
Change-Id: I4878ec35a44ddfa5dc9d9e358d81c3fd40389c0c
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Move-only functors must never be passed by value, so fix the
QFunctorSlotObject constructor accordingly.
This then requires adjustments to the various QMetaMethod::invokeMethod
overloads, as those must also perfectly forwad the functor type.
Enable the previously failing test case for move-only functors.
Change-Id: I9c544fd3ddbc5e1da3ca193236291a9f83d86211
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Amend 207aae5560, as code checker
complained that we std::move'd a potential lvalue. This warning was
valid if the public API did not accept the functor parameter by value.
Fix this by consistently std::forward'ing the parameters through the
call stack, and add a compile-time test. Writing that test revealed that
the helper API didn't work with free functions, so fix that as well. It
also revealed that QFunctorSlotObject couldn't work with a const
functor, which is also fixed by this change.
We cannot support move-only functors with that change, as it requires
a change to QFunctorSlotObject that breaks the QMetaObject test.
Change-Id: Iafd747baf4cb0213ecedb391ed46b4595388182b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Exercise the validity of update batches, i.e. that one can
safely commit it in later frames as well, as long as all
related buffers and textures stay valid.
Change-Id: Ia943e4b37141fe17253eeae32010e0f8d92c1583
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Christian Strømme <christian.stromme@qt.io>
This avoids constructing an object just to copy (later: move) it into a
QVariant.
ChangeLog will be in a follow-up change adding emplace support.
Task-number: QTBUG-112187
Change-Id: I444e580c7d8927d41b3d21d5a521e7c475119e4c
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Functions in Qt that take a callback need to support callables with or
without context objects, and member functions of an object. The
implementation of those overloads follows a pattern that ultimately
results in a QSlotObjectBase implementation being created and
passed to an implementation helper that takes care of the logic.
Factor that common pattern into a new helper template in QtPrivate
that returns a suitable QSlotObjectBase after checking that the
functor is compatible with the specified argument types.
Use that new helper template in the implementation of
QCoreApplication::requestPermission and QHostInfo::lookupHost.
The only disadvantage of centralizing this logic is that we cannot print
a more detailed error message indicating which argument types the
caller expects. However, that information is visible from the detailed
compiler errors anyway.
Change-Id: I24cf0b2442217857b96ffc4d2d6c997c4fae34e0
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Add the move ctor and move operator for QSqlField
Task-number: QTBUG-109938
Change-Id: Ib66eff76c3a920de9cfb3288f4219555005e7ae5
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
QTabBar lays out the tabs when the bar's size or content changes,
often lazily. This should not change the scroll offset of the tabbar,
which is controlled by the user, or at most when a tab needs to be made
visible (e.g. when it becomes the current tab).
Move the logic of updating the scoll offset into the makeVisible
function, so that the scroll is only adjusted to either leave no gap
between the last tab and the right edge of the widget of there is still
a scroll; or to reset it to 0 if there is enough space for the entire
tab bar. Since layoutTabs does show and hide the scroll buttons, we
cannot skip this when the buttons are invisible. However, the
normalizedScrollRect helper now needs to return the entire widget rect
if there are no visible scroll buttons.
Add a test case that simulates the previously broken behavior where
the scroll got unnecessarily reset to 0 when resizing.
Fixes: QTBUG-113140
Pick-to: 6.5
Change-Id: Ic19fbb82821ea09cc5e7646dcbce3aa7607909c2
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
These classes depend only on Core, not Gui.
This allows dropping the dependency of tst_qxmlstream and tst_qzip on
QtGui, and prevents a tst_qxmlstream FTBFS when building with
QT_NO_TEXTODFWRITER.
Symbols move from QtGui to QtCore, but the classes are private API, so
not under BC constraints.
The classes are not used outside qtbase, so no other in-tree users
need porting.
Task-number: QTBUG-3897
Change-Id: Ifa148f43ec139d7f9ac1f3893e2fcf4640e3c60c
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
The expected states are:
- nothing sets theMainThread before main()
- theMainThread is reset when the last QObject (the QCoreApplication in
the test) is destroyed
The GUI version of this test appears to leak a lot of QObjects. By the
time this function runs, theMainThread's QThreadData still has a
refcount of 66 on Linux/XCB. The Windows non-GUI version also
failed. Neither situation was investigated to see why objects are
getting leaked.
Pick-to: 6.5
Change-Id: Idd5e1bb52be047d7b4fffffd17507d9e6ef08743
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>