Commit Graph

39793 Commits

Author SHA1 Message Date
Edward Welbourne
064c3d35e6 Don't allocate an OCIDateTime object unless we're going to use it
The QOCIDateTime destructor carefully checks that dateTime is non-null
before tidying it away, but the constructor allocated it independently
of whether it was used, leaving it in a still-not-constructed state if
the date-time it was to represent was invalid.

Only allocate if the date-time is valid; and check against null when
an OCIDateTime is being converted back to QDateTime. Add warnings if
either allocation or construction fails. Incidentally use
static_cast<> instead of C-casting (and split a long line) in the
other place that allocates an OCIDateTime descriptor.

Pick-to: 6.2 5.15
Task-number: QTBUG-98471
Change-Id: Idd5531d9f7101878802cb9a3a016d3fd80903543
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-11-30 16:34:01 +01:00
Alexey Edelev
bcac7d9433 Use config-specific suffix of android deployment settings for multi-config only
QtCreator doesn't expect any config-specific suffixes in the android
deployment settings file, when running androiddeployqt. This avoids
adding the config-specific suffix in the single-config builds and
for the first config in the multi-config builds.

Amends a41d9bcac9

Change-Id: I606509c9bfd2e75cac144aca37b4568639aae74f
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-11-30 16:32:10 +01:00
Janne Juntunen
2bfa4b9960 QNX: check and use elf.h from alternative location
In QNX, instead of #include <elf.h>, we have to use #include <sys/elf.h>
since that file is placed in a subdirectory.

Also removed the previous workaround.

Fixes: QTBUG-97833
Change-Id: Id932a5eeb618a42c8778459cdfd8bb5bf903523c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-11-30 14:37:52 +02:00
Edward Welbourne
b9f7add531 Verify returns from QXmlTestLogger's xmlQuote() and xmlCdata()
Using partially-converted text would lead to invalid XML, so don't use
the buffer contents if the return is zero. As a result,
QTestJUnitStreamer::formatEnd() needs to return some indication of
whether *it* succeeded, so change it to forward their int returns;
and, as it's in fact only used internally by the streamer, make it
private.

Make these functions [[nodiscard]] so that further uses of them will
be discouraged from ignoring the possibility of failure. Make the
public versions return bool so that they can correctly succeed on
empty input. Assert various conditions we can infer to save work we
don't need to do.

Change-Id: I899bad23d1dfbd05fc725de269def4ce213dbc5a
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-11-30 12:26:08 +01:00
Marc Mutz
0265b923ac QVarLengthArray: simplify copy ctor implementation
std::tie(a, s, ptr) = {Prealloc, 0, (T*)array} is exactly the effects
of the default ctor, so just delegate to it, before calling
copyAppend().

Also clean up the copy ctor declaration (superfluous inline keyword,
and template arguments).

Change-Id: Iefc758a47996382fee10b1e081e44f008b146287
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-11-30 06:38:40 +01:00
Thiago Macieira
6855b80eae QList::count(T): remove the &* hack on iterators
Use data() and data() + size() instead.

This solves an UB when the list is in its default-constructed state,
for which constData() == nullptr.

Pick-to: 6.2
Fixes: QTBUG-98770
Change-Id: I2cffe62afda945079b63fffd16bc165978c769f6
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2021-11-30 01:42:50 +00:00
Tor Arne Vestbø
60d9509cb0 Teach QOpenGLTextureBlitter about GL_TEXTURE_RECTANGLE textures
Change-Id: Ie577bda046f60ce23dfb8cdd6164bb3de4b54358
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2021-11-30 02:36:29 +01:00
Lorn Potter
0fa98a26fd wasm: add Blob and File type
Convenience getters for mime type associated with the object.

Change-Id: I7e3530459e50ac4740d533db59c46e838c94dbcd
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2021-11-30 09:06:54 +10:00
Marc Mutz
be84b033dc QRegularExpression: don't detach() a pattern QStringLiteral
... just to pass it to pcre2_compile_16().

