Commit Graph

62096 Commits

Author SHA1 Message Date
Marc Mutz
aa8e8e94b9 QPixmapCache: DRY insert()
Implement insert(QString, QPixmap) in terms of insert(QPixmap) to
avoid duplicating code and to separate concerns: insert(QString,
QPixmap) is now only dealing with the cacheKeys, insert(QPixmap) is
only concerned with the Key-based lookup.

Task-number: QTBUG-112200
Pick-to: 6.6 6.5 6.2
Change-Id: I30394da43a5e93b7bd41ef9ce9c7aea044523c30
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-06-20 15:25:13 +02:00
Marc Mutz
c2bcba93a6 QPixmapCache: simplify remove(QString)
The previous code used `cacheKey` as the name of an iterator, which
made the code hard to understand.

Instead of renaming that to the more idiomatic `it`, use QHash::take()
to get an actual `cacheKey` back, and then delegate to
QPMCache::remove(QPixmapCache::Key) for the actual removal.

Pick-to: 6.6 6.5 6.2
Task-number: QTBUG-112200
Change-Id: I9311c19f12a05cad694702672f17ae19ba339b04
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-06-20 13:25:09 +00:00
Marc Mutz
8cad4c2903 QDebugStateSaver: mark ctors [[nodiscard]]
It's a RAII class, and RAII classes should have only [[nodiscard]]
constructors.

Pick-to: 6.6
Task-number: QTBUG-104164
Change-Id: Ia83fa003677a839734208b12bde2c6287c1b79a3
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-06-20 13:25:05 +00:00
Marc Mutz
ffed431293 QMac{,RootLevel}AutoReleasePool: mark ctors [[nodiscard]]
They're RAII classes, and QUIP-0019 says RAII class' constructors
should be marked [[nodiscard]].

Pick-to: 6.6
Task-number: QTBUG-104164
Change-Id: I0080f5b6a3cea346c0860e00958a8c204849040e
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2023-06-20 15:25:00 +02:00
Marc Mutz
2a76cf8181 QMacAutoReleasePool: unexport
We should not export non-polymorphic classes wholesale. Only export
the non-inline functions instead.

There are no implicitly-declared special member functions in this
class that could cause problems, so we don't need to delay until Qt 7.

