Commit Graph

13104 Commits

Author SHA1 Message Date
Edward Welbourne
3b51b8c31d Fix signed/unsigned comparison warnings in tst_QArrayData
QArrayDataPointer<>::size is now a qsizetype, not the uint it used to be.

Pick-to: 6.2
Change-Id: I09d7e5a50401b46a12f29f93b2b39d646b771cfc
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2021-10-29 14:11:46 +02:00
Janne Juntunen
825505c439 QNX: Handle missing elf.h gracefully
It seems that after commit id 46fc01d7ca
the qpluginloder test case cannot find elf.h in QNX test environment.

This is just a workaround, fix for missing elf.h (QTBUG-97833) needs
to be done later on.

Change-Id: I3f6ec36c8ceaed82552fd0e156a56637c056780d
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-10-28 20:14:45 +03:00
Volker Hilsheimer
05532a0968 Fix test to not rely on event processing
QTest's simulation of mouse move events currently uses QCursor::setPos
and then processes events. This is unreliable across platforms.

This test relies on the event processing and either way has inverted
logic in the paint event; the painted region needs to at least include
the tab's rect, not the other way around. Also, the mouse move wasn't
needed here at all, and some styles don't have a different style for
pressed tabs anyway.

Pick-to: 6.2
Change-Id: Ib8f6f7be017ff87458e96ec419edcd065dd75b15
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Reviewed-by: Doris Verria <doris.verria@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-10-27 20:08:33 +02:00
Antti Määttä
ea3ede9c45 Calculate effect bounds when drawing widget graphics effect
Calculate effect bounds for the updated region when drawing the effect
so that the whole affected area gets updated. The effect bounds have
already been added to the region so it doesn't need to be handled in
the drawing function.

Pick-to: 6.2 5.15
Fixes: QTBUG-96240
Change-Id: I0c317311622e6299fb1a3015541408d1d83c93de
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-10-27 14:32:35 +03:00
Chen Bin
6de36918c0 Update clipping area when antialiasing changes
Antialiasing is disabled when the painter's antialiasing attribute
is set behind the clipping function(example `setClipPath` or
`setClipRegion`). The cause of this problem is that the
antialiasing state of the clipping region is not updated after the
antialiasing attribute is set.

A variable is required to record the painter's transformation state
set before the clipping function, because the transformation will be
applied to the clipping region, resulting in the abnormal clipping
region. The value of `s->matrix` is not accurate for the clipping fun-
ction.

Pick-to: 6.2
Fixes: QTBUG-97269
Change-Id: I409a9db32efc3b991ebb97ec9aed19bbddb273d8
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2021-10-27 15:07:28 +08:00
Mårten Nordheim
323b97ccae QHash: avoid crashing when reserving on a shared hash
Pick-to: 6.2
Change-Id: I21ad13fa223bd5a2c61112e790965093a2750268
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-10-26 21:56:31 +02:00
Thiago Macieira
0077eac4e4 QHash: double the size of the stored seed
There's now another half of the seed which will be used by the hashers.
This is not stored in QHash, so it is never changed for the lifetime of
the application (not even when QHashSeed::setDeterministicGlobalSeed()
is called). However, we will not use it when we're in deterministic
mode.

This commit uses the compiler thread-safe statics to implement the
initialization of more than one atomic word, thus freeing us from having
to have a reserved value. As a bonus, the QT_HASH_SEED warning will only
be printed once.

Change-Id: Id2983978ad544ff79911fffd16723f1673f9a5b4
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-10-26 11:38:56 -07:00
Edward Welbourne
bb220f2d99 Fix overflow issue on parsing min-qint64 with its minus sign repeated
The call to std::from_chars() accepts a sign, but we've already dealt
with a sign, so that would be a second sign. Check the first character
after any prefix is in fact a digit (for the base in use). This is a
follow-up to commit 5644af6f8a.