The QString::utf16() function guarantees a NUL-terminated result, so
it detach()es from QStringLiteral (Qt 6) and/or QString::fromRawData()
(Qt 5 + 6).

This user doesn't require the NUL-termination, though, since
pcre2_compile_16() takes an explicit length, so the detach() is
completely unneccesary, yet common, since regex pattern strings are
often QStringLiteral()s.

Task-number: QTBUG-98763
Change-Id: I1d08ae1a1ec4281ff44a68c5ba5c56584b71d24e
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2021-11-30 00:04:38 +01:00
Mårten Nordheim
4c930e9d13 QNAM: Disable h2c by default
And since it's relatively unlikely to be used, just leave it
behind a environment variable for now.

[ChangeLog][QtNetwork][Potentially Source-Incompatible] Support for
clear-text http/2 was disabled due to incompatibility with certain
servers. If you were relying on this feature you must re-enable it by
setting the QT_NETWORK_ALLOW_H2C environment variable. For a later
version of Qt it will get a dedicated attribute.

Pick-to: 6.2
Task-number: QTBUG-98642
Change-Id: Id3e360726e285b3128e3e3f4bce9440404c9ad6e
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2021-11-30 00:04:38 +01:00
Marc Mutz
ccaeffe565 QT_SPECIALIZE_STD_HASH_TO_CALL_QHASH: use unqualified qHash() lookup
... instead of QT_PREPEND_NAMESPACE(qHash), which is qualified (prepends at least '::'), and therefore disables ADL.

This is not a problem as long as we wrote our qHash() overloads as free functions (incl. non-hidden friends), but it should™ fail for hidden friends, so use the old using-std::swap() trick to bring QT_PREPEND_NAMESPACE(qHash) into scope, proceeding with an unqualified lookup.

Pick-to: 6.2
Change-Id: I00860b2313699849f86bfe3dd9f41db4ce993cd3
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-11-29 18:55:10 +00:00
Eskil Abrahamsen Blomfeldt
793417ce75 Fix gaps between lines of selection
When a font has fractional metrics, we could get visible gaps
between lines in a multi-line selection, if the bottom of the
rect was not aligned to the pixel grid. In Qt 5, this was
primarily an issue on macOS, but since making vertical metrics
consistent in f761ad3cd9, we
could also get this on other platforms, causing a regression
on these platforms.

The fix is to align the rect to the pixel grid.

[ChangeLog][Text] Fixed an issue where there would sometimes be
visible gaps in selections spanning multiple lines.

Pick-to: 6.2
Fixes: QTBUG-98372
Change-Id: I03cb1465602b6d78c60a0c764d920f7f092418a8
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-11-29 16:25:38 +01:00
Volker Hilsheimer
56da533b45 Never handle scrollbars styled with box or border changes as transient
If scrollbars are styled with a style sheet that includes a box or
removes off the native border, then we never treat them as transient or
overlapping. Otherwise, the layout logic in QAbstractScrollArea will
show them on top of the viewport, overlapping the content.

Add case to the style sheet test baseline test. It's a test for
scrollbars in a scroll area, rather than a test for the styling of the
scrollbars themselves.

Fixes: QTBUG-98289
Pick-to: 6.2
Change-Id: Ic53ad248b3eedd54722ac7b2fe5256a27092dbc1
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2021-11-29 16:02:28 +01:00
Eirik Aavitsland
8fbedf2196 QTextDocument: fix an off-by-one in the changed signal for lists
When blocks are added or removed in block groups, i.e. items added or
removed from text lists, the whole group is marked as changed, but the
calculation of the before/after group length would be one off. That
was reflected in the contentsChange signal.

Add unit test. Since the whole group changes when list items are
added, text is removed and the change-begin is not where the cursor
was when the change was made.