Pick-to: 6.6
Task-number: QTBUG-104164
Change-Id: I2e98782160cccb9c0f59a68e67ffd29fec42b728
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2023-06-20 15:24:57 +02:00
Marc Mutz
c41e03008a tst_qmenu: fix -Wsuggest-override
... and fix placement of {.

Amends f0049873d2.

Pick-to: 6.6 6.5 6.2
Change-Id: I2479087005d350a23e45eda126a89e0be91c0701
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2023-06-20 15:24:50 +02:00
Volker Hilsheimer
8afe4faf29 QLineEdit: ignore key release events
Amends 55fe46fd58. Before that change,
key release events were ignored as the QLineEdit::event reimplementation
continued to call QWidget::event, and as QLineEdit didn't override
keyReleaseEvent, the default implementation in QWidget got called to
ignore the event.

Restore that behavior by explicitly calling the QWidget implementation
after updating QLineEdit-specific states, and add a test case.

Fixes: QTBUG-114654
Pick-to: 6.5 6.6
Change-Id: Ic8aa35a1c915b446aece47aaf03ef5cf1884b936
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2023-06-20 15:24:19 +02:00
Dennis Oberst
0235de994b QFuture: mention the work-stealing algorithm in the docs
A number of users have explored the behavior and complained about it.
Lets add a \note explaining this. The function in charge is
QThreadPool::stealAndRunRunnable(QRunnable *), which is a private
function, exclusively used by:

  QFutureInterfaceBase::waitForResult()
  QFutureInterfaceBase::waitForFinished()

also update the documentation to reflect these changes accordingly.

Fixes: QTBUG-112351
Pick-to: 6.6 6.5 6.2 5.15
Change-Id: I839858cb449063d8af9bef64d2f35a6816a419b0
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-06-20 12:24:00 +02:00
Arno Rehn
855c448469 QPromise: Propagate cancellation through failure handlers
Previously, failure handlers did not propagate cancellation. This would
lead to crashes when a QPromise was cancelled without having generated
any result. Subsequent continuations would be invoked and try to access
the result (which was nonexistent) and then crash.
This patch propagates cancellation through failure handlers to prevent
subsequent continuations from being called in the first place.

Fixes: QTBUG-114606
Pick-to: 6.6
Pick-to: 6.5
Change-Id: I23b28a8e70a76e1ba6416be4440360c6dbaef2a3
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2023-06-20 09:35:15 +02:00
Mikolaj Boc
1f6cac0da9 Make WASM export names different across modules
The export name is now ${TARGET_NAME}Entry. This can also be overridden
by using QT_WASM_EXPORT_NAME, both in CMake and qmake

Change-Id: I59c97ae6e22f0b2720716e9d7eff7b6b13d37ab5
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2023-06-20 09:08:03 +02:00
Ahmad Samir
db9e206dee Moc: fix narrowing conversion warnings with range-for loops
Pick-to: 6.6 6.5
Change-Id: I6dee1a6ae82c33bd6523734ee32ab4c83835f9d8
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-06-20 06:53:52 +00:00
Ahmad Samir
c88961bcf4 Moc: fix narrowing conversion warnings by using iterator-based for-loop
The alternative would be to explicitly cast each list.size() to int. I
think using iterators is a cleaner solution.

Drive-by changes:
- Give a std::pair's members better names than first/second, by using a
  structured binding
- Port to qsizetype

Pick-to: 6.6 6.5
Change-Id: Icff3126192f9813fba698d5722b209307011ca48
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-06-20 06:53:52 +00:00
Mårten Nordheim
1fcbe0f6c2 FontEngine[directwrite]: include leftBearing for boundingBox for glyphs
It was always 0

Task-number: QTBUG-113679
Pick-to: 6.6
Change-Id: I090036296ad2df99b986400863b1e57a5d6101fb
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2023-06-20 06:38:38 +00:00
Mårten Nordheim
8469b36928 FontEngine: Skip 0-width glyphs when finding first left bearing
Since they don't contribute to the width of a string then we may
accidentally end up ignoring the potential left-bearing that the first
non-zero-width glyph has.

Task-number: QTBUG-113679
Pick-to: 6.6
Change-Id: I8e89a428acf5d0a3da0255c50778ccc773ff20e1
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2023-06-20 06:38:38 +00:00
Ahmad Samir
2271ee6b4b Moc: port to qsizetype
Pick-to: 6.6 6.5
Change-Id: Ibacc9b4bd6c26b890a09f689c730286c2aa0894c
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-06-20 06:35:03 +00:00
Mikolaj Boc
7022d0e223 Replace QDialog::exec() with open() in text edit example
On WASM, the shortcut triggering the dialog in textedit example
seemingly lets the event invoke the default action. What really happens
is that the dialog's exec() does not return and WASM does not have a
chance to set preventDefault() on the keyboard event it receives. This
masks other problems with keyboards shortcuts.

Uses of exec() on message boxes were replaced, too. Closing operation
is now performed in two steps, first the event is ignored and maybeSave
is called to query for potential changes of the text document.
If there are no changes or the file is discarded, the close continues
with a second event, now accepted.

PrintDialog::exec(), QPrintPreviewDialog::exec(), QFileDialog::exec()
were also eliminated in favor of open().

Finally, indirect calls to exec() via QColorDialog::getColor were
removed.

Task-number: QTBUG-76587
Change-Id: Ia90fad46ec3f94244723512be3ec93b64df9d9ef
Reviewed-by: Mikołaj Boc <Mikolaj.Boc@qt.io>
2023-06-20 07:28:42 +01:00
Shawn Rutledge
a6059cebe8 Show decimal device IDs in QInputDevice qDebug output
The lack of 0x adornment made hex confusing. `xinput list` shows device
IDs as decimal, and device IDs appear in decimal in some categorized
qt.qpa.input.devices log messages, so let's be consistent here too.
Also fixed one more that was inconsistent in that category:
"scroll event from unregistered device <x>"

Change-Id: I98a39b30b1bc030611d3cfe9dd5e95886faf48ff
Pick-to: 6.5 6.6
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2023-06-20 07:56:31 +02:00
Shawn Rutledge
1a49eae776 xcb: Use QWSI::handleTabletEnterLeaveProximityEvent(.. QPointingDev* ..)
We want to pass the QPointingDevice* because we've already identified
it by its "system ID" (xinput device number). The other versions of
handleTabletEnterProximityEvent and handleTabletLeaveProximityEvent
try to identify the stylus by only its deviceType, pointerType and
unique ID, which can go wrong if there are multiple tablet devices and
the unique ID is not provided (as with N-trig and Wacom tablets being
used at the same time). Anyway this fixes a TODO comment from
6589f2ed0c

Leave a "deprecated" comment by the QWSI functions that should not
be used.

Pick-to: 6.6 6.5
Task-number: QTBUG-104878
Change-Id: Id9f19c60b54b7900b02d5f87b5d12f9a9189721d
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-06-20 07:56:31 +02:00
Axel Spoerl
b26cdbd877 QDockWidget: Don't insert gap item if QDockWidgetGroupWindow has one
When a dock widget is hovered over a QDockWidgetGroupWindow, a gap item
is inserted at its potential docking position. Since only one item at a
time can be moved with the mouse, only one such gap item can exist.
QDockAreaLayoutInfo::insertGap() therefore contains an assertion, that
kicks in if a second gap item is inserted.

QDockWidgetGroupWindow::hover() checks if the dock widget is hovered
over a gap item. If that is the case, no additional gap item is
inserted. The check fails if a gap item exists in the group window, but
the dock widget is hovered over another part of that group window.
This can be the case if the group window already contains more than
one dock widget: By inserting the gap, the group window's size changes,
one of the existing dock widgets receives another hover event and a
second gap insertion is attempted.

This patch adds QDockAreaLayoutInfo::hasGapItem() to check if a gap
already exists. The method is queried in addition to prevent a second
gap insertion.

An autotest has not been added, because gap items appear and disappear
during hovering. The improved functionality can be tested manually with
the mainwindow example.

Fixes: QTBUG-112491
Fixes: QTBUG-114542
Pick-to: 6.6 6.5
Change-Id: I9ea64e729873a86eb98ea950fbb066817fc25a07
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-06-20 05:55:53 +00:00
Axel Spoerl
faec937756 Implement debug operator for QDockAreaLayoutItem
QDockAreaLayout items can be widgets, gap or placeholder items.
They appear and disappear during hovering.

This adds a debug operator to make troubleshooting easier.

Task-number: QTBUG-114542
Task-number: QTBUG-112491
Pick-to: 6.6 6.5
Change-Id: I0fa5d3c96ab91838f28ad7cec3c049fd39f47576
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-06-20 07:55:53 +02:00
Fabian Kosmale
96e1381a0a QBindable: Fix out-of-bound access in non-bindable property support code
QObjectPrivate::getPropertyAdaptorSlotObject called
connectionsForSignal.
Calling this function is only safe after it has been ensured beforehand that the vector has size > signalIndex. As getPropertyAdaptorSlotObject
is not supposed to modify the vector, it does not resize the vector and it could consequently end up with an out-of-bounds read.

To avoid that issue, we instead first check if the vector can
potentially contain an entry for the signal. If not, we simply return
nullptr, and avoid the call to connectionsForSignal.

The issue and its fix can be verified by running the modified
tst_qproperty test with ASAN enabled. The test is modified in the
following way:
- We first create a signal connection to a dummy slot. Otherwise,
  connections.loadRelaxed() would return a nullptr, and the problematic
  code would never be reached.
- We add enough signals to ensure that the fooChanged signal will
  actually be out of reach (which means >= 8 signals, as the initial
  capacity of the vector is 8)
Running the test without ASAN will most likely not result in a failure,
as then the out-of-bounds read will simply read garbage, and the most
likely result is that the cast below will fail.

Pick-to: 6.6 6.5
Change-Id: I18a3c4f52769c2b6491a685abb84f6fcfb44e4d8
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2023-06-20 05:55:52 +00:00
Volker Hilsheimer
2c458a8221 macOS: work around getting invalid result from NSAlert::runModal
It is possible for an application to trigger the unexpected result of
NSModalResponseContinue from our call to NSAlert::runModal, by showing
and hiding a modal dialog first, and processing events explicitly. This
at best only flashes the native message box, at worst it triggers an
assert from our processResponse function evaluating that response value
as impossible (via Q_UNREACHABLE).

We should never call processResponse with NSModalResponseContinue,
but instead keep the modal loop running and the dialog visible.
So introduce a wrapper to NSAlert::runModal that keeps calling that
method until we get a result other than NSModalResponseContinue.

Writing an auto test for this failed; a simple test didn't reproduce the
assert; trying to place the opening of the native message box into a
lambda that would be called by the event loop (simulating the button
press from the bug report's reproducer) resulted in the native message
box never closing and the test blocking (and still not triggering the
assert).

Fixes: QTBUG-114546
Pick-to: 6.5 6.6
Change-Id: Iab25eff55c48b103287d1881ac355e6cdd190f7a
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2023-06-20 07:46:14 +02:00
Morten Sørvig
bc340abe87 wasm: Document (and rename) config.qt.module
This property can take a either a WebAssembly.Module
or a promise to a module, and we don't have to specify
the exact type in the property name.

Pick-to: 6.6
Change-Id: Iebaf52178253afe8c93cf78bbe0853461bf48b67
Reviewed-by: Mikołaj Boc <Mikolaj.Boc@qt.io>
2023-06-20 07:38:41 +02:00
Morten Sørvig
c2988de88d wasm: add "FS" to EXPORTED_METHODS
This is required when using the preload functionality
from qtloader.

Pick-to: 6.6
Change-Id: Ib1bf8788b87834ba0ff80d563897040e093a16b9
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2023-06-20 07:38:40 +02:00
Amir Masoud Abdol
45e17162ba Set QT_COMMAND_LINE_PARSER_NO_GUI_MESSAGE_BOXES before TRY_RUN
Set `QT_COMMAND_LINE_PARSER_NO_GUI_MESSAGE_BOXES` before trying to run
qt tools for correctness. This is to suppress QCommandLinerParser from
showing a message box when console is not available.

Pick-to: 6.5.2 6.5 6.6
Task-number: QTBUG-114530
Change-Id: Ib3d264a799a5da1f620d2bebe55539bafc43da0f
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2023-06-20 07:34:09 +02:00
Amir Masoud Abdol
cdcead0ab2 Introduce QT_COMMAND_LINE_PARSER_NO_GUI_MESSAGE_BOXES environment var
Add an environment variable to be able to stop QCommandLinerParser
from showing GUI message boxes when console is not available.

Pick-to: 6.5.2 6.5 6.6
Task-number: QTBUG-114530
Change-Id: I52500a2177894bc0bf2d20f9723ce3e8fe87420f
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2023-06-20 07:34:09 +02:00
Mikolaj Boc
b2093aad39 Add keyboard input testcase to the QWasmWindow test
The test checks whether correct windows get correct keyboard input,
having been activated with mouse clicks.

Also fixes the event propagation error found. Key events would propagate
to parent windows, which is something that should not happen with
window managers.

Change-Id: I18bae8c14cce5ccae151c2a00c84ffdba3b4587f
Reviewed-by: Mikołaj Boc <Mikolaj.Boc@qt.io>
Reviewed-by: Piotr Wierciński <piotr.wiercinski@qt.io>
2023-06-20 07:34:09 +02:00
Marc Mutz
603d6351cc Mark all ctors of [[nodiscard]] classes as Q_NODISCARD_CTOR
This works around around the difference in class-level [[nodiscard]]
behavior between Clang and GCC. While Clang already warns about

    QClass(~~~args~~~);

when QClass is marked as [[nodiscard]] at the class level, GCC does
not, and requires the ctor to be marked as [[nodiscard]] instead.

Pick-to: 6.6
Fixes: QTBUG-104164
Change-Id: Ifd7076ee422fb9472ae8bbba43d9bfeee1968a78
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-06-20 07:34:09 +02:00
Marc Mutz
21c344a221 QScoped(Array)Pointer: remove the class-level [[nodiscard]]
It was used as a work-around for constructor-level [[nodiscard]]
missing in C++17, but a) compilers are free to implement [[nodiscard]]
for constructors in C++17 (P1771 was not considered a normative
change, just a clarification of the existing wording), and b) prevents
useful code that returns such types from functions.

