Commit Graph

61352 Commits

Author SHA1 Message Date
Edward Welbourne
6aea6c25a5 QLocalTime: get offset from correct local time minus UTC time
In mapLocalTime(), we've constructed tmLocal from localSeconds, so
that's the local time mktime()'s returned utcSecs corresponds to.  So
use that, rather than freshly dividing the original local milliseconds
by 1000 (now rounding down, instead of towards zero), which could lead
to an off-by-one error. The intermediate offset miscomputed this way
was only used in overflow cases, before being replaced by a more
reliable result, but this saves some computation as well as getting
those right.

Change-Id: Ie34cf53cd2191e277835388fcd62dcf68eaf39c3
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-05-02 17:03:27 +02:00
Edward Welbourne
55fe3ee5e7 Replace runic XSLT with a python script and tidy cbordump code
Filters records on having value < 256, or an RFC, previously hacked
into the XSLT to produce the last update, with a bit of hand-editing.
Using a python script makes it easier to control the formatting and
other details; for example, severl entries previously had descriptions
that mentioned their RFC, with specific section, to which the XSLT was
adding a redundant mention of the RFC. It is also possible to exploit
C++ string juxtaposition to get tidily-presented string literals,
without having to resort to raw strings.

Task-number: QTBUG-111228
Change-Id: Ibd1c93dc1c88689e78b2b13a6bcb59a003f4df0f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-05-02 17:03:26 +02:00
Yuhang Zhao
4fcb348154 fix wrong and strange indentation
Change-Id: I803d85eb83ec8e6ea532095c34fa8b0ae104705d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-05-02 14:40:26 +00:00
Kai Köhne
9f9ff18ba9 Examples: Use versioned CMake targets for Qt modules
Use e.g. Qt6::Core instead of Qt::Core. This is better matching the
find_package(Qt6 ...) call, and also avoids issues that the versionless
targets have.

Pick-to: 6.5
Task-number: QTBUG-113277
Change-Id: Ib4373036092163518a611bd5c688591d18096d7e
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2023-05-02 16:20:08 +02:00
Kai Köhne
df862a940e Add reference location for positioning examples
Pick-to: 6.5
Change-Id: I4f58544cac439f2ad768032e3d54d5ab51fe0755
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2023-05-02 14:20:08 +00:00
Ievgenii Meshcheriakov
3ef514f8d3 QtDBus: Use QMetaObject::invokeMethod instead of QTimer::singleShot
Change-Id: I1a9ecdcb8df7804d13fdcf676fc12b1e0f6bddae
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-05-02 12:54:20 +00:00
Ievgenii Meshcheriakov
90d3c5b951 QDBusServer: Fix potential crash when private pointer is null
Check that the private pointer is not null before attempting
to dereference it. This can happen, for example, when
a QDBusServer instance was constructed with an empty string
as address. Attempting to destroy an object constructed
this way was causing a segmentation fault on Linux.

Add a test case that attempts to construct a QDBusServer
object with an empty string as address to check that this
does not cause a segmentation fault anymore.

Pick-to: 6.5 6.2
Change-Id: I5fe63134026e2a9f509b61d452285891b1ec624d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-05-02 14:54:19 +02:00
Topi Reinio
38bb088a26 Doc: Add 'Mobile' category to Qt Android Notifier example
The example demonstrates accessing native Android APIs in Qt applications,
tag it with 'Mobile' category.

Pick-to: 6.5
Task-number: QTBUG-112378
Change-Id: I5f936409aafb22175eab59fdb210ecd03fecb1f3
Reviewed-by: Kai Köhne <kai.koehne@qt.io>
2023-05-02 12:54:19 +00:00
Morten Sørvig
827e010233 QGuiApplication: Propagate wheel event accepted state
Propagate the accepted state from the QtGui event to
the QWindowsSystemInterface event. This makes it possible
for the platform plugins to propagate rejected wheel events
to the native OS.

Pick-to: 6.5
Task-number: QTBUG-107441
Change-Id: Ifa90ed2430e56120a1a04b6a5872a153d26aa6bc
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2023-05-02 12:54:19 +00:00
Morten Sørvig
3c23d701a7 wasm: build with -no-feature-accessibility
Add #ifdefs around the accessibility implementation.

