qsnprintf() does not make a difference between lvalue and rvalue
arguments, so the wrapper doesn't need to perfectly forward.
Use decay-copy via by-value arguments to potentially reduce the number
of instantiations required for the existing calls.
Adjust indentation so the continuation line doesn't need to be
re-indented when we'll port qsnprintf() to std::snprintf().
Amends 0e8eb20af4.
Pick-to: 6.7 6.5
Change-Id: Idcaa441517fdbf00fefd952db7928731779123ab
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit fba67959acb7be39942aa3ce829f6764c46ad3ee)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
qsnprint() is unconditionally called to fill the buffer and is
guaranteed to NUL-terminate, so there's no point in filling the whole
stack buffer with NULs beforehand. Leave it uninitialized.
The code was moved in 4ae6f40b3a, so not
picking further than that.
Change-Id: I34d456ebd2990aa242ccc42693adbbf1f64148de
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 4c5b437a3ce84354dfa3bf2c4706e05144ac03a3)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
qsnprint() is unconditionally called to fill the buffer and is
guaranteed to NUL-terminate, so there's no point in filling the whole
1KiB stack buffer with NULs beforehand. Leave it uninitialized.
Amends 930e59b798.
Pick-to: 6.7 6.5 6.2
Change-Id: I7da859d609ad4492c9038cb3e14f2a721b2acbe4
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
(cherry picked from commit 47c2263e896408e733c9aa466aec388cc4b4a6ad)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Document cycle_p.h's provenance - thanks to Morten Sørvig for digging
that up - and update to its version in the most recent release of
FFTW. Include patches to apply (after purging dangling hspace) for
future updates.
[ChangeLog][Third-Party Code] QtTest's benchlib now uses FFTW
v3.3.10's version of the clock-cycle counter, Cycle.
Task-number: QTBUG-126080
Change-Id: Ib59bc53e5d74cfdc889c03e78f9dd72100168f64
Reviewed-by: Jason McDonald <macadder1@gmail.com>
(cherry picked from commit 6e7c158152cef6a1ae6a628f08661fcc4b27de90)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Nothing hugely consequential, although __VALGRIND_MINOR__ was
previously out of step with the version given in qt_attribution.json.
[ChangeLog][Third-Party Code] Updated QtTest's Valgrind headers to
version 3.23.
Fixes: QTBUG-126080
Change-Id: Ie2c9d41d4f35cd497b1dcf9a366cf4b319b361ad
Reviewed-by: Jason McDonald <macadder1@gmail.com>
(cherry picked from commit efab6e69831c7fc8d35f18e211bda20f854f2f39)
Reviewed-by: Kai Köhne <kai.koehne@qt.io>
Our use of the clock-cycle counter from FFTW involved a rename of its
type ticks to our type CycleCounterTicks. This unnaturally bulks up
the diff from upstream, so undo it and use a simple #define to achieve
the same effect, as seen by our code.
Task-number: QTBUG-126080
Change-Id: Icbe9c413b73dd9213b95f183b71585f4a9c38de1
Reviewed-by: Kai Köhne <kai.koehne@qt.io>
(cherry picked from commit ed7becd9cba582640f19704b5c439e5f6807bc29)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Move from tests/auto/testlib/selftests/ to
src/testlib/3rdparty/cache2/, so that its path includes a 3rdparty
component and it's isolated from the rest of the selftest files.
Instead, it's now grouped with QtTest's other 3rdparty components, to
make it easier, when doing a 3rdparty update, to see what might need
an update.
In the process, document where in the upstream to find the file to be
copied, if an update is needed. The file is generated, so document its
generator, too, in case its output gets renamed. There is no more
recent release than the 2.13.10 we currently have, so no update will
follow.
Task-number: QTBUG-126080
Change-Id: I371bac233b00318f59d6043fb245ab44b914bf8a
Reviewed-by: Jason McDonald <macadder1@gmail.com>
(cherry picked from commit 31adb73e289d1bd93276af2b1df9bc356ba14766)
In the process, update the Linux perf_event.h provenance details to
make it possible to find the latest version. Also, remove 3rdparty
headers from the module's CMakeLists.txt (where possible) so that
anything that includes them makes its 3rdparty dependence visible in
the relative path. That can't be applied to cycle_p.h, though, as it's
used by the tests.
Task-number: QTBUG-126080
Change-Id: I3a7099bc123ba7188ad096714cb7ed45ff35a392
Reviewed-by: Jason McDonald <macadder1@gmail.com>
(cherry picked from commit b14906884c63b3f5f239d7d008eb23aba66836fa)
QBenchmarkEvent::nativeEventFilter() was changed with Qt6 but the old
Qt5 version was still there and no longer used.
Pick-to: 6.7 6.5
Change-Id: Ia740ce0dc743666c9b3bcbe12d1d310fb9ffcd7b
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit ef215fdd8bd36c0312d657e0aafaa766d7c297f7)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Better name given the value names, as discussed during header review.
Keep AnnouncementPriority as an alias until dependencies are updated.
Change-Id: I7b60c429fb60fc30378a9560da12abb87499225f
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
(cherry picked from commit bb305e63ff856a8c6f9649a27a5eabfb31df8aa7)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
The behavior that argument was enabling is the default one now.
Task-number: QTBUG-90492
Change-Id: I11711d4c794f0b22169abb595b8ffad2eeb1300d
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
(cherry picked from commit 1ef3bd05eb45d53cdcf92b933603b995283b3432)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This enables doing QtGui testing when using QAbstractItemModelTester
in Qt for Python, where the QTestlib binding only links against
QtCore.
Port the code to check against QMetaType constructed from type names.
Task-number: PYSIDE-2772
Change-Id: Ifcd8f1ea4758459d8a178226e3f215e5c2b273b8
Reviewed-by: hjk <hjk@qt.io>
(cherry picked from commit bb542a55b28dd591709ed2c68e4505ec08fc62b5)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
A standalone comment added before a test case or keyword will
be confusing once more test cases and keywords are added, as
the comment likely doesn't apply to those added lines.
Change-Id: I4e36c1c2ae4547bcffa9df817cd53c64cf66defb
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
(cherry picked from commit 2f939540c7a7dac262dd61210351cbd24545ee83)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Returning the wrong data type for Qt::SizeHintRole may lead to a size
of 0,0 and the item disappearing.
Task-number: PYSIDE-2772
Change-Id: I906445f2ed2141da2606774f2b8ad6282662eb17
Reviewed-by: hjk <hjk@qt.io>
(cherry picked from commit 84f2cd6523081ed8774b2a9fe9ee36d05172ff50)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Right now vxworks is not on the list of keywords used to blacklist
tests.
Because of that, it's not possible to blacklist a test specifically on
that platform.
Solve the problem by extending the list.
Pick-to: 6.7
Task-number: QTBUG-115777
Change-Id: I04d55eabc27f7554ea9e3fa030ff118a22a624b6
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 8f9b0891f59dbc59d1295bf8eff361070bd01a9d)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Makes sense to collect the stuff in a similarly-named header, and it's
not like any of the QTypeTraits stuff was needed for QTypeInfo.
Makes #include <qtypeinfo.h> _much_ lighter again, at the expense of
qminmax.h now getting <variant>, <tuple> and <optional> instead, but
qminmax.h is much easier to avoid in Qt headers (just use the std
versions) than qtypeinfo.h.
[ChangeLog][QtCore][Potentially Source-Incompatible Changes] The
qtypeinfo.h header no longer transitively includes <optional>, <tuple>
and <variant>.
Task-number: QTBUG-97601
Change-Id: Ied96113f38c1232fef3ec79847ee62f06c68f268
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit b2eb422699118f4ae8370519b4c7bb3fe121beb2)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
It seems like all subclasses of QAccessibleEvent need to be registered
here, otherwise tests explode.
Change-Id: I924961f351bda1f50e2c73d54abe4b51162dc82a
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
This requires some fixes in several classes that are also included
in this patch.
The QTestEvent hierarchy is all-inline and changes layout depending on
QT_GUI_LIB and QT_WIDGETS_LIB, so we can't just export it. Suppress the
warning in that header for now. Created QTBUG-104486 to track a fix for
the real issue.
The QFutureInterface hierarchy is also all-inline, but templates, so
doesn't trigger, except the <void> specialization. Created
QTBUG-125115 to track a fix for the real issue.
Done-with: Marc Mutz <marc.mutz@qt.io>
Task-number: QTBUG-45582
Change-Id: I96b3e109aa989b70e0d4809b90bd53a369e50d55
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Previously, the sig member was used to indicate successful
construction of the QSignalSpy (incl. successful connection to the
monitored signal), so it was set only after all other initialization
had taken place, preventing it from being marked as const, which would
indicate that accesses to it need not be protected by the mutex.
Now that we have it, we can instead use the d_ptr's value to indicate
success, and mark sig const.
[ChangeLog][QtTest][Important Behavior Changes][QSignalSpy] The
signal() method no longer necessarily returns an empty byte array when
the connection failed. Use the existing isValid() method to determine
whether a given QSignalSpy object listens to a valid signal on a valid
object.
Change-Id: Ia08fe3b383681f3f203cf1a121c0e1ce08ad268b
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: David Faure <david.faure@kdab.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Now that the private ctor that calls this function is finally
out-of-line, this function need no longer be part of the ABI.
Task-number: QTBUG-123544
Change-Id: Ia4656bf8bfd4d68d6925f93ef150593cd2de6ddf
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Many users (albeit mostly in qtdeclarative) of failOnWarning() are
passing a catch-all regexp, which is only supported when regular
expression support is enabled. Make their lives easier and those
checks independent of the feature by adding a third overload, taking
no parameter, that fails on any (unanticipated) warning.
Implementation is trivial - just put a null QVariant in
failOnWarningList; it won't match either check on the entry that might
exempt a test from failing on a warning, so any warning at all will
trigger failure.
[ChangeLog][QtTest] QTest::failOnWarning() now has a no-parameter
overload to support the common case of fail-on-any-warning, without
needing to construct a match-everything regular expression.
Change-Id: Ic693f1c8619fd6e495543b85737d566134cf9d20
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
There used to be an examples page; this is no longer the case. Thus,
remove the \note that indicates you can access the source code.
Fixes: QTBUG-122166
Pick-to: 6.7 6.6 6.5
Change-Id: I1abe88000ae406e8d2cc9cc1deed42664607626b
Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
Normally, we'd fix -Wweak-vtable by exporting the class and making at
least one virtual method out-of-line (typically the dtor), thereby
pinning the vtable to exactly one TU.
We can't export QSignalSpy, though, because it also inherits QList,
and we don't want to export QList subclasses to avoid QList API
becoming part of the ABI.
So remove the vtable, and therefore its being a weak symbol, by moving
the qt_metacall implementation from QSignalSpy into its newly-added
Private, at the cost of an additional memory allocation at
construction (though there was already the wish to make this class
pimpl'ed for extensibility, and this patch accomplishes exactly that).
This class used to be one of few places left that prevents adding
-Wweak-vtable to headersclean, so while this is a breaking change,
QSignalSpy doesn't really model is-a QObject. It uses QObject to
reuse, not to be reused. In fact, no external code should use the
QObject-ness of QSignalSpy, so it should be an acceptable SC break to
drop the inheritance.
We don't need to care about BC here, as we don't promise BC for
QtTest.
This now also allows (and requires) to make the dtor and the private
ctor out-of-line, avoiding the need for the init() hack.
[ChangeLog][QtTest][Potentially Source-Incompatible Changes]
QSignalSpy no longer inherits from QObject. If your code uses the fact
that QSignalSpy is-a QObject, you need to redesign around this now.
Task-number: QTBUG-45582
Fixes: QTBUG-123544
Change-Id: Id93ba0ee6bbb811455d3744a045e38e1b9f9c584
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Jason McDonald <macadder1@gmail.com>
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
There's no need to condition that comparison only for heterogeneous
types. The reverse comparisons will compile if the types are homogeneous
(it's what we had already tested), but this now ensures the results are
also the expected ones.
Change-Id: If1bf59ecbe014b569ba1fffd17c4a2dd756157b2
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Using templates to make the code look nicer and be more debuggable.
Previously, if you tried to step into the QCOMPARE_xx, you'd have the
creations of qxp::function_ref from the lambdas before you got to the
actual comparison. And all of this was in-place from macro expansion, so
you couldn't tell what was happening.
Now, if you step into QCOMPARE_xx, you go to qCompareOp. There are 5
frames between that point and the actual comparison (four std::forward()
and the Compare::compare()) and debuggers could step over std::forward.
Even if they can't, both libstdc++ and libc++ implementations are simple
casts, so there's nothing more to step into.
Change-Id: I12a088d1ae424825abd3fffd171dbbf7adb7e7e2
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
[ChangeLog][QtTest] The QCOMPARE_xx macros can now only find
QTest::toString() expansions that are either found via Argument
Dependent Lookup on the type in question or are an instatiation of the
QTest::toString<T>() template. This matches the behavior of the
QCOMPARE() macro.
This changes the way how the toString() overloads are selected, so
we need to explicilty constraint the main QTest::toString() template
in order to pick the free functions when they exist.
Change-Id: Ie28eadac333c4bcd8c08fffd17c54e768c5cffd0
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
This is causing huge code bloat because everything is a local lambda.
Instead, pass direct type-erased function and data pointers to the
replacement function. Testing with tst_qcborvalue, this reduces the
compilation time and the output binary size significantly:
Before After
Compiler Time Size Time Size
GCC 13.2 136.99 s 202.3 MB 13.88 s 14.3 MB
GCC 14.0 131.49 s 202.7 MB 14.69 s 14.4 MB
Clang 17 77.2 s 146.7 MB 13.62 s 12.2 MB
Clang 18 141.9 s 187.1 MB 13.62 s 12.4 MB
This causes a difference in how toString() overloads are
found. Previously it would match far more overloads because the
toString() calls were expanded by the macro. Now, we depend on
Argument-Dependent Lookup and associated namespaces, so toString()
overloads should not be in the QTest namespace any more.
With this patch applied, the testlib testcase of tst_selftest
started failing, because nullptr is now handled differently.
However, I consider it as a bugfix, because previously it was
falling back to a default implementation, and now it is using
the QTest::toString(std::nullptr_t) overload, which is a
desired behavior. Update the reference files for tst_selftest
with the new expected output.
Task-number: QTBUG-124272
Change-Id: Ie28eadac333c4bcd8c08fffd17c5484186accdf6
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
It was split between qtest.h and qtestcase.h, so the QTest::toString()
specializations were not available in qtestcase.h. And it was confusing.
Change-Id: Ie28eadac333c4bcd8c08fffd17c54fafc8014cc7
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
QtTest is not under the same Binary Compatibility guarantees as the
other modules, but let's try and do it where it's easy.
The toString() method can simply be removed from the header because it's
not a member function. Its deprecation wasn't marked with a version
number, so it starts now with 6.8.
Change-Id: Ie28eadac333c4bcd8c08fffd17c54faca7057b9c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
When 7bff20c9f5 renamed the file from
.qdoc to .cpp, it failed to adjust the license header from GFDL
(documentation license) to the QtTest default.
Copy the license from qsignalspy.h, whence the code originally came
from.
Task-number: QTBUG-121787
Change-Id: I969ddc2b92882107581bbd514a28af7337e0fb9a
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Following the verify() Extract Method refactorings, this function has
only one caller left, so it doesn't pull its weight anymore.
Task-number: QTBUG-123544
Change-Id: I93a296a9be81ef9c3b702065e76ecc4b822a0a43
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
... by moving its body into an out-of-line init() function.
This allows to drop the exporting of connectToSignal().
We can't de-inline the whole ctor (yet), because that would pin the
vtable to the qsignalspy.cpp TU, which would require us to export the
class wholesale to make the vtable accessible to users of the class,
but we can't export the class because it inherits QList.
Task-number: QTBUG-123544
Change-Id: Ieffd6d2f542daa20e876c6114cb5dc8150870bb4
Reviewed-by: David Faure <david.faure@kdab.com>
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
This means it's implicitly thread-safe now and we don't need to
protect accesses to it with the mutex.
Task-number: QTBUG-123544
Change-Id: I9f826003dca6fb81e7a75e283482c81ecff09be0
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
... because they can be.
As a drive-by, fix clazy-function-args-by-value by taking QMetaMethod
by value.
Task-number: QTBUG-123544
Change-Id: Icdad68b91850d284c918e6180f3ce841de2af016
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
First store the result in a temporary, and, in the critical section,
only move it into place. This minimizes the amount of code in the
critical section (Amdahl's Law) and also means we don't need to
permanently drop the mutex when we call unbounded code using
metacall(). That, in turn, makes sure the args member is only ever
seen empty or fully populated.
Since makeArgs() no longer accesses member functions now, we can make
it static.
Task-number: QTBUG-123544
Change-Id: If19db53f85d7c9eb18d4fb2c61e1aa3d4b9c2e00
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: David Faure <david.faure@kdab.com>
... instead of working directly on the member variable.
This is in preparation of making said member variable const, so it
need no longer be protected by the mutex.
Task-number: QTBUG-123544
Change-Id: Ifc407502ec2c5c52dc3b42edea18be7fc672a968
Reviewed-by: David Faure <david.faure@kdab.com>
Because we can now that there's a .cpp file.
Task-number: QTBUG-123544
Change-Id: Ie525e157016cb3c0c7a273fba3fadb13d54c1877
Reviewed-by: David Faure <david.faure@kdab.com>
Now that we're moving the code anyway, also move their declarations
into the general private: section of the class.
Task-number: QTBUG-123544
Change-Id: I6b1e7006b73b710daa4b511b2fd643293a3d4844
Reviewed-by: David Faure <david.faure@kdab.com>
Reduces the code a compiler including qsignalspy.h needs to parse and
codegen.
The order of the functions in the .cpp file is chosen to minimize the
diffs to follow-up changes.
We can't de-inline the private ctor, because that would pin the vtable
to the qsignalspy.cpp TU, which would require us to export the class
wholesale to make the vtable accessible to users of the class, but we
can't export the class because it inherits QList.
Task-number: QTBUG-123544
Change-Id: Ib26fdb68e1fc0e6f6919e4cd25759b7047f9977c
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
... because they can be. We call them without a value object and while
they don't touch *this, ubsan complained (rightfully):
qsignalspy.h:29:28: runtime error: member call on address 0x7ffdfaab2b20 which does not point to an object of type 'QSignalSpy'
0x7ffdfaab2b20: note: object has invalid vptr
00 00 00 00 00 00 00 00 00 00 00 00 00 2b 00 00 c0 60 00 00 60 14 00 00 60 60 00 00 70 14 00 00
^~~~~~~~~~~~~~~~~~~~~~~
invalid vptr
Amends e68edd6a07.
Task-number: QTBUG-123544
Change-Id: I8e9ba3270a35777a704e68130d2f2bccb658a536
Reviewed-by: David Faure <david.faure@kdab.com>
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Qt already runs on Vision Pro as "Designed for iPad", using Qt
for iOS. This change enables building Qt for visionOS directly,
which opens the door to visionOS specific APIs and use-cases
such as volumes and immersive spaces.
The platform removes some APIs we depend on, notably UIScreen,
so some code paths have been disabled or mocked to get something
up and running.
As our current window management approach on UIKit platforms
depends on UIWindow and UIScreen there is currently no way to
bring up QWindows. This will improve once we refactor our
window management to use window scenes.
To configure for visionOS, pass -platform macx-visionos-clang,
and optionally add -sdk xrsimulator to build for the simulator.
Change-Id: I4eda55fc3fd06e12d30a188928487cf68940ee07
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Having already caught some bugs in real code because of unchecked calls
to QFile::open, this commit marks QFile::open (and open() in other
file-I/O classes) as [[nodiscard]].
Since it's going to raise warnings, the plan is to keep the existing
behavior up to and including the next LTS. Then the warnings will switch
on by default. All of this is protected by system of macros to opt-in or
opt-out the behavioral change at any time.
A possible counter-argument for doing this is that QFile::open is also
used for opening files in the the resource system, and that opening
"cannot fail". It clearly can, if the resource is moved away or renamed;
code should at a minimum use a Q_ASSERT in debug builds. Another
counter-argument is the opening of file handles or descriptors; but
again, that opening may fail in case the handle has been closed or if
the flags are incompatible.
---
Why not marking *every* open() override? Because some are not meant to
be called directly -- for instance sockets are supposed to be open via
calls to `connectToHost` or similar.
One notable exception is QIODevice::open() itself. Although rarely
called directly by user code (which just calls open() on a specific
subclass, which likely has an override), it may be called:
1) By code that just takes a `QIODevice *` and does something with it.
That code is arguably more rare than code using QFile directly.
Still, being "generic" code, they have an extra responsibility when
making sure to handle a possible opening failure.
2) By QIODevice subclasses, which are even more rare. However, they
usually ignore the return from QIODevice::open() as it's
unconditionally true. (QIODevice::open() doesn't use the protected
virtual pattern.)
I'll try and tackle QIODevice in a future commit.
[ChangeLog][QtCore][QFileDevice] The open() functions of file-related
I/O classes (such as QFile, QSaveFile, QTemporaryFile) can now be marked
with the "nodiscard" attribute, in order to prevent a category of bugs
where the return value of open() is not checked and the file is then
used. In order to avoid warnings in existing code, the marking can be
opted in or out, by defining QT_USE_NODISCARD_FILE_OPEN or the
QT_NO_USE_NODISCARD_FILE_OPEN macros. By default, Qt will automatically
enable nodiscard on these functions starting from Qt 6.10.
Change-Id: Ied940e1c0a37344f5200b2c51b05cd1afcb2557d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Rename qsignalspy.qdoc to .cpp, include qsignalspy.h and add the
namespace macros.
Task-number: QTBUG-123544
Change-Id: Ibd89844018afc277e6a69e7200cdbd08befd4da2
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
As discussed in QTQAINFRA-6146, there were two potential approaches to
enabling backtraces in Qt Quick tests:
- Either via a thorough refactoring of quicktest.cpp so that each
testcase is a Slot in a programmatically-created QObject-derived class,
which will be executed via QTest::qExec() similar to the documented
QTest way. This way the pre-existing code in QTest::qRun() will setup
the fatal signal handler.
- Or as a quick fix, modify quick_test_main_with_setup() to setup a
FatalSignalHandler class and invoke prepareStackTrace() like it's
already done in QTest::qRun(). This would require exporting these
symbols in the private header.
This patch enables the implementation of the latter, as it has a
fairly light footprint, is easily revertable (should we need to),
and allows us to immediately gain insight into crashes in CI.
Task-number: QTQAINFRA-6146
Change-Id: Iedffc968acb3e570214df34884ab0afcb6b30850
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>