Commit Graph

2279 Commits

Author SHA1 Message Date
Eskil Abrahamsen Blomfeldt
49a63d3759 Fix infinite layout loop with negative line width
Setting a negative line width does not make much sense, but in
earlier Qt versions, this work the same as if the line width was 0
(just give you the minimal layout given wrapping constraints).

But since 991c056438, we check if
current width > line width at an earlier point, and because 0 > -1,
we would exit immediately before adding any characters to the text
line.

To restore the behavior in earlier versions, we set the minimum
possible line width to 0.

Pick-to: 6.5
Fixes: QTBUG-109474
Change-Id: Iceadd5135681f61b30de8221853834983941c5a4
Reviewed-by: Lars Knoll <lars@knoll.priv.no>
Reviewed-by: hjk <hjk@qt.io>
2023-01-09 14:48:39 +01:00
Kaj Grönholm
df00f9ea86 Support serializing the QShader for qsb version
Support serializing shaders with specific qsb version. The default
behavior remains the same, using the latest version.

Task-number: QTBUG-101062
Pick-to: 6.5
Change-Id: I090a88c1ccb3be4ac5eee1da4058afaa8bf3111c
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2023-01-07 18:24:47 +01:00
Ahmad Samir
2ed4e5d37d Fix two compiler warnings
Comparing singed/usigned ints.
Use override keyword.

Change-Id: I03d2c4359e0600360ebcfece593a3b125e5c9c53
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-01-05 21:01:22 +02:00
Ahmad Samir
41867c25f8 Use QFileInfo's file times in UTC for file timestamps
This is inherently faster than getting it in UTC from the underlying
native API stat call, then converting it to the Local Time Zone just to
compare them. The same goes for any use-case where you get a QDateTime
then the first thing you do is call t.to{Msec,Secs}SinceEpoch().

Change-Id: Ic13bcfd99b937c9f10f102ea7741832950a553c6
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Kai Köhne <kai.koehne@qt.io>
2023-01-04 19:15:52 +02:00
Volker Hilsheimer
2d87c4d881 QTextImageHandler: Resolve Nx images correctly for file or qrc URLs
The qt_findAtNxFile helper in qicon.cpp expects a local file name that
can be probed with QFile::exists. If the src attribute of an <img>
element specifies the location of the image as a file:/ or qrc:/ url
rather than as a local file name, then we need to strip the scheme
off the file path, and in the case of a qrc URL leave the :/ prefix
before calling the qt_findAtNxFile helper.

Amends, and partially reverts, 760df72565.
We can't avoid testing whether the source in the HTML is provided as a
URL before interpreting it as a file name.

Pick-to: 6.5 6.4 6.2
Fixes: QTBUG-109212
Change-Id: I7ea7a5bfde79bab90a8025c42e754129813dd0fc
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-12-22 19:19:33 +01:00
Volker Hilsheimer
c9cf4037ca QTextImageHandler: Add test coverage for resources and URLs
If an image source in HTML is specified via local file name or resource
path (i.e. without qrc prefix), then the correct image is loaded.

With file:/ or qrc:/ schema however, the image is either not loaded at
all, or the 2x image is not loaded. The qt_findAtNxFile helper in
qicon.cpp gets a URL path, but expects a file path (that can be tested
with QFile::exists).

Task-number: QTBUG-109212
Pick-to: 6.5 6.4 6.2
Change-Id: Ibcf687c69b3e53a10f21d718d28c8177a02d6be6
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-12-22 00:48:08 +01:00
Volker Hilsheimer
d8e213a9e6 Enable and fix the test for QTextImageHandler
Amends 52ce0c177e, which added the test
without adding it to the parent directory.

Refactor the test code to be data driven, add the image files as
external test data files, and adjust the test code to find the files.

Use the QTextImageFormat from the document rather than a manually
crafted one, as otherwise we don't test a real usecase.

This also makes the test more flexible for adding qrc, resources, and
file URLs.

