Commit Graph

61692 Commits

Author SHA1 Message Date
Eskil Abrahamsen Blomfeldt
659bb338fe Avoid infinite loop when loading huge files
QTextDocumentLayout could get into an infinite loop when the
contents exceeded QFIXED_MAX.

Specifically, QFIXED_MAX is used as meaning "one infinite page"
which means that newPage() will just return when it sees this
page height. If the page actually grew larger than this, though,
we would treat it as a page break and enter a loop where we try
to call newPage() to create new pages and never return.

The layout engine cannot support documents this large, so we detect
the case and then just finish the layout loop early when it is
encountered.

Fixes: QTBUG-112968
Change-Id: I485303d714d112119a971c43e0086bf6d3d23e9f
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
(cherry picked from commit 1dc88a1b5f)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-06-08 08:13:41 +00:00
Eskil Abrahamsen Blomfeldt
7a42679a98 Freetype: Don't do image transform for translations
In 6ba003f732, we added support
for transforming bitmap fonts in Freetype by rotating the rendered
glyphs as images rather than using FT_Set_Transform(). However,
we enabled this for all transforms, even the ones that were only
doing translations, which is unnecessary and also caused some
issues. We restrict the condition to only cover rotations, scales
and shears and let translations be handled as before.

[ChangeLog][Text][Freetype] Fixed an issue where setting a
translation matrix on text using a bitmap font would cause
rendering artifacts.

Fixes: QTBUG-114229
Change-Id: Ib3f2870e57c881364c85432a7937f15f3664eda7
Reviewed-by: Lars Knoll <lars@knoll.priv.no>
(cherry picked from commit 90e3f0bd73)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-06-08 08:13:41 +00:00
Laszlo Agocs
a9870df180 rhi widget compositor: Use Nearest filtering
To stay compatible what the OpenGL-based code did before Qt 6.4.

Fixes: QTBUG-113811
Change-Id: I80d89b21dcace9b5c361b964d56f29e996940c24
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
(cherry picked from commit ec27b99c2a)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-06-08 08:13:41 +00:00
Laszlo Agocs
03ad083057 rhi: gl: Switch back to Nearest filtering when resolving
...for Qt 5 compatibility. It seems both Qt Gui and Quick calls
the QOpenGLFramebufferObject helper for blitFramebuffer with
the default GL_NEAREST argument for the filtering. In Qt 6 we
must use the same if we want to ensure pixel-perfect compatibility.

Task-number: QTBUG-113811
Change-Id: I03c69448265e7b0d73f021d71135a1725e96fcbc
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
(cherry picked from commit 6ec01168d1)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-06-08 08:13:41 +00:00
Laszlo Agocs
aa0266b90b rhi: vulkan: Fix swapchain format check
Fix the treatment of the sRGB flag. That is independent from the value
of format(), and should be checked regardless of wanting a HDR swapchain
or not. On Android for instance Display P3 with RGBA8 or RGBA8_SRGB is
one of the formats offered. While we do not support this right now,
it is an example of a "HDR" format that still uses a color buffer
format where a dedicated sRGB format is available and must be
chosen according to the specified swapchain flags.

Change-Id: I2d97689fa5af7c08486702ae690f2230d06db469
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
(cherry picked from commit 526744ba65)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-06-08 08:13:40 +00:00
Laszlo Agocs
91f9cce4ce rhi: d3d12: Fix swapchain format check
Change-Id: Ie2c19ce0aa2c30997a682ed25bc69b2b8e9f7ee0
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
(cherry picked from commit dc341ea284)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-06-08 08:13:40 +00:00
Laszlo Agocs
9479b55672 rhi: metal: Fix a swapchain debug print crash
When enabling the logs, printing hdrInfo() to qDebug
in Qt Quick is something that is done before calling
createOrResize() on the swapchain. (logically since
this is still at the point of configuring the swapchain
settings)

Thus the correct thing to do is to only access m_window,
not the backend data's window.

Change-Id: I3004b0c4a4fdb09cb07a9c0e3c503f79c699c562
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
(cherry picked from commit bee7d2c610)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-06-08 08:13:40 +00:00
Amir Masoud Abdol
b61d67ff61 Add TRY_RUN to host tools
On Windows, we will try to run our host tools after a successful build.
If the build fails because of a missing DLL, we will be able to throw an
error with some direction on what might be the cause, and how to resolve
it.