Fixes: QTBUG-97521
Change-Id: I65fb144bf6a8430da90ec5f65088ca20e79bf02f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-10-26 17:38:22 +02:00
Volker Hilsheimer
da632baf34 QTabBar: re-layout when tab size hint depends on selected state
QTabBar caches the rects for the tabs to avoid costly recalculation of
each tab's size hint. That cache is only updated via layoutTabs if the
entire tab bar is resized or modified. However, when a style sheet is
set that calculates a different size hint for tabs that are selected,
then the tab bar also needs to be laid-out when the current tab changes.

To minimize the cost, compare the cached size for the new current tab
with its new size hint, and re-layout the tabs when they are different.

Fixes: QTBUG-6905
Fixes: QTBUG-8209
Pick-to: 6.2
Change-Id: I110444d18938c2b3446ee58e4a8c6c472b5f12c3
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2021-10-26 00:57:36 +02:00
Volker Hilsheimer
01f96b1764 Don't fire shortcut if the action only lives in an unreachable submenu
Menus can be represented by a menu action, and if that menu action has
been hidden or disabled, then the submenu is not accessible from the
parent menu or menu bar to which it was added. Don't walk the menu
action chain further when checking whether the shortcut should trigger.

Note that this is unrelated to the menu being visible or not; we
obviously want to trigger shortcuts for actions that only live in a menu
that has not been shown, otherwise the shortcut would be rather
pointless.

Pick-to: 6.2
Fixes: QTBUG-25743
Change-Id: I48735e17352989bbc84a72263e4828f519b78095
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2021-10-25 17:17:40 +00:00
Robert Löhning
a7d1c48ca3 QVarLengthArray: Reduce memory allocations in emplace()
Currently, we allocate memory for elements one by one which can get
pretty slow when adding many elements.

[ChangeLog][QtCore][QVarLengthArray] Reduced number of memory
allocations in emplace() by allocating more memory at once.

Fixes: QTBUG-97489
Pick-to: 6.2
Change-Id: Idfb5b5946b047d5215c8ed00770574249f9f5d40
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-10-23 01:22:15 +02:00
Volker Hilsheimer
71aaf831d1 QAbstractItemView: auto-scroll with selection rectangle
Some item views, such as QListView in icon mode, implement a selection
rectangle with which the user can "lasso" items. So far, dragging that
rectangle did not trigger auto scroll, so unless an item near the edge
was selected, the user had to stop the lassoing and scroll manually to
reach more items.

Since QAbtractItemView implements auto scrolling for drag'n'drop, we can
use that mechanism also when the selection rectangle is dragged. This
requires some modifications:

We need to make sure that scrolling the view during a drag-selection
generates mouse move events so that the selection is extended and the
rectangle is updated in subclasses.
And we need to stop using QCursor::pos to get the position of the mouse
pointer, as this makes the auto-scrolling untestable. Instead, record
the mouse position last seen during a mouseMove or dragMoveEvent in
content-coordinates (identical to pressedPosition).

As a drive-by, fix some coding-style issues in nearby code.

Done-with: Zhang Hao <zhanghao@uniontech.com>
Fixes: QTBUG-96124
Change-Id: I426f786e5842ae9f9fb04e9d34dc6d3379a6207f
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2021-10-22 09:43:53 +02:00
Volker Hilsheimer
7d133a5613 Consistently restore threadpool limit at end of tests
Fix warning about unused variable, and use qScopeGuard to make sure that
the limit of the global threadpool is restored even if one of the tests
fail.

Pick-to: 6.2
Change-Id: I36747cb451074cceea961561478210728ed6d313
Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-10-22 09:43:42 +02:00
Mårten Nordheim
bfe579613a QNI: Add a convenience method for loading the default plugin
We have some official plugins, we may as well treat them as default
and give a convenient function which loads those.