Fixes: QTBUG-111509
Pick-to: 6.5
Change-Id: I9a600781b4bf9545f046efa75f962cc40fe196a6
Reviewed-by: Mikołaj Boc <Mikolaj.Boc@qt.io>
2023-05-02 14:54:19 +02:00
Marc Mutz
b6d04c8a82 QMetaProperty: add writeOnGadget() overload taking rvalue QVariant
The writeOnGadget() function is implemented in terms of write() (UB,
btw, due to the cast to QObject*), which was recently overloaded for
rvalue QVariants.

Add a corresponding writeOnGadget() overload, too.

[ChangeLog][QtCore][QMetaProperty] Added writeOnGadget() overload
taking an rvalue QVariant.

Amends 968250ee14.

Task-number: QTBUG-112762
Change-Id: I7fc686fcab293159f5a0d76dd6c8e23d5779c96c
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-05-02 14:51:01 +02:00
Marc Mutz
426b5fbce4 D-Bus: use move() on QVariants in writeProperty()
The writeProperty() function takes the QVariant value by value, so we
can move from it, using the newly-added QMetaProperty::write() rvalue
overload.

As a drive-by, replace a copy-assignment with a move.

Task-number: QTBUG-112762
Change-Id: I6d5361830b4874fa846be513882ede4ab881246b
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-05-02 14:51:01 +02:00
Bartlomiej Moskal
1bf8c1e23d Examples doc: Remove not needed android tag
There are two examples for Camera in Multimedia module. One of them is
using widgets, while the second one is QML based.
In such case the QML example is preferred for Android platform. That is
why only QML example should have android tag.

This commit remove android tag from qtMultimedia Widget Camera example.

Fixes: QTBUG-113238
Change-Id: I9d2c072fcc18e8e5a5a44a9a2da887a7b6660b46
Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
2023-05-02 11:01:03 +00:00
Christophe Marin
b53bf18280 CMake: Fix a typo in QtModuleHelpers.cmake
Rename is_staitc_lib_during_static_qt_build to
is_static_lib_during_static_qt_build.

Pick-to: 6.5 6.2
Change-Id: Iec0f4d5d025e07a857a086e960eaf7b6fa2638a5
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2023-05-02 12:26:26 +02:00
Thorbjørn Lund Martsum
29b2506e8c Allow disable native messagebox dialog
The native style may not match the program style and it
makes sense to give an option rather than forcing native style.

Before it could only be done with setting AA_DontUseNativeDialogs
on the app, but it is reasonable to use native file dialogs and
Qt styled messageboxes - and it is extremely cumbersome - especially
since messageboxes often can start save dialogs.

It can look a bit strange that these introduced options has just one
option (DontUseNativeDialog) and four functions, but this way it works
similar to QColorDialog, QFileDialog and QFontDialog.

[ChangeLog][QWidgets][QMessageBox] Added options functionality to
QMessagebox. The currently only option available is DontUseNativeDialog.

Change-Id: I70282fcfaa66f245f7e679b8897c607bcaff333f
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-05-02 10:37:17 +02:00
Volker Hilsheimer
642f799fc6 Merge QSlotObject and QFunctorSlotObject, and use helpers to deduplicate
Now we can use QFunctorSlotObject for any kind of callable - free
function, functor, or PMF. This allows us to fold the various overloads
of QObject::connect together, removing duplicate code and error handling
logic.

Change-Id: I8842f5ddd29e86be07a422647a8fc1678fd534b1
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-05-02 06:28:56 +02:00
Volker Hilsheimer
76e25bdfdf Remove QStaticSlotObject, use QFunctorSlotObject instead
The two slot object types are identical as long as we use a universal
reference and perfect forwarding in the respective connect overloads.

Change-Id: I999d71707dd045a17156e3bfecd371da7979beb1
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-05-02 06:28:51 +02:00
Volker Hilsheimer
ee308018f3 Use QSlotObject helper to drastically simplify QTimer
Change-Id: Iaeef5dcb5282eef834df62c7db09d05851bd7c2b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-05-02 06:28:46 +02:00
Volker Hilsheimer
2cd2789a40 Respect expected return type in QSlotObject helper
When making asynchronous functions, then the return type is not ever
going to be anything but void, but this makes this helper symmetrical
with QObject::connect logic, where we can then use it to simplify
the code.

