Add Uint8Array::copyFrom() and Blob::copyFrom(), which
constructs JS data containers with content copied from
the C heap.
These should not be confused with e.g. the Uint8Array(buffer, size)
constructor, which creates a Uint8Array which references
content on the heap, without making a copy.
Change-Id: Id7d25d8044ee3914d74698e5a15c93226568eaf3
Reviewed-by: David Skoland <david.skoland@qt.io>
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
Like Q_NAMESPACE_EXPORT for Q_NAMESPACE, this variant of Q_GADGET
allows passing an export macro. This is useful to avoid exporting the
whole class just to get the staticMetaObject hidden therein exported.
Before anyone asks: No, we don't need Q_OBJECT_EXPORT, because QObject
subclasses, being polymorphic, always need to have a class-level
export macro (to export their vtable), but while that technique also
works for value classes (the Q_GADGET audience), it is not desirable
for them, because it makes inline functions exported in Windows debug
builds, which is not what we want, because it needlessly restricts
what you can to with the inline functions (e.g. remove).
[ChangeLog][QtCore] Added the Q_GADGET_EXPORT macro, which is like
Q_GADGET, but allows passing an export macro (like Q_NAMESPACE_EXPORT
for Q_NAMESPACE).
Fixes: QTBUG-55458
Change-Id: I546297de1e8aa45d83381991bcd3fbca61e1eef0
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
It is not immediately clear from the signature that the time parameter's
unit is miliseconds.
Pick-to: 6.2
Change-Id: Ifee3c6410b6b2352e75571cc53578a660aabb32d
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This time exercising series of buffer updates and texture uploads
within proper, on-screen frames. (particularly interesting for dynamic
buffers in case the double (or more) buffering and having multiple
frames in flight involves special bookkeeping for these - using
'offscreen' frames like in other test cases does not necessarily
exercise all of this)
Change-Id: Id470919d27037359a1f0346a50a2a0e3966f5cd2
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
QXmlDocumentLocator was introduced, so that QDomBuilder can work with
both QXmlStreamReader and QXmlInputSource. It had two subclasses -
QDomDocumentLocator and QSAXDocumentLocator, to allow getting line and
column numbers while parsing, depending on the implementation.
QSAXDocumentLocator was removed when removing SAX-based implementation
(79e0374143), and now it doesn't make
sense to keep QXmlDocumentLocator/QDomDocumentLocator, we can get line
and column numbers form QXmlStreamReader directly.
Change-Id: I75f4a776472ee31ddc3685a999f356be9bf47ac5
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Setting up the baseline tests, creating an appearance identifier,
and basic image-grabbing functionality doesn't need to be reinvented
for each test case that wants to use baseline testing of widget UIs.
As a drive-by, remove unneeded Qt 5 meta tags from .pri file.
Change-Id: I1562e1b377946305cac018e0f0f0175c2c07cd31
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
Also fix an unrelated minor issue in QtFuture::whenAll docs.
Task-number: QTBUG-86714
Change-Id: I45f06b17db0508be10215e6d260ef76ede3077fb
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
The declaration of insert(it, n, t) used qsizetype for n, while the
definition used size_type. That works by chance, because the size_type
typedef comes only after the insert(it, n, t) declaration. It was
detected when size_type became a typedef in a base class of
QVarLengthArray in my local branch.
Just use the same type name in the implementation as in the
declaration.
In 5.15, the same issue exists (with s/qsizetype/int/).
Pick-to: 6.2 5.15
Change-Id: I64235eeaeaed3d43f4c070ca536474fae94c1b5d
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
In qt6_android_add_apk_target we require that ${target} is already
defined. So to add custom command that runs androiddeployqt we may
simply read BINARY_DIR property of the target and use it as path to
generated apk file as OUTPUT argument. This avoids the use any
intermediate paths when producing apk and related artifacts.
Change-Id: I8bb4174f6f9696e7a2a6b5d6399bb410419495fc
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
When building for and running the '_check' target in Android we need
to make sure that target apk is assembled and ready for deployment.
Pick-to: 6.2
Change-Id: Ifc63aac230f0bb8375d319ec443174c5a436485e
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
De-unroll the loop over the "interesting" keyword ignore comments by
using the existing array of their names. Replace magic numbers by
strlen() calls. Use local starts_with() instead of strncmp() when
comparing with fixed-size constant string literals, to avoid repeating
the fixed string's lengths for the third argument of strncmp().
Task-number: QTBUG-55458
Change-Id: If458aced382948fb719d984702857fb2171c87ee
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Results on my machine (only forever results):
********* Start testing of tst_QWaitCondition *********
Config: Using QtTest library 6.3.0, Qt 6.3.0 (x86_64-little_endian-lp64 shared (dynamic) release build; by GCC 11.2.1 20211115), ubuntu 20.04
PASS : tst_QWaitCondition::oscillate_QWaitCondition_QMutex(forever)
RESULT : tst_QWaitCondition::oscillate_QWaitCondition_QMutex():"forever":
637 msecs per iteration (total: 637, iterations: 1)
PASS : tst_QWaitCondition::oscillate_QWaitCondition_QReadWriteLock(forever)
RESULT : tst_QWaitCondition::oscillate_QWaitCondition_QReadWriteLock():"forever":
909 msecs per iteration (total: 909, iterations: 1)
PASS : tst_QWaitCondition::oscillate_std_condition_variable_std_mutex(forever)
RESULT : tst_QWaitCondition::oscillate_std_condition_variable_std_mutex():"forever":
331 msecs per iteration (total: 331, iterations: 1)
PASS : tst_QWaitCondition::oscillate_std_condition_variable_any_QMutex(forever)
RESULT : tst_QWaitCondition::oscillate_std_condition_variable_any_QMutex():"forever":
627 msecs per iteration (total: 627, iterations: 1)
PASS : tst_QWaitCondition::oscillate_std_condition_variable_any_QReadWriteLock(forever)
RESULT : tst_QWaitCondition::oscillate_std_condition_variable_any_QReadWriteLock():"forever":
913 msecs per iteration (total: 913, iterations: 1)
~331 vs. ~630ms. A pretty significant win (2x).
Mårten noticed that on Windows, condition_variable::wait_for(x, 0ms)
will not unlock the mutex, which, however, the program requires, so
use a 1ns timeout instead.
Drive-by fixes:
- add override to run() reimplementations
- fix type of timeout member variable (was int, should be unsigned long)
- fix naming of test functions to distinguish better between QMutex
and std::mutex
Change-Id: Ib92310f15fbd58258b2043504642be5f0b860f39
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Also sync with latest version at https://www.gnu.org/licenses
Change-Id: Ia7cf90e68212969d017c8875ef306fba4db7df76
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
QAbstractProxyModel::itemData/setItemData should behave
just like data()/setData() instead of calling the
QAbstractItemModel implementation.
Before this change the QAbstractProxyModel implementation
calls its the QAbstractItemModel implementation,
which ends up calling data()/setData() in a loop
bypassing the convenience of itemData/setItemData.
[ChangeLog][QtCore][QAbstractProxyModel] The itemData()
and setItemData() functions will now call the respective
implementations in the source model (after mapping the
index to a source index), matching what data() and
setData() already did.
Before, the proxy model simply called the default
implementations of itemData()/setItemData() in its own
base class (QAbstractItemModel).
Change-Id: I9e680d355f44fa130660dd7e1c8ac37484c1566e
Reviewed-by: David Faure <david.faure@kdab.com>
A previous patch already introduced calling the correct
variant of drawIndexedPrimitives, but it was not done
for drawPrimitives.
When base vertex and instance is not supported (e.g. on the iOS
simulator), it does not mean that the value cannot be other than
0, but rather that the version of the function taking this
arguments must not be called at all, otherwise a Metal failure
occurs. The docs and logic is all in place, just add it to
draw() as well.
Amends 213755a866 which fixed this
for indexed draw calls. Now we also prevent aborting Qt Quick
applications that trigger non-indexed draw calls.
Change-Id: Icb4313ffd2d3a77a73f7b5f49d7ce63c935254d3
Pick-to: 6.2
Task-number: QTBUG-95795
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
When there is a context with a surface current, keep on using
that whenever ensureContext() is called without specifying a
QWindow.
Consider the following sequence:
<component A>
beginOffscreenFrame
render to texture 1
endOffscreenFrame
<component B>
beginOffscreenFrame
render to texture 2
endOffscreenFrame
<component C>
beginFrame (with swapchain)
render something using texture 1 and 2
endFrame
repeat all over again, continuously
(in practice this is what a top level widget with QOpenGLWidgets
and/or QQuickWidgets in it would lead to with the QRhi migration
in place)
Besides being more readable, the new version recognizes that resource
and offscreen operations do not need one specific surface (like the
one QOffscreenSurface every GL backend of QRhi has), but are functional
with any surface (or with surfaceless even) as long as the context is
correct. Thus with the above example we can work with only ever making
the one QWindow current.
Change-Id: I633071cae88f02e1d45e445ee55c8a58f9ec5a8c
Pick-to: 6.2
Fixes: QTBUG-96405
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Introduce a TRY_EXPECT macro that uses qWaitFor, and use it whenever
EXPECT was used after a call to processEvents.
Fixes: QTBUG-94036
Pick-to: 6.2 5.15
Change-Id: Ia935444d529c2798637bf9b4a56e47a8dc9d75d2
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
QXcbKeyboard only deals with core_device_id. With the reporter's test
case: using xdotool to send a string, the deviceID is not changed,
then we assume xkb_state_new() is more stable(or correct) than
xkb_x11_state_new_from_device() in this case.
See also https://www.x.org/releases/current/doc/man/man3/xcb_xkb_new_keyboard_notify_event_t.3.xhtml .
Fixes: QTBUG-95933
Pick-to: 6.2 5.15
Change-Id: Ic595e1f1424fbc6814871a85ac159907f1aeb12a
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Zhang Hao <zhanghao@uniontech.com>
Reviewed-by: Liang Qi <liang.qi@qt.io>
This function is useful also outside of local file access,
for example when reading clipboard (file) content.
Change-Id: I132546deb6df2969467051c348c05d9331d2cfd2
Reviewed-by: David Skoland <david.skoland@qt.io>
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
Extract Method QTest::qCaught() to take the string handling out of the
header. This should help a bit in speeding up compilation of large
unit test files (provided they use QVERIFY_THROWS_EXCEPTION), although
I have no data to support that.
Since we changed the error message, update the selftest accordingly.
Change-Id: Id4a3c8c34d5df8d0c7a861106d269097f4a6de5c
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Large address aware is enabled by default in 64-bit
compilers, but not 32-bit compilers. But Qt users
may build 32-bit Qt themself, in this case large
address aware is disabled in fact, and it may cause
some issues. So we pass /LARGEADDRESSAWARE to the
linker unconditionally to make sure large address
aware is enabled for both 32-bit and 64-bit builds.
Microsoft Docs:
https://docs.microsoft.com/en-us/cpp/build/reference/largeaddressaware-handle-large-addresses?view=msvc-170
Change-Id: Idb2603d9ba0ba9ef4477ce1c3174b7c7e8ba76f6
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Amends 2b2e7b2ac5, which rewrote the
rendering to remove the conflation of menu arrows and arrow icons, but
introduced double rendering of the arrow icons if only the border was
styled.
Add a baseline test for style sheets, with a test function for
QToolButton configured in various ways and styled with different style
sheets.
The new test case includes a Qt 5 build system so that we can compare Qt
5.15 with Qt 6.
Fixes: QTBUG-98286
Pick-to: 6.2 6.2.2
Change-Id: I09cdc829c1a7e7913df4c3768dbe44b6dba4778b
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
This solves the long-standing problem of not being able to easily
fail a test when a certain warning is output.
[ChangeLog][QtTest] Added QTest::failOnWarning. When called in a test
function, any warning that matches the given pattern will cause a test
failure. The test will continue execution when a failure is added.
All patterns are cleared at the end of each test function.
Fixes: QTBUG-70029
Change-Id: I5763f8d4acf1cee8178be43a503619fbfb0f4f36
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Use variable args macros to swallow any extra commas in the
expression. To use this, the type of the exception has to be first.
Use Eddy's suggestion for a new name to avoid breaking the old macro.
[ChangeLog][QtTest] Added QVERIFY_THROWS_EXCEPTION, replacing
QVERIFY_EXCEPTION_THROWN, which has therefore been deprecated.
Change-Id: I16825c35bae0631c5fad5a9a3ace4d6edc067f83
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Use new QDir::mkdir() method to set directory permissions at the time
of its creation on systems that support this feature. This removes the
time window when the created directory is potentially accessible to
everybody.
Task-number: QTBUG-79750
Change-Id: I82afee7f0708bfdcc9b3b3978af9a2aef1b8672d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This patch adds an overload of the QDir::mkdir() method that
accepts permissions. This allows setting of the directory
permissions at the time of its creation.
[ChangeLog][QtCore][QDir] Added QDir::mdkir() overload that
accepts permissions argument.
Task-number: QTBUG-79750
Change-Id: Ic9db723b94ff0d2da6e0b819ac2e5d1f9a4e2049
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Q(Multi)Map mutating functions that take reference to a key and/or a
value (e.g. insert(), take(), etc.) must make sure that those references
are still valid -- that is, that the referred objects are still alive --
after the detach() call done inside those functions.
In fact, if the key/value are references into *this, one must take extra
steps in order to preserve them across the detach().
Consider the scenario where one has two shallow copies of QMap, each
accessed by a different thread, and each thread calls a mutating
function on its copy, using a reference into the map (e.g.
map.take(map.firstKey())). Let's call the shared payload of this QMap
SP, with its refcount of 2; it's important to note that the argument
(call it A) passed to the mutating function belongs to SP.
Each thread may then find the reference count to be different than 1 and
therefore do a detach() from inside the mutating function. Then this
could happen:
Thread 1: Thread 2:
detach() detach()
SP refcount != 1 => true SP refcount != 1 => true
deep copy from SP deep copy from SP
ref() the new copy ref() the new copy
SP.deref() => 1 => don't dealloc SP
set the new copy as payload
SP.deref() => 0 => dealloc SP
set the new copy as payload
use A to access the new copy use A to access the new copy
The order of ref()/deref() SP and the new copy in each thread doesn't
really matter here. What really matters is that SP has been destroyed
and that means A is a danging reference.
Fix this by keeping SP alive in the mutating functions before doing a
detach(). This can simply be realized by taking a local copy of the map
from within such functions.
remove() doesn't suffer from this because its implementation doesn't do
a bare detach() but something slightly smarter.
Change-Id: Iad974a1ad1bd5ee5d1e9378ae90947bef737b6bb
Pick-to: 6.2
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
tst_QDate::startOfDay_endOfDay_data() naively assumed some zones would
exist. They don't on QNX, apparently.
Change-Id: I3a364964d03f59f5869b4b7639f089dd303180b1
Reviewed-by: Andreas Buhr <andreas.buhr@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
I was briefly confused about why an Etc/GMT+3 test was using GMT as
localtime. Fortunately I worked it out before mis-"correcting" it.
Change-Id: I7b0473c7d3974ef186e1170cf4999aca52aaaf45
Reviewed-by: Andreas Buhr <andreas.buhr@qt.io>
On QNX, tst_QDateTime::fromStringStringFormat_localTimeZone_data()
failed to set up any rows for the data-driven tests to fetch, leading
to an assertion failure on trying to fetch a row.
Change-Id: I7c405b1142a8cb6d445b501ea44fe3d440570cf3
Reviewed-by: Andreas Buhr <andreas.buhr@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Prevents QML app using QtActivity never calling
AndroidJniMain::startQt..'s to jam as ANR
Pick-to: 6.2 5.15
Task-number: QTBUG-97115
Change-Id: Ibfe8579dbb701068f4896b6d826ff487094bdf56
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
The old code attempted to detect the overflow of the requestCode
variable, but because it didn't do anything about it except warn, it
still ran into the overflow, and, since the variable is signed, into
UB. That means that a clever compiler will just eliminate the warning
as dead code because it can backtrack and see that the condition
guarding it is never true, because otherwise UB happens.
Fix that problem by using a uint counter (unsigned overflow is defined
to wrap) and only convert to int after the check.
Also fix two inefficiencies with the old code:
1. We don't need a mutex just to up a counter in a thread-safe
way. Upping a shared counter is the prototypical use-case for
relaxed atomics, so use that. That also solves the problem of the
non-POD static object at function scope (QMutex) that forced
compilers to emit thread-safe static initialization code.
2. We had a static variable whose initial value isn't 0, which means
it can't be in stored in the BSS, but only in the DATA segment. Do
the trivial transformation of subtracting the offset so the
variable starts at 0. The offset can be added afterwards.
Pick-to: 6.2
Change-Id: I3560df21d6b4e4201cb6772237780cc8b400631d
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Swallowing unknown exceptions is dangerous business, as the exception
might be a pthread cancellation token, the swallowing of which would
terminate the program.
Instead of returning from the catch-all-clause, therefore, re-throw
the unknown exception.
Fix tst_verifyexceptionthrown failure cases that use
non-std::exception-derived true negative exceptions to not let the
exception escape from the test function.
As a drive-by, pretty up the macro's docs.
[ChangeLog][QtTest][QVERIFY_EXCEPTION_THROWN] Now re-throws unknown
exceptions (= not derived from std::exception) (was: swallowed them
and returned from the test function), in order to play nice with
pthread cancellation.
Pick-to: 6.2 5.15
Change-Id: Ic036d4a9ed4b7683fa67e27af8bcbae0eefdd0da
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Bic tests do not work due to bic tests being broken.
A feature enables easier testing of the bic tests.
Change-Id: I15b400ee8f0f877ac2c6c71fc50d51c5e11b330d
(cherry picked from commit 31910cbc09ff219b332aac94afe78c99d34274b3)
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
The command-pair was recently deprecated.
The replacement code should produce an output that is equal to the
previous one.
Task-number: QTBUG-98499
Change-Id: If26e0d85a174ebc3858b638c34d7f43637eab46d
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
The compiler runs out of memory and fails to compile tst_qmetatype.cpp.
Set TST_QMETATYPE_BROKEN_COMPILER from a previous compiler workaround
for QNX to disable the most expensive part of the test.
Task-number: QTQAINFRA-4669
Change-Id: I3a99b6b790dc074e9d1db262e758555fb45e4331
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
If we detach from a shared hash while holding a reference to a key from
said shared hash then there is no guarantee for how long the reference
is valid (given a multi-thread environment).
Pick-to: 6.2
Change-Id: Ifb610753d24faca63e2c0eb8836c78d55a229001
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Which is anything other than MD5
Pick-to: 6.2 5.15
Fixes: QTBUG-98280
Change-Id: Ifbf143f233ee5602fed1594e3316e6b2adec1461
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Merge in various minor changes and fixes that have been done to the
branched copy in qtquick3d, and clean out some outdated code.
Mostly just coding style fixes and cleanups, but also:
- adds -keeprunning command line parameter, intended for tests that by
default exits early if it seems the platform is too unstable
(e.g. crashing) for a meaningful testrun.
- Changes behaviour for fuzzy matches, from SKIP to PASS. The (mis)use
of QSKIP was done to force log output; now the output is just
printed by qInfo() instead.
Pick-to: 6.2
Change-Id: I46e77a94cc5b1980ac420086c2ae88dc9b84ef12
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Use a local enum to enumerate the different "interesting" keywords.
Task-number: QTBUG-55458
Change-Id: I30a6336072d3184b720d8c016f199572dba87a81
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
When qmake and CMake build were both available next to each other, we
answered QMAKE_FOO=bar assignments in the CMake build with an error
message. This code is never triggered these days and can be removed.
Change-Id: Ifd29283b8ddc86b94c4e6cbce9e9252215e9f2fe
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>