Commit Graph

2279 Commits

Author SHA1 Message Date
Shawn Rutledge
f1e60de665 QTextMarkdownImporter: don't apply text char format to list item block
We want an ordered list item's number to be rendered with default char
format, like the others in the same list, even if the list item's text
begins with a span that has a different char format.  So insert the
list item's block with a default char format first, then change the
char format of the cursor to suit the text that's about to be inserted.
In HTML interpretation, it means the <li> does not have a style, but
contains a styled span.

Fixes: QTBUG-92445
Task-number: QTBUG-3583
Task-number: QTBUG-99148
Pick-to: 5.15 6.2 6.3
Change-Id: I7eb58a8d1171c16503cac01c8cce109d9f12e1af
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
2022-01-06 22:06:09 +01:00
Shawn Rutledge
7b4b5115dd Blacklist tst_QTouchEvent::multiPointRawEventTransOnTouchPad - macOS
Task-number: QTBUG-99489
Change-Id: Ia74b0f7e3a82fe7cf68248109e84e8decbbc4ae3
Reviewed-by: Dimitrios Apostolou <jimis@qt.io>
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2022-01-06 21:06:09 +00:00
Tor Arne Vestbø
10dc445d7c Blacklist quitOnLastWindowClosedWithEventLoopLocker on B2Qt
It's flakey according to http://testresults.qt.io/grafana/goto/1WdyblA7k

Pick-to: 6.2 6.3
Change-Id: I4e5a3492d55222675534359416c1017dcba2cbfe
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-01-06 17:11:48 +01:00
Laszlo Agocs
0a59101495 rhi: Add support for separate image and sampler objects
For Direct 3D, Metal, and Vulkan this is natively supported. (and
makes no difference in particular for D3D and Metal because they do
not have the legacy combined image sampler concept anyways)

With OpenGL it will work too, but this relies on SPIR-Cross magic and
is still using a combined sampler (e.g. a sampler2D) in the GLSL
shader. The GL backend walks back and forth in the mapping tables from
the shader baker in order to make this work, which is presumably
slightly more expensive than combined image samplers.

Do note that combined image samplers (i.e. sampler2D in the shader and
QRhiShaderResourceBinding::sampledTexture() in code) continue to be
the primary, recommended way for any user of the rhi for the time
being.

Change-Id: I194721bc657b1ffbcc1bb79e6eadebe569a25087
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2022-01-06 14:56:25 +01:00
Kai Köhne
93c1f481ab Add QTextDocumentFragment::toRawText()
Like QTextDocument::toRawText(), QTextDocumentFragment::toRawText()
does allow access to the raw string without normalizing nbsp,
line separator, paragraph separator unicode characters.

[ChangeLog][QtGui][Text] Added QTextDocumentFragment::toRawText() function.

Task-number: QTBUG-99572
Change-Id: Ia74150a3870ea0e6326fdcda4d9d0410019124ae
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2022-01-06 07:58:39 +01:00
Giuseppe D'Angelo
9ea1f0f8b9 Fix qobject_cast on partially destroyed QWidget/QWindow
QWidget and QWindow use bits in QObjectPrivate to provide for a couple
of shortcuts -- one in qobject_cast, and another in the isWidgetType() /
isWindowType() functions in QObject. These can be optimized by simply
looking at the bits, without actually doing more expensive runtime
casts.

These bits were set on construction, but not unset on destruction.  The
result was for instance that destroying a QWidget would report that the
object was still a QWidget when ~QObject was reached.

Fix this

1) by setting the bits only when QWidget / QWindow constructors start;

2) by resetting the bits once ~QWidget / ~QWindow are completed.
Technically speaking this is not 100% correct in the presence of data
members, but luckily those classes don't have any.

Amend an existing test for QWidget (whose comment said exactly the
opposite of what the test actually did) and add a test for QWindow.

Some other code was wrongly relying on isWidgetType() returning true
for destroyed QWidgets; amend it as needed.

[ChangeLog][QtCore][QObject] Using qobject_cast on partially constructed
or destroyed QWidget/QWindow instances now yields correct results.
Similarly, using the convenience isWidgetType() / isWindowType()
functions now correctly return false on such instances. Before,
qobject_cast (and the convenience functions) would erroneously report
that a given object was a QWidget (resp. QWindow) even during that
object's construction (before QObject's constructor had completed) or
destruction (after QWidget's (resp. QWindow's) destructors had been
completed). This was semantically wrong and inconsistent with other ways
of gathering runtime type information regarding such an object (e.g.
dynamic_cast, obj->metaObject()->className() and so on).

Pick-to: 6.3
Change-Id: Ic45a887951755a9d1a3b838590f1e9f2c4ae6e92
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-01-05 02:47:47 +01:00
Laszlo Agocs
23f8d6c57f rhi: Drop the profiler for now
The system we inherited from the original Qt 5.14 introduction of QRhi
is a text stream based solution where resource creation and frame
timings are sent in a comma-separated format to a QIODevice.

This, while useful to get insights about the number of resources at a
given time, is not actively helpful. The frameworks built on top (Qt
Quick, Qt Quick 3D) are expected to provide solutions for logging
timings in a different way (e.g. via the QML Profiler). Similarly,
tracking active resources and generating statistics from that is
better handled on a higher level.

The unique bits, such as the Vulkan memory allocator statistics and
the GPU frame timestamps, are converted into APIs in QRhi. This way a
user of QRhi can query it at any time and do whatever it sees fit with
the data.

When it comes to the GPU timestamps, that has a somewhat limited value
due to the heavy asynchronousness, hence the callback based
API. Nonetheless, this is still useful since it is the only means of
reporting some frame timing data (an approx. elapsed milliseconds for
a frame) from the GPU side.

Change-Id: I67cd58b81aaa7e343c11731f9aa5b4804c2a1823
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2022-01-04 13:00:40 +01:00
Laszlo Agocs
04cdde30d6 rhi: Enable exposing separate image and sampler objects from the shader
Adds the following in a QShader/QShaderDescription:

- a list of separate images
- a list of separate samplers
- a list of "combined_sampler_uniform_name" -> [
  separate_texture_binding, separate_sampler_binding ] mappings
  (relevant for GLSL only)

On the QShader (and qsb/QShaderBaker) level not having separate image
(texture) and sampler objects exposed in the reflection info is not
entirely future proof. Right now we benefit strongly from the fact
that Vulkan/SPIR-V supports both combined and separate
images/samplers, while for HLSL and MSL SPIRV-Cross translates
combined image samplers to separate texture and sampler objects, but
it is not given that relying on combined image samplers will always be
possible in the long run; it is mostly a legacy OpenGL thing that just
happens to be supported in Vulkan/SPIR-V due to some benefits with
certain implementations/hw, but is not something present in any newer
APIs.

In addition, before this patch, attempting to run a shader with
separate textures and samplers through qsb will just fail for GLSL,
even though SPIRV-Cross does have the ability to generate a "fake"
combined sampler for each separate texture+sampler combination. Take
this into use. This also involves generating and exposing a
combined_name->[separate_texture_binding,separate_sampler_binding]
mapping table for GLSL, not unlike we have the native binding map for
HLSL and MSL. A user (such as, the GL backend of QRhi) would then use
this table to recognize what user-provided texture+sampler binding
point numbers correspond to which auto-generated sampler2Ds in the GL
program.

Take the following example:

layout(binding = 1) uniform texture2D sepTex;
layout(binding = 2) uniform sampler sepSampler;
layout(binding = 3) uniform sampler sepSampler2;

Inn the reflection info (QShaderDescription) this (assuming a
corresponding qtshadertools patch in place) now gives one entry in
separateImages() and two in separateSamplers().  Assuming sepTex is
used both with sepSampler and sepSampler2, the GLSL output and mapping
table from QShaderBaker will have two auto-generated sampler2Ds (and
no 'texture2D' or 'sampler').

One immediate benefit is that it is now possible to create a shader
that relies only on separate images and samplers, feed it into qsb,
generate all the possible targets, and then also feed the SPIR-V
binary into a tool or library such as Tint (e.g. to generate WGSL)
that canot deal with combined image samplers.

Change-Id: I9b19847ea5854837b45d3a23edc788c48502aa15
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2022-01-03 14:57:01 +01:00
Oliver Eftevaag
b369dc6021 QTextHtmlParser: fix prefix lookahead and html comments
The hasPrefix() function would only use the second 'lookahead' parameter
to check if there was more unparsed text after the current character.
When it's obvious from the codebase that it should actually look ahead
of the current character being processed, and compare againt that future
character.

Html comments were also not handled quite right. Partially because of
the broken hasPrefix() function, but also because it would advance the
current index tracker by 3 instead of 2. Remember that the beginning of
an html comment is <!-- meaning that there are only supposed to be 2
dashes required, not 3. The result would be that something like this
<!----> would not automatically close, because the current index tracker
would jump over the first 3 dashes when it begins a comment, and the
remaining unprocessed string would be ->

Also, because of the broken lookahead in hasPrefix(), a comment could
actually be started with just <!- not requiring a second dash at all.

Pick-to: 6.3 6.2 5.15
Fixes: QTBUG-99147
Change-Id: I8f4d4a1107eaf2dae16d16b7b860525d45a1c474
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-12-22 15:56:30 +01:00
Ralf Habacker
2e2f1e2af7 Add css media rule support for QTextDocument::setHtml()
CSS styles can contain '@media <rule> {...}' blocks, which were
previously ignored for all values except "screen".

To use a media rule other than the default "screen" rule,
specify it before calling setHtml() with setMetaInformation()
and the new info value 'CssMedia'.

[ChangeLog][Gui][QTextDocument] Add css media rule support
for QTextDocument::setHtml()

Pick-to: 6.3
Fixes: QTBUG-98408
Change-Id: Ie05f815a6dedbd970210f467e26b116f6ee3b9ca
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2021-12-15 11:36:37 +00:00
Tor Arne Vestbø
ae6dc7d6df Fix qt_scrollRectInImage when scrolling outside of the image
We were clipping the source rect to the image, both pre and post
scrolling, but did not apply the same logic to the target position.
By computing the target position based on the already clipped source
rect we ensure that the target position is also correct.

This was causing valgrind warnings on Linux, and crashes on Windows,
when trying to test the lower level QBackingStore::scroll() function.
The reason we were not seeing this in practice was that QWidget does
its own sanitation and clipping of the arguments before passing them
on.

As a drive-by, fix the access of image to use constBits instead of a
manual cast, and rename variables to better reflect their use.

Pick-to: 6.3 6.2 5.15
Change-Id: Ibc190c2ef825e634956758f612a018f642f4202b
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2021-12-14 14:11:26 +01:00
Laszlo Agocs
bc4570ed24 rhi: Auto-rebuild rt by tracking attachment id and generation
Unlike the shader resource binding lists that automatically recognize
in setShaderResources() when a referenced QRhiResource has been rebuilt
in the meantime (create() was called i.e. there may be completely
different native objects underneath), QRhiTextureRenderTarget has no
such thing. This leads to an asymmetric API and requires also rebuilding
the rt whenever an attachment is rebuilt:

rt = rhi->newTextureRenderTarget({ { texture } })
rt->create()
cb->beginPass(rt, ...)
texture->setPixelSize(...)
texture->create()
rt->create() // this should not be needed
cb->beginPass(rt, ...)

Avoid having to do that second rt->create().

Change-Id: If14eaa7aac3530950498bbdf834324d0741a7c4d
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2021-12-10 15:08:51 +01:00
Liang Qi
c8609d1e7a tests: add a capability check for QWindow::requestActivate() call
This amends b65159a5ea.

Pick-to: 6.2
Change-Id: I6055004375b440997ea41b3e4538854780202e10
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-12-08 21:08:04 +01:00
Mårten Nordheim
6f542f19bf QFontDatabase (Windows): Sanitize font requests early
After the windows font engine was no longer marking everything as
scalable we started limiting the font size of requests to the maximum
of Courier when it was requested. This was a regression from 5.8 and not
in agreement with our documentation.

The problem is that we would only make the switch from Courier to
Courier New after having already gone through the foundry-lookup and
found a closest-available font size for Courier.

With this sanitization step in the backend we can make these changes
early enough that we haven't yet adjusted e.g. the font size.

Pick-to: 6.2 5.15
Fixes: QTBUG-58995
Change-Id: I319e93e6b78c7c3c5539964ac5ab4e05f8902ab6
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2021-12-06 20:06:06 +01:00
Volker Hilsheimer
56bd1b76d2 Don't change resolve mask when setting brush doesn't change palette
After 556511f9f3, which moved the resolve
mask storage into the palette's d-pointer, modifying the resolve mask
requires a detach. As of now, we only detached when setting a different
brush, but always modified the resolve mask, which broke palettes that
shared the d-pointer (likely the global default palette).

