Commit Graph

14016 Commits

Author SHA1 Message Date
Thiago Macieira
f569acd6ae tst_QStringConverter: roll up independent tests to rows in others
Simplifies the test a little.

Pick-to: 6.3
Change-Id: I77c8221eb2824c369feffffd16f0a7fc44215aaf
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2022-05-23 14:53:18 -07:00
Thiago Macieira
30721c3d03 tst_QStringConverter: implement the TODO of testing with flags
Pick-to: 6.3
Change-Id: I77c8221eb2824c369feffffd16f0a7e428b23fb6
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2022-05-23 14:53:18 -07:00
Thiago Macieira
aef27c5aa2 tst_QStringConverter: improve the char-by-char UTF-8 testing
The utf8.txt file was only 21 bytes and contained exactly two non-ASCII
characters. It wasn't very good.

This commit brings back the UTF-8 test rows that existed before commit
18ec53156e deleted tst_Utf8. There's a lot
of overlap with some of the other rows in this test, though.

Pick-to: 6.2 6.3
Change-Id: I77c8221eb2824c369feffffd16f094619b69faef
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2022-05-23 14:53:18 -07:00
Thiago Macieira
9bad4be214 QStringConverter: use the QUtf8 codec when Windows is using UTF-8
The QLocal8Bit implementation assumes that there's at most one
continuation byte -- that is, that all codecs are either Single or
Double Byte Character Sets (SBCS or DBCS). It appears to be the case for
all Windows default codepages, except for CP_UTF8, which is an opt-in
anyway.

Instead of fixing our codec, let's just use the optimized UTF-8
implementation.

[ChangeLog][Windows] Fixed support for using Qt applications with UTF-8
as the system codepage or by enabling that in the application's
manifest.

Discussed-on: https://lists.qt-project.org/pipermail/interest/2022-May/038241.html
Pick-to: 6.2 6.3
Change-Id: I77c8221eb2824c369feffffd16f0912550a98049
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2022-05-23 14:53:18 -07:00
Ivan Solovev
e2e0420028 Network: update Public Suffix List
using the description from qtbase/src/network/kernel/qurltlds_p.h.INFO

Task-number: QTBUG-103663
Change-Id: I543fa96d2538f5eb63b114fe6467fb5b0e891e3b
Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-05-23 22:28:49 +02:00
Allan Sandfeld Jensen
0d97723ee2 Fix separate delete of window and windowcontainer
The documentation says we can change window parent to avoid the widget
deleting the window. That didn't work as the widget didn't get the
child-removed event as it wasn't the parent.

This patch instead uses an event filter on the set parent.

Pick-to: 6.3 6.2
Change-Id: I1f61d1832fcf3257722f305beeefd8f1abf1f656
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2022-05-23 21:25:46 +02:00
Volker Hilsheimer
6b02c85f87 Android: Enable building of the QLocale test case
Amends 2a893db480, which changed the
#ifdef'ery but didn't actually enable the building of the test on
Android.

Task-number: QTBUG-87414
Pick-to: 6.3 6.2
Change-Id: Id944dd3023da40ecbf4b8a324784409a63f94aec
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2022-05-23 19:12:06 +00:00
Volker Hilsheimer
dd8da7ebd9 Compile-time generate a JNINativeMethod from a C function
Add a template function that allows us to get the method signature
string from a free function, which are used as native callbacks methods
from Java.

Provide a macro that defines a signature object, and a JNINativeMethod
object based on it, in an internal namespace so that we don't pollute
the namespace with generated names.

Add another macro to get the generated JNINativeMethod object based on
the free function name.

Lastly, add overloads to QJniEnvironment::registerNativeMethods that
take a std::initializer_list of JNINativeMethods.

We can now declare a free function to be a JNI native method:

static bool callbackFromJava(JNIEnv *e, jobject /*thiz*/, jstring p1)
{
   // ...
}
Q_JNI_DECLARE_NATIVE_METHOD(callbackFromJava);

and register it with the JNI environment like this:

QJniEnvironment jni;
jni.registerNativeMethods(clazz, {
    Q_JNI_NATIVE_METHOD(callbackFromJava)
});

removing a significant amount of boiler plate code.

Change-Id: Ie4007b24125879fed3dae1f4d232b4aa95999b44
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2022-05-23 21:12:06 +02:00
Volker Hilsheimer
fb56a0f2ce Don't hide a widget that is swapped into a hidden splitter
When replacing a widget in a hidden splitter, then we only need to keep
the new widget hidden if the previous widget was hidden.

If the new widget is not explicitly hidden, and the splitter is already
visible, then we need to explicitly show the new widget.

Augment test case; the existing test cases already cover swapping out a
collapsed or hidden widget.

Fixes: QTBUG-102134
Pick-to: 6.3 6.2
Change-Id: I9b60711a5c1cab79777ce4183783114a16ac3394
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2022-05-23 21:12:05 +02:00
Giuseppe D'Angelo
c613dd4765 QMetaType: disable conversion from smart pointer<const QObject>
QMetaType can register a converter from a smart pointer class to
QObject *. The code tries to do so even if the smart pointer is
actually holding a pointer to a _const_ QObject
(e.g. shared_ptr<const QObject>), causing a compile error:

  ../src/qt5/qtbase/build/include/QtCore/../../../src/corelib/kernel/qmetatype.h:1208:32: error: invalid conversion from ‘const QObject*’ to ‘QObject*’ [-fpermissive]
   1208 |             return p.operator->();
        |                    ~~~~~~~~~~~~^~
        |                                |
        |                                const QObject*

Disable the conversion if indeed the source is const qualified.

Change-Id: I9e9bc5992f74131e5cfd6ece9b83d4f26d370e92
Fixes: QTBUG-103741
Pick-to: 6.2 6.3
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-05-21 11:43:59 +02:00
Sona Kurazyan
bd1023a824 QtConcurrent: prevent conversion of ReduceOption to initial value
QtConcurrent map- and filter-reduce functions take an initial value,
which can be of any type that is convertable to the result type. The
side-effect of this is that the enum values passed as ReduceOptions can
be treated as an initial value (if they are convertable to the result
type) which will result into a wrong overload call. To avoid this, added
additional check to make sure that the initial value type doesn't match
with ReduceOption enum.

Note that this required including the qtconcurrentreducekernel.h header
in qtconcurrentfunctionwrappers.h (which contains compiler checks for
QtConcurrent) for accessing ReduceOption enum, so I had to get rid of
qtconcurrentfunctionwrappers.h include from qtconcurrentreducekernel.h
to avoid circular header includes. This, in turn, required moving the
QtPrivate::SequenceHolder helper type to qtconcurrentreducekernel.h,
which didn't belong to qtconcurrentfunctionwrappers.h anyway.

Pick-to: 6.3 6.2
Fixes: QTBUG-102999
Change-Id: Ieaa8ef2e4bd82ce2ada2e0af9a47b87b51d59e87
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-05-20 17:11:15 +02:00
Eskil Abrahamsen Blomfeldt
4fe9374589 Fix crash in tst_qquicktext::implicitSize
This reverts commit 1e938c348b
and bb2f4d08d9.

bb2f4d08d9 causes the crash, but 1e938c348b amends it, so
this reverts both. When the cause of the crash has been determined
and mitigated, the patches can be recreated.

Fixes: QTBUG-103719
Change-Id: Ifc36b3771a96f6c85387a5306a0402d4c508d006
Reviewed-by: David Faure <david.faure@kdab.com>
2022-05-20 13:14:01 +02:00
Tang Haixiang
efc02f9cc3 xcb: Delete touch points without target windows
When XCB_INPUT_TOUCH_BEGIN closes a popup, we then receive
XCB_INPUT_TOUCH_END, and cannot find a target window (because it's
destroyed). If we don't deliver it, we need to at least clear the
stored point from QPointingDevicePrivate::activePoints. Then when
we deliver the next touch press, m_fakeMouseSourcePointId also
needs to be reset.

It's now even more paramount that autotests (and real-world
touchscreens) must never omit any active touchpoint from a touch event.
If a point doesn't move, it must be included in the QTouchEvent, with
Stationary state. If not, QGuiApp::processTouchEvent() could generate
multiple TouchBegin events in a row, which gets other bits of logic
confused, here and there.

Fixes: QTBUG-94557
Fixes: QTBUG-98519
Fixes: QTBUG-102751
Fixes: QTBUG-103706
Pick-to: 6.2 6.3 5.15
Change-Id: Ia95e410a2bb8bc7784aa5d296fac2b89e53a9f55
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2022-05-20 10:26:18 +02:00
Shawn Rutledge
ff153d9874 Avoid ending Markdown fenced code blocks with gratuitous blank lines
This caused unnecessary empty <pre> blocks when converting markdown to
HTML, made code blocks too large using QSyntaxHighlighter to highlight
the whole block, and caused assymmetry when rewriting markdown.

Pick-to: 6.3
Fixes: QTBUG-101031
Change-Id: I08016577ccb92edb4afae31d7df3259cb011d5c8
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2022-05-20 00:49:18 +02:00
Shawn Rutledge
04a60bb033 Convert <pre> to Markdown ``` and vice-versa with nonBreakableLines
The HTML parser calls QTextBlockFormat::setNonBreakableLines(true) when
it sees a <pre> tag; so for symmetry, the markdown reader now does the
same when it sees a fenced code block, and the markdown writer honors
the nonBreakableLines property by writing a fenced code block. This
preserves the meaning better when reading HTML and writing markdown or
vice-versa, without modifying HTML reading or writing code.

Added a test tst_QTextMarkdownImporter::fencedCodeBlocks() which
unfortunately also highlights a known bug in the markdown reader: each
fenced code block ends with an extra empty block. That can be fixed
separately.

tst_QTextMarkdownWriter::fromHtml(preformats with embedded backticks)
that we re-enabled in 1abaf9d5d6 was not a
very useful test: ``` with a space and some words but no newline is not
a fence: it's just like a `monospace` span. We have had trouble with
those in CI because of missing monospace fonts, or inconsistency when
a supposedly mono font's QFontInfo::fixedPitch() returns false.
So just test proper <pre>/fence conversion for now.

Pick-to: 6.3
Fixes: QTBUG-100515
Fixes: QTBUG-100981
Task-number: QTBUG-101031
Change-Id: I88f0ede0810d8a9480b30eb0cd780e1af67cc5f2
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2022-05-19 14:43:39 +02:00
David Faure
1e938c348b QTextDocument: add setLayoutEnabled()
This allows to set up everything first - without paying for layouting
at every step - and only then trigger layouting.

Same performance behavior as setTextWidth(0), but this is a more
explicit/readable API.

Change-Id: I044dbd8b1301b1c97a92f9a29ccde2baf27a7665
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-05-19 12:26:57 +00:00
Anna Wojciechowska
2a34d4bc66 unblacklist passing tests 2022
Pick-to: 6.2 6.3
Change-Id: I7d37dd58eaede1bd0d1b53fe264b45be83cbca57
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2022-05-18 23:59:19 +02:00
Thiago Macieira
56dcb3b496 qglobal.h: #include <stdbool.h> in C mode
It's C99 and we require C11.

Change-Id: Ieb9a2aa1ea914b1b956bfffd16eff4556b99f976
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-05-18 09:14:18 -07:00
Marc Mutz
042bab072a Fix return value of qGlobalPostedEventsCount()
The unsigned return value was very un-Qt-ish, and, indeed,
tst_QCoreApplication just stored the result in ints.

Port to qsizetype, being the type of the expression that the function
calculates.

Task-number: QTBUG-103532
Change-Id: I95a81a686439b0686faad7a430adeaab66dc9e8d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-05-18 17:54:15 +02:00
Marc Mutz
7b736e1faf Make qGlobalPostedEventsCount() auto-test-exported-only
The only in-tree user outside QtCore is tst_QCoreApplication, guard
the (single) test function there with QT_BUILD_INTERNAL.

Change-Id: Ibc87ba76f2135cd8283acd75318f80a95e4b5c45
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-05-18 17:54:15 +02:00
Marc Mutz
f2fea2325d Remove manual declarations of qGlobalPostedEventsCount()
... in favor of including qabstracteventdispatcher_p.h, where needed.

Keeps the code DRY.

Change-Id: I5bee2e653cb29ffac2601ff03c952a4b3adbdb9c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-05-18 17:54:15 +02:00
Shawn Rutledge
1ad456c908 Un-blacklist markdown tests: QSKIP when fonts are scrambled
On QNX in CI we see
system fonts: fixed: monospace 9; general: Sans Serif 9
and "monospace" isn't really a fixed pitch font.
On B2Qt arm7 in CI we see
system fonts: fixed: monospace 9; general Sans Serif 9
and Sans Serif is actually fixed pitch.

So these tests can go wrong both ways; we need to skip them whenever
the fonts would lead QTextMarkdownWriter astray.

Pick-to: 6.3 6.2
Task-number: QTBUG-89819
Task-number: QTBUG-99676
Task-number: QTBUG-100515
Task-number: QTBUG-103484
Change-Id: I7b9adca967eaf9b8d33d1e03ef2627f70f375196
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2022-05-18 14:30:07 +02:00
Volker Hilsheimer
9d41bd4312 Stylesheet: Another positioning fix for the menu indicator
Draw tool button menu indicator relative to frame, not content, so that
padding added in the stylesheet creates room between text and indicator.

Also, prevent another double-arrow by ignoring menu indicator rendering
when a menu button subcontrol is used, as the two are mutually
exclusive. This amends 1c338e6d07.

Add problematic case to stylesheet baseline test.