Change-Id: I6251c77ac042b795bcf24b86e510e960ee4bab54
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2021-10-22 09:40:49 +02:00
Mårten Nordheim
5f8e9c194e QNI: Add supportedFeatures getter
Which just returns all the supported features

Change-Id: I8c3996b00a6ebb114bdbc9db3085a0e27fc8fa79
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2021-10-22 09:40:45 +02:00
Thiago Macieira
5bc315fbe2 tst_QVariant: suppress warning about memcpying over QVariant
tst_qvariant.cpp:3624:15: warning: ‘void* memcpy(void*, const void*, size_t)’ writing to an object of type ‘class QVariant’ with no trivial copy-assignment; use copy-assignment or copy-initialization instead [-Wclass-memaccess]

Change-Id: Ic17a33f599b844d8ab5dfffd16aafcbd74823696
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-10-21 23:40:40 +00:00
Sona Kurazyan
49f34a402a Remove the unnecessary compile-time check for recursive QSet
It doesn't make sense to have a recursive QSet with deleted operator==,
since it's not possible to add elements to it. Consequently declaring a
metatype for it also doesn't make sense. Remove the commented
compile-time check for it.

Task-number: QTBUG-96257
Change-Id: I74ebefb38adcbe36d5c2f317188743e1f37fe16d
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-10-21 12:58:05 +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ø
132ed5eb51 Centralize maybeLastWindowClosed checking in QWindow
Instead of plumbing QWidgetWindow close events via handleCloseEvent,
we just implement closeEvent directly. This allows QWindow do save
the state of the window/widget before the close event, so that we
know whether we should trigger lastWindowClosed handling, even if
the window was deleted as a result of the close event.

This also relieves QGuiApplication and QApplication from dealing
with the close logic in their notify functions, so that these
functions can focus on the propagation of events -- not how the
event is handled.

Change-Id: I8b586b53a53b1df1d8630c1acb635c60f191bb4b
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-10-20 21:17:08 +02:00
Volker Hilsheimer
a3c8518268 Make QMainWindow::restoreStateSizeChanged test less time sensitive
Amends 32edae5e26, which introduced a
timeout after which the restored state is discarded. If this timeout
hits during a CI run, then the test is expected to
fail.

Implement a lambda that watches for the restored state to disappear.

This happens primarily when restoring a fullscreen state, where some
desktop environments scroll in a new virtual desktop. It should not
happen for other data tags.

Change-Id: I5ff43a4e1857eca17a5d4fe2b47add1f70636e8d
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
2021-10-20 18:05:15 +02:00
Sona Kurazyan
a9d51298ae Fix metatype declaration for QHash/QMultiHash with no operator==
When declaring metatypes, the metatype system tries to detect if the
comparison operators for the given type exist and automatically register
them. In case of QHash, the equality operator was enabled if the value
type provides one. But the implementation needs equality operator of
the key type as well. As a result, when the key type has no equality
operator, the metatype system detects that the equality operator is
available for the QHash itself, but the compilation for metatype
registration fails when trying to instantiate the code that uses
equality operator for the key. This is fixed by enabling equality
operators for the QHash only when both the key and value types provide
one.

The same issue existed also for QMultiHash, with the difference, that
QMultiHash didn't have the constraints even on the value type. So added
checks for both.

Fixes: QTBUG-96256
Pick-to: 6.2
Change-Id: Ib8b6d365223f2b3515cbcb1843524cd6f867a6ac
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-10-20 17:16:53 +02:00
Ievgenii Meshcheriakov
af2f88f5b6 QObjectCompatProperty: Add support for custom getters
Add additional template argument to QObjectCompatProperty to specify
a custom getter. This may be useful for classes like
QAbstractProxyModelPrivate the need to customize property getters.

Task-number: QTBUG-89655
Change-Id: I34fe4bdebbbf1446aff60bd20a946454607f52d5
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-10-20 17:04:51 +02:00
Karsten Heimrich
bb8d84c358 Make QDir::mkpath() return true when given an existing root path
On macOs with APFS mkdir sets errno to EISDIR, so take the error code
into account.