However, detaching has negative side effects when styles set brushes on
temporary palette objects and then use that palette object's cache key
to build a cache of pixmaps. As each drawing would detach the palette
(even if the palette doesn't change, which is likely), the cache key
changes with each detach, and the cache would quickly increase in size.
This was addressed in changes d7bcdc3a44
and 1e75dcf251.

We can either detach and find other ways to address the issues from
QTBUG-65475, or we can not change the resolve mask when the brush doesn't
change and completely ignore the call.

Since QFont ignores the setting of any attribute to a value that is
identical to the current value, and since it's possible to force that
the resolve-bit is set by calling setBrush twice with different brushes,
ignoring the call seems like the better solution.

[ChangeLog][QtGui][QPalette] Setting a brush on a palette that is
identical to the current brush no longer sets the resolve mask bit for
that particular role, so items using the palette will continue to
inherit changes from parent items.

Fixes: QTBUG-98762
Task-number: QTBUG-65475
Pick-to: 6.2
Change-Id: Ife0f934b6a066858408ef75b7bb7ab61193ceb47
Reviewed-by: Simon Hausmann <hausmann@gmail.com>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-12-03 21:07:09 +01:00
Volker Hilsheimer
97cfd49401 Don't let text table cells shrink below their minimum width
We calculate the minimum width, but then use it only to make sure that
the maximum width is at least as large as it. Without setting the layout
struct's minimumWidth as well, table cells can be smaller.

Add a test case.

Fixes: QTBUG-86671
Fixes: QTBUG-97463
Pick-to: 6.2 5.15
Change-Id: Idf4ad015938abb8d3e599e9a58e002f29c0067be
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2021-12-02 15:16:49 +01:00
Eskil Abrahamsen Blomfeldt
6b02473e1e Fix overlapping text for Osaka font on macOS
The Osaka font on macOS has all zeroes in the OS/2 table, probably
because it is not intended to be cross-platform. In Qt 6 (since
f761ad3cd9) we are trying using the
same vertical metrics on all platforms, but this only works if
they are valid.

To work around this issue, we detect the case when ascent/descent
values are both 0, since this is very unlikely to be intentional,
so we fall back to the system-provided ascent and descent in these
cases.

Adding the test also revealed that we had missed the check for
a macOS-specific bitmap font format when skipping the check for
bitmap fonts in 7a18b7e2c2.

[ChangeLog][macOS][Text] Fixed a problem where using the Osaka
font would lead to overlapping text.

Pick-to: 6.2
Fixes: QTBUG-96880
Change-Id: Ifea7918641a68829e8f5ef20a4fb61c0a7e5b757
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-12-02 07:54:39 +01:00
Volker Hilsheimer
9538c7ca73 Don't shrink a column when it spans multiple columns
If a cell spans multiple columns, then the merged cells' starting
column's maximum width should never become smaller than what was
calculated from previous rows.

Otherwise, we'd distribute the space of the column that has a span
across all merged columns, resulting in unnecessary line breaks esp if
WrapAnywhere is enabled.

Add a test case.

Fixes: QTBUG-91691
Fixes: QTBUG-95240
Pick-to: 6.2 5.15
Change-Id: Ic27dbdb128071e50fba049de85c9f23ba2f059b3
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2021-12-01 21:23:05 +01:00
Alexandru Croitor
4ad57bb212 Re-enable tst_qopenglwindow on Linux
Amends 5d6705c567

Change-Id: I359b638465e24f3da0941083f9ad6f022b5222ed
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2021-12-01 03:28:56 +01:00
Eirik Aavitsland
8fbedf2196 QTextDocument: fix an off-by-one in the changed signal for lists
When blocks are added or removed in block groups, i.e. items added or
removed from text lists, the whole group is marked as changed, but the
calculation of the before/after group length would be one off. That
was reflected in the contentsChange signal.

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

Fixes: QTBUG-82455
Pick-to: 6.2 5.15
Change-Id: I99ee2cfef4944fcac8aca492741fd0f3b0de4920
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2021-11-29 13:25:31 +01:00
Laszlo Agocs
5a496a614b rhi: Add a more sophisticated resource update autotest case
This time exercising series of buffer updates and texture uploads
within proper, on-screen frames. (particularly interesting for dynamic
buffers in case the double (or more) buffering and having multiple
frames in flight involves special bookkeeping for these - using
'offscreen' frames like in other test cases does not necessarily
exercise all of this)

Change-Id: Id470919d27037359a1f0346a50a2a0e3966f5cd2
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2021-11-27 00:19:27 +01:00
Yuhang Zhao
e01c25e859 QtBase: replace windows.h with qt_windows.h
We have some special handling in qt_windows.h,
use it instead of the original windows.h

Change-Id: I12fa45b09d3f2aad355573dce45861d7d28e1d77
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-11-23 12:53:46 +08:00
Eskil Abrahamsen Blomfeldt
cde562cf6d Properly fix QFontDatabase test on Freetype
Amends 4dd5020fbdfdd34f1e4ec54521217e472942a4b4. I messed up the fix for
the XFAIL condition, since the font engine type we get from a normal QFont
will be QFontEngine::Multi regardless of whether the actual font engines
are Freetype or not. Use NoFontMerging to avoid this.

Pick-to: 6.2
Task-number: QTBUG-97995
Change-Id: I2298c997e6826e667dbb8e3d004821f296625ef7
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2021-11-19 15:59:41 +01:00
Eskil Abrahamsen Blomfeldt
71faedc5b4 Fix deserializing Qt 5.x fonts through QDataStream
In Qt 5, fonts had both singular family and plural families properties,
and both were stored separately when streaming through QDataStream. The
families list was treated as an extension of family in this case, and
the primary font family was always the singular family property.

In Qt 6, it has been merged into one and family() is now just a
convenience for families().at(0).

But when reading files generated with Qt 5, we would ignore the fact
that these were previously separated. We would first read the family
entry into the families list, and then we would later overwrite this
with  an empty families list.

Instead, we detect streams created with Qt 5.15 or lower and make sure
we append the families list instead of overwriting it in this case. In
addition, we need to make sure we split up the list again when
outputting to Qt 5.x.

This adds a file generated with QDataStream in Qt 5.15 to the test to
verify.

[ChangeLog][Fonts] Fixed a problem deserializing the family of fonts
that had been serialized using QDataStream in Qt 5.

Pick-to: 6.2
Fixes: QTBUG-97995
Change-Id: Id3c6e13fc2375685643caee5f8e3009c00918ccb
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
2021-11-18 23:41:02 +01:00
Eskil Abrahamsen Blomfeldt
518790af79 Fix tst_qfontdatabase on Windows with Freetype
Since e05e3c7762, the advance test in
tst_QFontDatabase::condensedFontMatching() passes with the bundled
freetype engine, so the XFAIL causes a failure when running with this
configuration.

Pick-to: 6.2
Change-Id: Ie6fbccfa0d9c79654563e9e3f19694f252e32fc6
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2021-11-10 15:37:03 +01:00
Laszlo Agocs
a8be40bd64 rhi: Expose the maximum uniform buffer range limit
Pick-to: 6.2
Task-number: QTBUG-97715
Change-Id: I7f0a52c410b9b77f735fb3b7fd33141674bb0cda
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2021-11-10 13:31:05 +01:00
Marc Mutz
0b768e3c43 Include qproperty.h where needed
Don't rely on transitive include from qobject.h, which will go away.

Change-Id: I99dd97ff4fb1d0632d040daab0bffa2d7b85d3ae
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-11-04 21:45:02 +01:00
Laszlo Agocs
e7a1fbfc47 rhi: Add texture array support
Arrays of textures have always been supported, but we will encounter
cases when we need to work with texture array objects as well.

Note that currently it is not possible to expose only a slice of the
array to the shader, because there is no dedicated API in the SRB,
and thus the same SRV/UAV (or equivalent) is used always, capturing
all elements in the array. Therefore in the shader the last component
of P in texture() is in range 0..array_size-1.

Change-Id: I5a032ed016aeefbbcd743d5bfb9fbc49ba00a1fa
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2021-10-29 15:57:13 +02:00
Allan Sandfeld Jensen
4748369eb2 Fix inconsistencies between advanceWidth and bounding rects
Unify the logic in QTextEngine

Ensure tightBoundingRect, and the FreeType boundingRect, calculates from
the shaped x offset when calculating the max x coordinate for a glyph.

Fixes: QTBUG-7768
Task-number: QTBUG-70184
Task-number: QTBUG-85936
Task-number: QTBUG-94023
Change-Id: I6daafb25c79158dc7e777529abb5e8d3a284dac0
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2021-10-21 12:37:22 +02:00
Tor Arne Vestbø
acb86da793 Prevent recursive calls to QWindow::close
QWidget will call close() in its destructor, which we might end up
in if a user deletes the widget in the closeEvent.

Pick-to: 6.2
Change-Id: I39684aec0ca130033dad60f2bbf823364a5edcec
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-10-18 19:06:48 +02:00
Tor Arne Vestbø
df359bcb70 Decouple quitOnLastWindowClosed from quitLockEnabled
In a512e210ac5b032c5fc2edf1ddf72e5a414485fda512e21 quitOnLastWindowClosed
was changed to be implemented in terms of quitLockEnabled, but without
any documentation to that end.

Although the two features are similar (automatic quit under certain
conditions), and interact, it doesn't make sense to overlap them until
we actually expose them as a single property (automaticQuit e.g.)

The logic for determining whether we can can quit automatically has
been refactored to take both properties into account, on both a Core
and Gui level. The call sites still need to check the individual
properties to determine whether to activate automatic quit for
that particular code path.

Change-Id: I38c3e8cb30db373ea73dd45f150e5048c0db2f4d
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-10-18 15:29:09 +02:00
Volker Hilsheimer
5335cc4a5a Fix cursor positioning on bidi boundaries
When the cursor is positioned between to script items that have different
writing directions, prioritise the script item that has the same direction
as the paragraph (i.e. the QTextEngine) when deciding where and how to
display the cursor. If visual cursor movement is enabled, the behavior is
unchanged.

As a drive-by, clean up coding style and avoid shadowing of function-
local variables.

Task-number: QTBUG-88529
Pick-to: 6.2
Change-Id: I15227b10b1469d9caf1235b00e4d6f9f64a8b510
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-10-18 13:05:42 +02:00
Volker Hilsheimer
f54044d4a9 Fix cursor placement at left and right ends of bidi text
In a text line that has a change of direction at either end of the text,
the cursor needs to be positioned where the next character is inserted,
or where backspace deletes the previous character. In bidi text, this is
ambiguous as illustrated by this example:

abcشزذ

Depending on whether this string was typed in a left-to-right document
or in a right-to-left document, it could be first latin, then arabic; or
it could be first arabic, then latin.

If a general left-to-right context, cursor position 0 should be in front
of the 'a', and cursor position 6 should be at the end of the arabic
text, in the visual middle of the line. Cursor position 3 can be either
after the 'c' if the next character typed would be latin, or at the
visual end of the line if the next character will be arabic.

Qt calculated the cursor position past the right end of the text as 3
(which is not wrong, but 3 has two visual positions), and placed the
cursor at the visual end of the line (favoring the right-to-left
alternative). Backspace would then delete the 'c', writing a new
latin character would insert a 'd' next to the 'c', writing a new arabic
character would insert it also in the middle - none of these operations
happen at the visual end of the line, where the cursor was blinking.

To fix this, we take into account the general layout of the text, which
is typically based on the document, or the user's locale setting and UI
translation, and calculate the cursor position accordingly: if we are
past the visual end of the document on either side, then the cursor
position is either 0 or the last character of the text, depending on the
direction of the QTextEngine used. This way, the cursor ends up in the
middle of the document when we click beyond the end of the line, which
is where characters are removed and inserted. Typing a 'd' at this point
will make the cursor jump to the end, where the d is added.

There are still corner cases: clicking on the right-most arabic character
calculates the cursor position as 3, which is then ambiguous, as it can
be either at the visual end of the string, or next to the 'c'. َQt makes
the inconsistent choice to place the cursor at the visual end, showing
the left-to-right indicator, but pressing a 'd' adds the 'd' after the
'c' in the middle of the text.

Fixes: QTBUG-88529
Pick-to: 6.2
Change-Id: Idccd4c4deead2bce0e858189f9aef414857eb8af
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-10-18 13:05:42 +02:00
Shawn Rutledge
362e56b520 Markdown importer: keep entities in HTML blocks with the HTML
If an entity occurs directly in markdown, we parse and insert it
directly; but if it occurs in an HTML block, it has to be added to the
HTML accumulator string for deferred parsing when the HTML block ends.

Pick-to: 6.2
Fixes: QTBUG-91222
Fixes: QTBUG-94245
Change-Id: I0cf586d68d6751892ca035a98f77cd67950d3bc4
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-10-16 16:10:49 +02:00
Andy Shaw
a36c84c6a3 When filling a pixmap after an assignment ensure the set DPR is not lost
Pick-to: 6.2 5.15
Change-Id: I649547ea277f9d074e6638e4b7b1206d3d3d976b
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2021-10-15 10:27:15 +02:00
Shawn Rutledge
5e55297ee0 Markdown writer: indent fence consistent with code block
- Under a list item, we've been indenting code blocks:
  ```
  int main() ...
  ```
- But it's also ok *not* to indent (and github handles that better):
```
int main() ...
```
- There was a bug that when the code is not indented, the fence would be
  indented anyway:
  ```
int main() ...
  ```
  and that was not OK, neither for md4c nor for github.

Now with this change, either way is rewritable: you can read markdown
into QTextDocument, make small edits and write it back out again, with
the indentation being preserved (the code block is either part of the
list item, thus indented, or else it's outside the list completely).

Pick-to: 6.2
Task-number: QTBUG-92445
Change-Id: I5f51899e28ba9f09b88a71e640d9283416cce171
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-10-14 19:57:09 +02:00
Shawn Rutledge
5c436365f5 Support background-color CSS styling on <hr/>
[ChangeLog][QtGui][CSS] The background-color style can now be applied to
<hr/> to set the rule color.

Task-number: QTBUG-74342
Change-Id: Ib960ce4d38caa225f258b6d228fb794cef43e1b7
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2021-10-14 17:09:20 +02:00
Volker Hilsheimer
8513bcd90c Fix caching of parsed border color values in CSS parser
When parsing CSS, a border-color value is parsed as four brushes, as css
allows assigning up to four values, one for each side.

When applying the CSS to the HTML, we accessed it as a color value,
which overwrote the parsed value with a QColor. So while we had a valid
parsed value (and didn't re-parse), the code accessing that value still
expected it to be a list, and thus failed to retrieve the data.

There are several ways to fix that, but the cleanest way without
introducing any performance penalty from repeatedly parsing (and in fact
removing a parse of the string into a color) is to enable colorValue to
interpret an already parsed value that is a list without overwriting the
parsed value again. To avoid similar issues in the future, add assert
that the parsed value has the right type in brushValues.

As a drive-by, speed things up further by making use of qMetaTypeId
being constexpr, which allows for it to be used in a switch statement.

Add a test case.

Fixes: QTBUG-96603
Pick-to: 6.2 5.15
Change-Id: Icdbff874daedc91bff497cd0cd1d99e4c713217c
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-10-12 18:26:26 +02:00
Thiago Macieira
8e5fcf02bd QPlugin: add qt_plugin_query_metadata_v2() to dynamic plugins
They return a pointer to the actual header, skipping the magic string.
This is done in preparation for the header located in an ELF note, which
won't have the magic.

Change-Id: I3eb1bd30e0124f89a052fffd16a8229bec2ad588
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-10-11 18:59:52 -07:00
Juan Casafranca
0263cfdfa0 Remove qshadergraph files
- Those files were moved as part of Qt3D as its the sole
  user of these
- Also removed associated unit tests

Pick-to: 6.2 5.15
Change-Id: I302bc219218a58071c86d2447cb4449601fca32c
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mike Krus <mike.krus@kdab.com>
2021-10-05 17:49:51 +02:00
Albert Astals Cid
ae10084ef9 Respect font stretch if set together with font style
Fixes: QTBUG-77854
Change-Id: I2bf9cea9d5ecd151a9d96bbe93e9477a9159ca1f
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2021-10-04 16:10:11 +02:00
Volker Hilsheimer
132d6d0127 QFontCache: don't start cleanup timer if we are not in the main thread
We can only start timers in threads started via QThread, and even then
we cannot assume that the thread runs an event loop. So only start the
timer when we are in the main thread.

Add a test that verifies that we don't get the warning message.

Pick-to: 6.2
Change-Id: I40d7d9ff115720f9ecd3eedaebbade2643daf843
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-10-01 16:46:48 +02:00
Eirik Aavitsland
66a44f4eba Preserve QImage metadata when converting format with color table
Unlike the other conversion functions, convertWithPalette() did not
call copyMetadata().

Fixes: QTBUG-96926
Pick-to: 6.2 5.15
Change-Id: I2b171cec16bc5a90d33e80d6fe178c650ed3fe36
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2021-09-28 15:59:31 +02:00
Volker Hilsheimer
6dc587dfdd Un-blacklist quitOnLastWindowClosedMulti test on macOS in CI
After the recent refactoring in 28b14b966f
this test should run stable on all platforms. However, the way the test
was written made it quite flaky. Simplify it to verify that closing one
window doesn't prevent a second timer to fire (which it would if closing
the first window already quit the application).

Change-Id: I0306792cd7573ebd3418d1aabffe2b78700ec2d9
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-09-20 19:00:05 +02:00
Volker Hilsheimer
8fcfd7f591 Eat expected warning messages in QGuiApplication test
Verifies that we get the messages we want, and makes it easier to see
relevant debug output.

Pick-to: 6.2
Change-Id: Ide92959b120f325badbf200236cdc85f72226e1e
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-09-20 19:00:05 +02:00
Tatiana Borisova
766904bf5b Compile autotests for Integrity
- process environment/DNS are OFF for INTEGRITY

Task-number: QTBUG-96176
Pick-to: 6.2
Change-Id: I189a97f88c96a428586c31a66b8d250e04482900
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-09-20 17:29:04 +03:00
Laszlo Agocs
481bc82d59 rhi: Remove Q_RELOCATABLE_TYPE for types with QVLA in them
QVLA itself is non-relocatable due to self references. (ptr pointing
to array[Prealloc] as long as capacity < Prealloc)

Seems we shot ourselves in the foot in multiple places with this.

Pick-to: 6.2 6.2.0
Fixes: QTBUG-96619
Change-Id: I57a2ce539b671326cd352dbe57a1f3d4c46a6456
Reviewed-by: Tobias Koenig <tobias.koenig@kdab.com>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-09-20 12:25:37 +02:00
Ivan Solovev
b4bb3a5415 Introduce QDoubleValidator::setRange overload with two parameters
The QDoubleValidator::setRange() used to have 3 parameters, with
the third one (the number of decimals) having a default value of 0.
Such default value does not make much sense for a *double* validator.
Also, since a default value was used, omitting the decimals was
silently overwriting the previous decimals value, discarding the
value that could be previously explicitly specified by user.

[ChangeLog][QtCore][QDoubleValidator][Important Behavior Changes] The
QDoubleValidator::setRange() method now has two overloads.
The first overload takes 3 parameters, but does not support a
default value for decimals.
The second overload takes only two parameters, not changing the
number of decimals at all.
Hence, the number of decimals will only be changed if the user
explicitly specifies it.
To maintain the old behavior of setRange(), pass 0 as the 3rd
argument explicitly.

Note that it is a source-incompatible change. But it should be fine,
because using QDoubleValidator with 0 digits after decimal point does
not make much sense and so, hopefully, is not that common.

At the same time, change the default-constructed QDoubleValidator
to use -1 for decimals, which allows arbitrarily many digits in
the fractional part. The value was previously 1000, which allowed
more than anyone would reasonably use, so this should make no
practical difference.

Some more unit tests to cover the behavior of the setRange()
overloads are also added.

As a dirve-by: remove unnecessary QValidator::State to int conversions
in the unit tests. QCOMPARE is capable of comparing these enums and
provides a better output in case of failure for enums.

Task-number: QTBUG-90719
Change-Id: I523d6086231912e4c07555a89cacd45854136978
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-09-20 09:39:13 +02:00
Edward Welbourne
7a4b586f4b Remove conditioning on Android embedded
It is no longer handled separately from Android.
This effectively reverts commit 6d50f746fe

Change-Id: Ic2d75b8c5a09895810913311ab2fe3355d4d2983
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2021-09-17 17:30:14 +02:00
Laszlo Agocs
0dbed05bbc rhi: vulkan: Reset state more aggressively
...when starting a render/compute pass.

This matches most other backends in fact, the Vulkan backend has
just certain historical differences, and is complicated due to the
fact that it has the option of using secondary command buffers for
passes that specify ExternalContents (to support the case of wanting
to issue direct Vulkan commands in a code block surrounded by calls
to beginExternal and endExternal).

Not resetting state such as the currently bound index buffer when
starting a pass quickly blows up when two consecutive render passes
use different settings, one targeting the primary while the other
the secondary command buffer. Instead of further complicating the
logic, just reset the relevant state in every begin(Compute)Pass.

Comes with an autotest that is crafted so that it manages to
downright crash when run with Vulkan without the fix to the backend.

Fixes: QTBUG-89765
Pick-to: 6.2
Change-Id: I8dc47bd179c17d45a0556ec31200dc90c4b67ca5
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2021-09-17 16:48:44 +02:00
Ivan Solovev
fb3549fc47 Introduce QDoubleValidator::fixup()
The provided implementation tries to fix positions for the group
separator.
In case of scientific notation it can also converts the value to
normalized form.
It uses QLocale::FloatingPointShortest internally to convert the
double value back to string, so the number of decimals may change
after calling this method.

Change-Id: I963bc5f97b653e2bb912f4b95b09a4d1ee201e7f
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-09-17 09:55:11 +02:00
Laszlo Agocs
43a42fa196 rhi: Allow testing renderpass compatibility without the objects
Follow what has been done for QRhiShaderResourceBindings. Have a way
to retrieve an opaque blob (that just happens to be a list of integers)
so that a simple == comparison can be used to determine compatibility
even when the objects from which the blob was retrieved are no longer
alive.

The contract is the following:

bool a = rp1->isCompatible(rp2);
bool b = rp1->serializedFormat() == rp2->serializedFormat();
assert(a == b);

Pick-to: 6.2
Change-Id: I45e7d05eeb6dfa2b2de474da0a0644912aaf174a
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Christian Strømme <christian.stromme@qt.io>
2021-09-16 22:58:17 +02:00
Eskil Abrahamsen Blomfeldt
e0ad2cee55 Fix querying font aliases that share name with other fonts
a332f3fabc disabled resolving all fonts
on the system for every font lookup, which was a significant startup
time improvement. But it also caused a regression: When a font has
an alias which shares the name of a proper font, then this would
not be resolved correctly.

This is fairly typical on Windows/GDI due to backwards-compatibility.
Instead of being collected under a shared typographical family, fonts
are disambiguated by adding the style name to the family name. The
proper typographical name is still available, but this is not
enumerated by the system.

So "Segoe UI" for instance, will be available as "Segoe UI",
"Segoe UI Light", "Segoe UI Bold" etc.

When we populate family aliases, we register that "Segoe UI Light"
is actually "Segoe UI" with Light weight, and prior to
a332f3fabc this would be done implicitly.

But after the optimization, we would only populate family aliases once
we stumbled over a font request for a non-existent font. For "Segoe UI",
we would simply return the regular weight font as the best imperfect
match.

The fix is to populate font family aliases not only when the family is
non-existent, but when the match is imperfect, e.g. if we are asking
for a Light weight font and only finding a regular one. User code can
still avoid this somewhat expensive operation by using the full
family names on Windows.

This also requires a fix to a test. When removeApplicationFont() is
called, we invalidate the font database, so it will be reset to a state
that does not contain the family aliases. Therefore we cannot guarantee
that it is identical to what it was before the test started, since this
depends on what has happened previously in the application.

[ChangeLog][QtGui][Text] Fixed an issue where some font styles and weights
would not be selectable. This was especially noticeable on Windows.

Pick-to: 5.15 6.1 6.2
Fixes: QTBUG-94835
Change-Id: I892855edd1c8e3d3734aace396f6000d897d2ec4
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-09-11 11:59:51 +00:00
Morten Johan Sørvig
04fd894400 High-dpi configuration change testing
Export configuration() and setConfiguration() from the offscreen
platform plugin using QPlatformNativeInterface. tst_qighdpi can
then resolve and make use of them since it always uses the offscreen
platform plugin.

Add screenDpiChange() auto test.

Change-Id: I459b4df5d94ec4991234a346e3a94618cb3485e9
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-09-08 19:01:54 +02:00
Ivan Solovev
2d97c08bcd QIntValidator: add tests for fixup()
Noticed the missing tests while implementing fixup() for
QDoubleValidator.

Change-Id: Ic0e053a6385e311e4a491c8bff8ec7fbb83c3944
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-09-08 15:43:16 +02:00
Laszlo Agocs
ce9d0491f2 rhi: Improve srb layout serialization helpers
Be idiomatic and return the output iterator one past the last element.
Otherwise passing in a plain pointer (as exercised by the autotest now)
fails to function because we write over the same 4 elements again and
again for each binding.

Pick-to: 6.2
Change-Id: If74463fa5140ffa2b1d5be97b71868848ad46614
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2021-09-07 21:47:44 +02:00
Laszlo Agocs
4cde0e484c rhi: Enable serializing a layout description without baking an srb
Pick-to: 6.2
Change-Id: I66d28cc9d5417bcd5d192fa100c21f69fd42fd6b
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2021-09-07 14:41:11 +02:00
Laszlo Agocs
b6b0c33058 rhi: Make the serialized srb layout description accessible
...by the Qt Quick renderer, for example.

A typical Qt Quick material binding set serializes to 8 uints. This
would not demand a container like QVector. However, being implicitly
shared is essential here due to the intended usage (query the
serialized blob, put it into a cache key, hash it, compare it, all
without any copying and new allocs; we can afford an extra alloc
upon each srb construction, but don't want more afterwards in the
rendering engines)

Also make it clear in the pipeline docs that the optimization Qt Quick
is (soon going to be) doing is legal. (the srb ref in the pipeline can
be dead and dangling as long as every call to setShaderResources()
specifies a layout-compatible alternative)

Pick-to: 6.2
Change-Id: I97efbea1fa3516b10c9832adbab0a21b7bc0845d
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2021-09-07 14:41:11 +02:00
Morten Johan Sørvig
8c2fda1ef5 Test QWindow close() behavior
Verify that closing a QWindow using either the close()
API or a close event works as expected, and that the window
can be re-created. Also test QWindows with child windows.

Task-number: QTBUG-46701
Change-Id: I4c12452ff58e1233536c2d6932e72cf924d8ed74
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2021-09-02 20:34:48 +02:00
Ivan Solovev
313de93b1d QDoubleValidator: fix NaN check in validateWithLocale
We can't really compare two NaN's. Should use qIsNaN() for that.

Pick-to: 6.2
Change-Id: Ia514cabe65cfcdeafb39cab91ecdb66f8fae725c
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-09-01 17:11:43 +02:00
Eskil Abrahamsen Blomfeldt
43a63901f4 Fix bug with NoFontMerging when font does not support script
When using NoFontMerging, no fallbacks should be resolved. If the
font does not support a specific character in the text, we should
display a box instead of merging it with another font.

But in practice, Qt would still apply the fallback mechanism for
one specific case: If the font itself does not support the script
of the text, we would get no match and do a search for a fallback
instead. Since NoFontMerging is set, we would then force this
as preresolved for *all* scripts in the QFont's private data
(logically, the match should only have a single response for
NoFontMerging).

The end result was that if you set the font family before updating
the text, you would get broken rendering. This can happen e.g. in
Qt Quick, where you could update the font family of a text label
while it contains characters which are not supported by the new
font. Qt would then pick a fallback instead. When you subsequently
update the text, the fallback would already be preresolved for
whatever script this is. If it does not support the updated text,
we would then see boxes, even if the requested font actually would
have supported it.

The fix is simply to do an additional pass if NoFontMerging is set
and we were not able to match with the specified script. Since
the same family might be available in different foundries, with
different writing system support, we still want to do a pass first
to see if we can match the exact script of the text.

Note that QRawFont::fromFont() exploited the bug by using
NoFontMerging for getting the fallback font for a specific
writing system. To keep this working without having to rewrite
fromFont() and risk introducing regressions, we add an argument
to make the findFont() function behave as before. It isn't
super-pretty, but since it is private API it is hopefully fine.

[ChangeLog][QtGui][Text] Fixed an issue with NoFontMerging and
changing font families dynamically, where boxes would be seen in
place of the correct text.

Pick-to: 5.15 6.1 6.2
Done-with: Andy Shaw
Fixes: QTBUG-81770
Change-Id: Ide9a36d7528a1040172c5864fa99e7a82eac4e83
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-08-19 13:35:40 +02:00
Ievgenii Meshcheriakov
a7484002a3 tests: Remove unused SRCDIR defines
Remove SRCDIR defines from tests that don't use them. There is a
standard define called QT_TESTCASE_SOURCEDIR that is available to all
tests and serves the same purpose.

Pick-to: 6.2
Change-Id: I2aa237739c011495e31641cca525dc0eeef3c870
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-08-17 12:41:57 +00:00
Ievgenii Meshcheriakov
c859b335b9 tests: Use QT_TESTCASE_SOURCEDIR define
Replace custom SRCDIR define with QT_TESTCASE_SOURCEDIR. The latter is
automatically available to all tests to use and serves the same purpose
but is not terminated by a slash.

Change-Id: I62896d0fd84ac63ac1b74a459ec1646c6bde0a46
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-08-11 21:03:56 +02:00
Eirik Aavitsland
84aba80944 Refix for avoiding huge number of tiny dashes
Previous fix hit too widely so some valid horizontal and vertical
lines were affected; the root problem being that such lines have an
empty control point rect (width or height is 0). Fix by caculating in
the pen width.

Pick-to: 6.2 6.1 5.15
Change-Id: I7a436e873f6d485028f6759d0e2c6456f07eebdc
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2021-08-10 12:00:13 +02:00
Tor Arne Vestbø
bef57b317f testlib: Deprecate QWARN() in favor of qWarning()
The QtTest best practices documentations recommends using output
mechanisms such as qDebug() and qWarning() for diagnostic messages,
and this is also what most of our own tests do.

The QWARN() macro and corresponding internal QTest::qWarn() function
was added when QtTest was first implemented, but was likely meant as
an internal implementation detail, like its cousin QTestLog::info(),
which does not have any corresponding macro.

This theory is backed by our own QtTest self-test (tst_silent)
describing the output from QWARN() as "an internal testlib warning".

The only difference between QWARN() and qWarning(), besides the much
richer feature set of the latter, is that qWarning() will not pass
on file and line number information in release mode, but QWARN() will.
This is an acceptable loss of functionality, considering that the user
can override this behavior by defining QT_MESSAGELOGCONTEXT.

[ChangeLog][QtTest] QWARN() has been deprecated in favor of qWarning()

Pick-to: 6.2
Change-Id: I5a2431ce48c47392244560dd520953b9fc735c85
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-08-04 19:31:51 +02:00
Laszlo Agocs
b594374ba8 rhi: Be more graceful when one destroys a resource after the QRhi
One is a bad application or library in this case, but nonetheless
we should handle this more gracefully then just crashing due to
the QRhi already having been destroyed. Mainly because in Qt 5 one
could get away with the same: releasing OpenGL objects underneath,
for example, a QSGPlainTexture with no (or wrong) GL context did
not generate any user visible fatal errors. So we should not crash
in Qt 6 either with these code bases.

In debug builds or when QT_RHI_LEAK_CHECK is set, one will get the
unreleased resources warning printed in Qt 6, which is a step
forward compared to Qt 5. So there is still some indication that
something is badly designed, even if the application survives.

Task-number: QTBUG-95394
Pick-to: 6.2
Change-Id: I944f4f425ff126e7363a82aff926b280ccf1dfc3
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2021-08-02 14:35:33 +02:00
Luca Beldi
1dcfb09c5b emit layoutAboutToBeChanged timely
layoutAboutToBeChanged must be called before
persistentIndexList as the user might create persistent indexes
as a response to the signal

Fixes: QTBUG-93466
Pick-to: 6.2 5.15
Change-Id: I73c24501f536ef9b6092c3374821497f0a8f0de4
Reviewed-by: David Faure <david.faure@kdab.com>
2021-07-20 21:27:27 +01:00
Eirik Aavitsland
f0510d5bd2 Improve support for saving QImage to QSaveFile
When saving to a QIODevice, QImage and QImageWriter will automatically
deduct the file format from the filename if it determines that the
device is a QFile. That did not work for a QSaveFile device. Fix by
using the common ancestor, QFileDevice, in the implementation.

Fixes: QTBUG-89022
Pick-to: 6.2
Change-Id: Ie01d80df4f29ca0d4ff30bf7e1b77605293c070e
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-07-14 11:02:25 +00:00
Marc Mutz
ff6156204d QColorTrcLut: hold in shared_ptr
... instead of raw pointers or QSharedPointer.

Raw pointers are, of course, a no-no in modern code. In particular,
when the result is then held in shared_ptr or QSharedPointer,
make_shared or QSharedPointer::create() should be used to reduce
number of memory allocations.

Since this is private API, we're free to use std::shared_ptr, which
does only half the atomic operations on copies, compared to
QSharedPointer, so is more efficient.

For either make_shared or QSharedPointer::create(), we need to work
around the private ctor, which we do by inheriting a member-function
local class from QColorTrcLut and make_shared'ing that. As a
member-function-local class, it has access to the otherwise private
parts of QColorTrcLut, including its default constructor. As a public
subclass, shared_ptr has no problem performing the derived-to-base
pointer adjustment in the return statement. This way, we can use
make_shared even though our target's class' ctor is private.

Change-Id: Icb11249b54cd5e544e692f6a0bf1f9dda1710454
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2021-07-12 22:16:41 +02:00
Marc Mutz
bc1808794d tst_QMatrixNxN: fix type-punning warning
... by making the test class a friend of the CUT, as we do elsewhere
for the same reason.

This allows to remove the duplicated enum and struct in favor of using
The Real Thing™, which means the test can no longer go out of sync
with the CUT anymore.

Change-Id: I87dc8bb4a5476ae4fc99e006c4690e96d2f530d2
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2021-06-30 23:13:28 +02:00
Marc Mutz
0ed1f8b54e tests: fix deprecated implicit capture of this via [=]
Fixes compiler warnings:
    warning: implicit capture of ‘this’ via ‘[=]’ is deprecated in C++20 [-Wdeprecated]

Change-Id: Ia7cf50f491e92f39162c69afb2a8320afedba056
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2021-06-30 23:13:28 +02:00
Marc Mutz
7a01e44404 tst_QWindow: fix -Wsuggested-override
Change-Id: I9e6eb0a4e0a64146d3c733c8cf34530a2cca5c4b
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2021-06-30 23:13:27 +02:00
Eirik Aavitsland
e473d96e65 Avoid overflow in text layout
Fixes oss-fuzz issue 34597.

Fixes: QTBUG-94197
Pick-to: 6.2 6.1 5.15
Change-Id: Icabcd5a87b809b6a5ae0f1a696ec3b5dd906886b
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2021-06-17 09:58:27 +00:00
Allan Sandfeld Jensen
ec675f5dc7 Improve tst_QColorSpace::imageConversion64PM test
Makes it able to catch the last bug of saturating color values above a
certain value.

Change-Id: Ib2a3918623a1defe2981efe61cf8118e019e9d4b
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2021-06-16 12:23:41 +02:00
Edward Welbourne
accdfbb396 Prefer QFAIL("Informative message") over QVERIFY(false)
Change-Id: I706b0aedfa870452331a8c2c488d55b279ee452a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-06-14 15:57:16 +02:00
Volker Hilsheimer
b65159a5ea Deliver WindowActivate/Deactivate events to QWindow
We need those events to trigger palette color group changes in QQuickItem
without having to connect every item to yet another QWindow signal.

Task-number: QTBUG-93752
Pick-to: 6.2
Change-Id: I8534808cdaab828e5876f8fda31567aeb1b4272a
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-06-11 23:30:09 +02:00
Laszlo Agocs
64089b900f rhi: Enable reading back slices of 3D textures
Change-Id: I0c687677b7e86b7284130c775718b29aca2cca40
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2021-06-03 17:05:44 +02:00
Eirik Aavitsland
2b52452843 Add load/fromdata() overloads taking QByteArrayView to QImage
Handy when one has the data buffer to be read in a QBAV.

This also fixes an issue and compiler warning about passing a
qsizetype data length value as an int, and makes it possible to pass
a qsizetype-size length without going through QByteArray.

Makes the QByteArray overload redundant.

Change-Id: Iba8825cf0fd8003fb2eac5b1d30a61ec91b85ceb
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2021-06-02 23:02:45 +02:00
Inho Lee
7ea2fbddcf QtGui/math3d : Fix QQuaternion::getEulerAngles
When rotating M_PI_2 based on x-axis, quaternion to euler conversion
makes NaN for the x-rotation value.  This patch fixes this corner case.

Fixes: QTBUG-93600
Pick-to: 6.1 6.0 5.15
Change-Id: Ice321a80ad90dba9cf3ee3a14ec7d3d047c21bd3
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2021-06-01 09:01:23 +02:00
Laszlo Agocs
51c22a1f51 rhi: Add support for 3D textures
Supported on OpenGL (and ES) 3.0+ and everywhere else.

Can also be a render target, targeting a single slice at a time.

Can be mipmapped, cannot be multisample.

Reading back a given slice from a 3D texture is left as a future
exercise, for now it is documented to be not supported.

Upload is going to be limited to one slice in one upload entry,
just like we specify one face or one miplevel for cubemap and
mipmapped textures.

This also involves some welcome hardening of how texture subresources
are described internally: as we no longer can count on a layer index
between 0..5 (as is the case with cubemaps), simply arrays with
MAX_LAYER==6 are no longer sufficient. Switch to sufficiently dynamic
data structures where applicable.

On Vulkan rendering to a slice needs Vulkan 1.1 (and 1.1 enabled on the
VkInstance).

Task-number: QTBUG-89703
Change-Id: Ide6c20124ec9201d94ffc339dd479cd1ece777b0
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2021-05-31 17:16:57 +02:00
Laszlo Agocs
5eab5d6253 rhi: vk: Switch to the modern validation layer internally
Task-number: QTBUG-88388
Change-Id: Ia30af6c4554594f094af7866ad6e10ed7929de27
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2021-05-31 17:16:53 +02:00
Laszlo Agocs
bbc6b5c3a7 vulkan: Update legacy tests and examples to the modern validation layer
Fixes: QTBUG-88388
Change-Id: Ib072f203ada5d692dea8d35da2b24db0deac0297
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2021-05-31 17:16:49 +02:00
Assam Boudjelthia
cbaff13701 Block flaky rhi and OpenGL tests on Android
Task-number: QTBUG-87429
Change-Id: I5a09a82b5fd27d9a36563e5270703a32c067d4b6
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-05-30 23:02:53 +02:00
Allan Sandfeld Jensen
da30e402f3 Add SIMD optimizations for color-transform writes
Add NEON for RGB32 and RGBA64 writeback, and SSE2 for
RGBA64 writeback.

Change-Id: Id9ee803267a78f5bdff5beaa719e7a59c1dbb9fb
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-05-27 00:18:04 +02:00
Allan Sandfeld Jensen
93cd9130d6 Introduce float QImage formats and rendering
Useful for some HDR representations and HDR rendering.

Change-Id: If6e8a661faa3d2afdf17b6ed4d8ff5c5b2aeb30e
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-05-26 18:00:01 +02:00
Allan Sandfeld Jensen
f1983dcdf6 Correct RGB to Grayscale conversion
The existing conversions weren't handling gamma correctly and used
an ad-hoc definition of gray instead of based on true luminance.

[ChangeLog][QtGui] RGB conversions to grayscale formats are now
gamma-corrected and produce color-space luminance values

Change-Id: I88ab870c8f5e502ddb053e6a14a75102239a26f2
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-05-21 15:37:32 +02:00
Dongmei Wang
e253a30238 QFileSystemModel fails to locate a host from root's visible children
In QFileSystemModel, in some cases the hostname in a UNC path is
converted to lower case and stored in the root node's visibleChildren.
When QFileSystemModel sets the UNC path as the root path, it tries to
get the row number for the host, but it didn't convert the hostname to
lower case before getting the row number, which resulted in the host
not found in the root node's visible children. As a result, it returns
-1, an invalid row number. Change the behavior to find the node for the
host using the host name case-insensitive and then get the row number.

Fixes: QTBUG-71701
Pick-to: 5.15 6.0 6.1
Change-Id: Ib95c7b6d2bc22fd82f2789b7004b6fc82dfcb13b
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2021-05-20 15:02:38 +00:00
Laszlo Agocs
8827cd657d rhi: gl: Add support for importing an existing renderbuffer object
Normally we only allow creating wrappers for texture objects. These
can then be used with a QRhiTextureRenderTarget to allow rendering into
an externally created texture.

With OpenGL (ES), there are additional, special cases, especially on
embedded. Consider EGLImages for example. An EGLImageKHR can be bound to
a renderbuffer object (glEGLImageTargetRenderbufferStorageOES), which
can then be associated with a framebuffer object to allow rendering into
the external buffer represented by the EGLImage. To implement the same
via QRhi one needs a way to create a wrapping QRhiRenderBuffer for the
native OpenGL renderbuffer object.

Here we add a createFrom() to QRhiRenderBuffer, while providing a dummy,
default implementation. The only real implementation is in the OpenGL
backend, which simply takes a renderbuffer id, without taking ownership.

Task-number: QTBUG-92116
Change-Id: I4e68e665fb35a7d7803b7780db901c8bed5740e2
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2021-05-19 17:35:35 +02:00
Luca Beldi
811a6c6b77 Fix QStandardItemModel signals on takeChild
takeItem and takeChild do not signal the change correctly to the
external world, this change fixes the problem

Fixes: QTBUG-89145
Pick-to: 6.1 5.15
Change-Id: Ib4844ace53007068a2cd62eba64df99e6e45fdc0
Reviewed-by: David Faure <david.faure@kdab.com>
2021-05-11 18:55:09 +01:00
Tor Arne Vestbø
edceff30b4 Move QtX11Extras into QtGui as private API
from qt/qtx11extras 0e67fb41cfc4b4bfbaa7dc75f8ddebdf5a08e836.

The plan is to expose these as native interfaces, so this is a first
step.

Task-number: QTBUG-83251
Change-Id: Iecba8db9a4f616a08a3750ddaae08cc30ec66f89
Reviewed-by: Liang Qi <liang.qi@qt.io>
2021-05-10 21:19:46 +00:00
Allan Sandfeld Jensen
f94b0e1dd9 Allow background inheritance between non-body block elements
Most nested block elements are merged together, so while we shouldn't
do real inheritance we need to do it when block elements are combined.

Pick-to: 6.1
Fixes: QTBUG-91236
Change-Id: I9e37b15f705db92c79a620d0d772f25d0ee72b8d
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2021-05-08 09:28:02 +02:00
Allan Sandfeld Jensen
50b9a4b357 Remove Qt6 switches from QtGui
Removing now dead code

Change-Id: I021539da6517fdb8443f8ae9431fc172b7910cfc
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2021-05-05 19:26:56 +02:00
Andy Shaw
72a5151403 Write out the HTML correctly for nested lists
When we are having nested lists then we need to ensure that the HTML is
outputted correctly so that the closing list and item tags are placed
in the right order.

[ChangeLog][QtGui][QTextDocument] The output of toHtml() now handles
nested lists correctly.

Fixes: QTBUG-88374
Pick-to: 6.1 5.15
Change-Id: I88afba0f897aeef78d4835a3124097fe6fd4d55e
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2021-05-05 15:14:12 +00:00
Oliver Eftevaag
38f4e1f3e7 Unit test for checking text-decoration in html export
This unit test is related to the parent commit.
Html export used to omit the text-decoration for the default font,
this unit test ensures that this property is added to the exported
html.

Fixes: QTBUG-91171
Change-Id: Ib68bec27f9963cdcac5c553b2c07557717b1c22e
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2021-05-05 16:28:54 +02:00
Allan Sandfeld Jensen
720defd2ca Export text-decoration
It used to be ignored because we couldn't disable it, but that works
fine now. So re-enable it.

Fixes: QTBUG-91171
Change-Id: I4cf966211bb200b73326e90fc7e4c4d3d4090511
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2021-05-05 16:28:54 +02:00
Morten Johan Sørvig
07516c0811 Test at some Android DPIs in addition
Currently, we test at 1x, 2x, and mixed typical desktop
DPI values. Add android DPI values, with scale factors
in the 2.5 - 3.75 range.

This test currently uses 96 as the base DPI (and so
does the Android platform plugin), so we normalize
the values to use that base DPI.

Change-Id: I25b66f5e16d37c01758d5623b805e4141247a74a
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-05-04 16:21:48 +02:00
Morten Johan Sørvig
5882131592 Remove setting of Qt 5 high-dpi attributes
This test is for Qt 6 now.

Change-Id: I839c2733d505cb4119b1fe3ad85d3c8d94a6c964
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-05-04 16:21:48 +02:00
Morten Johan Sørvig
b5ceba0128 Extend QT_SCREEN_SCALE_FACTORS test
Test the name=factor format and various incorrect spec
strings. We expect that the screen DPI is used if the
scale factor specification is incorrect.

Change-Id: Ia990e70cf71e370dd2bb4b1047a101dfe9e59cb0
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-05-03 13:33:43 +02:00
Shawn Rutledge
2ecd0f4194 Revert "Add grabber context pointers"
This reverts commit 40330b8f0a.
It was a bad idea to use QFlatMap here, because it is a sorted map, but
we need to keep the passive grabbers in the same order as the grabs happened.
So need to go back to an earlier version of the patch that uses two parallel QLists.

Pick-to: 6.1
Change-Id: I9e6013c2565986fe1eb9fd754f8259766f83bee5
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-04-29 16:49:57 +02:00
Morten Johan Sørvig
776734576c Call updateHighDpiScaling() on screenAdded()
QHighDpiScaling has two init/update functions:
 - initHighDpiScaling(): called once during QGuiApplication construction
 - updateHighDpiScaling(): called whenever (relevant) screen configuration changes

Currently the calls to updateHighDpiScaling() are made from
multiple places including platform code. Simplify by calling
it from two locations:
	- QWindowSystemInterface::handleScreenAdded()
	- QGuiApplicationPrivate::processScreenLogicalDotsPerInchChange()

Replace comment about early calls to qt_defaultDpi with a
test which calls qt_defaultDpiX/Y with no screens attached.
(Looking at the qt_defaultDpiX() implementation, it is unlikely
that there will be a problem as long as updateHighDpiScaling()
is called before QGuiApplication::primaryScreen() starts returning
a non-null value.)

Change-Id: I447db42894617495843a5cb531a1322b000fed62
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-04-28 18:23:39 +02:00
Shawn Rutledge
40330b8f0a Add grabber context pointers
In Qt Quick we now need to keep track of which QQDeliveryAgent is
responsible when a point is grabbed, either passively or exclusively.
When we re-deliver to that grabber, we need to do it via the same agent,
so that the same scene transform is used, and the grabber will see the
event in the correct coordinate system.  It's easier to track this
mapping here instead of in a separate map in Qt Quick.

Pick-to: 6.1
Task-number: QTBUG-92944
Change-Id: I69f769c694d0da24885cdf4087e5032022bff629
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-04-28 13:00:45 +02:00
Assam Boudjelthia
001e9c6a19 Android: unblock passing tests
Those tests don't fail anymore and show in CI as BPASS, so we
can safely, hopefully, unblock them

Task-number: QTBUG-87429
Fixes: QTBUG-68974
Fixes: QTBUG-69166
Fixes: QTBUG-87403
Fixes: QTBUG-87411
Fixes: QTBUG-69083
Fixes: QTBUG-69084
Fixes: QTBUG-87426
Pick-to: 6.1
Change-Id: I831b955116c0f465319b9c5fc726dd98804d1c00
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-04-27 21:12:50 +03:00
Allan Sandfeld Jensen
b1f956106c Fix tst_qicon for fractional dpr
Add rounding one place, and skip addFile for now since
the assumption about rounding dpr up no longer applies.

Pick-to: 6.1
Change-Id: I0a84dfabb218acf42cb3816ba50ef899c8762523
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2021-04-20 21:33:00 +02:00
Volker Hilsheimer
019f35524d Fix compiler warning on platforms without QRhiNativeHandles
Pick-to: 6.1
Change-Id: I61254290853cadf3b1edf6e7b0f82bba9e8d2efe
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2021-04-12 10:41:50 +02:00
Volker Hilsheimer
65e3dc5eac Fix warnings about lossy double/float conversion in tests
QVectorND, QQuaternion, and QColor all operate on floats rather than
qreal or double, so explicit use float literals in the tests.

Pick-to: 6.1
Change-Id: If12cc12ddd9cd8219f3d78bf24e1400921e26c2b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-04-11 19:53:32 +02:00
Heikki Halmet
c87847db87 BLACKLIST tst_qfont for Red Hat
Task-number: QTQAINFRA-4363
Task-number: QTBUG-84248
Pick-to: 6.1
Change-Id: I791aba3bf2b26f9c90201b1dcd67c2a85d28f08b
Reviewed-by: Jani Heikkinen <jani.heikkinen@qt.io>
2021-04-06 07:35:24 +03:00
Volker Hilsheimer
15b0809f06 Remove QEXPECT_FAIL for tests that pass now on Android
Fixes: QTBUG-69214
Fixes: QTBUG-69218
Fixes: QTBUG-69220
Change-Id: I8b780db8d9dad1a877bc16e802e6ae92de0c8f23
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2021-03-31 17:31:12 +02:00
Laszlo Agocs
7ccd2d0246 rhi: Add support for custom bytes-per-line for uncompressed raw data
Fixes: QTBUG-90770
Change-Id: Icba328c417bcce256e7b44f1d540af7f8e83376b
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Christian Strømme <christian.stromme@qt.io>
2021-03-30 16:43:35 +02:00
Volker Hilsheimer
ccf1a1a953 Replace QTextDocumentResourceProvider with a std::function
376e3bd8ec added the new class for Qt 6.1,
but during header review we concluded that using a class introduces
complexity wrt instance ownership and API design that can be avoided by
using a std::function instead.

The functionality is tied to QTextDocument, so the type definition and
the default provider API is added there.

Since std::function is not trivially copyable, the atomicity of the
previous implementation is not maintained, and concurrent modifications
of and access to the global default provider from multiple threads is
not allowed. The relevant use case can be supported by implementing a
resource provider that is thread safe.

Task-number: QTBUG-90211
Fixes: QTBUG-92208
Pick-to: 6.1
Change-Id: I39215c5e51c7bd27f1dd29e1d9d908aecf754fb7
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
2021-03-30 08:11:27 +02:00
Volker Hilsheimer
c8f6f8a222 Rename QUrlResourceProvider to QTextDocumentResourceProvider
While the class name is now a bit more than a mouthful, it's purpose
is very narrowly tied to QTextDocument, so don't use a very generic
name for it. That resources are provided based on a URL is to some
degree an implementation detail, and URLs are resource locators so
we don't need that in the class name.

Address code review comment for 6.1. Add documentation and links to
existing APIs with a similar purpose.

Task-number: QTBUG-90211
Task-number: QTBUG-92208
Pick-to: 6.1
Change-Id: I4f09057cc2f53a5595513c1c9422e6ccaad6ca13
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
2021-03-29 15:59:40 +02:00
Laszlo Agocs
9e662a0baf Skip a tst_QRhi test case with the Android emulator
Pick-to: 6.1
Task-number: QTBUG-92211
Change-Id: I63ff17b226d502189bc769b0b28640b849b8d39a
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-03-29 09:57:48 +02:00
Giuseppe D'Angelo
0b4ccbf81e QPainterPath: fix handling of fill rules
fillRule() contained a major blunder: instead of checking if the
d-pointer was allocated, and return a default value if it wasn't,
it checked whether the path contained any points. This means that

  QPainterPath p;
  p.setFillRule(x);
  Q_ASSERT(p.fillRule() == x);

was failing.

As a drive-by to test this change, fix another mistake in clear():
clear is documented to clear the elements in a path, but instead
it also changed the fill rule.

This commit partially reverses 697910e5fb.

Change-Id: Ieb8145694b672439c3380d9ccb87d1206a2dd115
Pick-to: 5.12 5.15 6.0 6.1
Done-with: Milian Wolff
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2021-03-26 10:45:46 +01:00
Allan Sandfeld Jensen
c32cd44d34 Fix alpha handling of QImage::setPixel
It was treated differently depending on format, made it consistently
behave the same for all formats (following the behavior of the primary
formats).

Pick-to: 6.1 6.0 5.15
Change-Id: Ie24e19957d076fdf3ebd333074e26ede187489eb
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2021-03-22 14:29:14 +01:00
Laszlo Agocs
19384f2e8f rhi: Make it possible to clone a QRhiRenderPassDescriptor
Pick-to: 6.1
Task-number: QTBUG-91888
Change-Id: Ib6d2e639e6c24f3e9a733c6563dc8a6d6da47719
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2021-03-19 10:46:23 +00:00
Volker Hilsheimer
5c396be4e3 Port away from deprecated QVariant::type
Use QMetaType instead to silence compiler warnings.

Pick-to: 6.1
Change-Id: Ic28b3406ddcd51935f42779e7708ea8a459d3a9e
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-03-17 12:57:39 +01:00
Morten Johan Sørvig
f9f9004b40 Add auto-test for QT_USE_PHYSICAL_DPI
Test that setting QT_USE_PHYSICAL_DPI uses physical
DPI instead of logical DPI.

Change-Id: I7f89cf1af5e013454cc3d8ec3559f2719514fea3
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-03-15 11:49:59 +01:00
Morten Johan Sørvig
f0bf7667a9 Auto-test some high-dpi env variables
Add auto-tests for QT_SCALE_FACTOR and QT_SCREEN_SCALE_FACTORS

Change-Id: I57bffa266be910f2ba26cb1a870e09ae202fcae0
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-03-15 11:49:56 +01:00
Eskil Abrahamsen Blomfeldt
2bf9061760 Skip tst_qwindow test when running on Wayland
The tst_qwindow test failed with a warning that programmatically
moving the mouse cursor is not possible with Wayland.

Task-number: QTBUG-91418
Change-Id: I02ceb2af43fbc83a4e6ae09718315f5f79ff8285
Reviewed-by: Liang Qi <liang.qi@qt.io>
2021-03-15 08:17:41 +01:00
Eskil Abrahamsen Blomfeldt
d16b171f1b Make tst_shortcut pass on Wayland
There was a race condition in the test, since the window
might be exposed before the event to activate the
application has been received. And the short cut is not
triggered before the application is active, which
means it could just be discarded and the window would
never be closed.

This happened consistently when testing on Wayland.

Task-number: QTBUG-91418
Change-Id: I40cb143985175f5f2b5405e9502a48475c93074a
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2021-03-11 11:59:14 +01:00
Eskil Abrahamsen Blomfeldt
30245c8515 Skip tst_QOpenGL::glxContext test on Wayland
This test depends on XCB, but is only protected by a build-time
flag, so it will be executed as long as XCB is available at
build-time. Do as with the offscreen backend and just skip it
when a different platform plugin is in use.

Task-number: QTBUG-91418
Change-Id: Ida076dc81d0740af2cec164bd40ca10d16345f05
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2021-03-11 11:58:42 +01:00
Eirik Aavitsland
bea214e765 Fix: QBrush autotest failure on Android and Wayland
Since Qt 5.5, brush textures are stored as QImages. If the texture has
been set as a QPixmap, the conversion to QImage may change its pixel
format, depending on the native system format. That is acceptable.

Fixes: QTBUG-69193
Task-number: QTBUG-91418
Change-Id: Ic4dbeaa552b1f2183774a011e38414855a9dc4b1
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2021-03-11 07:03:45 +00:00
Laszlo Agocs
80029e0ca6 rhi: gl: Fix missing uniform data with certain command lists
Following patterns from the other backends is insufficient with OpenGL
because we do not use real uniform buffers. There is currently a
possibility that a shader program will be bound without following it
with setting uniforms. Correct this by having a second level of tracking
of the associated srb object in the pipelines.

Pick-to: 6.0 6.1
Fixes: QTBUG-91630
Change-Id: I74a012daade826dd22c436bde06381c1233bad11
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2021-03-09 12:00:48 +01:00
Morten Johan Sørvig
1471f2ae09 Add deviceIndependentSize() to QPixmap and QImage
This function returns the size in device independent
pixels, and should be used when calculating user
interface sizes.


Change-Id: I528123f962595a3da42438ca560289a29aca4917
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-03-08 08:27:41 +00:00
Allan Sandfeld Jensen
01c55405fa Add QColorSpace::description
A way to read the description of the profile from ICC, or set one
yourself.

Change-Id: I68622e30ee209cac99c41f3df934712c3548c0de
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2021-03-04 22:37:08 +01:00
Alex Trotsenko
f265c87e01 Allow QWindowsPipe{Reader|Writer} to work with foreign event loops, take 2
When a foreign event loop that does not enter an alertable wait state
is running (which is also the case when a native dialog window is
modal), pipe handlers would freeze temporarily due to their APC
callbacks not being invoked.

We address this problem by moving the I/O callbacks to the Windows
thread pool, and only posting completion events to the main loop
from there. That makes the actual I/O completely independent from
any main loop, while the signal delivery works also with foreign
loops (because Qt event delivery uses Windows messages, which foreign
loops typically handle correctly).

As a nice side effect, performance (and in particular scalability)
is improved.

Several other approaches have been tried:
1) Using QWinEventNotifier was about a quarter slower and scaled much
   worse. Additionally, it also required a rather egregious hack to
   handle the (pathological) case of a single thread talking to both
   ends of a QLocalSocket synchronously.
2) Queuing APCs from the thread pool to the main thread and also
   posting wake-up events to its event loop, and handling I/O on the
   main thread; this performed roughly like this solution, but scaled
   half as well, and the separate wake-up path was still deemed hacky.