Fixes: QTBUG-113273
Change-Id: Iba548829bc41fbee95cef288faaf7edca118ee33
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
(cherry picked from commit 41b32cd2c4)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-06-08 08:13:40 +00:00
Marc Mutz
ff469d570b Add tst_QString::prependEventuallyProducesFreeSpaceAtBegin()
This seems to work with prepend(char), but not with prepend("data"),
cf. QTBUG-114167.

Task-number: QTBUG-114167
Change-Id: I7aa4dca7c2b5938c2e5ad416231945c23140d659
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
(cherry picked from commit e4682408b0)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-06-08 06:26:19 +00:00
Thiago Macieira
428821b675 tst_QProcess: move the crasher code to a header
So I can use it in tst_QProcess itself.

This also modernizes it a bit by using __builtin_trap() where available.
On x86-64, this expands to the ud2 instruction.

Change-Id: Ib5ce7a497e034ebabb2cfffd176288433378731b
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit f992402f15)
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-06-08 02:23:54 +00:00
Thiago Macieira
17537273f0 QElfParser: use ELFOSABI_LINUX instead of ELFOSABI_GNU
It seems to be the preferred constant in other OSes. In particular,
OpenBSD does not appear to have ELFOSABI_GNU[1]. Found while researching
if commit 9caac0f176 was still necessary
for OpenBSD.

This reverts commit ded2fd9ff4, which
implied NetBSD 9 doesn't have ELFOSABI_GNU either.

[1] https://github.com/openbsd/ports/blob/master/x11/qt6/qtbase/patches/patch-src_corelib_plugin_qelfparser_p_cpp

Change-Id: I63b988479db546dabffcfffd17662020d722af20
Reviewed-by: Lars Knoll <lars@knoll.priv.no>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
(cherry picked from commit 4e2f8bad0a)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-06-08 02:23:53 +00:00
Thiago Macieira
459ae9334d QElfParser: fix build if EM_S390 is not defined
Found in the OpenBSD ports patch collection[1] while researching if
commit 9caac0f176 was still necessary for
OpenBSD. They should upstream their changes instead of working around...

[1] https://github.com/openbsd/ports/blob/master/x11/qt6/qtbase/patches/patch-src_corelib_plugin_qelfparser_p_cpp

Change-Id: I63b988479db546dabffcfffd17662042c7130f7c
Reviewed-by: Lars Knoll <lars@knoll.priv.no>
(cherry picked from commit b1816c2718)
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-06-08 02:23:51 +00:00
Marc Mutz
a08ca88b24 QString: add STL-style assign() [2/4]: (it,it) overload for QChar-convertible *it
Restrict the permissible value_types to those QStringView can take,
plus QLatin1Char. All of these implicitly convert to QChar and give
the correct result, even when converted char-by-char.

Task-number: QTBUG-106198
Change-Id: Icb44244cb08af391161c4309467d4e0d2d3d3d62
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
(cherry picked from commit f5ed163c19)
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-06-08 02:23:48 +00:00
Thiago Macieira
e5d222867c CMake: apply OpenBSD patch to enable $ORIGIN
Found at https://github.com/openbsd/ports/blob/master/x11/qt6/qtbase/patches/patch-cmake_QtRpathHelpers_cmake

There are a lot more patches there whose purpose I can't tell. This is
the only CMake one that I do understand. They should upstream those
changes to us with an explanation, instead of carrying patches...

Found while researching if 9caac0f176 was
still necessary for OpenBSD.

Change-Id: I63b988479db546dabffcfffd17661fdd376bf8c8
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
(cherry picked from commit 604eb6f4cd)
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-06-08 02:23:31 +00:00
Szabolcs David
54eebc4918 Fix some syntax errors in snippets
- The following error occurs when trying to use these example codes:
"error: expected primary-expression before ‘!=’ token"
- Rename "map" to "hash" in the QHash snippet

Amends 7d542e1daf.

Change-Id: I1ad5b799f444bf074dbfb44223c00770ecf456c7
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
(cherry picked from commit 4e367fa17b)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-06-08 01:50:19 +00:00
Friedemann Kleint
f3d0f70949 Mimer SQL driver plugin: Reduce repetitive error messages
Introduce message helper functions for get/set, sparing the translators
having to translate the data types.