Pick-to: 6.2
Fixes: QTBUG-97110
Change-Id: I8e7d10c95430a2802bdbfbf94dd65219bd9071a7
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-10-20 15:04:51 +00:00
Karsten Heimrich
71652ad4bf Make QDir::mkpath() return true when given an existing drive name
Commit ed48391c59 removed the check for
ERROR_ACCESS_DENIED reported by the Windows CreateDirectory(...)
function in case an existing windows drive name was passed as argument.
This restores the behavior of the function which broke after 5.15.

Pick-to: 6.2
Fixes: QTBUG-85997
Change-Id: Ie86188100766f7364acee57b15a250f4a2720b9f
Reviewed-by: Karsten Heimrich <karsten.heimrich@qt.io>
2021-10-20 15:04:51 +00:00
Tatiana Borisova
57ec47921e Compile Private API autotests for INTEGRITY
- GHS's __PRETTY_FUNCTION__ (used by QT as Q_FUNC_INFO) doesn't have spaces
  round the = operator when indicating the type of the template parameter.

 The compilation error:
 qt5/qtbase/src/corelib/kernel/qmetatype.h", line 2104: note #3316-D:
 cannot access position 53 in array of 49 elements
 constexpr const char *begin = func + prefix;
                                             ^
   detected during:
     instantiation of
     "auto QtPrivate::typenameHelper<T>() [with T=void]" at
       line 2186


Task-number: QTBUG-97087
Pick-to: 6.2
Change-Id: I33e61f5d54a61944a5aecf07d149a8dee0ef1e5d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-10-20 15:04:51 +00:00
Friedemann Kleint
5074679cfc uic: Fix missing Python import when setting tab orders
Add QWidget as default import so that QWidget.setTabOrder() is found.

Pick-to: 6.2
Change-Id: I7593008d1395e3fddacf7124d271a0eaf4c345d9
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
2021-10-20 11:34:03 +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
Ievgenii Meshcheriakov
826fc8c9bd Update UCD to Revision 28
This corresponds to Unicode version 14.0.0.

Added the following scripts:

    * CyproMinoan
    * OldUyghur
    * Tangsa
    * Toto
    * Vithkuqi

Full support of these scripts requires harfbuzz version 3.0.0,
this version adds support for Unicode 14.0:

    https://github.com/harfbuzz/harfbuzz/releases/tag/3.0.0

With this release 10 test cases in tst_qurluts46 were fixed, one
additional test case is failing in tst_qtextboundaryfinder and
is commented out. In total 62 line break test cases and 44 word
break test cases are failing.

A comment in src/corelib/text/qt_attribution.json was updated to
include the URL of the page containing UCD version number.

Fixes: QTBUG-94359
Change-Id: Iefc9ff13f3df279f91cbdb1246d56f75b20ecb35
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-10-18 16:45:10 +00: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
Thiago Macieira
8c2969ea86 QPlugin: Move the plugin metadata to a note in ELF platforms
A few systems, like OpenWRT, may strip the section table off the
resulting binaries (see [1]), making it impossible for us to pinpoint
the exact location of the Qt plugin metadata. This commit moves the meta
data to a location that is identifiable even in fully stripped binaries:
an ELF note.

By naming our section ".note.qt.metadata", we instruct the linker to
place it along the other notes and to mark it in the program header
section. Another advantage is that the notes are usually in the very
beginning of the file, as they are used by the dynamic linker itself, so
we'll need to read much less of the full contents.

The unit test is modified not to attempt to strip the plugin of
debugging data. In fact, we add something to the end that would,
otherwise, be matched as (invalid) metadata.

The following was produced with GCC 11 and GNU binutils ld 2.36.1.