Fixes: QTBUG-102866
Pick-to: 6.3 6.2
Change-Id: I5d79e65b33a2e41ac07c8efe0c15697c5be65201
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2022-05-18 13:15:00 +02:00
Andreas Buhr
2f35653a30 Use QAbstractItemModelTester or QFileSystemModel
This patch enables usage of QAbstractItemModelTester on
QFileSystemModel. QAbstractItemModelTester called fetchMore()
on all items. QFileSystemModel represents the whole file system.
This led to very long test runs. To avoid this, this patch
introduces a new feature in QAbstractItemModelTester, namely
to disable calling of fetchMore().

Change-Id: Ie5d2e22fa4c143be7c080d9f79632cd2cbe07aac
Reviewed-by: David Faure <david.faure@kdab.com>
2022-05-18 12:58:06 +02:00
Andreas Buhr
ec7989aa66 Fix memory leak in tst_qtreewidget
Invalid inserts of items are tested. However, on an invalid insert
of QTreeWidgetItem into QTreeWidget, the QTreeWidget does not take
ownership of the to-be-inserted items. These items were leaked in
the past.
This patch introduces a scope-guard, so the items are not leaked.

Change-Id: Ib53ac02605c3a3c0bd1ae69bbd0876f860d08093
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-05-18 10:58:05 +00:00
Volker Hilsheimer
76e441c9ee Make uic generate correct C++ comments
Revert the change to uic of 05fc3aef53.

Task-number: QTBUG-67283
Change-Id: Icfd83bb6d80b91d4e58f1be460f6772ba49a6921
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-05-18 11:53:26 +02:00
Giuseppe D'Angelo
07d80deeab QtWidgets: restore Qt 5 compatibility for save/restore state
Several classes in QWidget use QDataStream internally in order
to save and restore state. These QDataStream usages were not
versioned, meaning that if Qt changes the serialization for some
datatype, then the data saved between different Qt versions becomes
incompatible. Note that the save/restore API in question just produce
opaque blobs as QByteArrays -- the user has no control over the
QDataStream objects and thus versions.

Fix by version the usages.

In QHeaderView this has caused a regression because QBitArray *did*
change version between Qt 5 and 6. In general, using QDataStream without
explicit versioning is a mistake, so deploy the same fix elsewhere as
well.

Fixes: QTBUG-99487
Pick-to: 5.15 6.2 6.3
Change-Id: I82bb5c266f4e5dedc0887cbef855dccab1015e29
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: <doctor.whom@gmail.com>
2022-05-18 02:21:31 +02:00
David Faure
bb2f4d08d9 QTextDocument/QGraphicsTextItem: skip layout in setTextWidth(0)
In a QGraphicsTextItem without a width yet, there's no need to do any
layouting. The use case is obviously items with an app-defined size,
not the default where text items adapt to their contents.

Results:
 0.065 msecs to create a QGraphicsTextItem with some text (layouted)
 0.036 msecs to set everything up in a QGraphicsTextItem with 0 width

QTextEdit was abusing the width 0 to mean "no wrap, width comes from
contents", but since the value -1 means that already in QTextDocument,
QTextEdit now uses a width of -1 for that meaning.

Change-Id: I67ad59c305e5dd34830886e4e6c56dde03c93668
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-05-17 22:37:40 +02:00
Alexey Edelev
b576d7f6d1 Guard the use of QWinEventNotifier in tests
Add the Q_OS_WIN32 guard for the include of QWinEventNotifier.

Change-Id: I7824b2ee236a370c83fd85a2f594a39cf36b36e6
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-05-17 02:51:22 +02:00
David Faure
546e11f1dc QDBusArgument: ensure std::vector isn't seen as an associative container
This broke compilation of qDBusRegisterMetaType<std::vector<MyStruct>>
because std::vector<T> is in fact std::vector<T, std::allocator<T>>.

Pick-to: 6.2
Change-Id: I6a13f5f0476a3faa3a43da54d90d652b4bdd8186
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2022-05-17 01:27:33 +02:00
Volker Hilsheimer
367092d7e0 Return specific types for frequently used Java objects
This allows us to specialize JNI type signature templates for e.g. the
context object, which in Java signatures is "android/content/Context".

Introduce a Q_DECLARE_JNI_TYPE macro that takes care of the plumbing.
The types declared this way live in the QtJniTypes namespace, and
transparently convert from and to jobject. Since jobject is a typedef
to _jobject* we cannot create a subclass. Use a "Object" superclass
that we can provide a QJniObject constructor for so that we don't
require the QJniObject declaration to be able to use the macro.

The APIs in the QNativeInterface namespace doesn't provide source or
binary compatibility guarantees, so we can change the return types.

Change-Id: I4cf9fa734ec9a5550b6fddeb14ef0ffd72663f29
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2022-05-17 00:34:06 +02:00
Volker Hilsheimer
f6e89e901b Fold methods for object return type into generic methods
Since we know at compile time whether the return type is an object type,
we can use 'if constexpr' and auto return type in the call(Static)Method
and get(Static)Field functions to call the object-type methods.

This makes the object-methods conceptually obsolete, but don't declare
them as deprecated as long as they are still used in submodules to avoid
warning floods and build failures in -Werror configurations.

Change-Id: Ic3019ed990a9252eefcb02cdb355f8a6ed6bc2ff
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2022-05-17 00:34:06 +02:00
Volker Hilsheimer
1c338e6d07 Stylesheet: fix toolbutton menu indicator rendering
Turn off native indicators if we have custom rules, and if we drew
natively, don't draw custom indicators. This amends
ea0e0a8652 which turned off custom drawing
too aggressively, removing custom indicators also if no custom drop
down arrow (which is only relevant for drop down menu buttons) was set.

When then drawing the custom indicator, respect positioning rules in the
style sheet.

Extend baseline test.

Fixes: QTBUG-102866
Pick-to: 6.3 6.2
Change-Id: I5ca353f42e704ec3f6e57677c35118a9cb358b0b
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2022-05-16 20:32:27 +02:00
Lucie Gérard
05fc3aef53 Use SPDX license identifiers
Replace the current license disclaimer in files by
a SPDX-License-Identifier.
Files that have to be modified by hand are modified.
License files are organized under LICENSES directory.

Task-number: QTBUG-67283
Change-Id: Id880c92784c40f3bbde861c0d93f58151c18b9f1
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-05-16 16:37:38 +02:00
Shawn Rutledge
7c76064604 Add QTextDocFragment::to/fromMarkdown() & QTextCursor::insertMarkdown()
Also add the beginnings of an autotest for QTextCursor::insertHtml(),
for comparison purposes.

We can see that the block to be inserted is merged with an existing
block by default rather than being inserted as a new one, with both HTML and
Markdown insertions.  So now we test for leading and trailing newlines
in the markdown to be inserted, to determine whether we need a new block
into which to insert, and to "hit enter" at the end of the insertion.

QSKIP the toMarkdown() comparisons if GeneralFont is mono. This happens
on Boot2Qt systems in CI.

Task-number: QTBUG-76105
Task-number: QTBUG-94462
Task-number: QTBUG-100515
Task-number: QTBUG-103484
Change-Id: I51a05c6a7cd0be4f2817f4a922f45fa663982293
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2022-05-14 21:32:05 +02:00
Allan Sandfeld Jensen
e69ebf93ca Add floating point color space conversions
This allows color space conversions that produces values outside the
0.0->1.0 range, which is one of the intended functions of the floating
point image formats.

Change-Id: I63b37b0f6934d4382edafb4709486c785a637c67
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2022-05-14 01:00:05 +02:00
Oliver Eftevaag
e33a449271 Add override keyword to avoid warning from compiler
A class that reimplements a virtual function isn't using the override
keyword, which generates a warning during compilation.

Pick-to: 6.3
Change-Id: Ic39ea24993e031f95ac9e61c3285d3be05fe6c34
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-05-13 18:49:05 +00:00
Volker Hilsheimer
601dbd6499 Add variadic template overloads for QJniObject/Environment methods
This allows the compiler to deduce the template arguments based on the
provided method parameters, which we can then pass to the methodSignature
and fieldSignature helpers to generate the signature string completely at
compile time.

Since we can't partially specialize template member functions, replace
the specializations for void methods with compile-time-if branches in
the general templates.

This variadic template now prevents implicit conversion from the
LiteralStorage types to const char* signatures, so catch the case where
such a type ends up in the parameter list.

Due to overload resolution rules for constructors, we need to explicitly
disable the constructor if any of the arguments is a string literal type,
as we have to keep the old C-style variadic function working for such
calls.

Add variations that use the variadic templates to the unit tests.

Change-Id: I8734664b38bae932369462330a9a03302254c33c
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2022-05-13 18:13:49 +02:00
David Skoland
8e07d5095b Only configure one test for wasm
Since we still don't support dynamic linking in wasm, we can't
use it for tests, which forces us to use static linking, which is
very slow (up to 30 seconds in some cases). The idea is to at least
have one test run for wasm before expanding it later.

Note that even with this change,
QT_BUILD_MINIMAL_STATIC_TESTS=ON needs to be defined to skip
the baseline test directory.

Change-Id: I39aea22087211fb39f03dfb0b39c55f63a26d2a7
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-05-12 18:55:04 +02:00
Ville Voutilainen
0c0a784c6f Add BiC data for the new way to do BiC testing
Change-Id: Id85fc21d4758eecc73b48f64370cc1479b618d81
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2022-05-12 13:33:41 +03:00
Fabian Kosmale
4e7f92bf0d QMetaType: Fix normalization on MSVC if name contains enum
During type normalization, we remove the struct, class and enum
keywords (see the skipStructClassOrEnum function). However, we only want
to do that for actual keywords, not for a name that happens to start
with e.g. "enum", as in "enumerationNameSpacce".
Adjust the MSVC check to still require no identifier character after the
keyword, while still allowing for some remaining characters.

Fixes: QTBUG-97813
Pick-to: 6.3 6.2
Change-Id: I82b873d02ff454cce4b75f2814a52a66f2268208
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-05-12 08:17:54 +02:00
Thiago Macieira
20104bb237 Remove remnants of the old Intel C++ compiler
We don't support it any more. I don't think it has ever properly
compiled Qt 6 (and it's no longer working for me against GCC 12's
libstdc++ headers). If you report a bug against it, Intel support's
first question is if you can try instead the new Clang/LLVM-based oneAPI
C++ compiler.

So we support only that one, which identifies itself as Q_CC_CLANG.

Change-Id: I5ff8e16fcdcb4ffd9ab6fffd16eb57a092c8439e
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-05-11 12:50:08 -07:00
David Skoland
0c44dd3a33 Exclude network tests based on feature
Both tests in the conditional depend on the
qnetworkinterface feature, and will fail to build
if qt is configured without the networkinterface feature.

Additionally, a missing system header in a test was added.

Change-Id: Ife5989ee57675ebe117de2c92a4f96c7125cbab1
Pick-to: 6.3
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-05-11 20:14:39 +02:00
Liang Qi
4872392925 Update shared-mime-info to the 2.2 release
This also includes the fix for x-objc++src mimetype.

Fixes: QTBUG-70739
Pick-to: 6.3 6.2 5.15
Change-Id: I24f70fa5cea2e5b1a7877569be98d36878fcfe72
Reviewed-by: David Faure <david.faure@kdab.com>
2022-05-11 11:36:49 +02:00
Marc Mutz
a1903eb941 QPolygon: add toPolygonF()
This was forgotten when implementing QTBUG-73160, but suggested in
passing in QTBUG-64.

[ChangeLog][QtGui][QPolygon] Added toPolygonF().

Task-number: QTBUG-73160
Task-number: QTBUG-64
Change-Id: I9b33cf47a0d432aa842ab0f8337001c66e4ca41c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-05-10 15:51:04 +02:00
David Faure
3bc80195df QWidgetTextControl: port to new-style connects (faster)
This speeds up creating a QGraphicsTextItem by 14% in an optimized build
Before: 0.070 msecs per iteration
After: 0.060 msecs per iteration

Those connects were showing up when profiling, because of the string
parsing that is necessary when using SIGNAL/SLOT macros.
The stacktrace was connect() => decodeMethodSignature() => argumentTypesFromString()
=> QArgumentType constructor => qMetaTypeInternal(const char*).

Pick-to: 6.3 6.2 5.15
Change-Id: I3cf5655c5450f121005140bdb587fafa083cce6a
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-05-10 15:20:57 +02:00
Lorn Potter
d490501641 wasm: add support for drag into browser window
Drag and drop into the browser will work.
Drag and drop out of the browser will not.

Fixes: QTBUG-102242
Change-Id: Id9981ab6f9514535e1409bec18068790833a67a6
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2022-05-10 01:20:45 +00:00
Marc Mutz
277c23956c tst_qobjectrace: fix potential UB (something with pointers and new)
The current [basic.life] wording seems to cover the existing code, but
IIRC, older versions of [basic.life] were not so relaxed. In
particular, while not completely pertinent, the second placement new
is awfully similar to http://eel.is/c++draft/ptr.launder#example-1

Just make all of this SEP and use std::optional. That way, the code
gets simpler, too, plus we get rid of the last use of C++23-deprecated
std::aligned_storage.

The reset() before the 2nd emplace() isn't necessary, but, in a test,
it doesn't hurt, either, and keeps code readers from guessing whether
the first-emplaced object's dtor is actually properly run (it is).