Fixes: QTBUG-82455
Pick-to: 6.2 5.15
Change-Id: I99ee2cfef4944fcac8aca492741fd0f3b0de4920
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2021-11-29 13:25:31 +01:00
Liang Qi
143f20692e gui: add QInputDevice::seatNames()
Change-Id: Ie6cedd62dcd684a8fd9adbc2409e5aa1f3490ede
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-11-28 13:15:00 +02:00
Thiago Macieira
0e72a846d3 QObject: Q_ASSERT the object type before calling a PMF
The old-syle signal-slot syntax had the advantage of not delivering
signals to slots in derived classes after that derived class's
destructor had finished running (because we called via the virtual
qt_metacall). The new syntax made no checks, so a conversion from the
old to the new syntax may introduce crashes or other data corruptions at
runtime if the destructor had completed.

This commit introduces a Q_ASSERT to print the class name that the
object is not any more. Since this is in inline code, this should get
enabled for users' debug modes and does not therefore depend on Qt being
built in debug mode.

It required some Private classes to be adapted to the new form, by
exposing the public q_func() in the public: part.

Pick-to: 6.2
Fixes: QTBUG-33908
Change-Id: Iccb47e5527544b6fbd75fffd16b874cdc08c1f3e
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2021-11-27 21:38:22 -08:00
Thiago Macieira
b41356658e QLocale: suppress annoying GCC warning in the bootstrap lib
Happens on line:
        return QList<QLocale>() << QLocale(QLocale::C);

QLocale's constructor taking the C "language" calls findLocalePrivate()
that returns indeed the non-heap object c_locale in the c_private()
function. But it also sets the refcount to 1, meaning it can never drop
to 0 under proper refcounting and will thus never be deleted.

Therefore, the compiler is wrong. I don't have time to figure out how to
teach it that the deletion can never happen. I just want the warning to
go away. It wsa probably introduced by commit
d4242b8af3.

In destructor ‘QSharedDataPointer<T>::~QSharedDataPointer() [with T = QLocalePrivate]’,
    inlined from ‘QLocale::~QLocale()’ at /home/tjmaciei/src/qt/qt6/qtbase/src/corelib/text/qlocale.cpp:1035:1,
    inlined from ‘void QtPrivate::QMovableArrayOps<T>::emplace(qsizetype, Args&& ...) [with Args = {QLocale}; T = QLocale]’ at /home/tjmaciei/obj/qt/qt6/qtbase/include/QtCore/../../../../../../src/qt/qt6/qtbase/src/corelib/tools/qarraydataops.h:829:5,
    inlined from ‘T& QList<T>::emplaceBack(Args&& ...) [with Args = {QLocale}; T = QLocale]’ at /home/tjmaciei/obj/qt/qt6/qtbase/include/QtCore/../../../../../../src/qt/qt6/qtbase/src/corelib/tools/qlist.h:891:15,
    inlined from ‘void QList<T>::append(QList<T>::rvalue_ref) [with T = QLocale]’ at /home/tjmaciei/obj/qt/qt6/qtbase/include/QtCore/../../../../../../src/qt/qt6/qtbase/src/corelib/tools/qlist.h:479:24,
    inlined from ‘QList<T>& QList<T>::operator<<(QList<T>::rvalue_ref) [with T = QLocale]’ at /home/tjmaciei/obj/qt/qt6/qtbase/include/QtCore/../../../../../../src/qt/qt6/qtbase/src/corelib/tools/qlist.h:726:13,
    inlined from ‘static QList<QLocale> QLocale::matchingLocales(QLocale::Language, QLocale::Script, QLocale::Territory)’ at /home/tjmaciei/src/qt/qt6/qtbase/src/corelib/text/qlocale.cpp:2684:54:
/home/tjmaciei/obj/qt/qt6/qtbase/include/QtCore/../../../../../../src/qt/qt6/qtbase/src/corelib/tools/qshareddata.h:91:55: warning: ‘void operator delete(void*, std::size_t)’ called on unallocated object ‘c_locale’ [-Wfree-nonheap-object]
   91 |     ~QSharedDataPointer() { if (d && !d->ref.deref()) delete d; }
      |                                                       ^~~~~~~~

Pick-to: 6.2
Change-Id: Iccb47e5527544b6fbd75fffd16b8d078987b812b
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-11-27 19:10:52 -08:00
Marc Mutz
df663625af QLayoutPolicy: un-export the class
The class is almost completely inline. Don't export it wholesale, only
export the few out-of-line members.

Also acts as a test-case for the new Q_GADGET_EXPORT feature.

Task-number: QTBUG-55458
Change-Id: I699a774614183960d7ac4e0afcdb57cfef76db15
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-11-27 17:22:57 +01:00
Lorn Potter
820a6d4117 wasm: fix mouse move and right click
Emscripten has no concept of 'no mouse button', so when there
is no button down, it was sending left mouse.

Also we were hiding mousepress for only leftmouse downs.

Fixes: QTBUG-97431
Pick-to: 6.2
Change-Id: Ibf078705c343944e45551830b7fee94ed5aa7333
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2021-11-27 14:17:37 +10:00
Jarkko Koivikko
625cfb6b40 QGraphicsItem: Update input context after InputMethod event
Without updating the input context, the input method goes out of sync
with the text control.

Fix by updating the input context after InputMethod event.

Fixes: QTBUG-98544
Pick-to: 6.2 5.15
Change-Id: Idfb99bb0f886249cdab923b8dbed96277800c064
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-11-27 04:14:15 +02:00
Marc Mutz
23f980799d QSharedPointer: fix counter-productive QT_PREPEND_NAMESPACE use in qHash() impl
The qHash(QSharedPointer) implementation is already in QT_NAMESPACE,
if any, so explicitly qualifying the call adds no functions to the
overload set, but actually removes functions that would be found by ADL
(which is only enabled for unqualified calls).

Fix by using an unqualified call.

[ChangeLog][QtCore][QSharedPointer] The qHash(QSharedPointer<X>)
overload can now use qHash(X*) overloads found (only) through ADL
(was: ADL was disabled due to qualified lookup of qHash(X*)).

Pick-to: 6.2 5.15
Change-Id: Ic6cc47103142d48b6cdefa2cd6552a65cf1cb222
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-11-27 01:37:06 +00:00
Morten Johan Sørvig
24134d5193 wasm: Move Blob creation code to qstdweb
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>
2021-11-27 01:13:12 +00:00
Marc Mutz
a0f9aef11b Long live Q_GADGET_EXPORT!
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>
2021-11-27 01:25:10 +01:00
Marc Mutz
cf2336ae6e QTest: fix grammar in static_assert()
Change-Id: I6fd408702bb43e37434b382cb6cb9057ca192064
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-11-27 01:25:09 +01:00
Fabian Kosmale
733bd81328 QThread::wait: Clarify documentation for unsigned long overload
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>
2021-11-27 00:19:28 +01:00
Sona Kurazyan
722df970e8 Remove leftovers for supporting SAX-based implenentation of QDomDocument
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>
2021-11-26 22:42:40 +01:00
Sona Kurazyan
086a08dcf9 Mention QtFuture::when* functions in QFuture's docs
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>
2021-11-26 22:40:54 +01:00
Marc Mutz
fd1a42490d QVarLengthArray: fix insert() type/alias mismatch between decl and impl
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>
2021-11-26 19:51:12 +00:00
Friedemann Kleint
fac5b084a9 uic: Refactor CustomWidgetsInfo::extends() to use QAnyStringView
Task-number: PYSIDE-1720
Pick-to: 6.2
Change-Id: I2db4ee9586a87c70db08298e311d692e20a93af0
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2021-11-26 18:19:07 +00:00
Alexey Edelev
271ea6cd3e Simplify apk build procedure when using DEPFILE
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>
2021-11-26 18:28:50 +01:00
Marc Mutz
ed343669f7 Long live QVERIFY_THROWS_NO_EXCEPTION!
Counter-part to QVERIFY_THROWS_EXCEPTION.