Change-Id: I9e1b8bfffb726bb3d6d7282c87e07dc7e9ede5d1
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-05-02 06:28:36 +02:00
Volker Hilsheimer
60655cbbbb Make QSlotObject helpers usable for SFINAE
Disable if any of the types used in the old-style connections is
involved.

Change-Id: Ie22c73704370c7f239d7303b555a0b572d2b4f22
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-05-02 06:28:31 +02:00
Volker Hilsheimer
4c5290e744 Modernize meta programming helpers
Use std::declval and remove_reference_t instead of home-baked
alternatives.

Change-Id: Ia1b3ac6c2d9a6cdba1650c3acb249f2d65bcf94d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-05-02 06:28:24 +02:00
Volker Hilsheimer
ee1bbedcd9 Give QtPrivate::List a size value, simplify QFunctorSlotObject
The meta-programming list can easily know its size, so no need to pass
both a list and its size as template parameters to QFunctorSlotObject,
which simplifies existing code and is a step towards merging
QFunctorSlotObject and QSlotObject.

Also, remove the unused List_Select helper.

Change-Id: I8ec6a0b707eab531ec06aba4e82223f242e53f2f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-05-02 06:28:18 +02:00
Thiago Macieira
8598e84c5f QMutex & QReadWriteLock: do a memory read before CAS
The testAndSet operation is expensive if the lock is contended:
attempting to CAS that lock will cause the cacheline containing the lock
to be brought to the current CPU's most local cache in exclusive mode,
which in turn causes the CPU that has the lock to stall when it attempts
to release it. That's not desirable if we were just trying an untimed
tryLock*.

In the case of timed, contended tryLocks or unconditional locks, we
still need to perform an atomic operation to indicate we're about to
wait. For that case, this patch reduces the minimum number of atomic
operations from 2 to 1, which is a gain even in the case where no other
thread has changed the lock status at all. In case they have, either by
more threads attempting to lock or by the one that has the lock
unlocking it, this avoids the cacheline bouncing around between the
multiple CPUs between those two atomic operations. For QMutex, that
second atomic is a fetchAndStore, not testAndSet.

The above explanation is valid for architectures with Compare-And-Swap
instructions, such as x86 and ARMv8.1. For architectures using Load
Linked/Store Conditional instructions, the explanation doesn't apply but
the benefits still should because we avoid the expense of the LL.

See similar change to pthread_mutex_lock in
https://sourceware.org/git/?p=glibc.git;a=commit;h=d672a98a1af106bd68deb15576710cd61363f7a6

Change-Id: I3d728c4197df49169066fffd1756dcc26b2cf5f3
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-05-01 17:22:54 -07:00
Volker Hilsheimer
8c085c5722 Fix test for move-only functor objects
Amend 3c6e9dcc623c9d7281a81174bb3a696e030f30a7 by making sure that
we explicitly move move-only functors into the slot object in the
respective tests, and that failing to do so doesn't compile.

Also add test coverage for mutable lambdas, which work as they do
with connected functors: the connection stores a copy, and calls
don't modify the original functor.

Change-Id: I637e6f407133e2f8f72109b3fe5369a11d19da93
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-05-01 22:50:58 +02:00
Volker Hilsheimer
1ed8c80ee3 Revert "Support move-only functors in invokeMethod and async APIs"
This reverts commit 9958edba41, which
incorrectly tested a move-only functor without actually moving the
functor.

Change-Id: I3707f9f8e5055102f7edfb3e1cb9750978356dd7
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-05-01 22:50:58 +02:00
Ahmad Samir
5c3888fe10 QJsonWriter: general cleanup
Use reinterpret_cast instead of C-style cast.

Take by QStringView directly so that we can use QSV::utf16().

Change-Id: I6d30669b0ed4bdf80a63043c364af695fd1d68b5
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-05-01 21:52:22 +02:00
Ahmad Samir
b2a95f9eee qc14n.h: general cleanup
- Add missing includes
- Use std::all_of, that also fixes a narrowing conversion warning
  (qsizetype).