Pick-to: 6.3 6.2
Fixes: QTBUG-99122
Change-Id: If31a46f8be3a74499f1176133029d097faf7dfe9
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-05-07 18:47:48 +00:00
Ulf Hermann
38002df206 Endian: Provide special integer bitfield unions
Our previous approach of creating a union from individual special
integer bitfields leads to undefined values because only one member of a
union can be active at any given time. Compilers have finally caught up
with us on that and have started removing "no-op" writes to members.

The primary user of the special integer bitfield unions is
qv4compileddata_p.h in qtdeclarative. We want our on-disk format of
QML compilation units to be platform agnostic and space efficient.

Pick-to: 5.15 6.2 6.3
Task-number: QTBUG-99545
Change-Id: I24847bda2c364eb8ba75f074cde2a9bec25ced06
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-05-07 08:37:42 +02:00
Volker Hilsheimer
2b99a71b22 Stylesheet: Don't ignore item check indicator styling
Amends cf52d725156811754cd4e094b0984864795d1d58, after which most
indicator styling was no longer taken into account unless some other
item aspects were styled. Calling the baseStyle to draw the entire item
doesn't call back into the style sheet style for the indicator itself.

The QCommonStyle code that breaks the item up into individual sub
elements cannot be called for each element. E.g. turning off the check
indicator feature changes the layout of the item.

So if the indicator is styled, then we have to draw an otherwise empty
item with the style sheet style, and then clip the already painted rect
before calling the base style to draw text and highlighting with the
correct palette.

Add baseline test for QTreeView with different style sheets.

Fixes: QTBUG-102820
Pick-to: 6.3 6.2
Change-Id: I1da5676cc63556230eac525bc550457ebd495a58
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2022-05-06 03:48:09 +02:00
Volker Hilsheimer
4222d117d2 Baseline tests: slow down cursor blinking
Override the default cursor blink time so that we don't get mismatches
from line edits. We need to set the time to > 0 so that QStyleHints does
not fall back to the platform integration.

Pick-to: 6.3
Change-Id: Ib1d04f7450c01c352c13098886aee032dcb14c72
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2022-05-05 16:50:31 +02:00
Volker Hilsheimer
dc96d812ec Baseline testing of widget: wait before taking snapshot
Widgets and styles might use fade effects or other asynchronous mechanisms
as part of hovering. This results in mismatches when the snapshot is
taken before those effects are completed.

Since we can't control all such animations from the outside, process
events for some milliseconds before taking the snapshot.

Pick-to: 6.3
Change-Id: I771658300628238552bddcd14a6751c3f6c0c63d
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2022-05-05 16:50:31 +02:00
Volker Hilsheimer
a085a14d76 Generate JNI signature strings at compile time
Introduce an internal QtJniTypes namespace with types that allow us to
concatenate string literals at compile time. This makes it possible to
generate arbitrary strings based on types, which we can then use as
signatures to JNI method calls.

Move some of the private members of QJniObject into the QtJniTypes
namespace for consistency, and to allow further template specialization
by user code to make other types and their JNI signature string known.
Remove the "Jni" prefix from names.

Use the compile-time generated string in QJniObject methods that created
the signature string at runtime, which involved a temporary memory
allocation.

Treat 'void' as a primitive type (with signature string 'V'), and
remove redundant template specializations.

Add a test case to verify the the strings are constructed correctly
at compile time.

Change-Id: I5e3895a97f7dc1b86961f7a7855b899d9203037d
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-05-05 07:29:25 +02:00
Mårten Nordheim
953512ec84 Add test-helper as dependency to tst_qdbusinterface
Then the test-helper is (re)built as part of `ninja tst_qdbusinterface`
or `ninja tst_qdbusinterface_check`

Pick-to: 6.3 6.2
Change-Id: Id129c2fdc5980ea268ef1383f0747589876e2a9f
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-05-04 12:14:49 +00:00
Marc Mutz
9b3885248b QTextStream: complete char16_t support
... by providing also op>> for char16_t.

[ChangeLog][QtCore][QTextStream] Added op>>(char16_t&).

Change-Id: I2f6cc2b2cdacd5190d364f94c1830f6de62d3b7e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-05-04 07:09:22 +02:00
CI Insignificant Platforms Monitor Bot
72a3172ea5 Blacklist: test cases blacklisted in tst_QTcpServer:
- serverAddress on qnx

Pick-to: 6.2
Pick-to: 6.3
Task-number: QTBUG-103056
Change-Id: I21b858fabc9d0ec49ded99c921ea399a0dc193a8
Reviewed-by: CI Insignificant Platforms Monitor Bot <ci_insignificant_platforms_monitor_bot@qt.io>
2022-05-04 05:08:37 +00:00
CI Insignificant Platforms Monitor Bot
80a8d9553f Blacklist: test cases blacklisted in tst_QDockWidget:
- floatingTabs on qnx

Pick-to: 6.2
Pick-to: 6.3
Task-number: QTBUG-103091
Change-Id: Ia8b4a60847ba27dd2e9e50148bbe1e37febe1498
Reviewed-by: CI Insignificant Platforms Monitor Bot <ci_insignificant_platforms_monitor_bot@qt.io>
2022-05-04 05:08:34 +00:00
CI Insignificant Platforms Monitor Bot
d106caeac8 Blacklist: test cases blacklisted in tst_QNetworkReply:
- ioGetFromHttpWithProxyAuth on qnx

Pick-to: 6.2
Pick-to: 6.3
Task-number: QTBUG-103055
Change-Id: I45bf4c2df7fa977ffa525bf80108a74f1e8f4eef
Reviewed-by: CI Insignificant Platforms Monitor Bot <ci_insignificant_platforms_monitor_bot@qt.io>
2022-05-04 05:08:32 +00:00
Marc Mutz
7905b624fd QTextStream: fix streaming of char16_t's
Clazy complains about all uses of QLatin1Char these days, but if one
actually applies the fixit to turn

   out << QLatin1Char(' ');

into

   out << u' ';

the space is now streamed as an int (20), not as a space.

Fix by providing an explicit char16_t overload.

[ChangeLog][QtCore][QTextStream] Added op<<(char16_t).

[ChangeLog][Important Behavior Changes] QTextStream streams char16_t's
as QChars now instead of outputting the numeric value. If you want to
preserve the old behavior, cast the char16_t to a numeric type, such
as ushort or int, and stream that. This is backwards-compatible.

Pick-to: 6.3
Change-Id: I42d422cdebb27d38ac1714b22ef186642ec407e7
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-05-03 11:44:56 +02:00
Sona Kurazyan
34242f843e Deprecate _qs and _qba literal operators in favor of _s and _ba
[ChangeLog][QtCore] Deprecated _qs and _qba literal operators
for QString and QByteArray in favor of _s and _ba in the
Qt::Literals::StringLiterals namespace.

Task-number: QTBUG-101408
Change-Id: I26aee0055e3b4c1860de6eda8e0eb857c5b3e11a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-05-02 12:23:56 +02:00
Sona Kurazyan
17e06afdc3 Replace remaining uses of deprecated _qs with _s
Task-number: QTBUG-101408
Change-Id: I1fda67c07e948af5017f0b99b67f8c20d7052033
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-05-02 12:23:44 +02:00
Mårten Nordheim
b322984b49 tst_QNetworkReply try stabilize autoDeleteReplies tests
The http test data hasn't always been stable but for some reason
it fails far more than usual.

Originally the domain was a non-existing one, because it would then work
on any machine (even if not in CI) and would finish() (with error)
after failing to look up the domain in DNS. However, some machines in CI,
for some reason, take too long to do this and end up failing the test.

So, we change the URL to point to the network server in CI. This should,
at the very least, finish quickly when running in CI.

Pick-to: 6.3 6.2 5.15
Fixes: QTBUG-102952
Change-Id: I3b3f6fa23acf78fefdb69ff9ae7722f15e5f1736
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2022-04-29 04:28:56 +00:00
Marc Mutz
e48b4d2b7c Implement support for '0b' prefix in toInt() etc
[ChangeLog][QtCore][QByteArray/QByteArrayView/QLatin1String/QString/QStringView]
The string-to-integer conversion functions (toInt() etc) now support
the 0b prefix for binary literals. That means that base = 0 will
recognize 0b to mean base = 2 and an explicit base = 2 argument will
make toInt() (etc) skip an optional 0b.

[ChangeLog][QtCore][Important Behavior Changes] Due to the
newly-introduced support for 0b (binary) prefixes in integer parsing,
some strings that were previously rejected as invalid now parse as
valid. E.g., Qt 6.3 with autodetected bases would have tried to parse
"0b1" as an octal value and fail, whereas 6.4 will parse it as the
binary literal and return 1.

Fixes: QTBUG-85002
Change-Id: Id4eff72d63619080e5afece4d059b6ffd52f28c8
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-04-28 08:40:19 +00:00
JiDe Zhang
7a5d7e8440 Optimize the QPalette::resolve from the other palette
If all the palette's colors are resolved, nothing needs to be done in
QPalette::resolve(const QPalette &other).

Change-Id: I1573cfa5b5cd1e7eb15f3242aff6ab92e9f8c84b
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-04-28 09:24:39 +02:00
Mårten Nordheim
41d217829c QHttp: Fix handling of redirect loaded from cache
In some situations when loading a redirect from cache which would lead
to a real request we would not emit the finished() signal because the
replyFinished function has a pre-condition that the response did
not originate from the cache.
However, after the initial redirect was loaded from the cache we never
unset the 'loadingFromCache' boolean, so it was still true after the
request had been made to the real target.

Pick-to: 6.2 6.3 5.15
Change-Id: I015a2ebae4af4bd17392182c3951e875a7b353c4
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2022-04-27 18:31:01 +02:00
Mårten Nordheim
d642c16fe7 QNetworkReply: update decompress error message and handling
The error message was quite vague since it would then not require
any additional translations. However, in hindsight this was a mistake
since now developers just thought their downloads were being corrupted.

Pick-to: 6.2 6.3
Fixes: QTBUG-101942
Change-Id: Ie9af42510ca027d15248e5bcf21e836e709898d9
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2022-04-27 18:31:01 +02:00
Giuseppe D'Angelo
45b09215e5 tst_qitemdelegate: make it more robust
Remove a processEvents() call followed by a QCOMPARE and turn it
into a QTRY_COMPARE. Otherwise it seems to be randomly failing on Ubuntu
22.04.

Change-Id: I3c1b9d55c857c79ffd36aeb98971db60267adace
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-04-27 17:54:19 +02:00
Edward Welbourne
0b5b98c4ae Fix qlocale_unix's handling of uiLanguages to take script into account
Some languages have, in the same territory, locales for more than one
script. In such cases, since we ignored the script, we got the one
that is used by default, instead of the one actually asked for. Take
the script into account.

Added TODO comment in test listing the known examples of this;
manually tested before and after the fix to verify the prior code was
indeed getting it wrong and now does do it right.

Change-Id: Iaf9201d6992bc39e6e9346ef8b7c69d418db7253
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-04-27 17:03:54 +02:00
Edward Welbourne
7a7f2547f3 Return more specific entries before less in QLocale::uiLanguages()
The documentation overtly listed entries in this order but the code
gave less specific entries before more specific (and the tests
verified the same). This is now reversed.

[ChangeLog][QtCore][QLocale] uiLanguages() now prefers more specific
locale names over less specific ones, matching its own documentation,
except where the system backend supplies them in some other order.
This means a translation with the expected script and/or territory as
well as language will be used in preference to a generic one for just
the language, rather than only as a fall-back when the more generic
one is missing.

Fixes: QTBUG-102796
Change-Id: I3c7b3627afb51246df5a6ad0230e23b60af78071
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-04-27 17:03:54 +02:00
Alexandru Croitor
bf96f0eea0 tests: Blacklist tst_QLocalSocket::threadedConnection on Windows
As well as processConnection.

These tests cause flaky failures on Windows.

Pick-to: 6.3
Task-number: QTBUG-102880
Change-Id: Ie4bfe2ef40ad44efcfd0d83711ce257d1244ecdc
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-04-27 17:03:54 +02:00
Tor Arne Vestbø
aa0a53fc19 Don't declare type 'id' in the global namespace in a public header
It's not necessary, and it breaks the qttools build (where we have a
global variable named 'id'), and thus will most certainly build a lot
of existing user code.

Amends e47c22480f.

Change-Id: I97a91c2cb23fdae65143cf14c81570cf88d529d5
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-04-27 00:16:26 +02:00
Laszlo Agocs
b78f3f4974 rhi: Make QRhiRenderTarget's rp getter functional with swapchains
swapchain->currentFrameRenderTarget()->renderPassDescriptor() is not
functional at the moment, it returns null. This is because no backend
ensures that the internal renderpass descriptor object is exposed via
that getter in a QRhiSwapChainRenderTarget. Whereas in a
QRhiTextureRenderTarget this would work by design because there the
setter must be called by the user.

Fix this up, providing better API symmetry, and also reducing the need
to pass along QRhiRenderPassDescriptor objects seprately alongside a
QRhiRenderTarget in some places, e.g. in Qt Quick.

Change-Id: I42c4e9aaee3202c1d23bd093d840af80c5f8cd0f
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2022-04-26 19:46:21 +02:00
Edward Welbourne
f056eed02e Clear tst_QSettings of deprecation warnings
Assorted QMetaType and QVariant methods deprecated in Qt 6 were still
in use - the deprecation warnings were suppressed by setting
QT_DISABLE_DEPRECATED_BEFORE=0 - fix them and clear that suppression.