[ChangeLog][QTest] Added QVERIFY_THROWS_NO_EXCEPTION macro.

Change-Id: Ib6a80c8e810d5e2298ff00d608dae04e7a0c3e8f
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-11-26 18:28:50 +01:00
Luca Beldi
c27d2a57a4 Make QAbstractProxyModel itemData() behave like data()
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>
2021-11-26 17:12:07 +00:00
Laszlo Agocs
99644a9e94 rhi: metal: Ignore baseInstance if not supported
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>
2021-11-26 14:22:05 +01:00
Laszlo Agocs
c1899ca310 rhi: gl: Optimize context/surface changes
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>
2021-11-26 14:22:05 +01:00
Joerg Bornemann
20783c4170 CMake: Fix cross-compilation to Windows
...and potentially to macOS.

This amends 3f56950862.

Change-Id: Idf2acded37b59994459bc80ecda5733232f721f6
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-11-26 13:13:09 +01:00
Liang Qi
27c25fc909 xcb: stablilize xkb state when keymap updated
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>
2021-11-26 12:00:06 +01:00
Morten Johan Sørvig
f92d4ffead wasm: Move streamFile() to qstdweb
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>
2021-11-26 10:04:31 +01:00
Marc Mutz
59600a514b QTest: de-inline QVERIFY_THROWS_EXCEPTION message formatting
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>
2021-11-26 09:57:59 +01:00
Volker Hilsheimer
77de4a9bb4 Fix and complete style sheet support for QToolButton
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>
2021-11-26 09:36:07 +01:00
Yuhang Zhao
00ea6f58da d3d11rhi: remove leftover of pre-win10 code
Amends commit 1e085b9e15

Task-number: QTBUG-84432
Pick-to: 6.2
Change-Id: Id48fb6c2a9c7d24f1525975c6c154dbc323bbc25
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2021-11-26 13:06:24 +08:00
Mitch Curtis
efb283fb7f Add QTest::failOnWarning
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>
2021-11-26 04:47:24 +01:00
Marc Mutz
1edf153a6b Long live QVERIFY_THROWS_EXCEPTION!
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>
2021-11-26 04:44:26 +01:00
Ievgenii Meshcheriakov
b9be035c62 QTemporaryDir: Set directory permissions at the time of creation
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>
2021-11-26 03:39:33 +01:00
Ievgenii Meshcheriakov
174af05400 QDir: Add support for setting directory permissions to mkdir()
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>
2021-11-26 03:39:33 +01:00
Giuseppe D'Angelo
8c9875893b Q(Multi)Map: prevent dangling key/value after detach()
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>
2021-11-26 02:14:52 +01:00
Edward Welbourne
297f9aa6c8 Add some missing entries to QTest::qExec()'s \sa line
Change-Id: I45300d5f9df519c5edb68d24232830bd0850915a
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2021-11-26 02:14:51 +01:00
Rami Potinkara
1a87f06916 Android: Set sem_wait m_terminateSemaphore behind an atomic flag
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>
2021-11-26 02:27:49 +02:00
Marc Mutz
9baf1d5256 QAndroidActivityResultReceiver: make uniqueActivityRequestCode() lock- and UB-free
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>
2021-11-25 13:16:06 +01:00
Marc Mutz
f4e89d58da QVERIFY_EXCEPTION_THROWN: re-throw unknown exceptions
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>
2021-11-25 13:00:55 +01:00
Luca Di Sera
c880696f06 Doc: Replace use of \oldcode-\newcode
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>
2021-11-25 09:55:48 +01:00