Section Headers:
[Nr] Name                 Type         Addr             Off      Size     ES Flags Lk Inf Al
[ 0]                      NULL         0000000000000000 00000000 00000000  0        0   0  0
[ 1] .note.gnu.property   NOTE         00000000000002a8 000002a8 00000030  0 A      0   0  8
[ 2] .note.gnu.build-id   NOTE         00000000000002d8 000002d8 00000024  0 A      0   0  4
[ 3] .note.qt.metadata    NOTE         00000000000002fc 000002fc 000001ac  0 A      0   0  4

Program Headers:
  Type           Offset   VirtAddr           PhysAddr           FileSiz  MemSiz   Flg Align
...
  NOTE           0x0002a8 0x00000000000002a8 0x00000000000002a8 0x000030 0x000030 R   0x8
  NOTE           0x0002d8 0x00000000000002d8 0x00000000000002d8 0x0001d0 0x0001d0 R   0x4

The Qt metadata note is 4-byte aligned and can thus be found in the
second note section, which spans from 0x02d8 to 0x02d8+0xac=0x0384.

GNU readelf -n can even show it:

Displaying notes found in: .note.qt.metadata
  Owner                Data size        Description
  qt-project!          0x0000018f       Unknown note type: (0x74510001)
   description data: 01 06 03 81 bf ...... ff

I chose 0x7451 as the prefix for our notes, even though they're already
namespaced by the owner in the first place, because eu-readelf
mistakenly tries to interpret note 1 as a GNU ABI tag regardless of
owner. The owner name was chosen to be 12 bytes long, so the ELF note
header is 24 bytes in total. There's no space wasted because the payload
needs to be aligned to 32-bit anyway and I didn't want to use only 4
characters (header total size 16 bytes) so we'd skip the "GNU" note on
size, without string comparison. And I couldn't think of a 4-character
representative string ("QtP" ?).

[1] https://github.com/openwrt/video/issues/1

Fixes: QTBUG-96327
Change-Id: I2de1b4dfacd443148279fffd16a3987729346567
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-10-18 01:53:27 -07: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
Volker Hilsheimer
32edae5e26 Fix restoring main window state for maximized/fullscreen windows
On systems that asynchronously resize the window to maximized or full
screen state, the window will become visible in its normal geometry
before it gets the final size by the windowing system. This might cause
multiple resize events, to each of which the widget's layout responds
with a call to its setGeometry implementation.

The QMainWindowLayout is special in that it will shrink dock widgets if
there is not enough space for them, but it doesn't grow them back once
there is. With the initial resize event being for a smaller size than
what was restored, the state is not restored correctly, but remains in
the state that fit into the smallest size with which setGeometry got
called.

To fix this, we have to keep the restored state around until the window
either gets a size that is large enough for it to fit, or until we can
be reasonably certain that the windowing system is done resizing the
window while transitioning it to the maximized or full screen state.
Since across the various platforms and windowing systems there is no
reliable way to know when the window reaches its final size, we have
to use a timer that we (re)start for each call to setGeometry with a
size that's not large enough. Once the timer times out, we have to
give up; then the last layout state calculated is the final state.

To calculate the size of the layout, introduce a function to the
QDockAreaLayout that returns the size required for the current sizes
of the docks. Refactor sizeHint and minimumSize (which were identical)
into a helper template that takes member-function pointers to call the
respective method from the dock area layout's content items.

Add a test case for various permutations of the scenario. The timeout
of 150ms is based on running this test case repeatedly on various
desktop platforms and X11 window managers.

Fixes: QTBUG-46620
Change-Id: I489675c2c40d3308ac8194aeb4267172b2fb38be
Reviewed-by: Albert Astals Cid <albert.astals.cid@kdab.com>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-10-16 09:46:22 +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
Tatiana Borisova
144f3fe5a3 Fix autotest public API compilation for INTEGRITY
- getgid/getpwuid are not supported
- process should be used with config check