Change-Id: I1aa8f45dcb5a18449b060b346c80ad70536896ab
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-04-26 15:10:16 +02:00
Edward Welbourne
2d0c603cdb tst_QSettings::testVariantTypes(): modernize list initializations
Change-Id: Ia84cd7590f9bcc95a790efb1e1dab46ab368cd2d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-04-26 15:10:15 +02:00
Edward Welbourne
7b909dccc2 Convert tst_QSettings::testVariantTypes()'s macro body into a lambda
Retain the macro, so as to automate checking
QTest::currentTestFailed() after return from the lambda.

Change-Id: If5873a533224ea3b809cef02255642a7d071d642
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-04-26 15:10:15 +02:00
Edward Welbourne
2b16997116 Clean up tst_QSettings::testVariantTypes()
Give the macro and its parameters clearer names, wrap the macro body
in do {...} while (0), use QCOMPARE() rather than QVERIFY()ing
comparisons, convert the result type to QMetaType::Type rather than
QVariant's deprecated equivalent, save one macro parameter by using
decltype() on another. Simplify one check by pulling out a common
sub-expression as a local variable.

In the process, give the settings keys meaningful names rather than
just "key" with a numeric suffix.

Ideally this test would be reworked to be data-driven, instead of
using macros, but the use of qvariant_cast<> to convert a read-back
value, along with the variable type of the input value compared to the
result of that cast, precludes this (as far as I can see).

Change-Id: I4e083cd0dea14d723910873829352e15740006bd
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-04-26 15:10:15 +02:00
Edward Welbourne
af61bb018f Rearrange tst_QSettings::testVariantTypes()
Move the large block unrelated to the macro-driven parts to before the
macro is defined. This makes it clearer that it has nothing to do with
the macro-driven part of the test. This is, in any case, a more basic
test of behavior, so may as well go first. Rename the tested key in
the process.

Change-Id: I783fcd812e36320e9bb9765bab3ec09b56d6e6e6
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-04-26 15:10:15 +02:00
Edward Welbourne
cfc2973eec Remove two unused resource files from tst_qsettings
Change-Id: Ia54fa1ffa6e739496667d1486ee7e5658cd6a74f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-04-26 15:10:15 +02:00
Edward Welbourne
b0d55004b8 Inline a shared data-driven test table in tst_QSettings
Move its static populateWithFormats to before the class is declared
and make the _data() methods that call it (including one that did so
via another) inline so that we can see which are this simple - and
thus which aren't.

Change-Id: I71863244ba0e4bd188424b6a3f8d86d5d9f635a9
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-04-26 15:10:15 +02:00
Edward Welbourne
a7138c4fd1 Clean up includes involving tst_qmetatype_common.h
The functions it defines depend on many many types in QtCore for which
it did not have a #include; both files that included it thus had to
pull in QtCore to compile. Put that #include where it belongs and
clean out many specific QtCore includes that it makes redundant.

Change-Id: Ie9d9ec325d4879d771cb14baecb06fecbdaf62c5
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-04-26 15:10:15 +02:00
Laszlo Agocs
4f2b4e0e5e rhi: Add a feature flag for non-fill polygon modes
It's one thing that this is not part of OpenGL ES, but it is optional
even with Vulkan, with some mobile GPUs not offering the feature at all.

Change-Id: I4e2c6642eccb0793e69074b4b6eeb2b7cef3516e
Reviewed-by: Christian Strømme <christian.stromme@qt.io>
2022-04-22 14:34:46 +02:00
Sona Kurazyan
9eb090d683 Add support for unwrapping QFuture<QFuture<T>>
Added QFuture::unwrap() for unwrapping the future nested inside
QFuture<QFuture<T>>. QTBUG-86725 suggests doing the unwrapping
automatically inside .then(), but this will change the return type
of .then() that used to return QFuture<QFuture<T>> and might cause
SC breaks. Apart from that, QFuture::unwrap() might be helpful in
general, for asynchronous computations that return a nested QFuture.

[ChangeLog][QtCore][QFuture] Added QFuture::unwrap() for unwrapping the
future nested inside QFuture<QFuture<T>>.

Task-number: QTBUG-86725
Change-Id: I8886743aca261dca46f62d9dfcaead4a141d3dc4
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-04-21 20:25:13 +00:00
Mårten Nordheim
f08fd3c055 tst_QNetworkProxyFactory cleanup genericSystemProxy skipping
Instead of having Q_UNUSED and QSKIP in the test itself, we just skip in
the _data function.

Change-Id: I9da3d3104ec25e2645e5770e6392bd46958da072
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-04-21 22:25:12 +02:00
Richard Moe Gustavsen
5907a0a944 QApplication: deliver activation events for non-widget windows
Problem: if you create a hybrid Widgets and Quick Controls
application, you would need to use QApplication rather than
QGuiApplication. But in that case, the QQuickWindows would
never receive window activation events from QApplication.
And this causes problems for controls, since, for example,
the palettes in use there will never update upon activation
changes, and instead sometimes get stuck as e.g QPalette::Inactive
after application startup.

This patch will make sure that we send out activation events
also for QWindows that are not QWidgetWindows.

Pick-to: 6.3 6.2
Change-Id: I649f5c653081c0c5249f4faf28a7de2c92f17421
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-04-21 22:05:05 +02:00
Axel Spoerl
9ff40b59da Fix QDockWidget parenting and dock permissions
Check DockWidgetArea permissions of QDockWidgetGroupWindows with single
dock widget. Obtain a dock widget's tab position from a dock widget
group window if it can't be established otherwise. Remove hardcoded
assumption that a dock widget is in the left dock. Both cases have lead
to inconsistent entries and dangling pointers in
QDockAreaLayoutInfo::item_list.
Remove warning: QMainWindowLayout::tabPosition called with out-of-bounds
value '0', which becomes obsolete by the fix.
Create a QDockWidgetGroup window prepered to become a floating tab,
whenever a dock widget is being hovered over. Store it in item_list so
it can be found and deleted when required.
No longer call e->ignore() after propagating close events to the first
dock widget and thus preventing others from receiving the event.
Add logging category qt.widgets.dockwidgets
Update dock widget autotest with tests to check the fixes mentioned:
plugging, unplugging, hiding, showing, closing and deleting.
Blackist closeAndDelete, floatingTabs test on macos, QEMU, arm, android
due to flaky isFloating() response after a dock widget has been closed
or plugged.
QSKIP dockPermissions and floatingTabs test on Windows due to mouse
simulation malfunction.
QSKIP hideAndShow test on Linux in case of xcb error (QTBUG-82059)

Fixes: QTBUG-99136
Pick-to: 6.3 6.2
Change-Id: Ibd353e0acc9831a0d67c9f682429ab46b94bdbb0
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-04-19 17:12:20 +00:00
Morten Sørvig
8ae20c975a wasm: add fps counter to the rasterwindow test
Change-Id: Iddda72287119bc3ee6495d746ac75d64ff0c2f2c
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
Reviewed-by: David Skoland <david.skoland@qt.io>
2022-04-19 14:46:18 +02:00
Marc Mutz
a0858c639e tst_qstringapisymmetry: check toInt() etc also with base != 0
This shows we're lacking support for the 0b prefix, and, as it turns
out, there's a request for it.

Task-number: QTBUG-85002
Pick-to: 6.3
Change-Id: Ie201c84bf906a7e482b929301699ceb429b53c14
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-04-17 21:55:23 +02:00
Giuseppe D'Angelo
41a7546789 QDate(Time): add a addDuration method
To complement the existing addSecs / MSecs / etc., add a function
that takes any compatible std::chrono::duration.

QTime also features similar functions, but it's also "unique" in that
it uses modular arithmetic (it wraps around in case of "overflow").
I'm not so sure that adding durations to a QTime object therefore
makes sense, and I'm not doing it in this patch.

[ChangeLog][QtCore][QDate] Added addDuration().
[ChangeLog][QtCore][QDateTime] Added addDuration().

Change-Id: I02aa37ff024d7f56fa976dc8f4f73523bdba8d94
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-04-14 21:56:56 +02:00
Marc Mutz
3141a13b2a QFutureCallOutEvent: de-export again
A previous commit Q_CORE_EXPORTed this class so it could be used in
tst_qevent. But we can also keep it Q_AUTOTEST_EXPORTed and make the
testing of the class subject to QT_BUILD_INTERNAL on the test side.

That's what this patch does.

Change-Id: I9bd5f80ada856b7db4b39dfb59b32bd825416c13
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2022-04-14 19:07:16 +02:00
Marc Mutz
da0f72ebb8 QEvent: start to de-inline copy ctor and clone() of all subclasses
There's no advantage to them being inline: Absent de-virtualisation,
clone() is only supposed to be called through the vtable, and the copy
ctor is only supposed to be used in the implementation of clone().

And when the compiler de-virtualises, we don't want the code
duplication associated with inlining.

Enforce this by introducing new macros to hide the boilerplate.

This fixes missing out-of-line dtors in:
- QSinglePointEvent
- QApplicationStateChangeEvent
- QFutureCallOutEvent

Wrong covariant return in:
- QFutureCallOutEvent

And missing clone() reimplementations in:
- QCloseEvent
- QIconDragEvent
- QShowEvent
- QHideEvent
- QDragEnterEvent
- QDragLeaveEvent

While these don't carry extra data or members, a dynamic_cast of the
result of clone() as well as using the expected covariant return value
would fail:

   QShowEvent *e = ~~~;
   QShowEvent *e2 = e->clone(); // ERROR: converting QEvent* to QShowEvent*

Check that reimplementing clone() is binary compatible (covariant
returns may change the numerical pointer value returned, cf.
https://community.kde.org/Policies/Binary_Compatibility_Issues_With_C%2B%2B).

The copy-assignment operator stays inline for the time being, as the
goal is to = delete it in the future.

This patch covers, roughly, QtCore and QtGui.

[ChangeLog][QtGui][QEvent subclasses] Fixed missing clone()
reimplementations on QCloseEvent, QIconDragEvent, QShowEvent,
QHideEvent, QDragEnterEvent, and QDragLeaveEvent.

Task-number: QTBUG-45582
Task-number: QTBUG-97601
Change-Id: Ib8a0519dbe85a7a8da61050d48be338004dfa69a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-04-14 19:07:16 +02:00
Giuseppe D'Angelo
7de83f06c1 QDateTime: add conversions for time_point and zoned_time
In C++20, QDateTime is a direct equivalent of a sys_time<milliseconds>
time point. (Before, it might not have been, because system_clock before
C++20 was not guaranteed to be tracking Unix time, AKA UTC time without
leap seconds.) To be specific, sys_time<milliseconds> corresponds to
a QDateTime using the Qt::UTC timespec.

This patch:

1) adds named constructors taking time_points:

* a generic one taking any time_point convertible (via clock_cast) to
  a system_clock (this obviously includes system_clock, but also e.g.
  utc_clock)

* another couple taking local_time, interpreted as a duration from
  1/1/1970 in local time.

2) adds a named constructor from zoned_time (i.e. a sys_time + a
   timezone), that we can easily support via QTimeZone.

3) add conversion functions towards sys_time, matching the existing
   to(M)SecsSinceEpoch() functions.

[ChangeLog][QtCore][QDateTime] QDateTime can now be constructed
from std::chrono::time_point objects (including local_time), as
well as from std::chrono::zoned_time objects. Moreover, they
can be converted to std::chrono::time_point using system_clock
as their clock.

Change-Id: Ic6409bde43bc3e745d9df6257e0a77157472352d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-04-13 18:45:54 +02:00
Giuseppe D'Angelo
2e29f55f76 QDate: add conversions for std::chrono calendaring classes
std::chrono::year_month_day and related classes offer very
convenient to specify dates.

This patch adds implicit constructors to QDate to support this
convenience, e.g.:

  // YYYY-MM-DD, DD-MM-YYYY, MM-DD-YYYY formats:
  QDate d1 = 1985y / December / 8;
  QDate d2 = 8d / December / 1985;
  QDate d3 = December / 8d / 1985;

  // Indexed weekday:
  QDate d4 = 2000y / January / Monday[0];
  QDate d5 = 2000y / January / Monday[last];

and so on.

These are all implemented using the conversion from the std
calendaring classes to sys_days. Conversions between sys_days
and QDate are also added, since they're basically "for free".

I don't expect "ordinary" users to stumble upon it, but it's
worthy mentioning that std::chrono::year *does* have a year
zero (hence, year_month_day in year 0 or below are offset
by one with the corresponding QDate). I've left a note
in the documentation.

[ChangeLog][QtCore][QDate] QDate (and therefore QDateTime)
is now constructible using the year/month/day/week classes
available in the std::chrono library. Moreover, it now
features conversions from and to std::chrono::sys_days.

Change-Id: I2a4f56423ac7d1469541cbb6a278a65b48878b4a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-04-13 18:08:38 +02:00
Giuseppe D'Angelo
33c88f86b5 QAbstractProxyModel: do not access invalid indexes
QAbstractProxyModel::headerData tries to do the "smart" thing and
map sections in the proxy to sections in the source. However there's
no "mapSectionToSource" virtual. Instead, to map horizontal headers, the
code builds a proxy index at row 0 and section N, maps it to the source,
and finds out which source column it gets mapped to. (Same story
for the vertical headers).

... in general this can obviously fail, say you've got a "horizontal
scrambling" proxy model, but in the common case this is OK.