Task-number: QTBUG-109212
Pick-to: 6.5 6.4 6.2
Change-Id: Id0771037b961d95ec3cadd0cd6467d2448f22884
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
2022-12-22 00:48:08 +01:00
Laszlo Agocs
4d36a83b6d rhi: vk: Fix up some legacy queue (family) index inconsistencies
Relevant mainly if we want to consistently expose these as the
theoretically correct uint32_t/quint32 from Qt Quick's
QSGRendererInterface. (not that int is not sufficient for
indexing the typical 3-4 families and 2-16 queues per family)

Some checks are not actually needed since the family index
must always be valid after create().

Pick-to: 6.5
Task-number: QTBUG-108895
Change-Id: I474ccea51a81e7a096281604ff79b7db4cdd2484
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2022-12-16 17:49:28 +00:00
Ben Fletcher
509fd9f2bb RHI: Buffer readback fixes and unit test
Fixes issues with readback of storage buffers modified on GPU for D3D
and Metal.  Adds unit test for storage buffer readback.

D3D
*  Fixes issue where QRhiBufferReadbackResult::completed callback could
be called twice on buffer readback completion.

Metal
* Fixes issue where buffer readback occurred prior to command buffer
being committed.

Change-Id: If55ac005f4438d66d2f65ea2e1ee0d5686c884ff
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2022-12-14 17:29:53 -08:00
Eskil Abrahamsen Blomfeldt
ca64365e3a Don't hide object replacement char except in rich text
The object replacement character (U+FFFC) is used to represent
inline objects such as images in rich-text. To enable this,
we have special handling of it in QTextEngine. For classes
where inline images are not supported, it will just be hidden
from the visual text, which is unexpected.

Instead of always special-casing it, we make this dependent
on whether the document layout has registered any object handlers.
If they have not, then there will be no visual representation of
the object, and it is better to show the glyph for it.

For anything based on QTextDocument, there will always be the
image handler, so U+FFFC will still have special handling there,
but for non-rich labels and plain text editors the glyph will
be shown instead.

Note that there was also a bug in QLineEdit, where the object
replacement character was always replaced by a space. This was
introduced in 2007, in a patch which replaced a !ch.isPrint()
with a check for "the most obvious non-printable characters"
to reduce the number of characters that were not shown. However,
U+FFFC is a printable character and would thus not have been
filtered by the !isPrint() condition, so I think this was a
mistake at the time. However, due to the special-casing of
the character in Qt, it would not have had any effect until
now.

This also changes the QTextLayout::cursorToXForInlineObject()
test to actually test proper inline objects, as this was
previously using a hack which depended on the inline object
code to be used even for plain QTextLayouts with no handlers
for these.

[ChangeLog][Text] The object replacement character (U+FFFC)
is now only filtered out in rich text controls, where they
represent inline objects. In other controls, its glyphs will
be shown as with other text.

Pick-to: 6.5
Fixes: QTBUG-101526
Change-Id: I7fcaf2b10918feb41589e1098016efbf79a0e62d
Reviewed-by: Lars Knoll <lars@knoll.priv.no>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-12-14 19:19:01 +01:00
Eskil Abrahamsen Blomfeldt
58907dfa81 Try to match variant-selector font to preceding character
Variant-selectors are special unicode symbols which are used to
modify glyph selection for the preceding character. For instance,
a regular symbol could be turned into a color emoji using VS16,
the emoji variation selector. In order for this to work, however,
the font that handles the selector has to handle the full pair of
characters, so that it can apply the correct substitution rules.

One specific example of this was on macOS, where an airplane
symbol + VS16 would match the symbol to the default UI font but
the VS16 to the emoji font. Since there string provided for the
emoji font did not have any preceding character for VS16, we just
ignored it.

To improve on this, we now detect variation selectors that have
been matched to different font engines than the preceding
character. When such a case occurs, we check if the selector font
also supports the preceding character, and if it does, we keep
the pair together and use the same font for both.

[ChangeLog][QtGui][Text] Fix some cases where a variation-selector
character would be ignored in font selection and the correct
variant of a character would thus not be selected.