Pick-to: 6.6
Task-number: QTBUG-104164
Change-Id: I440b418d58e86118e84689adb06d239ca598afcc
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-06-20 07:34:09 +02:00
Marc Mutz
c823bc2fdb Q(Explicitly)SharedDataPointer: mark ctors [[nodiscard]]
They're RAII classes, and RAII class' constructors should be marked
[[nodiscard]].

Pick-to: 6.6
Task-number: QTBUG-104164
Change-Id: If4265a431839a5d3c16dcc855b1ded2d2fc7408c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-06-20 07:34:09 +02:00
Marc Mutz
6dba28419b Q(Read|Write)Locker: mark ctors [[nodiscard]]
They're RAII classes, and RAII class' constructors should be marked
[[nodiscard]].

Pick-to: 6.6
Task-number: QTBUG-104164
Change-Id: I9b91c18e67e99bf84abdd12236a18a8c4ec39620
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-06-20 07:34:09 +02:00
Amir Masoud Abdol
1bf144ba78 Resolve an issue with detecting GSSAPI on macOS
Spack, like VcPkg, sets the `CMAKE_FIND_FRAMEWORK` to `LAST`, as a
result, similar to VcPkg, when Spack is used, FindGSSAPI opts for
`gssapi_krb5` which is not what we want. By dropping the `gssapi_krb5`
from the list of alternative names we can resolve this without much
tinkering with internals of these package managers.