3) Only posting wake-up events to the main thread from the thread pool,
   and still handling I/O on the main thread; this still performed
   comparably to 2), and the pathological case was not handled at all.
4) Using this approach for reads and that of 3) for writes was slightly
   faster with big amounts of data, but scaled slightly worse, and the
   diverging implementations were deemed not desirable.

Fixes: QTBUG-64443
Change-Id: I66443c3021d6ba98639a214c3e768be97d2cf14b
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
2021-03-02 22:53:06 +02:00
Morten Johan Sørvig
ee409e6f0c High-DPI: Set the minimum scale factor to 1
Avoid painting errors with dpr < 1, also for the PassThrough
mode.

This limits the minimum high-dpi scale factor to 1,
for the code path which determines the scale factor
based on screen DPI.

Pick-to: 6.1
Task-number: QTBUG-89948
Change-Id: I14b3f130f0ae141d5f05c87437f926a9f76d1dec
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-03-02 13:36:38 +00:00
Giuseppe D'Angelo
0e22001a3b Add more support for structured bindings
After QPoint(F), it's now the time of QSize(F) and QVectorND,
which can be unambiguously decomposed.

[ChangeLog][QtCore][QSize] QSize is now usable in a structured
binding declaration.

[ChangeLog][QtCore][QSizeF] QSizeF is now usable in a structured
binding declaration.