Task-number: QTBUG-96176
Pick-to: 6.2
Change-Id: Ib6854772bcf52f3533cb722f963426717926258b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-10-15 11:00:25 +03: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
Volker Hilsheimer
74e634d82c macOS: Correctly record normalGeometry in Cocoa plugin
Cocoa sends QWidget the state-change notification after the window has
been resized already, at which point we cannot store the normal geometry
anymore.

Handle zoom and full screen callbacks prior to the state changing
to store the geometry in QCocoaWindow. We do not need to handle
minimized state, as the window will still reflect the original
geometry.

Return the stored value from an override of
QPlatformWindow::normalGeometry so that QWidget gets the correct values
even though the new state is already active.

Fix the tst_QWidget::normalGeometry test to make it pass on all
platforms by waiting for the window to actually have transitioned to
the new state before comparing geometries. Both macOS and Windows fully
pass; on Xcb, deminimizing a window using setWindowState does not work,
which is why the test was partially skipped (confirmed by visual
testing). Move those problematic, complex test cases to the end so
that most cases are covered on Xcb as well.

Done-with: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Pick-to: 6.2
Change-Id: I518a5db9169b80e8fa25fe4fa2b50bd1ea0e6db3
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-10-14 17:19:38 +00:00
Tor Arne Vestbø
e95e9c28f0 QWidget: Don't rely on topextra to determine if window is top level
Doing so results in bailing out early for a widget that hasn't been
shown yet, or otherwise resulted in creating extra and topextra,
which means the normalGeometry will not reflect the widget's geometry.

Pick-to: 6.2
Change-Id: Ieb85e9a6109ae34fe20d79e3c12f4517f827a590
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-10-14 19:19:38 +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
Doris Verria
ec09900997 Call QWidget close handling in QWidget::close for non-toplevel native widgets
Since commit 7ba75d0 we close the QWindow in QWidget::close for native
widgets and trigger the closeEvent in QWidgetWindow. However, if the
widget's window handle is not a top level window, QWindow::close()
will not close the window, failing in this way to deliver the
closeEvent and call the close handling in QWidgetPrivate::handleClose.
To fix, call handleClose() from QWidget::close for such widgets.

Task-number: QTBUG-74606
Pick-to: 6.2
Change-Id: Ied342eced3340aaf19b5443762935b1a5fc5c27b
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-10-14 10:19:29 +02:00
Giuseppe D'Angelo
a45bc2d123 QList: avoid a iterator->pointer conversion in the test
Being a test, I'm going to abuse operator-> on end() to check
that we get what we want (a pointer past the end).

Change-Id: I7ab8d017b0fe320018820eff336d496328ade481
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-10-14 02:26:41 +02:00
Tor Arne Vestbø
947188b969 Fix references to QGuiApplication::lastWindowClosed
The signal is emitted from QGuiApplication these days.

Pick-to: 6.2
Change-Id: I7423cd4808e8df86960f225fd6e4a12a1a4f11f3
Reviewed-by: Doris Verria <doris.verria@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-10-13 22:30:08 +02:00
Thiago Macieira
cb0ea39895 CMake: remove support for building Qt with the old Intel compiler
This hasn't worked for some time. It's not in our CI and I don't think
it was working at all. When I tried to build it, I ran into several
problems with C++17 and an Internal Compiler Error I did not have any
interest in working around.

After discussing with the Intel compiler team, it was decided that
fixing those issues in the old compiler is not going to happen. Instead,
their recommendation is to adopt the new LLVM-based compiler, which
the last commit added support for.

This commit does not remove qmake support for the old ICC. It's possible
someone is using qmake with a non-Qt6 project and ICC.

Change-Id: Icb2516126f674e7b8bb3fffd16ad6350ddbd49e5
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-10-13 12:49:49 -07:00
Volker Hilsheimer
f7a4a79c62 Take overshoot into account when laying out QAbstractScrollArea
QAbstractScrollAreaPrivate::layoutChildren() positions the viewport, but
did not take the overshoot from scrolling with a scroller into account.
If the scroll area was resized during a scroll, then this resulted in the
roll back overcompensating for the overshoot, placing the viewport outside
the visible area.