Task-number: QTBUG-108799
Change-Id: I9f427e0520e652ee2f24a4f7dc3c1957251e06bd
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-12-12 19:25:45 +01:00
Ben Fletcher
0943b5d65d RHI: QShaderDescription storage buffer qualifiers / run time stride
Add storage buffer memory qualifier and run time array stride information
to QShaderDescription::StorageBlock.

Memory qualifiers allow more informed selection of RHI resource buffer
binding (bufferLoad / bufferStore / bufferLoadStore) function.

Run time array stride (for last block member unsized array) allows
packing of buffer data for transfer to / from GPU. Without this
information, applications must infer or guess which packing rules
(std430 / std140) are in use.

Change-Id: I676d7e848afefd40d01cdd463c569b07022b683e
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2022-12-11 11:05:24 -08:00
Volker Hilsheimer
12b7eab4d2 Detach event points when cloning pointer events
Input events that originate from actual device interaction should reflect the
device's state, and device and events need to be kept in sync so that event
sequences (such as multi-touch events, where we have begin/update/end cycles
spanning multiple events) are working correctly.

For that reason, the event point data in pointer events is explicitly shared,
and we only detach in exceptional situations. This saves us memory allocations,
and makes sure that the event point data carried by events, and the event point
data stored persistently in the device, are kept in sync.

Cloned pointer events do not originate from device interactions, and should
therefore not sync back to the device. E.g. accepting a clone should not modify
the original event data stored in the device. There are exceptions here as
well, e.g. when cloning an event in Qt in order to deliver a translated version
of it to a different scene. Different points might even get delivered to
different scenes or windows, or at least different items in the same scene. For
that reason, we explicitly detach, and then explicitly write back the relevant
states after the cloned event has been delivered.

But in general, we should assume that cloned events do not write back to the
device. Since QEventPoint is an explicitly shared data type that never detaches
itself, we have to explicitly detach it when making copies that should not be
shared.

The ideal implementation of this would be to do the detach in the copy
constructor of QPointerEvent, which is called when cloning. However, Qt itself
makes copies of QPointerEvent without using clone, e.g. when assembling lists
of touch events for the different subscenes or windows in
QGuiApplicationPrivate::processTouchEvent, where event objects are added to a
QVarLengthArray<QMutableTouchEvent>. This makes copies, and those copies must
not detach.

So we have to implement the special cloning behavior in each override of
QPointerEvent::clone(). For this, introduce a dedicated macro for the common
member functions. This macro must be used for QPointerEvent subclasses.

Fixes: QTBUG-107560
Change-Id: I4b56f9e71c7d067ba9054a2a631e8ba5bc7b1ab9
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2022-12-10 06:38:58 +01:00
Eskil Abrahamsen Blomfeldt
c9d991de1f Fix missing text when Harfbuzz fails to shape a substring
This amends fccd419dd6.

If Harfbuzz failed on one of the items in a string and returned
zero glyphs, then we would exit the shaping loop. The mentioned
change fixed a crash related to this when the ignored character
was the only character in the string, but it occurred in a
subitem of a longer string, then we would return and fail to
lay out the rest of the string.

This popped up recently because an update to Harfbuzz has caused
it to return zero glyphs when applying the Apple emoji font to
an isolated variant character (see bug report). When we matched
the symbol to the main font and only the variant character to
the emoji font, we would get in this situation, and end up
exiting the shaping early.

[ChangeLog][QtGui][Text] Fixed a regression which would
sometimes cause text to disappear if the string contained
an unmatched variation selector character.

Pick-to: 6.4
Fixes: QTBUG-108799
Change-Id: I616ab1b2d33c2df731419c5ce06fbc578a625a32
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-12-05 07:55:43 +01:00
Eskil Abrahamsen Blomfeldt
0dcd640a1f Don't return a visual glyph for ignorable characters
When Harfbuzz returns zero glyphs, this will typically be because
the character is ignored. We currently have no way to differentiate
this from actual error cases, so to avoid return the error glyph
for cases which are not really errors, we set the dontPrint flag
for this.

When we add a way to differentiate between error cases and non-error
cases later, we should revert this for the actual errors.