[ChangeLog][QtGui][QVector2D] QVector2D is now usable in a
structured binding declaration.

[ChangeLog][QtGui][QVector3D] QVector3D is now usable in a
structured binding declaration.

[ChangeLog][QtGui][QVector4D] QVector4D is now usable in a
structured binding declaration.

Change-Id: I67bb152f4210f2be27607179cd2ec522174cc483
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-02-25 16:08:44 +01:00
Allan Sandfeld Jensen
c2bec047e2 And fix handling and test of QImage::fill(uint) as well
Only RGB444 and RGB666 were treated slighlty different from the rest,
but the test had a few additional mistakes.

Pick-to: 6.1 6.0 5.15
Change-Id: I4728b4036affedfffce8bca5c1e7be3869344fbe
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2021-02-25 09:46:55 +01:00
Allan Sandfeld Jensen
b2631c72c0 Extend colorspace testing and fix bug it uncovered
When changing transferfunction the look-up-tables needs to be
regenerated.

Pick-to: 6.1 6.0 5.15
Change-Id: I83ca5fe570f85d478a374f52c0a82db84e70c3b8
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2021-02-13 09:16:38 +01:00
Samuli Piippo
0ce443691f Move QEMU emulation detector to QTest
The emulation detection has been usable only on qtbase tests, move it to
QTest so that it can be used in other modules as well.