Change-Id: I0f7f4b91bda4c187b8f8094e3039079c43fbf478
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-05-01 22:52:22 +03:00
Thiago Macieira
6000fa2adf moc: Use a much, much shorter structure name for the StringData
The old one kept all the indices in the type name, which was completely
unnecessary. This caused the symbol name to explode for some very large
meta object, notably that of the Qt namespace itself, causing gdb to
produce this warning at every start:

warning: internal error: string "StringData<3, 12, 7, 7, 6, 6, 9, 5, 10,
4, 6, 5, 5, 8, 7, 8, 10, 9, 9, 12, 11, 12, 12, 8, 6, 5, 13, 12, 9,
[many lines suppressed]
33, 6, 6, 5, 6, 17, 12, 17, 13, 8, 7>" failed to be canonicalized

To ensure there's no binary-compatibility problem with a StringData of
two entries, the first parameter is now of type int.

Pick-to: 6.5
Change-Id: I6f518d59e63249ddbf43fffd1759fbb66adc1299
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Lars Knoll <lars@knoll.priv.no>
2023-05-01 16:36:26 +00:00
Yuhang Zhao
53a4f02b01 Fix compilation warnings
When compiling with clang-cl 16.0.2, it gives me some warning like:
warning: use of bitwise '|' with boolean operands [-Wbitwise-instead-of-logical]

Change-Id: I2a1e80fa94b617c0f8fc6561c326c8ae98cada45
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2023-05-01 09:15:23 +08:00
Ivan Solovev
959800f6de Short live Q_NODISCARD_CTOR
[ChangeLog][QtCore] Introduced Q_NODISCARD_CTOR which resolves to
[[nodiscard]] attribute for constructors on compilers that support
it, and does nothing on other compilers.

Using [[nodiscard]] attribute on a constructor is a C++20 feature,
however in practice it is supported on most of the compilers that
we use in Qt 6. Clang generates a [-Wunused-value] warning, GCC
and MinGW generate a [-Wunused-result] warnings, and MSVC
generates a C4834 warning.
However, there are some exceptions.

The Integrity compiler provides the following warning:
 "tst_qglobal.cpp", line 699: warning #3435-D:
           the "nodiscard" attribute doesn't apply to constructors,
           destructors, or routines with void return type
           [[nodiscard]] explicit Test(int val) : m_val(val) {}

The QNX compiler (QCC 8.3.0) and GCC 9.3.1 on OpenSUSE generate
the [-Wattributes] warning:
 tst_qglobal.cpp: In member function
   'void tst_QGlobal::nodiscardConstructor()':
 tst_qglobal.cpp:699:44: warning: 'nodiscard' attribute applied to
   'tst_QGlobal::nodiscardConstructor()::Test::Test(int)' with void
    return type [-Wattributes]
          [[nodiscard]] explicit Test(int val) : m_val(val) {}

These warnings will lead to build failures when compiled with
-warnings-are-errors flag, so for these compilers the macro
does not do anything.

An attempt to use __attribute__((__warn_unused_result__)) was
also unsuccessful on these compilers, so this patch goes for
an easy solution, and simply checks
 __has_cpp_attribute(nodiscard) >= 201907L
to decide if the attribute is supported or not.

This commit also introduces a syntax-only test, and also applies
the new macro to QMutexLocker, because not all platforms in the
CI build and run unit tests.

Fixes: QTBUG-104161
Change-Id: Ib4230661a5ad5e8af0d67b21b034486ebcd67562
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-04-30 19:42:29 +02:00
Yuhang Zhao
d3b3fc538b Remove old clang-cl workaround
According to the upstream bug report [1], this bug has been fixed
already. So remove the now useless workaround.

[1] https://bugs.llvm.org/show_bug.cgi?id=41226

Change-Id: I7e17750f9e47fb9a0f8315ca15f89b741b107a35
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-04-30 10:31:41 +08:00
Marc Mutz
5f28d367d9 Make QPointer<T> constructible from QPointer<X>
QWeakPointer can do the same, so there's no reason to not allow it for
QPointer.

[ChangeLog][QtCore][QPointer] QPointer<T> can now be (move- and
copy-)constructed from QPointer<X>.