As a drive-by, use UUID/CLOB/BLOB consistently.

Amends 0efd8854c4.

Task-number: QTBUG-111219
Change-Id: I7a137c3797947523af5478b3add6ee0a26b295d7
Reviewed-by: Fredrik Ålund <fredrik.alund@mimer.com>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit de3795c2a6)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-06-08 01:50:17 +00:00
Tor Arne Vestbø
463a3d1f6a Add Q_OS_APPLE define on Apple operating systems
It's quite common that macOS and iOS share backends, for example due to
the functionality being part of one of the Apple core frameworks. In
this case the support isn't directly tied to the Darwin kernel per se,
so let's use a more general define to refer to the union of Apple
based features.

Change-Id: I71cac5ec1d74cd86eba67a64b20846e48c9f05c5
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit f34c5215f4)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-06-08 01:50:16 +00:00
Amir Masoud Abdol
760c9d6a6a Resolve an issue when running /qt-configure-module .
Accounting for the case where `MODULE_ROOT` is set to `.` which then
makes the `get_filename_component` command to return an empty string;
consequently, we cannot find the `config_file.txt`, and cannot process
the features correctly.

Amend f4bf7982a6

Fixes: QTBUG-114085
Change-Id: I55c7529be6caba4691adec80efca8021bd03c500
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
(cherry picked from commit 076b4bed9f)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-06-07 23:32:34 +00:00
Timothée Keller
e14fe5f848 Windows QPA: Change monitor index detection
Monitor index detection changed from comparing deviceNames to comparing
serialNumbers, to prevent the case where two monitors with identical
names might overwrite one another.

Fixes: QTBUG-112829
Change-Id: Ibfad08e178774396c4b347acfcfbdb83ed4fe332
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
(cherry picked from commit f4d6d04898)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-06-07 23:32:34 +00:00
Timothée Keller
4139b6d029 Windows QPA: Fix restore geometry after dragging from maximised - Fix
Small adjustment made to previous patch to fix the following issues:
- restoreGeometry not being updated after moving the window from one
screen to the other with keyboard shortcuts.
- restoreGeometry's size not being changed when moving screens if
WM_GETDPISCALEDSIZE isn't sent.

Task-number: QTBUG-112814
Change-Id: I9dd2340137ce57a731f8881d476e902323887e62
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
(cherry picked from commit 245c2b621f)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-06-07 23:32:34 +00:00
Axel Spoerl
78760fd3d8 QDockWidget: Propagate window title when re-docking
When a floating dockwidget's title changes, it is rendered as a
window title. When the title changes while floating, the change will be
reverted to the pre-change title when the dockwidget is docked again.

This patch explicitly propagates the window title, if it has been
programmatically changed while the dock widget is floating.

It adds test functionality in tst_QDockWidget::floatingTabs().

Fixes: QTBUG-113591
Change-Id: I96fa69fb27ad1a85f4ea9ce44c0a22290259fca6
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit c153066baa)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-06-07 21:24:24 +00:00
Edward Welbourne
d1bef7ea9a Fix deprecation warnings agains u"..."_qs in dnslookup.cpp
Change-Id: I29a177c7d46304c5b494218f5862195eb92c7684
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
(cherry picked from commit 3ab7b7e230)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-06-07 13:23:30 +00:00
Edward Welbourne
8984ea7b4d QCoreApplicationPrivate::initLocale(): report correct encoding
We override the old encoding because it wasn't UTF-8, then we use a
fresh call to nl_langinfo(CODESET) when reporting the encoding that
"is not UTF-8", except that we've just fixed that so it is now.

Store the old encoding in a std::string before we change it, so that
we can report what it was rather than what we changed it to.
Amends commit 3690c202f9

Task-number: QTBUG-113371
Change-Id: I5f7c3648890cb0abf1d4769af24715686762c176
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit a7c87be888)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-06-07 13:23:30 +00:00
Edward Welbourne
025ef096f7 Fix what we can of macOS's divergence for pre-1900 dates
The system locale backend on macOS uses system APIs to format dates
and times in localized ways. Those system APIs appear to know more
about time zones than the time_t functions (which artificially cut off
before 1900) are willing to tell us. As a result, QDateTime is left to
guess the offsets in use before 1900 but the locale-formatting takes a
correct offset into account, which can lead to QDateTime and the
locale-aware APIs using different offsets. This is further compounded
by the system APIs taking into account the calendar transition from
Julian to Gregorian. We can't do much about the latter.