Pick-to: 6.1
Change-Id: I4b2321b7856414d7b1cfd5e6b1405a633c6bb878
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-02-13 10:02:51 +02:00
Allan Sandfeld Jensen
95712c5e54 Fix QImage::fill with semi-transparent QColor
A few formats were not treating the input QColor correctly. Fixed and
added more exhaustive test.

Pick-to: 6.1 6.0 5.15
Change-Id: I872aeeb45e518f9a34b4ac35642264821f9927f2
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2021-02-12 17:40:44 +01:00
Volker Hilsheimer
d40ba4adee Fix compiler warning: don't mix signed and unsigned int in comparison
Change-Id: Ib6609d70900a0c26dd88bbfd16e886773ae67420
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-02-11 21:06:00 +01:00
Eirik Aavitsland
be4127d6f7 Fix recently added auto test of text layout overflow
Ignore width of trailing space.

Pick-to: 6.1 6.0 5.15
Fixes: QTBUG-91038
Change-Id: I74e278366a2c3b170335738bf6d6ee23933b361a
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2021-02-10 21:17:09 +01:00
Jonas Karlsson
2861cfb6f8 QTextureFileData: support key value metadata
Task-Id: QTBUG-76970
Pick-to: 6.1
Change-Id: I9dba1b373250cea4d0c806997290a7afcdc900d7
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2021-02-09 13:39:47 +01:00
Allan Sandfeld Jensen
0ffdbb2126 Handle macOS 11 issues in softHyphens test
Calculate the effective width of the hyphen better, and compare with
ceiled sizes.

Pick-to: 6.1 6.0
Fixes: QTBUG-90698
Change-Id: I7ed2eb44c54240ecb2f8a38e5acf1f32608b2bfb
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2021-02-08 11:22:08 +01:00
Samuli Piippo
d6f00c637d tst_qtexttable: fix fail on QEMU ARMv7
Different font was used when running on QEMU ARMv7 and the second page
was never reached.

Pick-to: 6.1
Task-number: QTQAINFRA-4127
Change-Id: Ic85b76661cf3642b69e6e1b21e8062d7c36231e3
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2021-02-05 18:36:51 +00:00
Eskil Abrahamsen Blomfeldt
8b485664e4 Fix flakiness in tst_QGlyphRun::drawRightToLeft
As described in 3279c8e7d7, we can't
depend on the widths of decoration to always be the same for
drawText() and equivalent drawStaticText/drawGlyphRun.

This is typically visible as an off-by-one when using the default
fonts on OpenSUSE.

Since this test was actually made to test positions of RTL glyphs,
we can just disable the decoration and simplify the text.

Fixes: QTBUG-89086
Change-Id: I139fe3e1c5e98d8b1d7e0e7c19645fd4717d1d95
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-02-04 18:02:34 +01:00
Eskil Abrahamsen Blomfeldt
fccd419dd6 Remove false Q_UNREACHABLE from shaping code
This was added by 9ff76c27b9 on
the basis that it signifies a shaping error and would later assert
or crash.

But the line is easily reachable by user code. If Harfbuzz returns
0 glyphs, it just means it is unable to shape the string, for instance
if the input string only contains default ignorables (like a ZWJ)
and does not have any appropriate glyph to use for replacement.

Qt expects there to always be at least one glyph in the output
(num_glyphs == 0 is used to indicate shaping is not yet done), so
to avoid asserts later on, we simply populate the output with a
single 0 token, which is a required entry in the font that is
reserved for representing unrepresentable characters.

This also adds a test and therefore a zero-width joiner to the test
font to reproduce the issue.

[ChangeLog][QtGui][Text] Fixed a possible crash with certain fonts
when shaping strings consisting only of control characters.

Fixes: QTBUG-89155
Pick-to: 5.15
Pick-to: 6.0
Change-Id: Ia0dd6a04844c9be90dcab6c464bebe339a3dab11
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
2021-02-03 09:44:44 +01:00
Allan Sandfeld Jensen
bde773ec6a Fix a few compiler warnings in tests
Change-Id: I22f6ac8ed02dd4ef4083ce3c781552623a0b08da
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2021-02-02 12:06:05 +01:00
Jonas Karlsson
c5e9708ce6 Support cubemap ktx files
Change-Id: I6905c393647d31fab958cdd9471bb0a6ffe83596
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2021-02-01 20:28:37 +01:00
Eirik Aavitsland
bfc09b8d8f Avoid overflow in text layout
Fixes oss-fuzz issue 29313.

Pick-to: 6.0 5.15
Change-Id: Idbabd162fa9e0dbce687981bdbcc75be37189a61
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Reviewed-by: Robert Löhning <robert.loehning@qt.io>
2021-01-28 11:02:18 +01:00
Samuli Piippo
07c248a594 Remove blacklisting for b2qt tests that now pass
With the updated QEMU and toolchain, these tests now pass.

Change-Id: Icb74562a0e6422cd4564f63db991aa431e0e3119
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2021-01-28 09:27:14 +02:00
Sona Kurazyan
3a5a404a53 Port QMovie to the new property system
Task-number: QTBUG-85520
Task-number: QTBUG-85521
Change-Id: Ib936020260cf01a5221b63fb1eb0ccb23f5553a3
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-01-27 15:16:20 +01:00
Sona Kurazyan
ba62256c5a Port QStandardItemModel to the new property system
Task-number: QTBUG-85520
Task-number: QTBUG-85521
Change-Id: I2f9bbe8bc06838fcbadd446e111fb697120f550c
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-01-26 21:48:00 +01:00
Bastien Bouclet
b69b04c479 QIcon: Use the @nx pixmaps in the paint method
Make use of the device pixel ratio in the QIcon paint method so the @nx
hi-dpi pixmaps are selected when appropriate when painting to a
QPainter.

Pick-to: 6.0
Fixes: QTBUG-90042
Change-Id: I53995a2285ef879e3c4fddb9f8da702e256a260f
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2021-01-26 15:33:08 +00:00
Morten Johan Sørvig
3a1773dd76 High-DPI: Test application startup with no screens
Initialize the offscreen platform plugin with no screens,
create QGuiApplication object.

Not much of the high-dpi related Qt API can be used
in this configuration, but at least Qt should not crash
on startup.

Task-number: QTBUG-71034
Change-Id: I6620843c3bd8b692c5c2419b1ba290e16175ba5b
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2021-01-22 14:27:27 +00:00
Laszlo Agocs
df0e98d408 rhi: Pipeline cache load/save
Add QRhi APIs to retrieve and reload the contents of the "pipeline
cache".

The only API where there is a true pipeline cache is object is Vulkan
(VkPipelineCache). For OpenGL, the other backend where we support this,
it is simulated with program binaries. The Qt 5 style OpenGL program
binary disk cache continues to work like before, but one has now the
option to do things in a more modern, graphics API agnostic way, that
leads to generating a single blob instead of a large set of files in
some system location, allowing easier "pre-baking" of the cache content.

It is expected that Qt Quick exposes the two new functions in form
if QSG_RHI_ environment variables, thus allowing easy testing and
cache file generation.

As an example for the performance improvements this can give, consider
Vulkan, where we do not have any existing persistent caching mechanism
in place:

Running BenchmarkDemoQt6.exe --scene flythrough --mode demo creates 18
QRhiGraphicsPipeline objects from Qt Quick and Qt Quick 3D.

The total time spent in QRhiGraphicsPipeline::create() during application
startup for these 18 pipelines is 35-40 ms on a given Windows (NVIDIA)
system.

When exporting the pipeline cache contents to a file, and then, in a
subsequent run, reloading the cache contents, this is reduced to 5-7 ms
on the same system, meaning we get a 6-7x improvement.

The generated data is always specific to a given Qt version, RHI
backend, graphics device, and driver version. Much of the implementation
consists of adding and verifying the appropriate header to the blobs
retrieved from the driver, to allow gracefully ignoring data that was
generated with a device or driver that differs from the one used at
run time. This should provide robustness, even if the Vulkan or OpenGL
implementation is for some reason not prepared to identity and reject
incompatible cache/program blobs.

Fixes: QTBUG-90398
Change-Id: I67b197f393562434f372c7b7377f638abab85cb3
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2021-01-22 10:26:03 +01:00
Samuli Piippo
946facb1ae tst_qfont: expect failure on font testcase for QEMU ARMv7
FontConfig related tests fail on ARMv7 QEMU.

Task-number: QTQAINFRA-4127
Change-Id: I3202f660d12d09a65bc50747d679921b6dfa75f8
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2021-01-22 09:00:24 +02:00
Laszlo Agocs
46b892c16c tst_qvulkan: Skip assumption about supportedApiVersion
...when the platform does not support Vulkan. The version is left
at the default 0 then, so checking for >= 1.0 is wrong.

This allows the test to pass with the offscreen platform plugin.

Change-Id: I5afba8f1e703e4fa0ff41da91d18f5fabfb54868
Reviewed-by: Andreas Buhr <andreas.buhr@qt.io>
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2021-01-21 17:00:32 +01:00
Laszlo Agocs
c6d6029909 Update QVulkan(Device)Functions to Vulkan 1.2
This also needs improvements to qvkgen. What we get with this patch
are the Vulkan 1.1 and 1.2 core API's additional 11 instance-level
and 30 device-level commands present in QVulkanFunctions and
QVulkanDeviceFunctions.

All of these are attempted to be resolved upon construction. When the
implementation does not return a valid function pointer for some of them
(e.g. because it is a Vulkan 1.0 instance or physical device), calling
the corresponding wrapper functions will lead to unspecified behavior.
This is in line with how QOpenGLExtraFunctions works. The simple
autotest added to exercise some Vulkan 1.1 APIs demonstrates this in
action.

The member functions in the generated qvulkan(device)functions header
and source files are ifdefed by VK_VERSION_1_{0,1,2}. This is essential
because otherwise a Qt build made on a system with Vulkan 1.2
headers would cause compilation breaks in application build environments
with Vulkan 1.0/1.1 headers when including qvulkanfunctions.h (due to
missing the 1.1/1.2 types and constants, some of which are used in the
function prototypes). In practice this should be alright - the only
caveat to keep in mind is that the Qt builds meant to be distributed
to a wide variety of systems need to be made with a sufficiently new
version of the Vulkan headers installed, just to ensure that the
1.1 and 1.2 wrapper functions are compiled into the Qt libraries.