Except, if the proxy is empty (e.g. 0 rows or columns). In this case,
it asks for an illegal index, and if you reimplemented index() yourself
(which you must, since it's a pure virtual in QAPM) and you do bounds
checking, you'll not be pleased at the result.

This turns out to be a massive API liability. To fix this somehow properly,
we can decide that empty models don't get the section remapped (easy).
Less easy is the fact that, when the model does get some data, we have to
emit headerDataChanged() otherwise the views will get broken. So add
this logic too.

Note that QAPM does not normally forward any source model's signal -- a
subclass has to connect to them and handle them explicitly. That's
*another* API liability, all over the place -- data(), headerData(),
flags(), etc.

What I mean by this is that one can create a valid QAPM (by implementing
its pure virtuals) that however is immediately broken by the convenience
that QAPM provides for the rest (data(), headerData(), etc.).

This commit doesn't try and change this in any way, but I'm less and
less convinced of the usefulness of QAPM in its current shape.

Change-Id: I45a8c2139f2c1917ffbf429910fdb92f005f4feb
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: David Faure <david.faure@kdab.com>
2022-04-13 18:08:38 +02:00
Marc Mutz
ef895869b4 QVarLengthArray: add missing (size, value) ctor
Extend the corresponding test in tst_containerapisymmetry.

[ChangeLog][QtCore][QVarLengthArray] Added (size, value) constructor.

Fixes: QTBUG-102469
Change-Id: I4802eebe6ba1a6835e4d6f41e1d3db2a0d7c7894
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-04-13 08:10:47 +02:00
Giuseppe D'Angelo
0a17a0da61 QDateTime: add support for std::chrono::duration arithmetic
QDateTime represents a specific point in time, so arithmetic
with durations makes perfect sense.

Moreover, we can finally equip QDateTime with a subtraction
operator, to calculate the duration between two QDateTime
objects.

[ChangeLog][QtCore][QDateTime] QDateTime now supports arithmetic
between QDateTime objects and std::chrono::duration objects.
A duration can be added to or subtracted from a QDateTime, yielding
another QDateTime; and two QDateTime objects can be subtracted
from each other, yielding the duration between them.

Change-Id: I656419f3bb9418c49f0e2fd0800c3dbaaf6aff32
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-04-13 01:24:04 +02:00
Morten Johan Sørvig
d99e8d96b6 wasm: make rasterwindow use non-deprecated API
Pick-to: 6.3
Change-Id: I17f2c9517cb8b8e7103fc40068580f953ceb6aff
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
2022-04-12 19:33:35 +01:00
Giuseppe D'Angelo
69555b364d QTimeZone: add construction from std::chrono::time_zone*
A time_zone represents a timezone identified by its IANA ID. This
allows for a straightforward conversion to QTimeZone.

[ChangeLog][QtCore][QTimeZone] QTimeZone can now be constructed
from a std::chrono::time_zone pointer.

Change-Id: I093d9fc2e989475d30730a9dcdef491903a2aeb2
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-04-12 20:26:55 +02:00
Dimitrios Apostolou
f9f1085735 Skip test that fails with Address Sanitizer enabled
These particular testcases request huge buffers from malloc() .This is
intentional and the test expects malloc() to return NULL. Address
sanitizer catches this and considers it a problem.

Could also be skipped in runtime by setting the environment variable:

  ASAN_OPTIONS=allocator_may_return_null=1

Task-number: QTBUG-89400
Change-Id: Id3a9b586be9c0bad4a007e1731f2bc1a879cc76e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-04-12 00:48:17 +02:00
Marc Mutz
ba0c2c4b46 tst_qsslsocket: remove tons of deprecation warnings
The TLS v1.0 and v1.1 enums are all deprecated since 6.3. At the same
time, the test requires their use, because none of the peers seeem to
implement TLS v1.2, yet (cf. e.g. QTQAINFRA-4499).

Fix by copying the relevant enum values into global variables and
using those. This is a selective way to deal with the issue. The use
of the enums is so widespread in the test that the alternative would
have been to globally suppress deprecation warnings, which, however,
may suppress warnings we may actually want to fix.

Pick-to: 6.3
Change-Id: I4186be72209527fc404f3ba0a5a15f9719c64698
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-04-12 00:48:17 +02:00
Jarek Kobus
b49f7e064c Ensure that readAllStandardError() doesn't crash on assert
Ensure that it's safe to call readAllStandardError()
when process channel mode is set to MergedChannels.

Pick-to: 6.3 6.3.0
Task-number: QTBUG-102177
Task-number: QTCREATORBUG-27196
Change-Id: I01073255d9347dee4654d602802a12d341372b73
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-04-09 20:31:11 +02:00
Liang Qi
09e9f45933 xcb: get geometry correctly for rotation with RAndR 1.5
xcb_randr_get_crtc_info() returns already rotated size.

Pick-to: 6.3
Change-Id: I33eacf988b44cea77411ad79ae24fef7e8e1564e
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-04-08 18:30:17 +00:00
Liang Qi
4609cc8631 xcb: compare with screen name instead of old monitor info
because the old xcb_randr_monitor_info_t was invalid very often
during update.

Pick-to: 6.3
Change-Id: I8c0bda93bde4e816fc98cde1a7205c6369ab39e1
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-04-08 20:30:17 +02:00
Ivan Solovev
44f3fe1cf4 Android: use BCP 47 tag to create a correct Locale for QTimeZone::displayName()
Before the patch we tried to create a java Locale object by passing the
human-readable language, territory and variant strings. However, the
Locale constructor accepts ISO-defined codes.

Fix it by using a factory method Locale.forLanguageTag() [0] that
constructs a Java Locale object based on BCP 47 tag.

[0]: https://developer.android.com/reference/java/util/Locale#forLanguageTag(java.lang.String)

Fixes: QTBUG-101460
Pick-to: 6.3 6.2 5.15
Change-Id: If414c66cf0e5b7e8299ffc3a6038b6f9eb79d5ec
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2022-04-08 00:13:01 +02:00
Edward Welbourne
9fee35a2ed Fix assertion failure when parsing a doubly-invalid date-time text
When the date-time string falls in a spring-forward (so is invalid)
and one of the fields of the parsed string doesn't match the format
it's meant to (e.g. a single-digit seconds field when format ss was
specified), a check that the current fall-back date-time is between
the minimum and maximum for the parser object failed, triggering an
assertion.

In any case, an invalid default-value wasn't useful to the code that
parsed a single section of the date-time string, so brute-force the
current value to a valid date-time (when possible) using the usual
round-trip via milliseconds since the epoch.

Added the test-case which first revealed the problem, plus a couple
more informed by it, to exercise the same code-paths with fewer things
failing.

Fixes: QTBUG-102199
Pick-to: 6.3 6.2 5.15
Change-Id: I658308614505ef25f4c97d0de6148acb54a65a0f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-04-07 23:04:04 +02:00
Edward Welbourne
d82301a900 Don't use QSKIP() when merely eliding part of a test
Use of QSKIP() means the whole test is skipped; when all applicable
parts of a test have passed and some part of the test is inapplicable,
merely report that it is skipped, rather than discarding the PASS for
all the parts that do work.

In the process, eliminate a spurious layer of indentation; the earlier
test only needed a scope to contain its declaration, a goal adequately
achieved by the scope of the if constexpr block.

Task-number: QTBUG-99123
Pick-to: 6.2 6.3
Change-Id: Ie4790a24ebf49a7f3035ffad42d78450e1560832
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-04-07 22:04:04 +01:00
Timur Pocheptsov
8b446859de tst_QTcpSocket: remove redundant include
... a leftover from the initial patch-set not required in the one that
merged.

Change-Id: I0c5e94d8a0409faf4f7f9a354e98e239f7186da3
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-04-07 22:45:05 +02:00
Sona Kurazyan
80363889fe Replace uses of _qba with _ba
Task-number: QTBUG-101408
Change-Id: I5175428c2be934b09f45bd06b0b47643003e25c7
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-04-07 19:30:17 +02:00
Sona Kurazyan
a885f28933 Replace uses of _qs with _s in tests
Task-number: QTBUG-101408
Change-Id: If092a68828a1e8056259cf90d035d9a87989244b
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-04-07 19:30:17 +02:00
Pasi Petäjäjärvi
9e0ba8b927 CI: Blacklist failing networks tests for QNX qemu
Most likely related to qemu network configuration which cannot be
modified. Reason is that in QNX there is tool which can be controlled
qemu configuration, and it does not provide options for more finer
grade network configuration.

Pick-to: 6.2 6.3
Task-number: QTBUG-101274
Change-Id: I660466e36252e902a2314fb3f4988c531cda9214
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-04-07 15:39:22 +03:00
Sona Kurazyan
8aa3cf21da Add literal operators for QString/QByteArray to StringLiterals namespace
[ChangeLog][QtCore] Added literal operators for _s and _ba for QString
and QByteArray respectively in the Qt::Literals::StringLiterals
namespace.

Task-number: QTBUG-101408
Change-Id: I5cd4e7f36f614ea805cfecc27b91c5d981cd3794
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-04-07 09:22:28 +02:00
Ivan Solovev
7c9afa8d00 Q[Multi]Hash: fix squeeze()
When calling QHash::reserve(), or when creating the
internal QHashPrivate::Data structure, the value 0
for the size parameter is reserved for performing
the squeeze operation.

However commit 8a984ab772
broke it, by using the 0 value in QHashPrivate::Data
constructors as a mark that no resizing needs to be done.

This patch reverts the problematic commit (also applying
some later fixes to the code), and adds the missing
tests for Q[Multi]Hash::squeeze().

Pick-to: 6.3 6.2
Change-Id: Id644df7b2beb008e6a37b2c89b709adfbd893e25
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-04-06 16:46:59 +02:00
Ivan Solovev
d11941db41 Q[Multi]Hash::reserve(): do nothing if desired size is less than current
Calling Q[Multi]Hash::reserve(n) when n is much smaller than the
current amount of elements in the hash, could result in an infinite
loop, because at some point the algorithm could not find a free bucket
for the element.

Fixing it by returning early if the new desired capacity is less than
current.

Fixes: QTBUG-102067
Pick-to: 6.3 6.2
Change-Id: I38ef0b2168c4e2a317eedf91b2155b1fdffb1c27
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-04-06 16:46:59 +02:00
Eirik Aavitsland
0ff7328f37 Improve surface format request for baseline test of GL painter
Different platforms and drivers hae different defaults, so make sure
to request what we need.

Pick-to: 6.3 6.2
Change-Id: I54ae6e0770fea53fbf59c86d7e55aa5897292b67
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2022-04-06 12:44:40 +02:00
Marc Mutz
a00a1d8806 QByteArray/QVarLengthArray: add missing resize(n, v) overloads
QList and QString had them, so add them to QByteArray and
QVarLengthArray, too.

In the QVLA case, we need to jump though a hoop or two to avoid having
to duplicate all the reallocation logic. Nothing a few template tricks
cannot solve.

[ChangeLog][QtCore][QByteArray] Added resize(n, ch) overload.

[ChangeLog][QtCore][QVarLengthArray] Added resize(n, v) overload.

Fixes: QTBUG-102270
Change-Id: I0d281ae5b574f440f682e4a62427b434dcf5b687
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-04-06 10:44:40 +00:00
Marc Mutz
0c1f9ab36b benchmarks: fix deprecation warnings
- count() -> size()
- QCryptographicHash::addData(ptr, ch) -> ({ptr, ch}) (QByteArrayView overload)

Pick-to: 6.3
Change-Id: I15dddfa5c4385dd2a0fa0c3ae06c303c7151e2dc
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-04-06 12:44:40 +02:00
Pasi Petäjäjärvi
a322af7df4 CI: blacklist fromHtml:preformats with embedded backticks for QNX
Pick-to: 6.2 6.3
Task-number: QTBUG-100515
Change-Id: I82b06ef1d2e275e256f8d811bc70f425c6e6bf7e
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2022-04-06 11:42:55 +02:00
Marc Mutz
4bc85b9850 QBuffer: fail early in seek() beyond QByteArray's max capacity
On 32-bit platforms, the range of qsizetype is smaller than the range
of the qint64 used as a parameter in seek().

When seek()ing beyond the current buffer's size, the old code relied
on a write() to fill the gap with NUL bytes. This has two problems:

First, this may allocate a huge amount of memory just to find that it
cannot write that much, possibly even taking the program down when the
allocation in the QByteArray ctor fails, instead of returning false from
seek().

Second, the QByteArray ctor to which we pass the gapSize only takes
qsizetype, not qint64, so we were writing data of size gapSize mod
(INT_MAX+1) on 32-bit platforms, which may succeed, just to find that
that wasn't the number of bytes we expected to be written. By that
time, however, the internal buffer has already been enlarged.

Fix by checking whether the desired seek position is within the limits
that QByteArray can contain early on, before attempting to construct
such a large QByteArray.

[ChangeLog][QtCore][QBuffer] Fixed silent data corruption on 32-bit
platforms when seek() fails due to position > INT_MAX.

Pick-to: 6.3 6.2 5.15
Fixes: QTBUG-102274
Change-Id: Ib63cef7e7e61ef8101a5f056c7b2198bb7baa228
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-04-05 20:34:44 +00:00
Andreas Buhr
ea6f556186 Activate tst_qmessagebox for Android
tst_qmessagebox was disabled because it crashed.
It does not any more. Now it hangs, which
is a new problem.

Fixes: QTBUG-87671
Task-number: QTBUG-101217
Pick-to: 6.2 6.3
Change-Id: Iec15cf82a4112ee79182ec091622e40147bd3e7f
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2022-04-05 18:40:17 +01:00
Laszlo Agocs
a5db072dc2 rhi: Add explicit subclass for RTs from swapchains
We want to enable gaining access to the underlying resource(s) by
inspecting a QRhiRenderTarget. This is not currently possible for
swapchains since there is nothing that references the actual
QRhiSwapChain. To clean this up, make an explicit, new
QRhiSwapChainRenderTarget subclass. Thus the logic already used in a
couple of places to examine the resources attached to a
QRhiTextureRenderTarget can now work with swapchain render targets too,
by branching based on the resourceType().