Previously we were formatting dates by passing the start of the day to
the system APIs (which take a date-time, albeit using a "Date" name
for the type), along with a date-format that ignores the time of day.
For dates before 1900, if the system APIs know the offset in use was
less than that in use in the early 1900s, QDateTime (using the latter)
gets the start of the day slightly earlier than where the system APIs
know it is, so the day before is the date at that time. Use noon on
the day in question to avoid this problem, at least for zones that
didn't do whole day offset-shifts (crossing the date line) before
1900. Document the problem and the limited extent to which we can
solve it.

Task-number: QTBUG-54955
Change-Id: I5be1bfdb3013433ee248846533ef73af39f173f5
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
(cherry picked from commit 9155a07667)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-06-07 13:23:30 +00:00
Marc Mutz
010b9adb95 QFusionStyle: optimize cache-key generation for qt_fusion_draw_button():
Instead of passing a QLatin1StringView to QStyleHelper::uniqueName(),
which takes a QString, allocating, and then using QStringBuilder to
append something to the result of uniqueHelper(), allocating again,
pull the appends to before the call to uniqueName(), folding these two
allocations into one.

Task-number: QTBUG-112200
Change-Id: I501dd4a3df4b9f5267ca931b550d521f4dafe493
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 362b5b8428)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-06-07 13:23:29 +00:00
Marc Mutz
a95930282e QFusionStyle: de-pessimize arrow painting
Instead of holding three QPointF's in a QPolygonF, which will allocate
them on the heap, use QVarLengthArray<>, which will allocate them on
the stack instead.

Task-numbber: QTBUG-112200
Change-Id: If078e5a9a5cb82fd03b511e28cceb88bd42996f8
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit d6ce0bad67)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-06-07 13:23:29 +00:00
Marc Mutz
e6fb3b4ea0 QPixmapCache: fix leaking of QStrings and Keys on clear()
QPixmapCache maintains a mapping from QString to QPixmapCache::Key, in
the form of the cacheKeys QHash, but QPixmapCache::clear() didn't
touch it, leading to the string data (as well as the Keys) being
retained after any possible use. This can lead to memory slowly being
eaten up, as reported in QTBUG-112200, and prevents a periodic calling
of QPixmapCache::clear() from being a work-around for the issue in the
bug report.

Fix by clearing cacheKeys in QPixmapCache::clear().

This is designed as a low-risk enabler of a work-around, not a fix for
the issue. The work-around enabled by this is periodic calling of
QPixmapCache::clear().

[ChangeLog][QtGui][QPixmapCache] Fixed QString key data not being
freed on clear().

Task-number: QTBUG-112200
Change-Id: Ica6fa0e27e1b47b8df58d5e996378a2ececa5f9c
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
(cherry picked from commit 6ab0d25a09)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-06-07 13:23:29 +00:00
Mikolaj Boc
f5e52d209e Modernize the qtloader
This is a minimal version of qtloader. The load function accepts
the same arguments as emscripten runtime with a few additions:
- qt.environment
- qt.onExit
- qt.containerElements
- qt.fontDpi
- qt.onLoaded
- qt.entryFunction

State handling has been removed in favor of making the load async
(assume loading when the promise is live).

Public APIs getting crashed status, exit text and code have been
refactored into the new qt.onExit event fed to load. No need for
keeping the state in the loader.

The loader is integration-tested. A test module with test APIs
has been created as a test harness.

The runtime APIs exposed by Qt (font dpi and screen API) are handled
by the qtloader seamlessly.

Change-Id: Iaee65702667da0349a475feae6b83244d966d98d
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
(cherry picked from commit b9491daad0)
2023-06-07 13:10:01 +02:00
Amir Masoud Abdol
f1fa472c9f Use parentheses for Xcode specific variables
If I'm not mistaken we would like to leave this to Xcode, if so, we can
use `$()` to make our intention more clear in the code.