Task-number: QTBUG-90219
Change-Id: I48360a8a2e915d2709fe82993f65e99b2ccd5d53
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2021-01-19 14:17:55 +01:00
Laszlo Agocs
9f7088fd7f rhi: Stop hardcoding the Vulkan backend's desired instance extensions
Instead, have a static function in QRhiVulkanInitParams then Qt Quick
and anyone else who creates a QVulkanInstance that is then used in
combination with QRhi can query.

Change-Id: I046e0d84541fc00f5487a7527c97be262221527f
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2021-01-18 13:21:15 +01:00
Laszlo Agocs
7d378bd780 vulkan: Add instance-level version getter
...as described in the Vulkan >= 1.1 spec. One can now call
supportedApiVersion() (before create(), similarly to the other
supported* functions) to determine the available Vulkan
(instance-level) version.

Fixes: QTBUG-90333
Change-Id: Ibe8482402b7f07e4abc48c88252ff0365e4e2faa
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2021-01-18 13:21:15 +01:00
Shawn Rutledge
aeeac48cbd AA_SynthesizeTouchForUnhandledMouseEvents: keep correct coordinates
QGuiApplicationPrivate::processMouseEvent() sends a
QWindowSystemInterfacePrivate::TouchEvent if the mouse event is not
accepted and AA_SynthesizeTouchForUnhandledMouseEvents is enabled.
A QPA TouchEvent always contains native touch points, which is why
it calls QWindowSystemInterfacePrivate::fromNativeTouchPoints to
translate the QMouseEvent's device-independent position back to the
raw position that it would have had if it came from a real touchscreen.
Therefore we must give that function touchpoints that are actually in
native coordinates.

It may be that some of this transformation could be avoided entirely,
but here we prove that the existing way works correctly, by adding
coordinate checking to the tst_QWindow::mouseToTouchTranslation() test.

Pick-to: 6.0
Task-number: QTBUG-86165
Change-Id: I4c9ca2b11e9eb76d79712c187db3eb9865da581a
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-01-14 19:09:28 +00:00
Morten Johan Sørvig
a2db96e253 Skip tst_qhighdpi when offscreen is not built
Android and Wasm do not build the offscreen platform
plugin (see src/plugins/platforms/CMakeLists.txt).

Skip building the tst_qhighdpi test as well in this
case. Remove the BLACKLIST entry.

Task-number: QTBUG-88505
Change-Id: I172198c8c24759b14f73ad07260c449fc6ab893f
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-01-14 14:21:45 +01:00
Laszlo Agocs
c262a69851 rhi: gl: Add some enablers for supporting GL_TEXTURE_EXTERNAL_OES
From QRhi's perspective this consists of two things:

- A shader with samplerExternalOES in it cannot go through the standard
  pipeline. Rather, a QShader with suitable GLSL code in it has to be
  constructed manually. As this is something useful as an autotest
  anyway, add a test case to the qshader autotest that demonstrates
  this.

- When it comes to correctly calling glBindTexture, add a QRhiTexture
  flag. The expectation is that an OpenGL-only client sets this in
  combination with QRhiTexture::createFrom(), thus wrapping an existing
  texture that then gets bound to the GL_TEXTURE_EXTERNAL_OES target
  instead of our usual GL_TEXTURE_2D.

For completeness we also add a SamplerExternalOES variable type to
QShaderDescription, but the sampler type is not actually used by the
QRhi OpenGL backend, as it is the QRhiTexture that defines the
texture target.

Change-Id: I36b52325deb3703b59186ee3d726d0c3015bfc4b
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2021-01-13 10:08:23 +01:00
Laszlo Agocs
042cd97884 rhi: Expose device name, type, and IDs
...to the extent it is sensible. We have to make compromises still,
meaning some fields will only be applicable with certain APIs.

Most of this is already shown upon QRhi::create() as info debug
prints, when enabled. Now expose it all through the QRhi API as
well.

This is useful for printing in qtdiag, and, while it should be
avoided as much as possible, to make decisions about disabling
3D rendering features depending on the driver and GPU in use.

Change-Id: Iebe1e192965c928b82a094d1c7c50ddf4b38b9a2
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2021-01-13 10:08:23 +01:00
Joerg Bornemann
04f11f9935 Remove .prev_CMakeLists.txt files
Those serve no purpose anymore, now that the .pro files are gone.

Task-number: QTBUG-88742
Change-Id: I39943327b8c9871785b58e9973e4e7602371793e
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
2021-01-12 20:59:13 +01:00
Alexander Volkov
376e3bd8ec Introduce QUrlResourceProvider to load resources for HTML
QTextDocument and the text editor classes suggest to override
their loadResource() methods to provide data associated with
a text document. This approach has the following drawbacks:
- it requires subclassing
- there is no way to set a global resource provider
- QLabel is missing virtual loadResource() method and
  it can't be added without breaking ABI

QUrlResourceProvider is designed to solve these issues.
One should create a derived class that implements
QUrlResourceProvider::resource(). The objects of the derived
class then can be set for any text document.
The default resource provider can be set with
QUrlResourceProvider::setDefaultProvider().
This change also adds QLabel::setResourceProvider(),
which doesn't break ABI.

[ChangeLog][QtGui][Text] Introduced QUrlResourceProvider that allows to
load resources for HTML. It is intended to replace the use of
QTextDocument::loadResource().

Change-Id: Iaf19b229f522a73508f20715257450fe58f68daf
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-01-12 15:33:10 +03:00
Volker Hilsheimer
9963aaacdb Remove irrelevant test row, fix compiler warning
With the introduction of QKeyCombination, the result of |'ing together
a set of modifiers and a key goes always through the same QKeySequence
constructor, no matter the order.

The implicit conversion through int when the wrong order is used
causes a compiler warning as that conversion is deprecated. So remove
that test case.

Pick-to: 6.0
Change-Id: I04e27bcd51723ee0efc77e52e45ca3eb8bac5fc7
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2021-01-08 16:37:22 +01:00
Samuli Piippo
18ef1b83fb tst_qtextmarkdown: blacklist tests for QEMU ARMv7
Most tests fail when running on QEMU ARMv7, but not on target HW or
QEMU ARM64.

Task-number: QTBUG-89819
Change-Id: I686268c200cce1a44a717b80c2970f608be44636
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2021-01-08 09:04:55 +02:00
Joerg Bornemann
ad2da2d27a Remove the qmake project files
Remove the qmake project files for most of Qt.

Leave the qmake project files for examples, because we still test those
in the CI to ensure qmake does not regress.

Also leave the qmake project files for utils and other minor parts that
lack CMake project files.

Task-number: QTBUG-88742
Change-Id: I6cdf059e6204816f617f9624f3ea9822703f73cc
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
2021-01-07 15:32:28 +01:00
Liang Qi
e688b99995 QInputControl: accept surrogate category character
See also https://unicodebook.readthedocs.io/unicode_encodings.html#utf-16-surrogate-pairs .

Fixes: QTBUG-89184
Pick-to: 6.0 5.15
Change-Id: I04eff7f42f0030346603a7b31e4ac854a477030c
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-01-05 16:24:29 +01:00
Laszlo Agocs
8da171a5ae Adjust surface type usage for onscreen tests in tst_qrhi
Change-Id: I1ae076f8bb44e00bf9ff7706063344e8c5502101
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2021-01-04 17:30:37 +01:00
Liang Qi
489ce6f91b tests: unblacklist tst_QWindow::modalWithChildWindow() on openSUSE
This reverts 3d53cf976d.

Task-number: QTBUG-66851
Change-Id: Ib2b76c539c57fe70ee60426635e6ba59291a1f90
Reviewed-by: Liang Qi <liang.qi@qt.io>
2020-12-23 19:41:42 +00:00
Samuli Piippo
d6c3d6355a qfont: blacklist tests for QEMU
Blacklist qfont tests that don't work correctly with qemu.

Task-number: QTQAINFRA-3836
Change-Id: I7f5d4b07428febb0adb82d38203226b5c56a2ad5
Reviewed-by: Tony Sarajärvi <tony.sarajarvi@qt.io>
2020-12-23 10:55:56 +02:00
David Skoland
27d96b4789 Replace QtTest headers with QTest
Complete search and replace of QtTest and QtTest/QtTest with QTest, as
QtTest includes the whole module. Replace all such instances with
correct header includes. See Jira task for more discussion.

Fixes: QTBUG-88831
Change-Id: I981cfae18a1cabcabcabee376016b086d9d01f44
Pick-to: 6.0
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-12-22 15:20:30 +01:00
Friedemann Kleint
f6bf303cee tst_qimagereader.cpp: Fix MSVC int conversions warnings
Change-Id: I1b002ffde60dea9c54a8c41985ed295c05c45858
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-12-21 16:21:28 +01:00
Friedemann Kleint
a46a723dba Tests: Fix building with qmake on Windows
Apparently some library definitions went overboard, link them directly.

Pick-to: 6.0
Change-Id: I009737f7e3edff5619241b700a627dc4e25e6018
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-12-17 13:02:15 +01:00
Alexandru Croitor
2304acab5f CMake: Regenerate projects using pro2cmake one last time
And fix up some wrong qmake project files

Pick-to: 6.0
Change-Id: I66cb82aeb9c1419a74df1a650fa78a511ade7443
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-12-10 11:52:30 +01:00
Allan Sandfeld Jensen
48346e8d2d Add colorspace transfer functions based on tables of inputs
This is the most basic way to represent custom transfer functions.

Change-Id: I529fb647ece82c03e85ef77b056d9daf13fe5a61
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2020-12-10 11:03:12 +01:00
Liang Qi
4a85160e0b tests: blacklist tst_QGlyphRun::drawRightToLeft() on openSUSE
Task-number: QTBUG-89169
Change-Id: I4dfd608e264c9503093cc9fe27e80c489efe7aaf
Reviewed-by: Tony Sarajärvi <tony.sarajarvi@qt.io>
2020-12-08 09:35:21 +01:00
Allan Sandfeld Jensen
0c19e3f703 Fix QImage::setPixelColor on RGBA64_Premultiplied
QColors were not premultiplied before being set.

Pick-to: 6.0 5.15 5.12
Change-Id: Id3765b6932a72374ddfd788fae4bb628a4edf0b7
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-12-04 15:09:47 +01:00
Eskil Abrahamsen Blomfeldt
34fa01be82 Fix tst_QFontDatabase::aliases failure with ambiguous font
If the first font in the families list happens to have been
disambiguated because of duplicates, two things went wrong:

1. hasFamily() would return false for the font family, because
it does not disambiguate when checking for the family name and
only checks if the families list contains the exact string.

2. Adding aliases to the full disambiguated string is not supported,
only the family name.

The first issue has been reported separately as QTBUG-89068.

The test failure is fixed by just avoiding the fonts that
are ambiguous in the test, as it really doesn't matter which
font we pick.

Fixes: QTBUG-89008
Pick-to: 5.15 6.0
Change-Id: I829778c2e7bb6090475c34dcf9cdce58862729d6
Reviewed-by: Liang Qi <liang.qi@qt.io>
2020-12-02 16:22:27 +00:00
Andreas Buhr
caa632803d Disable some OpenGL and QRhi tests for offscreen backend
This patch disables four failing unit tests when executed with the
offscreen backend.

Change-Id: Ie67341b886984e6de19cd8dd8a8a237a620a1b7a
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2020-12-01 14:14:45 +01:00
Edward Welbourne
bbe74df26f Use QCOMPARE(,) in preference to QVERIFY(qFuzzyCompare(,))
The former also does fuzzy comparison, but it reports what the values
were, if the test ever fails.

Change-Id: I36ecda1f69bf3f430c904b37cd8c3a23201ab7e2
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2020-11-27 13:26:52 +01:00
Volker Hilsheimer
c2dbc26893 Fix compiler warnings from deprecated method
QTextCharFormat::fontFamily is deprecated in favor of fontFamilies,
which returns a QStringList wrapped in a QVariant, whereas the setter
expects a QStringList.

Change-Id: I3333eaae4fc5ec3e3bdbec58047d6b3554b4a171
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
2020-11-27 07:28:24 +00:00
Volker Hilsheimer
63c5d13885 Fix compiler warning from deprecated function
Change-Id: I34d6788fd5b9ab004b0e337933bea90c8f63717a
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
2020-11-27 08:28:24 +01:00
Volker Hilsheimer
cd2f29891f Fix compiler warning from deprecated function
Make the string into a list and call setFontFamilies.

Pick-to: 6.0
Change-Id: I1b70db784fd6e495b48917141d07bacd1e883882
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
2020-11-25 22:08:09 +01:00
Andy Shaw
8302ca22f4 Return a QString() if the families list is empty
Fixes: QTBUG-88781
Change-Id: Iafed2be29e2e0c3029e832986ba58d19446214eb
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-11-24 21:49:54 +01:00
Volker Hilsheimer
e59ab8b590 Fix compiler warning about discarded return value
Not testing the result of the copying, just verifying that it doesn't
assert.

Pick-to: 6.0
Change-Id: Ib51129134b74c17eada7e3819ccfff10bb9affbf
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2020-11-23 12:51:41 +01:00
Eskil Abrahamsen Blomfeldt
1d14067680 Fix weight when reading old serialized QFonts
The QFont::fromString() needs to differ between strings
produced before and after Qt 6.0 when interpreting the
weight value, since in older strings this will be the legacy
scale.

Luckily the number of tokens in the string can be used for this
purpose, since many tokens were added in Qt 6.0.

This broke KDE, where font settings are stored in QSettings
and serialized using QFont::toString() from Qt 5.

Fixes: QTBUG-88589
Pick-to: 6.0.0 6.0
Change-Id: I199737fed61917f8b9d8f86176ead29a89eb8e0c
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
2020-11-20 20:29:00 +00:00
Andy Shaw
d8602ce58b QFont: Prefer setFamilies() over setFamily()
By depending on setFamilies() then we can be sure that font names with
spaces, commas, quotes and so on are correctly handled without being
misinterpreted. For now it will split on the comma when a string
containing one is passed to setFamily. But from Qt 6.2 this will be
removed to preserve the family string as a convenience function.

[ChangeLog][QtGui][QFont] Indicated that setFamilies/families is
preferred over setFamily/family to ensure that font family names are
preserved when spaces, commas and so on are used in the name.

Change-Id: Id3c1a4e827756a4c928fed461a4aafa5a0f06633
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2020-11-20 14:30:22 +01:00
Kai Koehne
ce29ce586f Revert "Allow QWindowsPipe{Reader,Writer} to work with foreign event loops"
This reverts commit ee122077b0.

Reason for revert: This causes QProcess::readAll() to sometimes
return nothing after the process has ended.

Fixes: QTBUG-88624
Change-Id: I34fa27ae7fb38cc7c3a1e8eb2fdae2a5775584c2
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
(cherry picked from commit 23100ee61e33680d20f934dcbc96b57e8da29bf9)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2020-11-20 13:28:31 +00:00
Shawn Rutledge
5509449daf Add tst_QHighDpi::mouseVelocity()
Ensure the values are reasonable regardless of screen DPI.  Velocity
is supposed to be in logical pixels / second.

Task-number: QTBUG-88252
Task-number: QTBUG-88346
Change-Id: Ic209887f8ed0381c033a9ff04ae48b072c444df4
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2020-11-20 10:45:11 +01:00
Allan Sandfeld Jensen
34304e3100 Get rid of Q_COMPILER_CONSTEXPR checks
Is required now.

Change-Id: I62e95929d1649ea1390392230b619bd56d2a0349
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-11-17 21:28:11 +01:00
Piotr Mikolajczyk
f92e195369 Android: Ensure windows always have a geometry on creation
A QWindow created without an explicit geometry needs to pick up
a default geometry in the platform plugin. If the window has a
maximized of fullscreen window state, it will fill the entire
available geometry of the parent window (or the screen if there's
not parent window).

Fixes: QTBUG-69159
Fixes: QTBUG-69156
Fixes: QTBUG-69154
Pick-to: 5.15
Change-Id: If8565d92a97bb4b3fa44757e68969d54d0bc7ebe
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2020-11-17 10:48:05 +00:00
Alex Trotsenko
ee122077b0 Allow QWindowsPipe{Reader,Writer} to work with foreign event loops
When a foreign event loop that does not enter an alertable wait state
is running (which is also the case when a native dialog window is
modal), pipe handlers would freeze temporarily due to their APC
callbacks not being invoked.

We address this problem by moving the I/O callbacks to the Windows
thread pool, and only posting completion events to the main loop
from there. That makes the actual I/O completely independent from
any main loop, while the signal delivery works also with foreign
loops (because Qt event delivery uses Windows messages, which foreign
loops typically handle correctly).

As a nice side effect, performance (and in particular scalability)
is improved.