Fixes: QTBUG-112464
Change-Id: I77cf5d39974bf2b3ec849b4afc33e286e864821e
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2023-04-29 20:22:39 +00:00
Ahmad Samir
9b47c62682 QStandardPaths/Unix: adjust a comment after recent changes
No duplicate paths in any XDG_* env var.

Also borrow some text from the original commit 9deacd7f20 message.

Change-Id: I89f1fe3093dd7fea2d1bb555e36f299a73685f07
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: David Faure <david.faure@kdab.com>
2023-04-29 18:15:58 +02:00
Ahmad Samir
7564583d36 QString: add a tst_QString variant with QT_NO_CAST_FROM_ASCII
Now the tst_qstring is compiled three times:
- with QT_NO_CAST_FROM_ASCII defined
- with QT_RESTRICTED_CAST_FROM_ASCII defined
- with neither of the above defined

so as to cover more code paths.

Pick-to: 6.5
Task-number: QTBUG-109228
Change-Id: I65eca0f6f6aea66fed6eeda1eb77a50a97210807
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-04-29 18:15:23 +02:00
Topi Reinio
37dc52d4f2 Doc: Fix documentation warnings
These warnings slipped in during a time period where documentation
testing in the CI was disabled.

src/network/kernel/qhostinfo.cpp:254: (qdoc) warning: clang couldn't
    find function when parsing \fn template<typename Functor>
    int QHostInfo::lookupHost(const QString &name, Functor functor)

src/widgets/widgets/qcheckbox.cpp:102: (qdoc) warning: clang couldn't
    find function when parsing
    \fn void QCheckBox::stateChanged(Qt::CheckState state)

src/corelib/kernel/qcoreapplication.cpp:2769: (qdoc) warning: clang
    couldn't find function when parsing
    \fn template<typename Functor> void
        QCoreApplication::requestPermission(
        const QPermission &permission, Functor functor)

src/corelib/serialization/qxmlstream.cpp:3806: (qdoc) warning: clang
    couldn't find function when parsing
    \fn bool QXmlStreamAttributes::hasAttribute(
        const QString &qualifiedName) const

src/corelib/text/qtliterals.qdoc:11: (qdoc) warning: Multiple topic
    commands found in comment: \namespace and \headerfile.

Pick-to: 6.5
Change-Id: I38c605f358dbca1ef3e2bfe20a6424f7a4d44b4a
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-04-29 13:22:21 +00:00
Tor Arne Vestbø
4160817050 macOS: Don't leak QEventDispatcherUNIX during event dispatcher creation
During QCoreApplication initialization, we create the main thread's event
dispatcher, which for a GUI app happens via QGuiApplicationPrivate's
createEventDispatcher() override. This in turn relies on the platform
integration to create the event dispatcher, but to do that it needs to
create the platform integration first. And this might result in calling
APIs that themselves initialize the main thread event dispatcher, such
as QEventLoop, which non-lazily creates an event dispatcher for the thread.

We already had a check to catch the platform integration setting the
QCoreApplictionPrivate::eventDispatcher member, but not anything for
checking the current thread data.

On macOS this resulted in a leak of QEventDispatcherUNIX because
QCocoaDrag contained a QEventLoop member. We now track the event
loop temproarily via a pointer instead, like we do in other places.

An alternative fix would be to defer the initialization of QCocoaDrag
until QCocoaIntegration::drag() is called, but that would run the
risk of something calling the function during platform initialization
and we'd be back to the same problem.

It's unclear why QEventLoop is not lazily ensuring the event dispatcher,
and this might be a wider fix for similar issues.

Pick-to: 6.5
Change-Id: I643010ddb09945936ce9b0b94de0df96f6fe218f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-04-29 13:25:24 +02:00
Tor Arne Vestbø
d01aa39617 macOS: Fix leak of application menu NSMenuItem
Pick-to: 6.5 6.2
Fixes: QTBUG-112697
Change-Id: I0fe62e5a66f57bb9b8c073e636be346e088e0986
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2023-04-29 10:41:59 +02:00
Thiago Macieira
6a4901db25 IPC: QSystemSemaphore/SystemV: move up the check for handle
This avoids recalculating the native key file name every time we call
handle() to ensure the handle exists. The POSIX backend already has the
code like this (whence the comment was copied) and the Win32 backend is
similar.