Pick-to: 6.4
Task-number: QTBUG-108799
Change-Id: I2a910d951b71c705fb4dd761fcfe3a942b3afa7c
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-12-05 07:55:25 +01:00
Volker Hilsheimer
ef379f95c7 QPalette: always increase serial number when modifying
After 109e088c7c, cache keys were unique
for palettes with different private or data instances, but the key did
not change when a palette without any shared copies was modified, as
that does not create new private data structures.

To fix this, always increase the counter for the private data structure,
also when not detaching from shared copies.

Augment test case with scenario that broke.

Pick-to: 6.4
Fixes: QTBUG-108709
Change-Id: I606abfb8b1a03e515e46b10dc840a631eb31d496
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: JiDe Zhang <zhangjide@uniontech.com>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2022-11-25 14:28:48 +01:00
Vladimir Belyavsky
991c056438 QTextLayout: fix maximumWidth() for a text containing line separator
This is improved version of previous fix
013c346a8d that was reverted because it
broke some tests for Quick Text. The problem was that it did not work
correctly in the case the text was wrapped to a fixed width.
To deal with this we'll accumulate current line full width (as if it
hadn't been wrapped) in layout data (layoutData->currentMaxWidth).
Then when the next line is explicitly wrapped by line or paragraph
separator, this accumulated width will be used to adjust layout's
maximum width.

Change-Id: Iad7119d9808e1db15fe1fbc5db049c3db928529f
Fixes: QTBUG-89557
Fixes: QTBUG-104986
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2022-11-19 18:03:32 +03:00
Volker Hilsheimer
649dccf57b Reintroduce converter APIs for supporting native clipboard formats
In Qt 5, QWin(dows)Mime and QMacMime lived in the respective Extras
modules, which were removed and partially folded into the relevant
modules in Qt. QWindowsMime and QMacMime continued to provide the
abstraction for implementing built-in support for native clipboard
formats and UTIs within Qt, but only as private APIs.

After the recent clean up of those APIs and respective infrastructure,
we can now bring them back as public converter interfaces. Application
developers can subclass those and instantiate an instance of their
implementation to add support for platform or application specific
data formats.

These interfaces are not in the QNativeInterface namespace, as
applications don't call into Windows or macOS using those interfaces.
I.e. there is no class on which an application would call

  auto *converter= nativeInterface<QWindowsMimeConverter>();

Also, since applications override those converter types, we do want to
guarantee binary and source compatibility.

[ChangeLog][QtGui][QWindowsMimeConverter] Reintroduced to allow
applications to add support for conversion from and to Windows-native
clipboard formats to MIME-encoded data.

[ChangeLog][QtGui][QUtiMimeConverter] Reintroduced to allow
applications to add support for conversion from and to clipboard data on
macOS and iOS to MIME-encoded data.

Fixes: QTBUG-93632
Change-Id: Iebd909c3970015d203f59d5ab15e306b3d312f6e
Reviewed-by: Yuhang Zhao <2546789017@qq.com>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-11-16 22:14:00 +01:00
Ben Fletcher
85a1663eb1 RHI: Add support for 1D textures
Support for 1D textures on Vulkan, OpenGL, Metal, and D3D.

Change-Id: Ie74ec103da9cfcbf83fa78588cf8cfc1bd6e104f
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2022-11-15 11:36:18 -08:00
Lucie Gérard
ea7a3105de Use SPDX license identifiers
Amends commit 05fc3aef53.
Some files were still missing.

Task-number: QTBUG-67283
Change-Id: I78b3cbf31138192805b7e186337c6fda4ac844aa
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-11-15 07:50:17 +00:00
Samuel Mira
35cd0db935 Android: Skip/blacklist remaining tests for emulator bump to API 24
Skip on crashing tst_qvulkan test
Blacklisted completer_data on qfiledialog
(8d76c5af51 should have been enough but
it is still failing)