Pick-to: 6.5 6.6
Fixes: QTBUG-114537
Change-Id: If517c409511f58e3bed78316a2030393dc249a40
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2023-06-20 07:34:09 +02:00
Mikolaj Boc
451c0a6b1c Make qtbase compile for WASM with Werror
There are unused variable warnings which cause the compilation to
fail when Werror is used in qpermissions_wasm.cpp

Change-Id: I2cf2035f52f0a5d570a56dcd4c82bf2ecf3006c7
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2023-06-20 06:07:30 +02:00
Shawn Rutledge
a8a75d2c4b xcb: Don't clear touch or tablet devices due to device hierarchy event
When QXcbConnection::xi2SetupDevices() reacts to a device hierarchy
event and re-discovers an already-known slave device, it doesn't call
xi2SetupSlavePointerDevice() again. I.e. it won't attempt to add it to
m_touchDevices or m_tabletData because it was already known. So it
should not clear m_touchDevices or m_tabletData either, but only remove
the touch devices that are known to have disappeared. Tablet styli
normally come and go from proximity, so it's ok to avoid deleting the
corresponding device data.

Also fix some other failure cases after testing hotplugging more with
tests/manual/inputdevices: there should be no crashes, no duplicated
devices after plugging (although the QAIM might have a bug that makes
it look that way), no leftover instances after unplugging.