Fix this by taking the overshoot into account when positioning the
viewport.

Add a test case. We have to use QWindow-based mouse event simulation, as
the QWidget based move events use QCursor::setPos, which doesn't reliably
go through the gesture framework.

Done-with: Volker Hilsheimer <volker.hilsheimer@qt.io>
Done-with: Zhang Hao <zhanghao@uniontech.com>
Fixes: QTBUG-94769
Pick-to: 5.15 6.2
Change-Id: Idf650c91e5a9cffa996e23e743939243b1d4fcc0
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-10-13 14:27:12 +00:00
Giuseppe D'Angelo
49cf0b9459 Re-enable QT_NO_NARROWING_CONVERSIONS_IN_CONNECT for Qt
This define used to be set for the entirety of the Qt build but
was lost during the qmake->CMake transition. Re-enable it.

Change-Id: Idc4cb6ada485158559485b60f62f76439550b255
Pick-to: 6.2
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-10-13 04:09:21 +02:00
Edward Welbourne
ba23507960 Fix handling of time-zone gap in QTimeZonePrivate::dataForLocalTime()
This was handled correctly when the backend supplies transitions
bracketing the time in question, but the fallback code tried to use
the DST offset at the time with larger offset from UTC; this did not
work when the gap was due to a change in standard time. Discovered by
ANS1 parsing of a date-time with two-digit year, for which the
date-time parser tried to use 1921-05-01T00:00 local time when filling
in the fields it had parsed; but, when run in Europe/Helsinki, there
is no such time due to the 20m 11s skipped when joining EET from the
prior local solar mean time.

Correct the calculation to use the actual change in offset from UTC,
as used in the (far better tested) between-transitions branch of the
code, rather than the DST offset after the transition.

Add a test-case based on the ASN.1 certificate date whose parsing
revealed the issue. Although it seems nothing in Coin can reproduce
the issue, the reporter has verified that the test does indeed fail on
the system where the bug was found and the fix does fix it.

Fixes: QTBUG-96861
Pick-to: 6.2
Change-Id: I12b02bad01daca2073d1a356452cd573684aa688
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-10-12 22:52:50 +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
878b2047b5 QList::iterator: use templates for advancing operators
Because of the addition of the operator T*(), the expression "it + N"
where N was not exactly qsizetype but any other integer type was a
compilation failure because of ambiguous overload resolution.

With GCC it's apparently a warning:

 warning: ISO C++ says that these are ambiguous, even though the worst conversion for the first is better than the worst conversion for the second:
 note: candidate 1: ‘QList<T>::iterator QList<T>::iterator::operator+(qsizetype) const [with T = char; qsizetype = long long int]’
 note: candidate 2: ‘operator+(char*, ptrdiff_t {aka long int})’ (built-in)

With Clang, it's an error:

 error: use of overloaded operator '+' is ambiguous (with operand types 'QList<int>::const_iterator' and 'ptrdiff_t' (aka 'long'))
 note: candidate function
        inline const_iterator operator+(qsizetype j) const { return const_iterator(i+j); }
 note: built-in candidate operator+(const int *, long)

Pick-to: 6.2
Fixes: QTBUG-96128
Change-Id: Ie72b0dd0fbe84d2caae0fffd16a06f23dd56b060
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2021-10-12 08:46:31 -07:00
Volker Hilsheimer
971bf3a9bb Activate tst_QWidget_window::tst_showWithoutActivating on cocoa
The test passes, the functionality is implemented in QCocoaWindow.

Task-number: QTBUG-8857
Pick-to: 6.2
Change-Id: I2f4b3a39cec1aaaf4351753b590f35e280503461
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2021-10-12 14:08:08 +02:00