This eliminates the somewhat odd setup where a "RenderTarget" resource
is QRhiRenderTarget corresponding (but not exposing!) a swapchain,
whereas a "TextureRenderTarget" is a QRhiTextureRenderTarget which
is a subclass of QRhiRenderTarget. Now we correctly have an (abstract)
base and two subclasses, one for each type of render targets.

Besides, it allows us to clean up the oddly named
Q...ReferenceRenderTarget classes in the backends, which initially tried
to indicate that this "render target" merely references (or, in
practice, is) a swapchain. We can now have a nice and symmetrical
Q...SwapChainRenderTarget and Q...TextureRenderTarget naming scheme.

Change-Id: Ib07e9be99a316eec67b94de0860e08f5f4638959
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2022-04-05 19:40:17 +02:00
Nodir Temirkhodjaev
99f22e3fc8 QSplitter: Don't move handle in non-pressed state
Fixes: QTBUG-102249
Pick-to: 6.2 6.3
Change-Id: Ib1d74447e346760d1fc9960e11486e8dc7ea3bc0
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2022-04-05 17:03:40 +03:00
Pasi Petäjäjärvi
6c760f8cef CI: Blacklist mixedScripts for QNX
QNX tests are run under QEMU so have the same problem as Ubuntu.

Pick-to: 6.2 6.3
Task-number: QTBUG-100928
Change-Id: Id7c7639b743062c777502e2ba8b28f9bb18deb19
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2022-04-05 12:27:49 +00:00
Assam Boudjelthia
855ca9f48a Android: skip flaky tst_qcalendarwidget::showPrevNext()
Pick-to: 6.2 6.3
Task-number: QTBUG-102258
Change-Id: I96b5003e0b4266250e526439370603b47562cdea
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2022-04-04 14:27:22 +03:00
Marc Mutz
61157c8354 QBuffer: fix writing more than two GiB of data
In Qt 6, QByteArray can hold more than two GiB of data on 64-bit
platforms, so QBuffer should be able to handle writes of more than two
GiB, too. But the implementation didn't check for overflow and held
sizes in int variables, so it happily reported success but wrote data
only mod INT_MAX.

Fix by carefully avoiding overflow and using size variables of proper
type.

[ChangeLog][QtCore][QBuffer] Fixed silent data truncation when writing
more than two GiB at once on 64-bit platforms.

Pick-to: 6.3 6.2
Fixes: QTBUG-102171
Change-Id: Ib666f9f7db24495b4ed64191a48b35edc410f7e9
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2022-04-04 08:17:09 +02:00
Ivan Solovev
6f725e6ef9 Revert "Activate all tst_qgridlayout tests on Android"
This reverts commit b39d3cfe30.

Reason for revert: the test fails in dev again

Task-number: QTBUG-87404
Change-Id: Icc51e36e037e9c7e8154266def129dd8ad412775
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2022-04-02 16:57:32 +00:00
Assam Boudjelthia
c5dd2c1f35 Android: skip few tst_qopenglwidget tests that crash on CI
To allow other cases to run while finding the reason. Most of these
cases fail only on CI and not locally.

Pick-to: 6.3 6.2
Task-number: QTBUG-102043
Change-Id: Ib552ab00b4232f6aabdf85acf050633251d9e71d
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2022-04-02 15:23:58 +03:00
Edward Welbourne
9e1a2b4603 We do in fact support 'F' format for floating-point values
Update docs and add tests.

[ChangeLog][QtCore] Documented existing support for 'F' format when
converting floating-point numbers to strings in QLocale::toString(),
hence equally for QString's floating-point formatting. Previously it
was supported but the documentation neglected to mention it; it only
differs from 'f' for infinities and NaN.

Change-Id: Ic946c0f7b9e86fdf512daa3124bea57fc664b34b
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2022-04-01 23:11:35 +02:00
Edward Welbourne
2e044791b8 Move some purely floating-point testing from tst_QLocale to tst_QNumeric
The testing of infinity and NaN somewhat duplicated existing tests in
tst_QNumeric and, in any case, belongs there.

Change-Id: I6b5d1ff9767daf8e4bbe0025d3efab3d74ed35de
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2022-04-01 23:11:35 +02:00
Edward Welbourne
3a2e3625d1 Use constants of the correct type in qnumeric NaN test
Replaces 0, 0.0, 1, 1.0 and 2.0 with zero, one and two constants of
the templated floating-point type, to avoid type-conversions which
might have meant the test only checked doubles, or similar.

Change-Id: Id9d4488f0cc7226b5b8958d2a204a76fe5ae469d
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2022-04-01 23:11:34 +02:00
Edward Welbourne
67a563e5c5 Clean up and modernise tst_QLocale::fpExceptions()
Use the modern "portable" _clearfp() and _controlfp(), that work
regardless of the hardware MS is running on, rather than the
x86-specific _clear87() and _control87(); and move some defines into
the #if-ery context in which they're used, rather than defining them
regardless of whether they're used.

Change-Id: I13abf2c85525b1182b99bc2c366aadd6b5fc656f
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-04-01 23:11:34 +02:00
Mårten Nordheim
50a5ef9945 tst_QIODevice::unget() without network: skip only the affected part
Instead of QSKIPing the whole test, ignoring what was already tested

Change-Id: Iced928ce1bce92b447c8698a9942973cb78b6c15
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-04-01 23:03:58 +02:00
Sona Kurazyan
a3f7dd5260 Allow brace initialization for some of QLatin1StringView constructors
Removed "explicit" keyword from constructors taking
(const char *, qsizetype) and (const char *, const char *).

Switched to using brace initialization for creating QLatin1StringView
in QtCore.

[ChangeLog][QtCore][QLatin1StringView] The (const char *, qsizetype)
and (const char *, const char *) constructors are no longer explicit.

Change-Id: I4f6760692e4df60fe4231e86a25f6ea03cd1bf82
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-04-01 19:33:12 +01:00
Pasi Petäjäjärvi
1032cc54ea Revert "Blacklist: test cases blacklisted in tst_QSystemSemaphore:"
This reverts commit 797a6ca7e6.

Reason for revert: Fixed 98de89cc15

Task-number: QTBUG-101618
Change-Id: I49c59715b8880bd89cc5cd0c8b3443a834689bab
Reviewed-by: Heikki Halmet <heikki.halmet@qt.io>
2022-04-01 08:00:39 +00:00
Sona Kurazyan
de6a004bc5 tst_QByteArrayView:: disable failing constexpr checks for GCC
When comiling with ubsan, GCC is being too restrictive and ignores that
'static constexpr char []' can never be nullptr. It tries to evaluate
the comparison with nullptr, and fails with:

 error: ‘(((const char*)(& hello)) == 0)’ is not a constant

Disable the checks when compiling with GCC.

Fixes: QTBUG-101307
Pick-to: 6.3 6.2
Change-Id: I8322bb7cb326e06cd03b8b107c46a494c825087b
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-04-01 09:51:29 +02:00
Tor Arne Vestbø
496bf5a946 lance: Handle unspecified size or weight in setFont command
We have test cases that call setFont without a specified weight, in
which case we would end up parsing an empty string into a number,
giving a weight of 0. This weight would in turn result in the
thinnest font on the system, which presumably was not the intent.

We now use default sizes and weights (similar to the default QFont
constructor arguments) if we're missing those arguments to setFont.

Pick-to: 6.2 6.3 5.15
Change-Id: I5a96f08cfa1b9e4f1de5edee6bf69ddd46f0ce92
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2022-03-31 20:54:29 +02:00
Edward Welbourne
3febcd6286 More startOfDay() fixes, in tst_bench_QDateTime
Update a QDateTime benchmark to use QDate::startOfDay() when setting
up its lists of date-times in helper functions, and to use noon as the
moment in the day in a creation test. Also move creation of a QTime
outside the loop: we're testing speed of creation of QDateTime here,
not QTime (and were already using the most trivial QTime constructor).

Change-Id: I26bf3369aae84a802ab03791f7341e107fede87c
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-03-31 17:42:47 +02:00
Qt CI Bot
c168edba21 Merge integration refs/builds/qtci/dev/1648720546 2022-03-31 14:02:01 +00:00
André de la Rocha
4114a0ea75 Windows QPA: Fix slowdown with large table/tree views with accessibility
The accessibility code for notifying focus changes related to a
table/tree view was iterating over all items to find the focused one,
which for a very large number of items could cause a major slowdown
and UI freeze. This patch avoids the issue by removing the loop and
implementing the focusChild() method in the table/tree accessibility
classes.

Fixes: QTBUG-100997
Pick-to: 6.2 6.3 5.15
Change-Id: I04c847a5e65223b7a93ab82363feb32e1ebab9f3
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-03-31 09:04:09 -03:00
André de la Rocha
37b702dc12 Windows: Fix accessibility tests
Accessibility tests were not being built on Windows as they were
depending on a WindowsUIAutomationSupport internal module that no
longer exists, as the UI Automation support classes are now in QtGui.
The patch also fixes a test that was calculating widget geometry
incorrectly on high DPI screens.

Pick-to: 6.2 6.3
Change-Id: Iefed0f6d147853484dfab4b16838b9088fd32dcf
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-03-31 09:04:08 -03:00
Ivan Solovev
aa451b13b0 Android: enable tst_QScreen::grabWindow
Two things are done here:
- use showNormal() instead of show() to get an expected widget size.
- skip the test if HighDPI scaling is enabled with non-integer scaling
  factor, because there can be rounding errors.

Fixes: QTBUG-87390
Pick-to: 6.3 6.2
Change-Id: I653a17bac2142838b03a328e1629582384b6c7b3
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2022-03-31 11:48:54 +01:00
Mårten Nordheim
8367be8ede QNetworkInformation: Deprecate vague load functions
And replace them with more descriptive versions

Change-Id: I3d5256072a5bbe0919a08b800877aa9b6a305a0b
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2022-03-31 11:54:42 +02:00
Edward Welbourne
605c747321 QSettingsPrivate: fold from/to parameters into the view they bound
Two methods of the private class used to take a QByteArray with from
and to indices into it, for where to start and stop a scan. Now that
they take a QByteArrayView, those parameters can be used by the caller
to shorten the view to the desired portion.

Change-Id: Id1586afb87a9e8a189b69e485278375ff504fb7b
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2022-03-30 21:37:24 +02:00
Assam Boudjelthia
d1d96a3cdd Android: skip crashing tests tst_QOpenglWidget::clearAndResizeAndGrab()
Skip the crashing case temporarily to allow other tests to run
while finding a fix.

Pick-to: 6.2 6.3
Task-number: QTBUG-100470
Task-number: QTBUG-102043
Change-Id: I8b16f95e5c66b95cc9959494b5317d39d58194e6
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2022-03-30 21:55:21 +03:00
Pasi Petäjäjärvi
8e08286d45 tst_QNetworkInterface: Update network test server handling
Adds docker support and makes it no longer skip the whole test
if there is no docker or network server.

Pick-to: 6.2 6.3
Change-Id: Ie98496df338a804d5c9842cce372e3410fdf9990
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2022-03-30 17:33:08 +00:00
Pasi Petäjäjärvi
82188607e3 CI: Add docker support for qnetworkaccessmanager_and_qprogressdialog test
Currently test relies solely for external test server. This makes it
not possible to run test successfully with environment where docker is
used.

Pick-to: 6.2 6.3
Change-Id: I51f4f48a80c1be8dd24359fe24d9cbfd471d2195
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-03-30 19:33:08 +02:00
Ivan Solovev
ad9f748db5 Android: skip tst_QNetworkProxyFactory::genericSystemProxy
Android uses its own implementation of QNetworkProxyFactory, so the
test of a generic implementation will never be working there. The
"http_proxy" environment variable is simply ignored in Android's
implementation.

Fixes: QTBUG-87385
Pick-to: 6.3 6.2
Change-Id: I3c24e3481b70872d332310aa86c68adad9c2b7e6
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-03-30 19:05:59 +02:00
Ivan Solovev
7c9b4f86b6 Android: activate tst_QPluginLoader
- Use QT_ANDROID_EXTRA_LIBS to correctly deploy libraries on Android.
- Update the test code to use application libraries directory
  on Android.

This allows to enable the test for Android in CMakeLists.txt

Task-number: QTBUG-87438
Pick-to: 6.3 6.2
Change-Id: Ib74da036472320736888052b63a45ca50431de48
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2022-03-30 19:05:59 +02:00
Ivan Solovev
ed6fe5abc8 Android: activate tst_QLibrary
On Android we demand the libraries to always start with "lib" and
end with ".so" extension. Also Android does not support versioned
libraries.

This patch updates CMakeLists.txt to fulfill these requirements,
and also omits some unsupported test cases.

This allows to enable this test for Android in CMakeLists.txt

Task-number: QTBUG-87438
Pick-to: 6.3 6.2
Change-Id: Iec30acdefe00c471acc7139cd255b3389e31d22b
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2022-03-30 19:05:59 +02:00
Edward Welbourne
784f5d76b9 TAP test logger: report B?XFAIL (mostly) as a message
Previously, only the first B?XFAIL would be reported, all others would
be discarded. Furthermore, if a B?XFAIL had happened, B?PASS was also
not reported, since the B?XFAIL served as test line. However, if the
B?XFAIL was followed by a SKIP, B?XPASS or B?FAIL, these were reported
as normal, producing exactly the kind of duplicated test line that the
skipping of B?PASS was meant to supply.