Amends 2a9d93efc6

Pick-to: 6.6 6.5 6.5.2
Fixes: QTBUG-114334
Change-Id: I30f5e532f7dd3a465d56ecdd34d893cbadbf0453
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-06-20 06:07:30 +02:00
Volker Hilsheimer
89566bf749 QKeySequenceEdit: don't finish when opening a context menu
Right-clicking in a QKeySequenceEdit opens the usual context menu for a
line edit, which generates a focusOut event. QKeySequenceEdit finishes
the recording when it loses focus, which includes deselecting the text.

We should not finish or deselect if the focusOut event has focusReason
FocusReasonPopup, as otherwise users cannot copy the text (keyboard
shortcuts don't work for that, obviously).

Pick-to: 6.6
Task-number: QTBUG-114624
Change-Id: I0b3c535c189151daa29cf17640493f3353e6394b
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2023-06-20 02:03:21 +02:00
Liang Qi
b992aabd89 Android: use logging category for im debug
Pick-to: 6.6 6.5
Change-Id: I78e84313841f83416dee6b6b2970b402acce5060
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2023-06-19 10:37:32 +02:00
Thiago Macieira
d2368cde70 Long live futexes for Darwin!
Like commit 91f6460aff which added support
for Windows, this commit does the same for our final major OS.

The Darwin kernel exposes a set of __ulock_{wait,wait2,wake} APIs [1],
but these APIs are marked as private, so we cannot rely on them being
stable, nor we can use these APIs in builds of Qt intended for
the Apple App Store. By wholesale disabling the use of the APIs
in App Store compliant builds, and runtime checking availability
of the APIs when we do build them in, we should be safe, unless
the semantics of the APIs change in ways we haven't accounted for,
but that's a risk we're willing to take.

Note that libc++ uses these private APIs to implement P1135R5
(the C++20 synchronization library) [2], but that use is under
a "special permission" from the Darwin team, and meant only for
use in the Apple vendored version of libc++ shipped with their
operating systems, where they control both the kernel and the
standard library.

[1] https://github.com/apple-oss-distributions/xnu/blob/xnu-8792.81.2/bsd/sys/ulock.h
[2] https://reviews.llvm.org/D68480.

Change-Id: Ib709fc1585f647a98d54fffd16663b4965458404
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2023-06-18 15:45:37 -07:00
Thiago Macieira
674aa084c2 Q*ValueRef: suppress MSVC warning on deriving from non-exported base
Warning C4275 non dll-interface class 'QJsonValueConstRef' used as base for dll-interface class 'QJsonValueRef' UniRemoteAdapter C:\qt\Qt6.5.1\6.5.1\msvc2019_64\include\QtCore\qjsonvalue.h 219

Pick-to: 6.5 6.6
Fixes: QTBUG-114629
Change-Id: I443cf0c8a76243eead33fffd176930f96c43eb47
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-06-18 20:06:57 +00:00
Ahmad Samir
7779400ba6 Moc: fix generated code for nested enum class corner case
Fixes an issue with generated code where the name of an enclosing
namespace is identical to an enum class type, when Q_ENUM_NS is used.

Consider:
namespace a {
    Q_NAMESPACE
    namespace b {
        enum class b { Key, Key2 };
        Q_ENUM_NS(b);
    }
}

moc generated code such as:
Q_CONSTINIT const QMetaObject a:🅱️:staticMetaObject = { {
    ...
    qt_incomplete_metaTypeArray<qt_meta_stringdata_CLASSaSCOPEbENDCLASS_t,
        // enum 'TestEnum'
        QtPrivate::TypeAndForceComplete<b::b, std::true_type>,
        // Q_OBJECT / Q_GADGET
        QtPrivate::TypeAndForceComplete<void, std::true_type>
    >,
    nullptr
} };

which confused the compiler:
error: ‘b’ is not a member of ‘a:🅱️:b
   83 |         QtPrivate::TypeAndForceComplete<b::b, std::true_type>,

Fixes: QTBUG-112996
Pick-to: 6.6
Change-Id: I37aee83c32efe96cc9d6c2bd0bdb9ba80bb7b8a7
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-06-18 21:28:58 +03:00
Tor Arne Vestbø
e603661c48 QIcon::fromTheme(): Always consult "hicolor" theme last
The Freedesktop Icon Theme Specification [1] describes that,
if a theme does not specify anything for its 'Inherits' key,
"implementations are required to add the 'hicolor' theme to
the inheritance tree. An implementation may optionally add
other default themes in between the last specified theme and
the hicolor theme."

And later, when describing the lookup algorithm, that "The
lookup is done first in the current theme, and then recursively
in each of the current theme's parents, and finally in the
default theme called 'hicolor' (implementations may add more
default themes before 'hicolor', but 'hicolor' must be last)".

But it doesn't explicitly describe the behavior when a theme
does specify a list of inherited themes via the 'Inherits' key,
and this list explicitly includes 'hicolor'.

In that case, our custom fallback theme, which we inject after
the theme's explicit parents, will be prioritized after 'hicolor'.

As it's likely that the theme author added 'hicolor' to their
parent list to ensure that 'hicolor' is at some point consulted,
but didn't intent it to be priorized, and that the spec puts focus
on 'hicolor' being last, it seems reasonable that we can move the
'hicolor' theme to the end of the fallback list, and as a result
always prioritize fallbackThemeName() over 'hicolor'.

[ChangeLog][QtGui][QIcon] The 'hicolor' theme will now always be
prioritized last when looking up fallback themes, even if
explicitly declared as a theme parent in a theme.

[1] https://specifications.freedesktop.org/icon-theme-spec/icon-theme-spec-latest.html

Pick-to: 6.6
Change-Id: I76538e4e7e9e395f9e5a38e704c60fb6b9688885
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2023-06-18 20:28:58 +02:00
Tor Arne Vestbø
addde7843f Consult QIcon::fallbackThemeName() even when theme name is empty
We still need to consult fallbackThemeName() when computing the
parent list for an individual theme, as the Freedesktop Theme Icon
spec mandates that the "hicolor" theme comes last, but we no longer
need to do explicit fallback to fallbackThemeName() if a theme is
not found.

Pick-to: 6.5 6.6
Change-Id: I6c0b5a45d8258c5b6eaa761402944a735b1606ba
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2023-06-18 20:28:58 +02:00
Tor Arne Vestbø
dde45bcefb Consult QIcon::fallbackSearchPaths() even when theme name is empty
The use of fallback icons should not depend on a theme being set.

[ChangeLog][QtGui][QIcon] QIcon::fallbackSearchPaths() will now be consulted
for fallback icons even if the current theme name is empty.

Pick-to: 6.5 6.6
Change-Id: Ia8d14062de7c53601fd9dac30f87a9e672aa2207
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2023-06-18 20:28:57 +02:00
Ahmad Samir
bb16c215e3 QProcess: add testUnixProcessParameters as a dep. for tst_qprocess
So that building only tst_qprocess also builds the required test app.

Change-Id: I19a92f9dd2f4de08302d09cad0caf55c285a6dae
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-06-18 20:32:30 +03:00
Ahmad Samir
5eec5a674b QStringBuilder: fix typos in API docs
My fault, I had added that bit of the docs a while ago.

Pick-to: 6.6
Change-Id: I1fa2c10b0f7263e12b5b2a4d18f362c702f9d831
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-06-18 14:39:57 +00:00
Tor Arne Vestbø
f4dca7c512 Consult QIcon::fallbackThemeName() even for themes with explicit parents
We would previously only use the fallback theme for themes that did
not exist, or for themes that did not declare any parent theme.

We now unconditionally use the fallback theme, even for themes that
declare their own parent themes, so that a QIcon::fromTheme("foo")
that doesn't exist in the current theme, nor any of its parents,
nor in "hicolor", will still be looked up in the fallback theme.

The reason this seemed to work in the existing tests was because
our test themes inherit system themes such as crystalsvg and gnome,
and we didn't provide a hicolor theme. Any of these themes missing
would lead us into the code path where we use the fallback theme
for a missing theme, masking that fact that we had not added the
fallback theme to the list of fallbacks for the theme that had
explicit parents declared.

The logic has been moved out of the theme parsing and into an
accessor in QIconTheme, so that we're not caching the fallback
theme lookup.

[ChangeLog][QtGui][QIcon] QIcon::fallbackThemeName() will now be
used as fallback even for themes that declare a parent theme.

Pick-to: 6.5 6.6
Change-Id: Ib0ce1dfe97030f23893460ed624073a719a3ebd1
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2023-06-18 10:49:14 +02:00
Tor Arne Vestbø
ae36c1dc9c Invalidate QIconLoader cache when setting fallback theme
Setting a fallback theme will affect the lookup strategy, so we need
to invalidate earlier lookups.

Pick-to: 6.5 6.6
Change-Id: I962245ddb3a20b7798d5ce831ed8a369b0ab76b4
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2023-06-18 00:05:18 +02:00
Amir Masoud Abdol
059f4dc6f8 Disable TEST_separate_debug_info when building with MSVC or on Apple
As mentioned, separate debug info will always be generated when building
with `-release -force-debug-info`.

Pick-to: 6.5 6.6
Fixes: QTBUG-108015
Change-Id: I49e79177ca833007b932b58a76261c07acd52ca6
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2023-06-17 23:21:18 +02:00
Tor Arne Vestbø
4dacaaf15a Skip clearing the QIcon cache on QIconLoader theme key change
QThemeIconEngine takes care of creating a new icon engine when
the icon theme key changes, so we don't need to invalidate the
entire QIcon cache.

Pick-to: 6.6
Change-Id: Ie3bca00a9146d1f429b2a6f8ab0b39e15834d158
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2023-06-17 22:13:36 +02:00
Amir Masoud Abdol
331f316b91 Disable TRY_RUN when cross compiling
Fixes: QTBUG-114625
Pick-to: 6.5.2 6.5 6.6
Change-Id: Idec5ea438ebf3f88d63da7d956ab52e2a0fa1821
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Samuli Piippo <samuli.piippo@qt.io>
2023-06-17 20:26:12 +02:00
Tor Arne Vestbø
a452e22546 Unify QIcon theme icon loading and cache invalidation
The logic for invalidating a theme QIcon when the platform theme
changed, or when the user set an explicit icon theme, was tied
to QIconLoaderEngine, so any platform theme implementing
QPlatformTheme::createIconEngine() with a custom icon engine
would not take part in this cache invalidation.

As we want users of QIcon::fromTheme to be agnostic to where the
icon is actually coming from, and have a consistent behavior for
the various QIcon APIs for setting explicit themes, the logic
for invalidating the themed icon has now been moved up one
layer, to a new QThemeIconEngine, that is responsible for
lazily creating the actual engine based on the name. The
engine proxies the actual icon loading through to the
real engine via a new QProxyIconEngine helper class.

Pick-to: 6.6
Change-Id: I474589981f751d7467e3073533cba542182f2d36
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2023-06-17 17:52:01 +02:00