Task-number: QTBUG-108328
Task-number: QTBUG-108329
Change-Id: Iad5573af60cca16d16ba0462293e276186e25653
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2022-11-15 01:01:54 +00:00
Axel Spoerl
52dcd47850 emit QWindow::windowStateChanged only when state has changed
Upon programmatic window state changes, windowStateChange was fired
once in QWindow::setWindowStates and once when the visual state had
been changed by the window interface.

This patch adds if guards to ensure that the singal is fired only once.

It adds a corresponding autotest to tst_QWindow.
tst_QWidget::resizePropagation() is adapted to no longer expect double
signal emission.

Fixes: QTBUG-102478
Pick-to: 6.4 6.2
Change-Id: If093c0a883d76d8a676e4fab90db6b0676452267
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-11-11 11:21:32 +01:00
Axel Spoerl
baa1228b43 Fix type mismatch compiler warning in tst_QGlyphRun
When comparing a glyphIndex with a hard coded number, the number is
cast to an int, whereas the glyphIndex is an unsigned int.
That causes a compiler warning.

This patch forces the numbers to be cast to an unsigned int.

Change-Id: I8a31124c6afacfc4ecfb13caf2cb8133dad44a21
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2022-11-10 17:16:59 +01:00
Axel Spoerl
3cadb68a59 Fix unused variable compiler warning in tst_qpalette
Debug serials and detatch numbers of deep and shallow detatch in test
function cacheKey, if it fails.
That implicitly removes a compiler warning about these variables being
unused.

Change-Id: I481f4b63e3ed0d50fb442dffc658b97d913059bc
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2022-11-10 17:16:59 +01:00
Marc Mutz
1c6bf3e09e Port from container::count() and length() to size() - V5
This is a semantic patch using ClangTidyTransformator as in
qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8, but extended to
handle typedefs and accesses through pointers, too:

    const std::string o = "object";

    auto hasTypeIgnoringPointer = [](auto type) { return anyOf(hasType(type), hasType(pointsTo(type))); };

    auto derivedFromAnyOfClasses = [&](ArrayRef<StringRef> classes) {
        auto exprOfDeclaredType = [&](auto decl) {
            return expr(hasTypeIgnoringPointer(hasUnqualifiedDesugaredType(recordType(hasDeclaration(decl))))).bind(o);
        };
        return exprOfDeclaredType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes))));
    };

    auto renameMethod = [&] (ArrayRef<StringRef> classes,
                            StringRef from, StringRef to) {
        return makeRule(cxxMemberCallExpr(on(derivedFromAnyOfClasses(classes)),
                            callee(cxxMethodDecl(hasName(from), parameterCountIs(0)))),
                        changeTo(cat(access(o, cat(to)), "()")),
                        cat("use '", to, "' instead of '", from, "'"));
    };

    renameMethod(<classes>, "count", "size");
    renameMethod(<classes>, "length", "size");

except that the on() matcher has been replaced by one that doesn't
ignoreParens().

a.k.a qt-port-to-std-compatible-api V5 with config Scope: 'Container'.

Added two NOLINTNEXTLINEs in tst_qbitarray and tst_qcontiguouscache,
to avoid porting calls that explicitly test count().

Change-Id: Icfb8808c2ff4a30187e9935a51cad26987451c22
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-11-03 14:59:24 +01:00
Assam Boudjelthia
3731e04668 Android: skip tessellation(Vulkan)
Fails on CI's Android 12 emulator.

Amends c681c7c23f.

Change-Id: Icb0c39a9d0b7952aea76b7b0c45fbfc7f2b0556f
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2022-10-20 20:52:47 +00:00
Edward Welbourne
e7913006f1 tst_QDoubleValidator::setRangeOverloads(): rename a data row
Two rows shared the same name. They claimed the value used was out of
range, but actually that was only true for one of them. The other was
in range, but the test reduced the number of digits allowed after the
decimal point, thereby making it invalid, so rename that one to
reflect this.

Change-Id: I0936ea25ec799c0069cd148b9f9bae5d35906093
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2022-10-18 14:13:28 +02:00
Edward Welbourne
09e86cfbef tst_QFont::serialize(): distinguish two letterspacing data tags
Include the spacings used, to avoid a naming collision.