Change-Id: I3867f68f371a1cf1a5db5e639ec740f2546ccd75
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
(cherry picked from commit a471324a03)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-06-07 08:41:31 +00:00
Eskil Abrahamsen Blomfeldt
ad4a011ebd Upgrade Harfbuzz to 7.3.0
Fixes: QTBUG-114098
Change-Id: I7bc766e6edada6f964c2dc40f18ff710249fb159
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
(cherry picked from commit d390ac99f2)
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-06-07 08:41:31 +00:00
Friedemann Kleint
d0962ccebe uic: Generate QFont::Weight
Check for the new "fontweight" attribute before "bold".

Task-number: QTBUG-113670
Change-Id: Ib34ab5a19872adb3c063861ffbe6b2d3374afcaa
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
(cherry picked from commit 79436bd34d)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-06-07 06:24:21 +00:00
Volker Hilsheimer
38c0d60047 QTabBar: recalculate scroll offset when showing
If an application sets the current index and resizes the tab widget
before showing it, then the scroll offset might be calculated based on
an old size. Since after ca15f650a1,
resizing explicitly avoids scrolling, this could result in tabs ending
up scrolled outside of the tab bar when showing the tab widget.

Fix that by explicitly making the current tab visible in the tab bar's
showEvent handler, which recalculates the scroll offset based on the
actual size.

This is only reproducible with a tab widget, which lays out the tab bar
for each change and resets the tab bar's layoutDirty flag. Add a test
case there.

Fixes: QTBUG-114204
Change-Id: I1e9506b9dde1dd892291d108dd2c7b675ef99509
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Jonas Kvinge <jonas@jkvinge.net>
(cherry picked from commit 2a7da1b3c8)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-06-07 02:12:27 +00:00
Andy Nichols
2c12c9b010 Revert "QStringBuilder: remove unneeded specializations"
This reverts commit 3c6c3eccd1.

Reason for revert: They do appear to be needed, and removing them
changes behavior: QTBUG-114206

Fixes: QTBUG-114206
Task-number: QTBUG-114238
Change-Id: Iac75bbc1ef14fe89f4282bd58fe996f9a09b8506
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 4d261c1b54)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-06-06 09:26:10 +00:00
Kai Köhne
d6d16aa17f Doc: Small fixes to QCommandLineParser overview
Change-Id: I535944b747ed511cfe5e6efe8ca2c13b52c2cfbb
Reviewed-by: Andreas Eliasson <andreas.eliasson@qt.io>
(cherry picked from commit 1352dba3b0)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-06-06 08:44:01 +00:00
Ahmad Samir
7126a58f6f Moc: streamline how diagnostic messages are printed
If we don't have a valid Symbol to get a line number from, or if the
symbol.lineNum is -1, print a shorter message containing only the file
path. Printing: '/path/to/file👎1' isn't useful (and looks wrong).

Change error/defaultErrorMsg/warning/note() to delegate to one central
method, so that they all behave the same; e.g. previously warning() and
note(), guarded against printing "-1" for the line number, whereas
error() didn't.

This also makes it possible to use error() for reporting other issues
(e.g. the size of generator.strings list exceeding INT_MAX, which will
happen in a later commit).

Change-Id: Iddc96e08315fae415be6a84928f845d7bceb4c5f
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit 9cb08c4c0d)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-06-05 22:23:20 +00:00
Ahmad Samir
059acac8f9 Moc/Generator: fix 64-to-32 narrowing conversion warnigns
Change-Id: Id1094aaba284c51c3a840a8e107abd837a825593
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit e22f766bda)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-06-05 22:23:14 +00:00
Ahmad Samir
f22bedf5af Misc.: fix narrowing conversion warnings with explicit cast to int
And using qsizetype in some places.

::pathconf() returns long.

Found by using -Wshorten-64-to-32 clang compiler flag, or adding that
flag to the flags clangd uses.

Change-Id: I9f9abd3d4d6fe73f525eec869ceabc799317f3d6
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
(cherry picked from commit 8d77ee0f2b)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-06-05 20:35:41 +00:00
Ahmad Samir
e71dfbb7db Misc.: fix narrowing conversion warnings
Using:
- range-for and iterator-based loops
- QList constructor that takes a pair of iterators