Change-Id: Idd5e1bb52be047d7b4fffffd175076ec09334ae1
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-04-28 22:30:15 -05:00
Thiago Macieira
bc99f84478 IPC: QSharedMemory: use q20::construct_at
Commit 72c2cdbc57 said "Move the helper
from qsharedmemory.cpp" but didn't actually move it probably because
commit 72c2cdbc57 got cherry-picked to 6.5 but the original
introduction to qsharedmemory.cpp didn't.

So do it now.

Change-Id: Idd5e1bb52be047d7b4fffffd175067701d4ea58c
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-04-28 22:30:14 -05:00
Thiago Macieira
80c6f378e7 IPC: tst_QNativeIpcKey: rename duplicate row in test
Change-Id: Idd5e1bb52be047d7b4fffffd1750b949e7b94b26
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2023-04-28 22:30:13 -05:00
Thiago Macieira
3690c202f9 QCoreApplication: fix use-after-free of nl_langinfo() result
The result is retained so long as we don't attempt to change our locale,
but failing to change that is the reason why we printed anything.

==20227==ERROR: AddressSanitizer: heap-use-after-free on address 0x000107312696 at pc 0x000103c48088 bp 0x00016ee180c0 sp 0x00016ee17880
READ of size 9 at 0x000107312696 thread T0
    #0 0x103c48084 in wrap_strlen+0x164 (libclang_rt.asan_osx_dynamic.dylib:arm64e+0x18084) (BuildId: f0a7ac5c49bc3abc851181b6f92b308a32000000200000000100000000000b00)
    #1 0x1023804bc in QString::vasprintf(char const*, char*) qstring.cpp:7112
    #2 0x102243578 in qt_message(QtMsgType, QMessageLogContext const&, char const*, char*) qlogging.cpp:368
    #3 0x10252630c in QMessageLogger::warning(char const*, ...) const qlogging.cpp:647
    #4 0x10229f940 in QCoreApplicationPrivate::initLocale() qcoreapplication.cpp:664
    #5 0x10229fba0 in QCoreApplicationPrivate::init() qcoreapplication.cpp:826
    #6 0x1022a07c0 in QCoreApplication::QCoreApplication(int&, char**, int) qcoreapplication.cpp:799
    #7 0x101454ef8 in main+0xeb0 (WSgen:arm64+0x100470ef8) (BuildId: ae9b4fec1fd73c1693047a6b9d9ce91432000000200000000100000000000b00)

Pick-to: 6.5
Task-number: QTBUG-111443
Change-Id: I6f518d59e63249ddbf43fffd1759d28738124797
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2023-04-28 20:30:12 -07:00
Marc Mutz
58ebbb6220 [docs] QList: fix history of resize(n) semantics change
The description was copied from QVector, and doesn't exactly fit
QList. For QList, the function is \since 6.0 when QList became
QVector, not in Qt 5.7, as indicated.

Be more precise.

Amends 13293d3308, which changed the
docs for clear().

Pick-to: 6.5 6.2
Fixes: QTBUG-112334
Change-Id: I457a1f699ddcdcdad2f1daf88f577007c136ee8f
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-04-28 21:06:00 +00:00
Mårten Nordheim
c69a5611ae QNAM: Fix double-connect for manual redirect handling
The other signal connections are broken because we create a new
delegate. But 'q' is still the same, so we should not connect to
it a second time.
Just connect it in the constructor instead.

Fixes: QDS-9687
Pick-to: 6.5 6.2 5.15
Change-Id: Id47492c2e734087281a3d3488649471814fd981d
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-04-28 20:24:52 +02:00
Marc Mutz
968250ee14 QMetaProperty: add write() overload taking rvalue QVariant
The existing overload unconditionally copies the QVariant, causing it
to unconditional detach in most cases (when calling data() later).

The rvalue overload need not preserve the source object, so doesn't
need to copy.

Implement the lvalue overload in terms of the rvalue one, but keep the
sanity check in both to avoid copying the QVariant just to find that
there's nothing to do.

Following the copy, there were some references to the source object,
but they can all be replaced by references to the target object
instead, which hasn't been touched by then, yet.

[ChangeLog][QtCore][QMetaProperty] Added write() overload taking an
rvalue QVariant.