Change-Id: Iaf78f7142f6780dcf4c7a0b973db9f625af06767
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2022-10-18 14:13:27 +02:00
Edward Welbourne
b65a7d80be tst_QPainter::blendARGBonRGB(): rename some data rows
Avoid duplication by distinguishing similar test-cases.

Change-Id: I1a100d6c9729f0ea356f177535d15c3d36e2da9e
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2022-10-18 14:13:27 +02:00
Edward Welbourne
bed8663a0b tst_QPainterPath::testNaNandInfinites(): anticipate the warnings
The test used to trigger a lot of QWARN messages; these are clearly
intended, so tell QTest to expect them, so that we get an error here
if those warnings ever don't show up.

Incidentally tidy up a comment and convert a != verify to a
QCOMPARE_NE(), since it's now available to do that job.

Change-Id: I83e225c37abe8446dac06ebe4e75258cb87b71b0
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2022-10-18 14:13:27 +02:00
Edward Welbourne
4af55438d0 tst_QPainterPath::testArcMoveTo(): include index in some data tags
In the process, clean up the building of the data tags: use a
range-for loop, albeit we do need an index to show in tags; show it
and the angle in the tags using addRow()'s easier formatting. Change
the low angle tests to show the sign of the angle (which is how they
differ)rather than just labeling them 1 and 2.

Change-Id: Ib5aaa3e22d771c530c9343ba368b0fdfceb264ce
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Jason McDonald <macadder1@gmail.com>
2022-10-18 14:13:27 +02:00
Edward Welbourne
119801f70d tst_QPainterPath::contains_QRectF(): rename some data rows
The last three duplicated earlier ones; and their names didn't take
into account the circle that had been added to the path since those
tests. So revise their names to reflect that.