So change B?XFAIL to be reported among the messages, but retain the
TODO annotation of the first on the test line of a subsequent B?PASS,
if nothing more drastic happens in the mean time. So now more than one
B?XFAIL can be reported, the test is still marked as a TODO and we
don't get duplicate test lines for a subsequent non-passing result.

This replaces the bool m_wasExpectedFail member with a QTestCharBuffer
m_firstExpectedFail that records the first XFAIL's TODO line (so its
isEmpty() fully replaces m_wasExpectedFail).

Previously, the at/file/line information for a B?XFail would be
supplied as top-level keys in the YAML block for a "Pass" reported as
not ok due to the XFail, as this location information is now part of
the B?XFail's message in the extensions/messages block. Duplicating
the first B?XFail's location at top level would add complexity and is
arguably misleading, as the test result is really a pass (after
ignoring known issues), and the location of the pass is indeterminate
(nominally the end of the test function, but actually also after the
cleanup() call for this test, when relevant), which is why a Pass has
no location information.

Task-number: QTBUG-96844
Change-Id: Ib3f24f56266ff49bf3bc9759ac8263ac69a62130
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-03-29 22:21:58 +02:00
Edward Welbourne
ac38401d31 Move TAP's messages block to after the primary report details
In the process, split it from its comments block and don't bother with
a YAML block if it would only have contained comments.

Task-number: QTBUG-96844
Change-Id: I08c20f796252bb270ba9caa4c055cdcc0843a88b
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-03-29 22:21:58 +02:00
Edward Welbourne
299186602a Add a test and remove a work-around for a fixed bug
The ASN.1 parser for a date-time had to check the date-time string was
all digits to catch the case of a sign in the month field, which used
to be accepted when it should not be. That bug has now been fixed, so
remove the work-around and add a second date-time test-case, renaming
(and modernising) the existing one for consistency.

Task-number: QTBUG-84349
Change-Id: I649c5129312b6865af08b22ba6893cb4e29243f8
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2022-03-29 22:21:57 +02:00
Ivan Solovev
d85c6527b5 Android: fix fullscreen handling
Commit a35a7fcb5a introduced the usage
of insets to correctly take into account the default Android status bars
and other reserved regions.

However in practice that does not work as expected - the bottom inset
is always reported to be non-zero, even when fullscreen mode is enabled.
To fix the issue, FLAG_FULLSCREEN is explicitly checked before applying
the insets.

Fixes: QTBUG-99624
Pick-to: 6.3 6.2
Change-Id: I8b25f0b06447cd452c42ef072493e3137e25f38b
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2022-03-29 13:56:14 +01:00
Ivan Solovev
3033d89674 Android: activate tst_QWidget
Fix some obvious issues, QSKIP or blacklist other problems.
This does not fix all the test failures, but allows to enable most of
the test cases, so that we could catch future regressions.

Task-number: QTBUG-87668
Pick-to: 6.3 6.2
Change-Id: I1ed0b476d4ac55c658c572cfa1379fcdc6137ee8
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2022-03-29 13:56:14 +01:00
Ivan Solovev
2a893db480 Android: enable tst_QLocale
Do not try to properly specify a path to an external syslocale app,
because the related test can't be executed on Android anyway.
This fixes a failure in initTestCase() and allows to unblock other
test-cases.
Also skip systemLocale() test, because Android platform plugin already
creates a custom QSystemLocale instance, so a hack with MySystemLocale
does not work.

As a drive-by: simplify the #ifery in initTestCase() and remove an
unused second parameter of QSKIP() in emptyCtor_data().

Fixes: QTBUG-87414
Pick-to: 6.3 6.2
Change-Id: Iefc587062362469856fdca77f9ec9d96f5552e45
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2022-03-29 13:56:14 +01:00
Ivan Solovev
9578a3f72f QFileSystemWatcher: Blacklist failing tests on macOS arm
The tests started failing for some reason, so blacklist them to
unblock the CI.

Task-number: QTBUG-102095
Task-number: QTBUG-102096
Change-Id: I3e0667581bb1a9fd08dedcdab08878b1f738ac92
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-03-29 00:39:20 +00:00
Edward Welbourne
7d60fde9a7 Include file and line information in TAP diagnostics blocks
When producing a diagnostics block, include the file and line
information, if we have it, to describe it. This presently only adds
this information for skip, but could in principle do the same for a
B?XPass.

Task-number: QTBUG-96844
Change-Id: I6cc375d98e2369eba262010f9c2dfbcba931a6f1
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-03-29 00:05:12 +01:00
Edward Welbourne
ae37fa0464 TAP test logger: move messages into the diagnostics block
Our TAP output was delivering messages as comments before the test
line, where TAP clearly expects the details of a test to follow its
test line. Version 13 provides a YAML block to deliver diagnostics and
encourages use of this, so accumulate our messages in a
QTestCharBuffer instead of emitting them one by one.

However, messages produced after a test has produced its test line
belong to that test, but are too late to be included in its
diagnostics block, so should be emitted immediately as before, albeit
now with a type prefix. This at least separates such messages, from
the end of one test, from messages produced early in the next.

In the process, add a type-prefix to each, to make clear what type of
message it was. Since the Yamlish supported by TAP consumers doesn't
support a way to have many messages, use the extensions: top-level
hash tag with a messages: sub-tag to gather our messages as a list.
(This expands at least one expected output file significantly and
substantially rewrites some others.)

Add methods to QTestCharBuffer, and a helper function, to support this.

Task-number: QTBUG-96844
Change-Id: If44a33da5879ed1670ef0980042599afd516f9d2
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-03-29 00:05:12 +01:00
Ivan Solovev
d329a98fa9 Android: re-enable skipped tests
Now when 71b3d18ea7 is merged,
we can re-enable the previously skipped tests, as they do
not crash anymore.

Task-number: QTBUG-101423
Task-number: QTBUG-101321
Task-number: QTBUG-87417
Pick-to: 6.3 6.2
Change-Id: I6b4b3619b0af5e48b5e92b514bc0ab6586a76d51
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2022-03-29 00:01:30 +02:00
Ivan Solovev
9a4c32cedd Android: unblacklist tst_QStringConverter::convertUtf8()
The test was failing because test data was not provided correctly.
That was fixed in 4aea86f5e8 but the
test was never unblacklisted.

Fixes: QTBUG-87418
Pick-to: 6.3 6.2
Change-Id: Ibef7dcfaf59ef50f90d6538a562d03af17f065e0
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2022-03-28 08:52:31 +01:00
Marc Mutz
edb64351cd QDom: preserve empty CDATA sections
Restores Qt 5 behavior.

Fixes: QTBUG-101992
Pick-to: 6.3 6.2
Change-Id: I3b9fc077c0a0fd30f4fcce7bfa342dbe96b2c582
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-03-26 12:01:14 +01:00
Volker Hilsheimer
e709e254d7 Make QUnixEventDispatcherQPA XFAIL the test
Needed for QNX, don't be overly specific with XcbUnix.

Pick-to: 6.3 6.2
Change-Id: I240313bc48d9d81d1f18f27ee11f7c9352e3e452
Reviewed-by: Pasi Petäjäjärvi <pasi.petajajarvi@qt.io>
2022-03-25 22:52:33 +01:00
Ivan Solovev
862f42e806 Android: activate tst_qfactoryloader
- Use QT_ANDROID_EXTRA_PLUGINS to specify a correct plugins directory
- Update plugin names on Android to match the expected format
- Add explicit dependency on the plugins, so that they always get built
  and included in the APK
- Update the test code to respect the fact that plugins are packed
  differently on Android.

All these steps allow to enable this test for Android in CMakeLists.txt

Task-number: QTBUG-87438
Pick-to: 6.3 6.2
Change-Id: I09e389c761688cea216d8922b94ea3a2600f7a67
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2022-03-25 22:43:49 +01:00
Ivan Solovev
904d613a51 Android: activate tst_QPlugin
- Use QT_ANDROID_EXTRA_LIBS to correctly deploy libraries on Android.
- Update the test code to use the application libraries directory
  instead of resources on Android.

This allows to enable the test for Android in CMakeLists.txt

Task-number: QTBUG-87438
Pick-to: 6.3 6.2
Change-Id: I2f6d2d4f3ab3872cf7d7fad1668b5c2c3eef3aad
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2022-03-25 22:43:49 +01:00
Ivan Solovev
5ef748d321 Android: skip tst_QFileSystemModel::specialFiles()
The test will never pass on Android because it's missing permissions
to read root filesystem.
Skip the test instead of blacklisting it.

Fixes: QTBUG-87427
Pick-to: 6.3 6.2
Change-Id: Ib57a49b1d2bc4204f8aa2c3028c7220d23ff2a91
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2022-03-25 22:43:49 +01:00
Ivan Solovev
83a587bfa6 Android: activate tst_QThreadStorage
Skip a test that uses QProcess instead of blacklisting it.
Re-enable this test in CMakeLists.txt, so that it can be checked
in the CI.

Fixes: QTBUG-87431
Pick-to: 6.3 6.2
Change-Id: If8a4acd60735f355dffa60c28b8d07695ee33ec8
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2022-03-25 22:43:49 +01:00
Ivan Solovev
68f7ba2150 tst_QAtomicInt: do not check qlonglong alignment for x86_32 CPUs
For x86_32 the alignment of QBasicAtomicInteger<8 bytes> is not
equal to the alignment of TypeInStruct<8 bytes>, so do not perform
the check.

Fixes: QTBUG-87422
Pick-to: 6.3 6.2
Change-Id: I6e6c6cb7b2b7195e430d6a6991004bcfce16d4cb
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-03-25 21:55:51 +01:00
Edward Welbourne
a8a7f6c4e6 Fix parsing of .cmake.conf in generate_expected_output.py
It relied on the set(QT_REPO_MODULE_VERSION ...) line being the first
thing in the file. It no longer is, and the variable is referenced in
an earlier condition.

Change-Id: I2bd2abd2a5680782ddd61f4bf4a4a3265b444d52
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-03-25 21:55:51 +01:00
Pasi Petäjäjärvi
ce0d7477a9 Disable test tst_qxmlstream for QNX
Copying lot of testdata over NFS to qemu image start failing with
errors of "No space left on device" even there is enough space left.

Pick-to: 6.2 6.3
Change-Id: I2a417ed5b8c131e0a1f68c37b1fc2446ea013304
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-03-25 20:16:30 +02:00
Edward Welbourne
57742f7728 Include zone name on tst_QTimeZone::isTimeZoneIdAvailable() failure
The zone name was reported if isValid() failed, but not if
isTimeZoneIdAvailable(), where it also proved useful in uncovering
ICU's use of over-long zone name components.

Change-Id: I4b3b65b1a4a338b638c01fc7ad47294118ee0efc
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-03-25 17:04:37 +01:00
Edward Welbourne
9e01a9a5d1 Apply the East-Saskatchewan exception to zone-fragment lengths to ICU
The exception was previously limited to Android, but I now find that
ICU has the same over-long names; it seems likely that's where Android
gets them. Also update the link to the theory page from the TZ DB, as
it now has an official home on www.iana.org.

Task-number: QTBUG-99747
Pick-to: 6.3 6.2
Change-Id: I9af67426d15609dfaf5f335405ceb1218fcf40ff
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-03-25 17:04:37 +01:00
Volker Hilsheimer
71b3d18ea7 Notify about focus object changes upon widget destruction
If the active QWidget gets destroyed, then QWidgetWindow::focusObject
will return nullptr. If then no other object takes focus, then we'd
never emit change signals, and QGuiApplication's _q_updateFocusObject
(which then informs the input context and emits signals) didn't get
called. This left the input context with a dangling focus object
pointer, which resulted in crashes.

If the QWidget clears its focus, but the corresponding window doesn't
know that it had focus, then fall back to the widget's focus widget
to see if we have a change in focus, so that signals get emitted.

Add a test case that shows that we didn't call _q_updateFocusObject
by counting emissions of the QGuiApplication::focusObjectChanged
signal, which we emit in this function. The signal is emitted more
than once both when showing a widget, and now also when destroying
a widget that has a focus child. The former is a previous issue,
the latter is an improvement to not emitting the signal at all.

Pick-to: 6.3 6.2
Fixes: QTBUG-101423
Fixes: QTBUG-101321
Change-Id: Ib96a397211d442f52ce795a3eebd055a0ef51b0d
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-03-25 17:04:37 +01:00
Sona Kurazyan
76a1c060ac Always cancel unfinished QPromises on destruction
If the QPromise is being destroyed, we should signal the associated
futures to stop waiting. No matter in which state the promise is, if
it's not finished, we should always cancel to avoid infinite waits.
This is also what docs state:

"The promise implicitly transitions to a canceled state on destruction
unless finish() is called beforehand by the user."

Fixes: QTBUG-101284
Pick-to: 6.3 6.2
Change-Id: I65ebfefe03b79b41afacda78a4f49938c54d8b37
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-03-25 08:05:12 +01:00
Pasi Petäjäjärvi
fe93a5f42d CI: Add docker support for tst_qiodevice test
Currently test relies solely for external test server. This makes it
not possible to run test successfully with environment where docker is
used.

Pick-to: 6.2 6.3
Change-Id: Idf7e99c19ab630065b651f2f6d957311f45f0db7
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-03-24 22:09:43 +02:00
Pasi Petäjäjärvi
f00e332d39 CI: Add docker support for tst_qtextstream test
Currently test relies solely for external test server. This makes it
not possible to run test successfully with environment where docker is
used.