Found by using -Wshorten-64-to-32 clang compiler flag, or adding that
flag to the flags clangd uses, e.g. adding this to clangd's config file
(see https://clangd.llvm.org/config):
CompileFlags:
    Add: [-Wshorten-64-to-32]

Change-Id: I13ae65e09ab59a59f9e5c189ea27e4e16527df2d
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
(cherry picked from commit 3ee289e40d)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-06-05 20:35:35 +00:00
Joerg Bornemann
e0ec19de41 CMake: Fix unnecessary rebuilds in Visual Studio projects
User projects that use qt_add_qml_module faced unnecessary rebuilds when
using the Unix Makefiles or Visual Studio project generators.

The bug was in qt6_extract_metatypes. For the mentioned generators (and
CMake 3.16 in general), we detect that CMake's AUTOMOC does not generate
a dep file, and we use a custom target to trigger cmake_automoc_parser.
That custom target runs always.

Later, we call moc to generate meta_types/foo_metatypes.json.gen. To not
trigger a rebuild of its dependents on every build, we use
copy_if_different to generate meta_types/foo_metatypes.json only if the
content changed.

The custom command for that had two outputs:
     add_custom_command(
         OUTPUT
             ${metatypes_file_gen}
             ${metatypes_file}
         ...
     )

The Unix Makefile generator and the Visual Studio generator (and
potentiall others) interpret this as "all outputs are always changed by
this command". The Unix Makefile generator even ensures that by creating
an additional foo_metatypes.json target that touches the file. In the
generated Visual Studio project, the dependents of foo_metatypes.json
are out of date even if the actual file has an old timestamp.

In projects with QML modules, the QML type registration depends on this
file. This caused a near full rebuild of the affected QML modules.

We must mark foo_metatypes.json as byproduct of the command to specify
that it is a file "whose modification time may or may not be newer than
the dependencies".

Unfortunately, there's CMake upstream issue #19005. There's a dependency
missing between the consuming target and the byproduct. We must work
around this issue with an additional custom command with OUTPUT
${metatypes_file}.

Pick-to: 6.5
Fixes: QTBUG-106683
Change-Id: Icc2f7227c3e7b523631c1f361e29e26ae4efc46c
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2023-06-04 20:44:39 +02:00
Axel Spoerl
8a9e3c7869 Default to WindowText color in QTextDocumentLayoutPrivate::drawBlock()
When a block is drawn in a text document, drawBlock is checking,
whether the block has a BackgroundBrush property defined. If none is
defined, the color used to draw lines around the block defaults to
QPalette::Dark. This was implemented, assuming a light color scheme.
In a dark color scheme, the lines become hardly or even not visible.

This patch changes the default to Inactive/WindowText of the underlying
QPalette. This provides contrast to the document's text content and
is dark/light sensitive.

Fixes: QTBUG-113990
Pick-to: 6.5
Change-Id: Ie855852f441a0efb11c318c7edb27395151cbcce
Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
2023-06-04 13:51:54 +00:00
Dennis Oberst
54d8d8055e QString: add STL-style assign() [1/4]: non-(it,it) overloads
Implemented assign() methods for QString to align with the
criteria of std::basic_string, addressing the previously missing
functionality. This is a subset of the overloads provided by the
standard.

Reference:
https://en.cppreference.com/w/cpp/string/basic_string/assign

The assign(it, it) overload is a bit more complicated and will be
added in follow-up patches.

[ChangeLog][QtCore][QString] Added assign().

Task-number: QTBUG-106198
Change-Id: Ia1481d184865f46db872cf94c266fef83b962351
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-06-04 06:33:12 +00:00
Marc Mutz
ef1be84551 QStringDecoder: add a char16_t overload of appendToBuffer(QChar*, ~~~)
More and more code in Qt uses char16_t instead of QChar, even
QString::Data, so reduce the impedance mismatch with such code and
supply a char16_t overload in parallel to the existing QChar* one.

[ChangeLog][QtCore][QStringDecoder] Added appendToBuffer() overload for
char16_t*, complementing the existing overload taking QChar*.

Task-number: QTBUG-106198
Change-Id: I0cb8ab22c897c14b1318a676f5212cc0cf1b72b7
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-06-04 06:32:59 +00:00
Fabian Kosmale
f9fe333018 QVariant: replace fromValue() specializations with if-constexpr
Keeps all the special cases in a central place and will help with
adding an rvalue overload of fromValue() for 6.6.

Change-Id: I14f12bb98a2e2f4edfcec8ce39660643e23c1d07
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-06-04 06:32:46 +00:00
Thiago Macieira
114d00f043 QDnsLookup/Unix: cache previously decoded domain names
Change-Id: I5f7f427ded124479baa6fffd175f3ce37f0e49aa
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-06-03 19:28:15 -07:00
Thiago Macieira
59a2a32276 QDnsLookup/Windows: add a simple decoded domain cache
Avoid decoding multiple times the domain name when it comes in
sequence. This happens when a given domain label either has multiple
entries in its record set or when it's a CNAME (or both), such as in:

;; ANSWER SECTION:
cname-cname.test.qt-project.org. 3600 IN CNAME  cname.test.qt-project.org.
cname.test.qt-project.org. 1614 IN      CNAME   multi.test.qt-project.org.
multi.test.qt-project.org. 1614 IN      A       198.51.100.2
multi.test.qt-project.org. 1614 IN      A       198.51.100.3
multi.test.qt-project.org. 1614 IN      A       198.51.100.1

Label targets from other records such as MX and SRV usually do show up
again, in the Additional section, but the chance that they are
sequential isn't very good, so we don't cache those.

;; ANSWER SECTION:
mx-multi.test.qt-project.org. 3354 IN   MX      10 multi.test.qt-project.org.
mx-multi.test.qt-project.org. 3354 IN   MX      20 a-single.test.qt-project.org.

;; ADDITIONAL SECTION:
multi.test.qt-project.org. 1145 IN      A       198.51.100.3
multi.test.qt-project.org. 1145 IN      A       198.51.100.1
multi.test.qt-project.org. 1145 IN      A       198.51.100.2
a-single.test.qt-project.org. 3364 IN   A       192.0.2.1

Change-Id: I5f7f427ded124479baa6fffd175f5cf88939ee73
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-06-03 19:28:14 -07:00
Thiago Macieira
8b6bd8ed99 QDnsLookup: allow looking up the root domain
[ChangeLog][QtNetwork][QDnsLookup] It is now possible to look up the
root DNS domain, by setting the name property to an empty string. This
query is usually done while setting the query type to NS.

Change-Id: I5f7f427ded124479baa6fffd175f688395941610
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-06-03 19:28:13 -07:00
Thiago Macieira
01dfcfcecf QDnsLookup: merge some of the domain label expansion code
Use qt_ACE_do directly from QtCore, to avoid going through Latin1
(US-ASCII) multiple times.

Drive-by reduce the size of the buffers from PACKETSZ (512) to the
maximum name a label can be (255 plus 1 for the null, just in case).

Drive-by replace the last QString::fromWCharArray with QStringView,
saving an unnecessary memory allocation before calling
QtPrivate::convertToLatin1().

Change-Id: I3e3bfef633af4130a03afffd175d8be1feb5d74b
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-06-03 19:28:11 -07:00
Axel Spoerl
eda71105ff Move widgets Application example to manual tests
With 6e77da640aa84c1efe330d4a5224c9c7425ece57, the documentviewer
demo's TxtViewer plugin has been fully documented in order to replace
the Application example.

This patch moves the application example to manual tests.

Pick-to: 6.5
Change-Id: I67d975e478c7bc840613c8af1301a4eafe8f1a42
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-06-04 01:18:19 +02:00
Axel Spoerl
27906b7da8 QXmlStreamReader: Add key/value to "Invalid attribute" error message
When QXmlReaderPrivate::startDocument() parses declarations, it reports
an error if a declaration contains an unknown attribute. The message
doesn't mention the invalid attribute's key and value, so the user has
to guess which one is the faulty declaration.

This patch extends the error message by adding the respective key/value
pair.

Pick-to: 6.5
Change-Id: I7f5a228bed44937472880c3b3d63d5e816b39361
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2023-06-04 01:18:05 +02:00
Thiago Macieira
4ce97e25d3 tst_QProcess: put the tests in the right order
They were in the right order before rebasing multiple times. kdiff3 is
currently broken, so I don't know what happened.

Change-Id: Ib5ce7a497e034ebabb2cfffd17626fcf46c541fd
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-06-03 08:50:53 -07:00