Fixes: QTBUG-112762
Change-Id: I0a8a91aa32143f071ebc8dae8f1f64b07fad9764
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-04-28 17:37:30 +00:00
Edward Welbourne
5fc53f58e9 Correct Julian Day numbers in 1800
This follows up on commit b906796af6.
Fix an off-by-one error - I was testing the last days of December 1799
and June 1800.

Change-Id: I79ab622978d35f91e3e1b1b8d00d93b0d4b31c07
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-04-28 16:13:32 +02:00
Edward Welbourne
5dabac2c9c Change QTimeZone's offset range into constants, not an enum
Use static constexpr int values instead of abusing enum.

[ChangeLog][QtCore][QTimeZone] The MinUtcOffsetSecs and
MaxUtcOffsetSecs constants are now static constexpr members of
QTimeZone, rather than members of an anonymous enum. Their values are
now 16 hours either side of zero, to allow for some historical zones.

Change-Id: I1c3a0f85a2b83b5010f021ca0f5ca5baefbf32e4
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io>
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2023-04-28 16:13:25 +02:00
Volker Hilsheimer
127e33d4c6 Don't set focus when moving the cursor with a touch pad
On macOS, swiping with a single finger on the track pad (which Qt
identifies as a QInputDevice::DeviceType::TouchPad) results in a
TouchBegin event. For widgets that accept touch events (perhaps
implicitly because they want pan gestures, like QGraphicsView),
this results in a TouchBegin event to be delivered.

QApplication::notify will then check the widget's focus policy, and with
ClickFocus set, will set focus on the widget.

This is not what we want for a TouchBegin on a touch pad, so skip the
setting of the focus for that device type.

Pick-to: 6.5
Fixes: QTBUG-112922
Change-Id: Ie828793a784cc0e2fa47954bf5b396d6a44bd5e8
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2023-04-28 16:12:07 +02:00
Fabian Kosmale
c2f01d4cfb QVariant: Fix support for metatypes created by Qt < 6.5
In Qt >= 6.1, < 6.5, a trivially constructible type would have the
NeedsDestruction flag set, but it's dtor pointer would have been null.

In Qt 6.5, the meaning of the NeedsDestruction flag was changed to be
more aligned with what the name suggests, and thus would only be set for
non-trivially destructible types. For QMetaType this was fine, but
QVariant has a check for acceptable metatypes which attempts to verify
whether a QMetaType is usable for QVariant. The check assumes the
semantics of Qt 6.5, and thus fails for metatypes created by older Qt
versions.

To fix this issue, we increment the QMetaType revision field, and only
check the metatype's destruction support if the revision is high enough.

In theory, that allows passing unsuitable metatypes from older Qt
versions to QVariant; however, such code would have been broken in prior
Qt releases already (which didn't attempt the check), and no code that
used to work in any released Qt version will break (as we simply skip a
check that was passing before).

Fixes: QTBUG-113227
Pick-to: 6.5
Change-Id: I12e02bd97d2c410ea1a36efb0ce2389f21d50a30
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2023-04-28 12:37:03 +02:00
Laszlo Agocs
fdb287e620 rhi: gl: Introduce a fourth code path to query the max vertex outputs
Three is not enough, need four. This is because in core profile contexts
querying GL_MAX_VARYING_COMPONENTS may apparently be an error (this is
enforced in macOS with 4.1 core contexts for example), so we need to
use something else: GL_MAX_VERTEX_OUTPUT_COMPONENTS.

Change-Id: I005c30e5798b0bf8bb7666bd732aaf996d123db9
Pick-to: 6.5 6.2
Fixes: QTBUG-112985
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-04-28 12:07:34 +02:00
Joerg Bornemann
bbadd4205d Doc: Fix example for QT_DEPLOY_TRANSLATIONS_DIR
The shared example for modifying deployment directory variables now sets
QT_DEPLOY_TRANSLATIONS_DIR too.

Also, add the missing install(SCRIPT) call.

Pick-to: 6.5
Fixes: QTBUG-113216
Change-Id: I6d52d946a21f006ae6222de1211f3d239bd03fc4
Reviewed-by: Orkun Tokdemir <orkun.tokdemir@qt.io>
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
2023-04-28 09:37:16 +02:00