Pick-to: 6.2 6.3
Change-Id: If716921ce6ceea1ced2d0d7025c6e9768b4ed7a7
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-03-24 22:09:43 +02:00
Laszlo Agocs
e25fc5a197 rhi: d3d11/vulkan: Allow passing in an array range override
Only (straightforwardly) implementable with modern APIs, and
only really exists to handle special platform cases, such as
when a video framework gives us a D3D texture array with
D3D11_BIND_DECODER | D3D11_BIND_SHADER_RESOURCE
which is only possible to use as a shader resource if the SRV
selects a single array layer.

Has no effect on the normal usage of texture arrays, where all
array layers are exposed, and it is the shader that selects the
layer when sampling or loading via the sampler2DArray. That
continues to be the standard way to work with texture arrays.

Change-Id: I0a656b605da21f50239b38abb83067e0208c1dbe
Reviewed-by: Piotr Srebrny <piotr.srebrny@qt.io>
Reviewed-by: Christian Strømme <christian.stromme@qt.io>
2022-03-24 19:19:35 +01:00
Volker Hilsheimer
1fe5ea3f83 Fix compiler warnings in tests
Don't mix unsigned and signed types in comparisons.

Pick-to: 6.3
Change-Id: Ia4ba9c114177425a21cadc8cafe8179928315a5d
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2022-03-24 13:23:16 +01:00
Volker Hilsheimer
dfb4697e4a QAbstractItemView: with single selection, deselect on Ctrl+Release
After cbf1b4bc60bca3994b8f8685ee922e53a6b4eed2 the selected item got
deselected on Ctrl+Press, which made Ctrl+dragging a selected item
impossible.

Only deselect on Ctrl+Release. Add scenario to existing test case,
and update the documentation to clarify the properties involved, and
to point out that the event parameter might be nullptr.

Fixes: QTBUG-101647
Pick-to: 6.3 6.2
Change-Id: I749b1cb1a0a311f5c1d4c333984716f05f2c90b5
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Volker Enderlein <volker.enderlein@ifm-chemnitz.de>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2022-03-24 00:42:00 +01:00
Mårten Nordheim
d34ae86a00 tst_QLocalSocket: Add helper to dependencies
To enable using `ninja tst_qlocalsocket_check` and have the
helper (re)built as part of the dependencies.

Pick-to: 6.3 6.2
Change-Id: I8703c4202a97606991d1cffe0d0f8e909a51f12f
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-03-23 21:19:35 +00:00
Ivan Solovev
21e7216670 Android: activate tst_QLineEdit
Skip some of the obviously failing QCompleter-related tests instead of
blacklisting them.
Skip a test that causes a crash.

This allows to re-enable this test in CMakeLists.txt for Android.

Task-number: QTBUG-87417
Pick-to: 6.3 6.2
Change-Id: Ie7ee708df8ceddf117689e8ac749850ba86e8816
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2022-03-23 21:03:03 +01:00
Assam Boudjelthia
8c4894f94b Android: don't QEXPECT_FAIL in tst_QTextDocument::task240325()
This test doesn't fail on Android anymore, so don't use QEXPECT_FAIL.

Pick-to: 6.2 6.3
Task-number: QTBUG-100470
Fixes: QTBUG-69242
Change-Id: I5a96566728a486c701656aede1818e7ab7f019be
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2022-03-23 18:22:06 +00:00
Volker Hilsheimer
3fbe201d21 Try to stabilize QWidget::enterLeaveOnWindowShowHide
The test is very flaky on Windows 11. Make sure that we have a secondary
window to close before proceeding, and wait for fade effects to finish,
otherwise we might never get the leave event from the windowing system.

Also replace a QVERIFY(qWaitFor) construct with a simple QTRY_VERIFY.

With these changes, a local run of 20 repeats of this test on a stressed
VM improves from 75% to 100%.

Pick-to: 6.3 6.2
Fixes: QTBUG-98477
Change-Id: Iedcc175b336e3cab23817b954aba1736d02f1b9d
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Heikki Halmet <heikki.halmet@qt.io>
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2022-03-23 03:31:44 +01:00
Edward Welbourne
02d130db7e Avoid duplicate descriptions in TAP's incident YAML
When a B?Fail's description doesn't match the QVERIFY/QCOMPARE
regexes, it got output as a comment in the YAML block after the test
line had already reported it as a TODO comment. An empty description
would also have lead to an empty comment in the YAML block. Condition
this fallback output case on there being a description that hasn't yet
been reported in the test line.

Task-number: QTBUG-96844
Change-Id: Id7fe81d26ddb01da3d8003ada8fa590a5e1a166f
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-03-22 17:43:13 +01:00
Edward Welbourne
58b0d72f8d TAP test logger: treat blacklisted XFail the same as XFail
In all places but one they were treated the same; fix that last one to
match the rest. This removes one line from the YAML block for each
blacklisted XFail test; in each case, this message duplicates the one
on its "not ok ... # TODO..." test line.

Change-Id: Iff2028afccd979db7f2c84e85d1b78541900008e
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-03-22 17:43:13 +01:00
Samuel Mira
2ba3cde348 Android: Blacklist failing tests on tst_QGraphicsProxyWidget
Backlist failing tests on Android. To be fixed later.

Task-number: QTBUG-100470
Task-number: QTBUG-101888
Pick-to: 5.15 6.2 6.3
Change-Id: Iaa33b555f6063702af683c683e0b07ce2910fe13
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2022-03-22 17:49:05 +02:00
Pasi Petäjäjärvi
5c85b0c7a4 CI: QNX qemu need docker service ports explicitly defined for visibility
Network autotests cannot connect to services on docker containers from
QNX qemu without all ports explicitly defined (both host and container)
side.

Pick-to: 6.2 6.3
Task-number: QTQAINFRA-4684
Change-Id: Iba44cfa17d42d43ecec3e29985e404f75d5fc232
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Dimitrios Apostolou <jimis@qt.io>
2022-03-21 22:30:01 +02:00
Ulf Hermann
908ee8aab1 QProperty: Allow manual scheduling of binding notification
In some situation we want to notify even if the value didn't change.

Task-number: QTBUG-101771
Pick-to: 6.2 6.3
Change-Id: I7d82a9f6e0f7d5eb48065e3f428b814939181ea8
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-03-21 20:41:23 +01:00
Volker Hilsheimer
c924c05ae2 Replace deprecated QColor::fromString in tests and documentation
Don't use deprecated methods in tests, and don't refer to them in
documentation.

Change-Id: I110480742d9a7b9b0a2e194e3fe610208c1e07da
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-03-21 20:41:23 +01:00
Øystein Heskestad
eaabd0c545 QAnyStringView: constexpr detect 8-bit ASCII as Latin 1
This has performance benefits when doing comparisons.
The check is only performed at compile time.

Task-number: QTBUG-101014
Change-Id: I55694b045fe5e75d9671d0a3a70c80d998cf98c8
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-03-21 20:36:23 +01:00
Volker Hilsheimer
f3466fad53 Build QMenuBar test without warning
Adapt to changes in QWidget::addAction API from 08e4d2db08.

Pick-to: 6.3
Change-Id: If6e05b47de88cf55070238f08b96586b855cc5c1
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-03-20 23:19:03 +01:00
Sona Kurazyan
d0f9e593d4 Rename tst_qlatin1string and switch to using QLatin1StringView
Task-number: QTBUG-98434
Change-Id: Iec477835880263175edbc03f21b40f1ad67dbef0
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-03-19 18:51:08 +01:00
Marc Mutz
c52ebb3aba QRect: add toRectF()
For symmetry with QRectF::toRect().

[ChangeLog][QtCore][QRect] Added toRectF().

Fixes: QTBUG-73160
Change-Id: If2bda64b8fe4bc113191dda927e9bb86ebcb4c69
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-03-19 12:02:24 +01:00
Marc Mutz
5dc570f8b1 QLine/QMargins: add toLineF/toMarginsF()
For symmetry with QLineF::toLine().

[ChangeLog][QtCore][QLine] Added toLineF().

[ChangeLog][QtCore][QMargins] Added toMarginsF().

Task-number: QTBUG-73160
Change-Id: I69051cdd2fe4a3c0a000ab86e363a2918a7aea7c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-03-19 12:02:24 +01:00
Marc Mutz
2fb0135efa QSize/QPoint: add toSizeF/toPointF()
For symmetry with QSizeF::toSize().

[ChangeLog][QtCore][QSize] Added toSizeF().

[ChangeLog][QtCore][QPoint] Added toPointF().

Task-number: QTBUG-73160
Change-Id: I65b088b4f7365ab671ef2f0c75821b707f5ac26d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-03-19 12:02:24 +01:00
Marc Mutz
f97daab7a6 QObject: restore flags printing in dumpObjectTree()
This was lost when QtCore, QtGui and QtWidgets were split up. Restored
now via a virtual function on QObjectPrivate.

Chose to return std::string instead of QString or QByteArray because
its SSO is usually sufficient to hold these flag strings.

[ChangeLog][QtCore][QObject] Restored printing of Qt3-style
information from dumpObjectTree().

[ChangeLog][QtWidgets][QWidget] Restored printing of Qt3-style
information from QWidget::dumpObjectTree().

Fixes: QTBUG-101732
Change-Id: I39ff5728ea5f5abbdbf81b5d7e13b8d16b6ee8b7
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-03-19 12:02:24 +01:00
Marc Mutz
6ec1dc904d QSettings: port key processing to QAnyStringView
... in preparation for replacing the QString keys in the public API
with QAnyStringView ones.

This removes the "important optimization" that avoids a detach in the
common case where the input is the same as the output of
normalization. But that optimization is beside the point, because it
trades a memory allocation avoided in the library for O(N) allocations
inserted into user code for each call to QSettings::value(), the vast
majority of which are calls with string literals.

With the public interface ported to QAnyStringView in the follow-up
patch, we can then internally optimize memory allocations _in a central
place_ (e.g. by returning std::u16string or QVarLengthArray<QChar> from
normalizeKey() instead of QString). But first we need to get rid of all
the unwarranted allocations in user code.

Change-Id: I45fc83d972c552a220c9c29508001d3f172e1162
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2022-03-19 07:09:55 +00:00
Volker Hilsheimer
5e566ab373 When clearing selected items, iterate over a copy of the QSet
Selection change handlers of the items might call a method that
implicitly recreates the selectedItems QSet, which then invalidates
the iterators of the ranged for loop, resulting in crashes.

Iterate over a copy of the set instead.

Add a test case that crashen without the fix.

Fixes: QTBUG-101651
Pick-to: 6.3 6.2
Change-Id: I6da6f4043fe1906b0186931a37283f635cb5a404
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2022-03-18 21:56:19 +01:00
Luca Di Sera
33d62de7c8 Enable move semantics for QTemporaryDir
Add move constructor and move assignment operator.

To allow for the the change to be implemented QTemporaryDir, the
internal d_ptr was modified from a QScopedPointer, which is not movable,
to a raw pointer.

Add member + free swap implementations.

Add tests.

[ChangeLog][QtCore][QTemporaryDir] Enabled move semantics.

Change-Id: I9f196a77c70b4ca0b7f0c06505d00fdd87a9785c
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-03-18 20:56:19 +00:00
Ivan Solovev
30830e0cba Android: use empty Intent to clear clipboard data on API < 28
ClipboardManager didn't have any APIs to clear clipboard data before
API level 28.
As a workaround an empty Intent with MIMETYPE_UNKNOWN is created and
inserted into the clipboard for lower API levels.
This makes the QApplication::clipboard()->clear() method work more or
less as expected.
This allows to unblacklist tst_QPlainTextEdit::copyAvailable().

Task-number: QTBUG-87423
Task-number: QTBUG-89402
Pick-to: 6.3 6.2
Change-Id: I454376199cf3b8eed0fa2ecf2f85b87f40892280
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2022-03-18 18:35:03 +01:00
Marc Mutz
9985cc330a uic: use C string literals for setObjectName()
Because setObjectName() now takes a QAnyStringView, passing C string
literals is much more efficient than using QString::fromUtf8().

This patch only deals with setObjectName() as a known property,
probably from a name attribute. If the objectName property is set by a
<property> element (or so I assume), we still emit a
QString::fromUtf8(). Detecting objectName there would be too much
magic.

Besides, I haven't been able to find why sometimes there's a second
setObjectName call right after the first, when in the XML it seems all
kosher (name attribute and objectName <property> agreeing on the
content).

Change-Id: Icf07bad841ac735a9c744bbd955428ba15758089
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-03-18 18:35:03 +01:00
Janne Juntunen
a5ee74754d tst_qopengl: set surfaceType explicitly
Parent window in sizeLessWindow test was using software pipeline at
least on webOS, causing a QCRITICAL() exit when the test was executed.

Fixes: QTBUG-101869
Pick-to: 6.3
Change-Id: Ie8cc0ea0b6a09729475389be44197e01a45b217f
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2022-03-18 13:02:11 +02:00
Giuseppe D'Angelo
1b14569753 QMutexLocker: strenghten the locking operations
There is no reason to allow relock() on a locked locker, or unlock()
or an unlocked one, just like we don't allow that on a plain mutex
to begin with. The docs already said that e.g. relock() locks an
_unlocked_ locker.

[ChangeLog][QtCore][QMutexLocker] QMutexLocker allowed relock() and
unlock() on an already closed (resp. open) locker object. These
semantics have always been undocumented and are now unsupported
(in both cases they yield undefined behavior.)

Change-Id: Id5f67beb5dc30d6435dae88a3085fba93ec7d96e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-03-18 05:18:28 +01:00