Change-Id: I32d74f21947b4ba0c04eee53daf8efde6b4a6409
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2022-10-18 14:13:27 +02:00
Edward Welbourne
d52abad85d tst_QImage::reinterpretAsFormat(): deduplicate a data tag
Two rows shared a data tag. Prefixed one of them with the color of the
half-transparent image it involves (the other's is fully transparent).

Change-Id: I1bd174008ed29bcf2f460e683fdf6d1f12ba19d0
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2022-10-18 14:13:27 +02:00
Edward Welbourne
e6fb0e0779 tst_QImage::mirrored(): deduplicate some data row names
Change-Id: Ia10c72c450eed12d29c9608c6a6270dd4dc4ef7c
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2022-10-18 14:13:27 +02:00
Edward Welbourne
c13df5b6ea tst_QImageReader::preserveTexts(): deduplicate data tags
The same data tags were used with two distinct filenames in their
data. Include the basename of each filename in the data tag, to avoid
duplication.

Change-Id: I216fecbd413fab409227ad6f93f8ac3fcc74b059
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2022-10-18 14:13:27 +02:00
Edward Welbourne
af0c910912 tst_QKeySequence::parseString_data(): drop duplicated rows
The "a" and "A" rows appeared under Valid, then again under Only Keys.
The two copies were identical, in each case, so drop the latter.

Change-Id: Ib3d84710e772171bb4a5e0aefd20022810fb41cd
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2022-10-18 14:13:27 +02:00
Liang Qi
f2aa04722a tests: skip tst_QTouchEvent::multiPointRawEventTranslationOnTouchPad() on Wayland
QWindow::requestActivate() is not supported.

Task-number: QTBUG-107158
Pick-to: 6.4 6.2
Change-Id: I047337d736ff10693d98075e2636028225162765
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2022-10-14 17:18:53 +02:00
Volker Hilsheimer
cdadd1bdb3 Allow programmatic closing of windows that are modally blocked
In Qt 6, after changes such as 121fddcf5a,
we go through the QPA layer to close widget windows properly. Closing
and hiding of windows is now done in when we receive and handle the
window system's CloseEvent.

Such an event to a modally blocked window should be blocked, so that
users can't close a modally blocked window. However, if the event is the
result of a call to QWindow::close, then it should not be blocked.
Luckily, we know that the event is the result of such a call, so let
such events through. This restores compatibility with Qt 5, where it was
possible to first open a new dialog, and then close the previous dialog.

Add a test case.

Fixes: QTBUG-107188
Pick-to: 6.4 6.2
Change-Id: Id812c1fc36aa0e1a10dfb8d3a16a11d387289b05
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-10-12 01:53:42 +02:00
Marc Mutz
aa37e67ef7 Port from qAsConst() to std::as_const()
We've been requiring C++17 since Qt 6.0, and our qAsConst use finally
starts to bother us (QTBUG-99313), so time to port away from it
now.

Since qAsConst has exactly the same semantics as std::as_const (down
to rvalue treatment, constexpr'ness and noexcept'ness), there's really
nothing more to it than a global search-and-replace, with manual
unstaging of the actual definition and documentation in dist/,
src/corelib/doc/ and src/corelib/global/.

Task-number: QTBUG-99313
Change-Id: I4c7114444a325ad4e62d0fcbfd347d2bbfb21541
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2022-10-11 23:17:18 +02:00
Edward Welbourne
f71daf857c Fix tst_QQuaternion's duplicate test tags
Having the same test tag for two rows of a data table makes the report
less useful. We also intend to forbid doing that.

Change-Id: I67ec32514b6550f4f97610a2140f1383d0d85b23
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2022-10-11 11:20:58 +02:00
Liang Qi
f8898cae83 Revert "tests: XFAIL tst_QOpenGL::bufferMapRange() on Wayland"
This reverts commit e49d2daf19.

This doesn't fail on Wayland, perhaps a false alarm.

Fixes: QTBUG-100918
Pick-to: 6.4 6.2
Change-Id: I1415afdeaf1bff26dba3b3100b2aafcda00bcdd9
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2022-10-07 13:20:12 +02:00
Liang Qi
5ddb015038 Revert "tests: XFAIL tst_QGuiApplication::genericPluginsAndWindowSystemEvents()"
This reverts commit ae1197fc56.

This doesn't fail on Wayland, perhaps a false alarm.

Fixes: QTBUG-100891
Pick-to: 6.4 6.2
Change-Id: I3e1d2488b090f186c64d63cb6c9f97dfaafc8fff
Reviewed-by: Liang Qi <liang.qi@qt.io>
2022-10-07 13:20:08 +02:00
Vladimir Belyavsky
4945fd93f1 QTextLayout: fix maximumWidth() for a text containing spaces
When laying out a text and calculating maxWidth, we must _always_ take
into account the accumulated width of spaces (lbh.spaceData.textWidth)
regardless of wrapMode, other text content, spaces position, etc.

Fixes: QTBUG-106947
Change-Id: I2ac9af92ed7dd07c1e040bfcf83949a358d1c9c9
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2022-10-06 08:43:11 +00:00
Marc Mutz
df9d882d41 Port from container.count()/length() to size()
This is semantic patch using ClangTidyTransformator:

  auto QtContainerClass = expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o)
  makeRule(cxxMemberCallExpr(on(QtContainerClass),
                             callee(cxxMethodDecl(hasAnyName({"count", "length"),
                                                  parameterCountIs(0))))),
           changeTo(cat(access(o, cat("size"), "()"))),
           cat("use 'size()' instead of 'count()/length()'"))

a.k.a qt-port-to-std-compatible-api with config Scope: 'Container'.

<classes> are:

    // sequential:
    "QByteArray",
    "QList",
    "QQueue",
    "QStack",
    "QString",
    "QVarLengthArray",
    "QVector",
    // associative:
    "QHash",
    "QMultiHash",
    "QMap",
    "QMultiMap",
    "QSet",
    // Qt has no QMultiSet

Change-Id: Ibe8837be96e8d30d1846881ecd65180c1bc459af
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-10-04 07:40:08 +02:00
Volker Hilsheimer
109e088c7c Make sure that palette cache keys are unique
After 1d961491d8, palettes are different
if they either have different brush data, or a different private. Two
privates can share data, but still must generate different cache keys.
The cacheKey has so far been composted of the serial number of the Data
struct, and a detach number that is incremented when we detach the
private.