Several other approaches have been tried:
1) Using QWinEventNotifier was about a quarter slower and scaled much
   worse. Additionally, it also required a rather egregious hack to
   handle the (pathological) case of a single thread talking to both
   ends of a QLocalSocket synchronously.
2) Queuing APCs from the thread pool to the main thread and also
   posting wake-up events to its event loop, and handling I/O on the
   main thread; this performed roughly like this solution , but scaled
   half as well, and the separate wake-up path was still deemed hacky.
3) Only posting wake-up events to the main thread from the thread pool,
   and still handling I/O on the main thread; this still performed
   comparably to 2), and the pathological case was not handled at all.
4) Using this approach for reads and that of 3) for writes was slightly
   faster with big amounts of data, but scaled slightly worse, and the
   diverging implementations were deemed not desirable.

Fixes: QTBUG-64443
Change-Id: I1cd87c07db39f3b46a2683ce236d7eb67b5be549
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
2020-11-17 12:45:50 +02:00
Assam Boudjelthia
87fdad35ca Android: exclude failing tests of tst_qhighdpi
Tests in tst_qhighdpi are crashing on Android.

Task-number: QTBUG-88505
Task-number: QTBUG-87025
Change-Id: Ie1350e06fb30d90f20c550f91555f4023eee56b6
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-11-16 13:35:46 +02:00
Assam Boudjelthia
ac1cbc752f Android: exclude tests crashing at start
These tests are failing with "java.lang.UnsatisfiedLinkError: dlopen
failed: invalid ELF file" at the start, excluding them now to enable
Android testing until they're fixed later.

Task-number: QTBUG-87671
Task-number: QTBUG-87025
Change-Id: Ida7d7158fccdc31df1f9689f77fde832964d732f
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-11-16 13:35:44 +02:00
Giuseppe D'Angelo
1869615fc9 QChar: make construction from integral explicit
QChar should not be convertible from any integral type except from
char16_t, short and possibly char (since it's a direct superset).

David provided the perfect example:

  if (str == 123) { ~~~ }

compiles, with 123 implicitly converted to QChar (str == "123"
was meant instead). But similarly one can construct other
scenarios where QString(123) gets accidentally used (instead of
QString::number(123)), like QString s; s += 123;.

Add a macro to revert to the implicit constructors, for backwards
compatibility.

The breaks are mostly in tests that "abuse" of integers (arithmetic,
etc.). Maybe it's time for user-defined literals for QChar/QString,
but that is left for another commit.

[ChangeLog][Potentially Source-Incompatible Changes][QChar] QChar
constructors from integral types are now by default explicit.
It is recommended to use explicit conversions, QLatin1Char,
QChar::fromUcs4 instead of implicit conversions. The old behavior
can be restored by defining the QT_IMPLICIT_QCHAR_CONSTRUCTION
macro.

Change-Id: I6175f6ab9bcf1956f6f97ab0c9d9d5aaf777296d
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2020-11-15 14:41:05 +01:00
Volker Hilsheimer
e796857abb Stop copying events in tests
It's unnecessary, and copying QEvents is a bad practice since it's a
polymorphic class.

Change-Id: Ieb6de106084f838c5e6c8a0643c54fd3c7f4a7a8
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-11-12 15:25:06 +01:00
Allan Sandfeld Jensen
94dd2cebdc Remove Qt4Compatible painting
Change-Id: Ie54206ca9b509875568f2158e229fca9cb1860a2
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-11-12 08:31:18 +01:00
Eirik Aavitsland
7aa68ee6f2 Fix misidentification of some shearing QTransforms as only rotating
The dot product used rows instead of columns.

Pick-to: 5.15 5.12
Fixes: QTBUG-87984
Change-Id: I922f67ed0fa9a4f88aa4e9fc6d3c09f8dda21688
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-11-11 12:48:21 +01:00
Allan Sandfeld Jensen
04413b9dd8 Allow painting above INT16_MAX on 64-bit architectures
The logic in qgrayraster was ready for it except for an intermediate
format. qrasterizer.cpp and qcosmeticstroker.cpp uses a dot-16 fixed
point format, and had to be changed to handle higher coordinates on
64-bit architectures.

Fixes: QTBUG-84428
Change-Id: I85ab7a04e38bd0dbcefa9f16c16ccc84785a33cf
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-11-09 14:04:13 +01:00
Morten Johan Sørvig
46a552583f Teach QPixmapIconEngine how to handle @Nx pixmaps
Bring QPixmapIconEngine on par with QIconLoaderEngine
when it comes to @Nx pixmap handling: Make the scale
factor a test parameter during icon lookup.

This allows storing e.g 16x16@1, 16x16@2, 16x16@3 versions
of a pixmap in the icon, and then having QIcon select
the correct one based on the target devicePixelRatio.

Extend the qiconhighdpi test to also cover QPixmapIconEngine,
via the addPixmap() API.

The corner cases of pixmap lookup can be much complicated.
QIconLoaderEngine and QPixmapIconEngine should ideally
have identical behavior in order to avoid surprises.

Change-Id: I17552cc61755bff9553c4a462e3983ac6759c13b
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2020-11-08 19:49:53 +01:00
Volker Hilsheimer
b14b1c99f8 Rename QRangeCollection to QPageRanges, make it a proper value type
The type is specific about printing, so give it a name in line with
QPageLayout and QPageSize.

As per API review comment, it's not clear why this type should not be a
regular, copyable and movable value type. It stores a list of intervals.
Give it value-type semantics, as an implicitly shared class.

Convert the parse method into a static factory function.

Add a Range type and use it instead of the semantic-free QPair.
Move QPrinter getter into QPagedPainteDevice, make it return a copy
rather than a pointer, and add a setter.

Extend test case to cover all members and more merge cases. Fix bugs
found that way.

Fixes: QTBUG-88113
Change-Id: If17ea4d410d49f16b097e88b7979db5d72add820
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-11-08 11:49:54 +01:00
Alexandru Croitor
f5b214130a tests: Blacklist tst_qwindow failing test on Windows
Amends b13bad3ab0

Task-number: QTBUG-35109
Task-number: QTBUG-88250
Change-Id: I0b37369bb7cfc58e6968ca20969725e2f4143200
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-11-07 19:33:37 +01:00
Shawn Rutledge
f5c7799f59 Support the markdown underline extension
MarkdownDialectGitHub now includes this feature, so *emph* is italicized
and _emph_ is underlined. This is a better fit for QTextDocument capabilities;
until now, _underlined_ markdown could be read, but would be rendered with
italics, because in CommonMark, *emphasis* and _emphasis_ are the same.
But QTextMarkdownWriter already writes underlining and italics distinctly
in this way.

[ChangeLog][QtGui][Text] By default (with MarkdownDialectGitHub), markdown
_underline_ and *italic* text styles are now distinct.

Fixes: QTBUG-84429
Change-Id: Ifc6defa4852abe831949baa4ce28bae5f1a82265
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-11-07 09:35:11 +01:00
Shawn Rutledge
9a1a15b42f Introduce QEvent::isSinglePointEvent()
This makes high-level event dispatching easier: for example we often
need to cast an event to access getters like button() and buttons().
We can so far assume that any QPointerEvent that is not a QTouchEvent
is a QSinglePointEvent; but more explicit type-checking looks safer.

Implemented in a similar way as c7f7279969.

Change-Id: I980d759e2a7538b6b30fd3bdc3be0c351ec6c246
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-11-07 06:24:38 +01:00
Alexandru Croitor
b13bad3ab0 tests: Blacklist failing tests on MinGW
Also move redudant Android entries to already existing sections.

Task-number: QTBUG-35109
Task-number: QTBUG-88250
Change-Id: I9d5eaa5a3f11b55566a7c74f84a972a0c272cfea
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2020-11-06 21:03:51 +00:00
Morten Johan Sørvig
52ce0c177e Set the url to have the AtNx filename if one is found
There’s no need to convert the file name/path to QUrl,
and then back again to QString before calling qt_findAtNxFile().

Call qt_findAtNxFile first, and then convert to QUrl.
This makes sure the url-name and string-name stays
in sync.

Change-Id: I8b8939eabbdaff473945ebe31faafd408e9c4295
Pick-to: 5.15
Fixes: QTBUG-60793
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
2020-11-06 09:16:30 +00:00
Assam Boudjelthia
039d3fe4e8 Android: blacklist a list of failing tests for android
We want to re-enable Android tests in QTQAINFRA-3867. However,
many tests are failing already preventing that from happening.
QTBUG-87025 is currently keeping track (links) to all of those
failing tests.

The current proposal is to hide those failing tests, and enable
Android test running in COIN for other tests. After, that try
to fix them one by one, and at the same time we can make sure
no more failing tests go unnoticed.

Task-number: QTBUG-87025
Change-Id: Ic1fe9fdd167cbcfd99efce9a09c69c344a36bbe4
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-11-04 12:27:49 +02:00
Shawn Rutledge
f6418343f1 Add QEventPoint::normalizedPosition() to replace normalizedPos()
In 4e400369c0 we deprecated
normalizedPos() because we suspect it's a legacy feature that few
users will need.  However Qt developers keep bringing up the continued
usage in autotests over and over.  (It's IMO not wrong to keep testing
deprecated functions in autotests, but the warning keeps attracting
attention.)

Of course it will turn out that normalizedPos() has users; we just
don't know how many.  One way to look at it is: why should they copy
a snippet of code to calculate it, when it costs us so little to
continue to provide this accessor.

It might also turn out that some users will complain that in Qt 5
it was passed through from the device driver (or at least from the
window system API) to the application, and perhaps the replacement will
not always work, for example if availableVirtualGeometry() ends up
wrong, or there is some strange scenario that generates events that are
out-of-bounds for the device that the event professes to come from, so
that the "normalized" coordinates also go outside the [0..1] range.
We reserve the right to put back the storage in QEventPointPrivate if
the need arises; so that's why this function is not inline.

We continue to hope that startNormalizedPos() and lastNormalizedPos()
are used even less and won't be missed much, because it would be
wasteful to store them all the time if only a few users need them.

Change-Id: I23ed78843e3f9e16133c5b6f462884a3845f91b6
Reviewed-by: David Skoland <david.skoland@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-11-03 20:36:35 +01:00
Volker Hilsheimer
a50f0f045d Get rid of all instance usage of QFontDatabase
All QFontDatabase APIs are static, use them accordingly.

Task-number: QTBUG-88114
Change-Id: I0e4a7508646037e6e2812611262eed8b6d7ad3de
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2020-11-03 20:36:34 +01:00
David Skoland
56a1a645ac Update tst_qguivariant to use QMetaType
Change-Id: I4c789ecfc9f4613bd4820a8a6530249c51344a83
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-10-28 22:18:45 +01:00
Lars Knoll
11bad61096 Deprecate QVariant::Type
It's been obsolete for a long time already. Make sure
the compiler now warns about it and remove all remaining
uses in qtbase.

Change-Id: I0ff80311184dba52d2ba5f4e2fabe0d47fdc59d7
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-10-23 09:58:57 +02:00
Lars Knoll
4175175588 Rename the QMetaType::MovableType flag to RelocatableType
Keep this in sync with the changes we have done in QTypeInfo.

Change-Id: Iaacb0f3cc5c46d3486084a1f6eca480a233d5e1a
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-10-23 09:49:36 +02:00
Allan Sandfeld Jensen
e356ab2c32 Make QPointer comparisons hidden friends
Reduces ADL noise.

Change-Id: Id0aa4b32b7bb6d70ed9106b949452d895d9060a9
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-10-23 09:32:37 +02:00
Shawn Rutledge
0e5bbf3507 Make QEvent::setAccepted() virtual; set QEventPoints state the same
In Qt Quick, when we deliver an item-specific QTouchEvent that contains
only the subset of eventpoints that are inside the Item's bounds,
traditionally the Item can accept the event to tell the delivery logic
that the event is handled and doesn't need to be delivered further.
But an Item cannot be expected to have total scene awareness; so now,
the delivery is "done" only when all eventpoints in the original event
are accepted.  This behavior has been working well enough already due to
logic in QQuickWindow that iterates the points and accepts them if the
event is accepted; but it seems appropriate to move this enforcement
into QPointerEvent itself.  Making setAccepted() virtual gives us a
useful degree of freedom.

Event-handling code should alternatively use QEventPoint:setAccepted()
or QPointerEvent::setExclusiveGrabber() to take resonsibility for only
a subset of the touchpoints.

Another way to put it is that we treat QPointerEvent::setAccepted() as a
convenience method: accepting the QEventPoints is what counts (at least
in Qt Quick).

Change-Id: Icec42dc980f407bb5116f5c0852c051a4521105a
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-10-22 04:54:17 +00:00
Volker Hilsheimer
875a7fad52 Fix a bunch of compiler warnings in event handling test cases
Leave the normalizedPos warnings, there is no equivalent function.

Change-Id: I50c72ab24b4855e36941aafdee30cdb0e94c1684
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2020-10-22 02:43:26 +02:00
Piotr Mikolajczyk
a02ea26b46 [Android] Make sure expose events are emitted after window resize
Expose event would not be sent when window was resized

Fixes: QTBUG-69155
Pick-to: 5.15
Change-Id: I81bf2d54f830a0dabf15398e1f25b55ff7ff4479
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Rami Potinkara <rami.potinkara@qt.io>
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
Reviewed-by: Heikki Halmet <heikki.halmet@qt.io>
2020-10-21 07:08:54 +00:00
Shawn Rutledge
9aba868571 QEvent copy constructor: copy the type flags too
Failure to copy m_inputEvent and m_pointerEvent actually left them
uninitialized, and resulted in random behavior in Qt Quick when
Flickable clones a pointer event for later replay.

Remove the comment about copying events being a "bad idea" in Qt 4,
while we're at it.  Copying became more common in Qt 5, and we
probably won't be able to stop doing it now.

Change-Id: I40b6ba5ad696e7aaafbeefbca86eca00cab40616
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-10-21 08:22:36 +02:00
Morten Johan Sørvig
3df2448f63 Merge existing tst_qhighdpiscaling into tst_qhgihdpi
Move the factor() test, drop scale() which should be
covered already.

Change-Id: Id2079536a91c7e9f7199960bdf6b33489d0a6670
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2020-10-20 07:27:04 +02:00
Morten Johan Sørvig
d023da8639 Add high-dpi auto test
Use the new screen config feature of the offscreen
platform plugin to run tests on virtual screen setup.

This has the benefit that we can auto-test the QHighDpiScaling
implementation (as well as its usage in QtGui) on any platform
with a fixed mock screen setup which does not rely on physical
screen configuration.

Test the following configurations:
   - three screens: 96 DPI. (reference)
   - three screens: 192 DPI
   - three screens: mixed (high) DPI

Change-Id: I2fac889d896cf30ab2a79c306cee22177ad8f4ac
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2020-10-20 07:26:57 +02:00
Volker Hilsheimer
b61d67f897 Fix compile warnings from ignored return value
The return value can be ignored here, so make intention clear.

Change-Id: I116869c47039b159db96f133b5850a2215873c2f
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-10-17 08:21:52 +02:00
Allan Sandfeld Jensen
986c09f815 Test QImage move semantics
Tests the move semantics of QImage in Qt6.

Change-Id: Ia4d95f0b88ca7dde0daf85a0f53049b42b5be1a5
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2020-10-16 18:49:01 +02:00
Andy Shaw
bdc9d272ee Fallback to using the family when doing an exact match
If the difference between the families sizes is just 1 where one of them
is 0 in size then we can fallback to the family in that case.

Pick-to: 5.15
Fixes: QTBUG-87267
Change-Id: I62b25b06c88000b4d7defe91871c07873b1fc792
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2020-10-12 14:08:06 +02:00
Laszlo Agocs
2189e0f2fc rhi: Make the new direct buffer update available for non-uniform buffers
The original restriction to UniformBuffer was due to the GL backend
where there is no GL buffer object for QRhiBuffers with usage
UniformBuffer. However, we can still implement this for cases when
there is a true GL buffer object underneath. With other backends it
should all work as-is already.

This becomes useful when one has buffers with usage Vertex that need
full updates every frame. (f.ex. instance data)

Unfortunately this involves renaming the function. But while at it, add
an autotest case as well.

Change-Id: Iff59e4509a8bae06654cc92fe8428bd79eb012fb
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2020-10-12 07:55:37 +02:00
Allan Sandfeld Jensen
564b59d903 Another round of replacing 0 with nullptr
This time based on grepping to also include documentation, tests and
examples previously missed by the automatic tool.

Change-Id: Ied1703f4bcc470fbc275f759ed5b7c588a5c4e9f
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2020-10-07 23:02:47 +02:00
Tor Arne Vestbø
0efe79f80d Rename the new platform APIs from QPlatformInterface to QNativeInterface
We were already using the 'native' nomenclature when referring to these
kinds of APIs, e.g. when talking about native handles, or the existing
QPlatformNativeInterface on a QPA level. Using 'native' for the user
facing APIs also distinguishes them from the 'platform' backend layer
in QPA and elsewhere.

Change-Id: I0f3273265904f0f19c0b6d62471f8820d3c3232e
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-10-07 13:03:27 +02:00
Shawn Rutledge
f51e6552e3 End touch->mouse synthesis when the chosen touchpoint is released
During delivery of a TouchBegin event, if no widget accepts it,
we begin treating the first touchpoint as a synth-mouse, as before.
If a second touchpoint is pressed or released in any order, it's
irrelevant: the fake mouse button is released as soon as the first
touchpoint is released.  This fixes the bug that such a scenario
caused the mouse release not to be sent, so that a widget could get
"stuck" in pressed state.

Done-with: Tang Haixiang <tanghaixiang@uniontech.com>
Fixes: QTBUG-86253
Pick-to: 5.15
Change-Id: I7fbbe120539d8ded8ef5e7cf712a27bd69391e02
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-10-02 14:17:44 +02:00
Laszlo Agocs
0b7aef08dc rhi: vk: Alter command buffer strategy
Reports on the Web have it that there's nothing guaranteeing a
driver does any actual freeing of resources then doing
vkFreeCommandBuffer for a command buffer from a command pool that
does not have VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT, thus
leading to continuously growing resource usage with our current
allocate/free pattern. It could be that this is the source of out
of memory problems we are seeing on some Android devices.

Instead of just going straight for said command pool flag and doing
ResetCommandBuffer for the command buffers individually, take one
step further and use per-slot (slot being 0 or 1 if QVK_FRAMES_IN_FLIGHT
is 2) command pools. The current pool is reset in each
beginFrame/beginOffscreenFrame, moving all allocated command buffers
to the initial state (while other command buffers with the other pool
are not affected).

This may be (while impossible to tell from just guessing based on the
spec) our best approach to command buffer allocation since a Vulkan
implementation can likely just use some simple per pool allocator,
knowing that we never want to free or reset individual command buffers,
but we rather only reset the whole pool at once.

The option of importing an existing VkCommandPool when creating the
QRhi instance is now gone, but there was probably no point in offering
that in the first place.

When it comes to VK_COMMAND_POOL_RESET_RELEASE_RESOURCES_BIT it will
not be set unless releaseCachedResources() (in Qt Quick this is hooked
into QQuickWindow::releaseResources()) was called. What this does in
practice is unknown, but have an option to set it now and then if the
application really wants.

While we are at it, rename secondaryCbs to activeSecondaryCbStack to
indicate what it really is. (it's a stack as each call to
beginExternal() pushes a new one, while each endExternal() pops)

Change-Id: I2e5c1fad26d794e1f56c778e38f750998d706d84
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2020-10-02 13:14:31 +02:00
Laszlo Agocs
d92b0e18c1 rhi: Make per-frame flags per-pass where appropriate
ExternalContentsInPass becomes a per-pass flag now. Why is this
beneficial? Because while Qt Quick has no choice for its render
pass, not being able to guess if the application wants to do some
native rendering in there, Quick 3D's render passes, all the ones
that are under Quick3D's control, do not have native rendering
from the application in them, and so using secondary command
buffers with Vulkan is not necessary.

Introduce something similar for compute and OpenGL. By knowing that
none of the resources used in a pass are used with a compute pass
(e.g. because we know that there are no compute passes at all) a small
amount of time can be saved by skipping tracking buffers and textures
because the only purpose of said tracking is to generate barriers that
are relevant only to compute.

Change-Id: I0eceb4774d87803c73a39db527f5707a9f4d75c1
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2020-10-02 13:14:08 +02:00
Shawn Rutledge
8f74f7d25b tst_qwindow: verify isBeginEvent(), isUpdateEvent() and isEndEvent()
It also demonstrated that the tests were out of sync with reality:
since a97759a336c597327cb82eebc9f45c793aec32c9 QMouseEvent::button()
and QWindowSystemInterfacePrivate::MouseEvent::button should be the
button that changes state of course; but when a button is pressed,
we are reacting to it after the fact, so QMouseEvent::buttons() and
QWindowSystemInterfacePrivate::MouseEvent::buttons should include the
new button that was just pressed.  Likewise when a button was released,
we send the event with buttons _omitting_ the button that was just
released.

Amends 147a8bc4c8 and
6d6ed64d6c

Change-Id: I670289019fcfa7de685ca38799804772dc0f1c8f
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-09-30 23:17:57 +02:00
Allan Sandfeld Jensen
426308a93b Add logging categories to image handlers
Change-Id: Ia0c47826d08b3f641c17d8a585f62d008a8b095b
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2020-09-30 08:39:45 +02:00
Liang Qi
be7d46f5e2 Revert "Blacklist tst_QWindow::exposeEventOnShrink_QTBUG54040"
This reverts commit b1ef104866.

This test is BPASS on openSUSE_42_3 for 5.12 and PASS on openSUSE_15_1
for 5.15.

Pick-to: 5.15
Pick-to: 5.12
Change-Id: Ia1d81ed38491c27c01f270623c5082663f4da699
Reviewed-by: Tony Sarajärvi <tony.sarajarvi@qt.io>
2020-09-30 06:18:49 +02:00
Laszlo Agocs
848ed9644c rhi: Drop QBitArray usage
Change-Id: I4ae92e6c8c91111a4593c51ee05443b3bc806c35
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2020-09-29 21:24:38 +02:00
Lars Knoll
0902508411 Fix compiler warnings from QKeyCombination
Change lots of code to avoid the deprecated operator+() or implicit
casts to int.

Change-Id: I0c343cd5b28603afdf1214eefb85e928313345e2
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-09-28 17:23:20 +02:00
Allan Sandfeld Jensen
b0b4fcd05c Preserve formats in QImage::scaled()
Do not always use the smoothScaled routine, the normal routines are
also optimized, and do not convert to alpha formats when not necessary.

Task-number: QTBUG-49719
Change-Id: I6ee9b620cc259472c419e7363357f41ce29b594a
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2020-09-26 18:49:10 +02:00
Volker Hilsheimer
2f319f3be9 Give QPixmap a move constructor
It already has a move-assignment operator, and implements swapping.

This requires a specialization of the QExplicitlySharedDataPointer
destructor to be forward declared, and an implementation that is
identical to the default version. Otherwise we would need
QPlatformPixmap to be fully defined in the public QPixmap header.

Change-Id: I2651bbc29a7083a93e3b3ad671d3aeea659b7d5a
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2020-09-23 18:00:54 +02:00
Allan Sandfeld Jensen
7c1f94f387 Fix Qt6 todo in qcssparser
Colors with wrong number of elements are now invalid.

Change-Id: I32c934894de86095d9790baa5f0d2001d76bcd3c
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-09-23 17:01:29 +02:00
Laszlo Agocs
fe3a1617af rhi: d3d: Fix dynamic offsets with multiple buffers
Fixes: QTBUG-86821
Change-Id: I57f86bf0f7e95b92f5b2c5fee587112ecf0fc8e6
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2020-09-23 16:59:06 +02:00
Alexandru Croitor
403213240c CMake: Regenerate projects to use new qt_internal_ API
Modify special case locations to use the new API as well.
Clean up some stale .prev files that are not needed anymore.
Clean up some project files that are not used anymore.

Task-number: QTBUG-86815
Change-Id: I9947da921f98686023c6bb053dfcc101851276b5
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2020-09-23 16:59:06 +02:00
Alexandru Croitor
a3bd80c08c CMake: Regenerate projects
Clean up the state of the projects,
before changing the internal CMake API function names.

Task-number: QTBUG-86815
Change-Id: I90f1b21b8ae4439a4a293872c3bb728dab44a50d
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-09-22 19:08:53 +02:00
Alexandru Croitor
9959090da8 CMake: Fix failing tests on macOS developer builds
tst_qguiapplication was missing an Info.plist file.
We can't directly reference the tst_qcoreapplication Info.plist
file like the qmake project does, because that breaks ninja
(says multiple rules create the same output file), so use a
copy instead.

Blacklist the qpluginloader loadMachO test when doing CMake builds.
The qmake projects use multiple custom rules to build the macho
plugins, which need to be ported to CMake.

Task-number: QTBUG-86053
Task-number: QTBUG-86792
Change-Id: Iaff2b2d5e9e84a457b4f2ffc011a580388498f00
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-09-22 19:08:53 +02:00
Allan Sandfeld Jensen
5f198584e2 Define inverted QRects consistently
Changes the definition of invalid QRects to be more consistent.
This simplifies the logic, and makes it possible for us to fix
normalized() so dimensions don't change.

The actual API is not changed except for inverted rects.

Only one use-case for the old normalized() function existed,
and has been reimplemented as QRect::span().

Fixes: QTBUG-22934
Change-Id: I29dad2952dc6c8e84a6d931898dc7e43d66780f3
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-09-21 15:04:51 +02:00
Lars Knoll
848927b688 Cleanup API of QMimeData
Do not use QVariant::Type anymore, instead use QMetaType

For some reason, this pushed the qvariant autotest over the limit where
MSVC requires the /bigobj flag, so add that one.

[ChangeLog][QtCore][QMimeData] The signature of the virtual retrieveData()
function has changed and now takes a QMetaType instead of a QVariant::Type.

Change-Id: Ib46773bd731ee2177b1ef74d8162d744be7017ef
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-09-21 14:56:09 +02:00
Shawn Rutledge
153dcfbbba Rename is[Begin|Update|End]Event, reimplement in QWheelEvent
These states correspond well with ScrollPhase, and this abstraction
makes it possible to handle wheel events the same way as mouse events
in Qt Quick: on "begin" we deliver to all Items and Handlers until
all points (the only point) are accepted; on "update" and "end" we
deliver only to the exclusive grabber, if there is one, and to any
passive grabbers.

Change-Id: I702dbd4f2c1bf5962eb3dbb9e4b725300a00a887
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-09-17 19:03:24 +02:00
Volker Hilsheimer
861c4d8548 Deprecate implicit QPixmap conversion to QBitmap
It is lossy, so should be requested explicitly, using a dedicated
fromPixmap factory function.

Deprecate the constructor and assignment operator, and make the
constructor explicit.

[ChangeLog][QtGui][QBitmap] Implicitly constructing and assigning
to a QBitmap from a QPixmap has been deprecated, and the respective
constructor has been made explicit. Use the fromPixmap factory
function instead.

Change-Id: I68ce85b26c901415137b664a1db687021d48bae0
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-09-17 13:26:50 +02:00
Volker Hilsheimer
fe3bebbd68 Fix deprecation warnings in tests
Adjust to changes to QIcon::pixmap, QMetaType::type, and
QAbstractItemView::itemDelegate.

Change-Id: I9eb0331ef899131afc86c33f27feeee76331ffc8
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2020-09-17 06:45:59 +02:00
Shawn Rutledge
a54988c822 Mouse->touch synthesis: send touch event with mouse device
In 4e400369c0 we began to send synth-mouse
events from the touch device, but in the opposite direction it was not
consistent.

Add autotests to prove that it's consistent both ways now.

Change-Id: I7df2328fef224dc1529ca5d27411cd8a5a9c8df9
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-09-16 14:47:45 +02:00
Shawn Rutledge
1fdbbb49d9 Calculate velocity in QMutEventPoint::setTimestamp() with Kalman filter
This functionality was only in Qt Quick in Qt 5.  Now we move it up to QtGui
so that every QEventPoint will have a valid velocity() before being delivered
anywhere.

[ChangeLog][QtGui][QPointerEvent] Every QEventPoint should now carry a valid
velocity(): if the operating system doesn't provide it, Qt will calculate it,
using a simple Kalman filter to provide a weighted average over time.

Fixes: QTBUG-33891
Change-Id: I40352f717f0ad6edd87cf71ef55e955a591eeea1
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-09-16 14:47:36 +02:00
Shawn Rutledge
2692237bb1 Track grab state in QPointingDevicePrivate::activePoints
QQuickEventPoint instances were very long-lived and got reused from one
event to the next.  That was initially done because they were "heavy"
QObjects; but it also became useful to store state in them between
events. But this is in conflict with the ubiquitous event replay
code that assumes it's OK to hold an event instance (especially
a QMouseEvent) for any length of time, and then send it to some widget,
item or window. Clearly QEventPoints must be stored in the QPointerEvent,
if we are to avoid the need for workarounds to keep such old code working.
And now they have d-pointers, so copying is cheap. But replay code
will need to detach() their QEventPoints now.