This failed for two reasons:

- the implicit copy constructor of the Data class copied the serial
number, when it should have incremented it. Fix that by member-
initializing the serial number rather than doing it only in the default
constructor. The member initialization is also executed for the copy
constructor.

- the detach_no logic as it was implemented does not guarantee that two
copies of the same palette that share data, but have different resolve
masks (and thus different privates) have different detach_no values.
Use a static serial counter for that number as well.

Amend the test case to verfiy that cache keys, and the elements of the
cache keys, change when they are expected to.

Fixes: QTBUG-106984
Pick-to: 6.2 6.4
Change-Id: I84d7055ce8bfe0d42f1f8e9766f3f1ad610f4ec8
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2022-10-03 23:39:23 +02:00
Eskil Abrahamsen Blomfeldt
1fe7144a07 Introduce QGlyphRun::stringIndexes()
This introduces a way to trace each entry in the glyph index
array to a specific index in the original text passed to
QTextLayout, as well as a convenience function to access
the original string from the QGlyphRun.

The index information is stored in the logClusters array internally
in Qt, but it contains the inverse information: For each
character in the output string, it contains an index into the
glyph array. In order to get the string indexes for each glyph,
which makes a lot more sense in the context of the QGlyphRun
API, we need to do a little search to construct the data.

To avoid adding unnecessary allocations, we make the new APIs
opt-in. If you do not specify anything, you will only get the
glyph indexes and glyph positions as before. However, you
can now specify exactly which parts of the layout to extract
using an optional flags parameter.

This also adds a manual test which can be very handy to
visualize QTextLayouts and how they are split into QGlyphRuns.

Fixes: QTBUG-103932
Change-Id: Ie4288fff338b9482aba0aba29fc7e1e59fa60900
Reviewed-by: Lars Knoll <lars@knoll.priv.no>
2022-09-29 18:06:40 +02:00
Eirik Aavitsland
72a3da3d4d Style sheets: add placeholder text color property for edit widgets
The placeholder text was given its own QPalette color role in Qt 5.12,
but there has been no way to specify it from a Qt style sheet.

Fixes: QTBUG-93009
Change-Id: If58ca844c19c65b7eee14c6d5730a4ba27640c33
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-09-29 08:20:56 +02:00
Eirik Aavitsland
458ec4cb54 Fix setScaledClipRect autotest for reading SVG format
Since setScaledClipRect will actually render only the necessary parts,
there may be insignificant differences in rounding/anitaliasing
compared to rendering the whole image first and then clipping.

Hence this autotest case would always fail. But that would not happen
in CI, since it tests qtbase without the qtsvg module, and then the
SVG tests are skipped. (For some reason, one ran into this in wayland
testing and made an exception for that, but obviously this failure has
nothing to do with wayland).

Work around the issue by converting the rendered images to 4 bpc
format, so the differences in the least significant bits get truncated
away.

Fixes: QTBUG-100917
Task-number: QTBUG-81044
Pick-to: 6.4
Change-Id: I1c14e98af22d0ae22a751960b69e692c7a38399b
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2022-09-27 13:12:11 +02:00
Eskil Abrahamsen Blomfeldt
ce4c26c8d1 Revert "QTextLayout: fix maximumWidth() for a text containing line separator"
This reverts commit 013c346a8d. It was
determined to cause a regression in Qt Quick: QTBUG-106899.

In order to unblock integrations, we need to revert the change. It
can be re-committed later when the problem has been analyzed and
addressed.

Pick-to: 6.2 6.4
Fixes: QTBUG-106899
Task-number: QTBUG-89557
Task-number: QTBUG-104986
Change-Id: I04054587f68ab39fdb038b02fc69ebfa3dc7d197
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-09-23 20:08:56 +02:00
Edward Welbourne
73a2320278 Fix signed/unsigned comparison warning in shader test
Trivial, noticed while looking for deprecation warnings.

Change-Id: Ie2c450d457e25b998fb686c4c22333781364073c
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2022-09-22 17:34:51 +02:00