QEventPoint is useful as an object to hold state, but we now store
the truly persistent state separately in an EventPointData struct,
in QPointingDevicePrivate::activePoints. Incoming events merely
update the persistent points, then we deliver those instead.
Thus when event handler code modifies state, it will be remembered
even when the delivery is done and the QPA event is destroyed.

This gets us a step closer to supporting multiple simultaneous mice.

Within pointer events, the points are moved up to QPointerEvent itself:
 QList<QEventPoint> m_points;
This means pointCount(), point(int i) and points() can be non-virtual.
However in any QSinglePointEvent, the list only contains one point.
We hope that pessimization is worthwhile for the sake of removing
virtual functions, simplifying code in event classes themselves, and
enabling the use of the range-for loop over points() with any kind of
QPointerEvent, not just QTouchEvent. points() is a nicer API for the
sake of range-for looping; but point() is more suited to being
non-const.

In QML it's expected to be OK to emit a signal with a QPointerEvent
by value: that will involve copying the event.  But QEventPoint
instances are explicitly shared, so calling setAccepted() modifies
the instance in activePoints (EventPointData.eventPoint.d->accept);
and the grabbers are stored separately and thus preserved between events.
In code such as MouseArea { onPressed: mouse.accepted = false }
we can either continue to emit the QQuickMouseEvent wrapper
or perhaps QEvent::setAccepted() could become virtual and set
the eventpoint's accepted flag instead, so that it will survive
after the event copy that QML sees is discarded.

The grabChanged() signal is useful to keep QQuickWindow informed
when items or handlers change exclusive or passive grabbers.

When a release happens at a different location than the last move event,
Qt synthesizes an additional move.  But it would be "boring" if
QEventPoint::lastXPosition() accessors in any released eventpoint always
returned the same as the current QEventPoint::xPosition()s just because
of that; and it would mean that the velocity() must always be zero on
release, which would make it hard to use the final velocity to drive an
animation.  So now we expect the lastPositions to be different than
current positions in a released eventpoint.

De-inline some functions whose implementations might be subject to
change later on.  Improve documentation.

Since we have an accessor for pressTimestamp(), we might as well add one for
timestamp() too.  That way users get enough information to calculate
instantaneous velocity, since the plan is for velocity() to be somewhat
smoothed.

Change-Id: I2733d847139a1b1bea33c00275459dcd2a145ffc
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-09-16 11:33:03 +02:00
Alexandru Croitor
9ce8281417 Fix tests to build in a no-widgets configuration
The qfilesystemmodel.pro was recently moved to the gui tests subfolder,
but it uses widgets inside. Skip it in a no-widgets build.

Amends fb9ec8ad44

Task-number: QTBUG-86187
Change-Id: I955556ffddad483d4c25602ae126b8c2433091b2
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2020-09-15 15:55:47 +02:00
Mitch Curtis
fb65b32d76 Add qHash implementation for QPoint
[ChangeLog][QtCore][QPoint] Added qHash() implementation.

Change-Id: I65332e7aafab53af40a6e11457b9b457196d584c
Fixes: QTBUG-86457
Reviewed-by: Thorbjørn Lindeijer <bjorn@lindeijer.nl>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-09-15 02:46:40 +02:00
Lars Knoll
2c698a6d07 Fix compiler warnings about missing overrides
Change-Id: I52bf9fe45607f4a99cafa441bd78dfe5f7adb0e1
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-09-13 21:03:31 +02:00
Lars Knoll
557623cc4f Rename QLibraryInfo::location() to path()
As per ### Qt6 comment. Also rename the LibraryLocation enum
to LibraryPath.

Change-Id: I556025a19c5bcdf2ff52598eaba32269522d4128
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-09-12 23:35:56 +02:00
Allan Sandfeld Jensen
5bb4baae03 Replace qreal with float in QColor
There is no reason to use double precision for colors. We at most have
16 significant bits anyway.

Change-Id: I8b402cd978675b8ba7248176976d934363212ff1
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
2020-09-11 20:41:15 +02:00
Lars Knoll
6ae7a02104 Remove most compiler warnings about missing overrides
Remove around 1000 compiler warnings about missing overrides
in our auto tests.

This significantly reduce the compiler warning noise in our auto
tests, so that one can actually better see the real problems
inbetween.

Change-Id: Id0c04dba43fcaf55d8cd2b5c6697358857c31bf9
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-09-11 00:20:47 +02:00
Morten Johan Sørvig
b3c991ae8f Port from devicePixelRatioF() to devicePixelRatio()
This ports all of QtBase.

Change-Id: If6712da44d7749b97b74f4614a04fac360f69d9e
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2020-09-10 17:28:11 +02:00